Hello Conor,
CBsc> test.  Care to post the whole function, Al?
Using D5:
function EditBox(Prompt, Caption, Default, PassChar, CheckBox, Sound: string;
  Pic: Tpicture;
  BoxColor, EditColor: Tcolor; Position: Tposition; StayOnTop: Boolean;
  EditFont, CheckBoxFont: Tfont; EditWidth: Integer): string;
var form: Tform;
  ww, Ttop, i: Integer;
  p: array[0..255] of char;
  hList, el, dl, cb: TstringList;
begin
  Result := '';    //without this no warning
  if (Prompt = '') and (CheckBox = '') then exit;
  hList := TstringList.Create;
  el := TstringList.Create;
  dl := TstringList.Create;
  cb := TstringList.Create;
  Ttop := 1;
  if Prompt <> '' then
  begin
    if Prompt[1] = '|' then delete(Prompt, 1, 1);
    if Prompt[length(Prompt)] <> '|' then Prompt := Prompt + '|';
    for ww := 1 to length(Prompt) do if Prompt[ww] = '|' then
      begin
        el.Add(copy(Prompt, Ttop, ww - Ttop));
        Ttop := ww + 1;
      end;
  end;
  if el.Count > 1 then if pos('|', Default) > 0 then
    begin
      Ttop := 1;
      if Default[1] = '|' then delete(Default, 1, 1);
      if Default[length(Default)] <> '|' then Default := Default + '|';
      for ww := 1 to length(Default) do if Default[ww] = '|' then
        begin
          dl.Add(copy(Default, Ttop, ww - Ttop));
          Ttop := ww + 1;
        end;
    end;
  if CheckBox <> '' then
  begin
    Ttop := 1;
    if CheckBox[1] = '|' then delete(CheckBox, 1, 1);
    if CheckBox[length(CheckBox)] <> '|' then CheckBox := CheckBox + '|';
    for ww := 1 to length(CheckBox) do if CheckBox[ww] = '|' then
      begin
        cb.Add(copy(CheckBox, Ttop, ww - Ttop));
        Ttop := ww + 1;
      end;
  end;
  WW := 20;
  playsnd(Sound);
  if not hasparent__ then
  begin
    if (Position <> poDeskTopCenter) or (Position <> poScreenCenter) then
      Position := poDesktopCenter;
  end else if Caption = '' then Caption := Screen.ActiveForm.Caption;
  if mb_CreateNotOwned then form := Tform.Create(nil) else
    form := Tform.Create(Screen.ActiveForm);
  try
    with form do
    begin
