Board index » delphi » Custom dialogs send response ?

Custom dialogs send response ?

Hi,

I would like to know if it's possible to create a dialog with Resource
Workshop and make it reply by a value when closed like MessageBox does
(ie IntegerVariable := MessageBox(...)).

If anybody has a clue, thank you in advance.

Dr David Tetard

 

Re:Custom dialogs send response ?


In article <33AE3613.3...@fs1.ch.umist.ac.uk>, mcdst...@fs1.ch.umist.ac.uk
says...

Quote
>...DialogBox reply by a value when closed like MessageBox does ...

Very easy (if you hate objects): {$K+}
function EnterProc(blabla):Bool; export;
 begin
  EnterProc:=false;
  case Msg of
   WM_InitDialog: SetDlgItemInt(Wnd,EDIT_ID,LongRec(lParam).Lo,false);
   WM_Command: case wParam of
    ID_OK: EndDialog(Wnd,GetDlgItemInt(Wnd,EDIT_ID,nil,false));
   end;
  end;
 end;

ReturnValue:=DialogBoxParam(ParentWindow,HInstance,YOUR_RES,
  @EnterProc,Default);

But a better solution is to return a bool and modify the var. pointed by the
data param:
 var
  ResultOK:Bool absolute lParam; ...
   WM_InitDialog: begin
    SetWindowLong(Wnd,DWL_User,lParam); {memorize the pointer}
    SetDlgItemInt(Wnd,EDIT_ID,PWord(lParam)^,false);
   end; ...
    IDOK: begin
     wParam:=GetDlgItemInt(Wnd,EDIT_ID,@ResultOK,false);
     if not ResultOK then MessageBox(...report error here...)
     else begin
      PWord(GetWindowLong(Wnd,DWL_User))^:=wParam;
      EndDialog(Wnd,1);
     end;
    end;
    IDCancel: EndDialog(Wnd,0);...
and use
InputWasOK:=Bool(DialogBoxParam(blabla,LongInt(@YourWordVar)));

--
Henrik Haftmann           | email: henrik.haftm...@e-technik.tu-chemnitz.de
Reichenhainer Str. 51/105 |   www: http://www.tu-chemnitz.de/~heha
D - 09126 Chemnitz        | hobby: teletext in WWW at ~heha/toaster/vtnet.htm

Other Threads