//   Alphablend := mb_Alphablend;
//   AlphaBlendValue := mb_AlphablendValue;
//   TransparentColor := mb_TransparentColor;
//   TransparentColorValue := mb_TransparentColorValue;
      Color := BoxColor;
      BorderStyle := bsSingle;
      BorderIcons := [biSystemMenu];
      WindowState := wsNormal;
      if mb_CreateNotOwned then FormStyle := fsStayOnTop else
      begin
        if StayOnTop then FormStyle := fsStayOnTop else FormStyle := fsNormal;
      end;
    end;
    form.Position := Position;
    form.Caption := Caption;
    TTop := GetSystemMenu(form.Handle, False);
    EnableMenuItem(TTop, SC_CLOSE, MF_BYCOMMAND or MF_DISABLED or MF_GRAYED);
    DeleteMenu(TTop, SC_MAXIMIZE, MF_BYCOMMAND);
    DeleteMenu(TTop, SC_MINIMIZE, MF_BYCOMMAND);
    DeleteMenu(TTop, SC_SIZE, MF_BYCOMMAND);
    DeleteMenu(TTop, SC_RESTORE, MF_BYCOMMAND);
    DeleteMenu(TTop, SC_CLOSE, MF_BYCOMMAND);
    DeleteMenu(TTop, 1, MF_BYPOSITION);
    DrawMenuBar(form.Handle);
    TTop := 20;
    if pic <> nil then
      with timage.Create(form) do
      begin
        parent := form;
        transparent := True;
        height := Pic.Height;
        width := Pic.Width;
        top := TTop;
        left := 20;
        picture := Pic;
        TTop := TTop + Height + 20;
        WW := width;
      end;
    if el.Count > 0 then
      for i := 0 to el.Count - 1 do
      begin
        with Tlabel.Create(form) do
        begin
          parent := form;
          if mb_MsgFont <> nil then Font := mb_MsgFont;
          caption := el.Strings[i];
          Top := TTop;
          Left := 20;
    //Ttop := Ttop + height + trunc(height / 4);
          Ttop := Ttop + Height + 8;
          if WW < width then WW := Width;
        end;
        if not mb_ExcludeEditInEditBox then
          with Tedit.Create(form) do
          begin
            parent := form;
            left := 20;
            top := ttop;
            if EditWidth > 0 then Width := EditWidth;
            if dl.Count > i then Text := dl.Strings[i]
            else if dl.Count = 0 then Text := Default;
            Ttop := Ttop + trunc(height * 1.6);
            Color := EditColor;
            MaxLength := 255;
            if EditFont <> nil then Font := EditFont;
            if length(PassChar) = 1 then passwordchar := PassChar[1];
            if WW < width then WW := Width;
            hList.Add(inttostr(Handle));
          end;
      end;
    el.Clear;
    dl.Clear;
    if cb.Count > 0 then for i := 0 to cb.Count - 1 do
      begin
        with TCheckbox.Create(form) do
        begin
          parent := form;
          top := ttop;
          ttop := ttop + height + 8;
          left := 20;
          if CheckBoxFont <> nil then Font := CheckBoxfont;
          if mb_CheckBoxWidth > 0 then Width := mb_CheckBoxWidth;
          if cb.Strings[i][1] = #1 then
          begin
            Checked := True;
            cb.Strings[i] := copy(cb.Strings[i], 2, Length(cb.Strings[i]) - 1);
          end;
          Caption := cb.Strings[i];
          if WW < width then WW := Width;
          el.Add(InttoStr(handle));
        end;
      end;
    Ttop := Ttop + 10;
    with TBitBtn.Create(form) do
    begin
      Parent := form;
      top := TTop;
      Kind := bkOk;
      Default := True;
      if mb_BtnFont <> nil then font := mb_BtnFont;
      if mb_BtnOk = '' then mb_BtnOk := _Btn_Ok;
      Caption := mb_BtnOk;
      if mb_BtnHeight <> 0 then Height := mb_BtnHeight;
      if mb_BtnWidth <> 0 then Width := mb_BtnWidth;
      Left := 20;
      i := Left * 2 + Width;
    end;
    with TBitBtn.Create(form) do
    begin
      Parent := form;
      top := TTop;
      Kind := bkCancel;
      Default := False;
      if mb_BtnFont <> nil then font := mb_BtnFont;
      if mb_BtnCancel = '' then mb_BtnCancel := _Btn_Cancel;
      Caption := mb_BtnCancel;
      if mb_BtnHeight <> 0 then Height := mb_BtnHeight;
      if mb_BtnWidth <> 0 then Width := mb_BtnWidth;
      Left := i;
      if Left + Width - 20 > ww then ww := Left + Width - 20;
      TTop := TTop + Height + 20;
    end;
    form.ClientHeight := TTop;
    form.ClientWidth := WW + 40;
    with Tbevel.Create(form) do
    begin
      Parent := form;
      Shape := bsFrame;
      Style := bsLowered;
      Top := 3;
      Left := 3;
      height := form.ClientHeight - 6;
      width := form.ClientWidth - 6;
    end;
    form.ShowModal;
    if form.ModalResult = mrOK then
    begin
      if hList.Count > 0 then for i := 0 to hList.Count - 1 do
        begin
          fillchar(p, sizeof(p), #0);
          getwindowtext(StrToInt(hList.Strings[i]), p, sizeof(p));
          if i > 0 then Result := result + #10;
          result := result + strpas(p);
        end;
      if el.Count > 0 then
      begin
        if Result <> '' then Result := result + #13;
        for i := 0 to el.Count - 1 do Result := Result + inttostr(SendMessage(
            StrToInt(el.Strings[i]), BM_GETCHECK, 0, 0));
      end;
    end else result := #0;
    form.release;
    form.free;
  except
    Result := #1;
  end;
  hList.Free;
  el.Free;
  dl.Free;
  cb.Free;
end;


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to