RAD Studio VCL Reference
|
Provides a mechanism for using non-VCL dialog boxes in an application.
property DialogHandle: HWnd;
__property HWnd DialogHandle;
Use DialogHandle when displaying a modeless dialog box that was created using the CreateDialog API function. Assigning the handle of the modeless dialog box to DialogHandle allows the dialog to see messages from the application's message loop.
Assign the handle of the modeless dialog box to DialogHandle when it receives an activation message (WM_NCACTIVATE) and set DialogHandle to zero when the dialog box receives a deactivation message.
Delphi Examples:
{ Here is replacement of the window procedure for Delphi's encapsulation of the Windows search-and-replace common dialog box. Click on Button2 to activate an open dialog and send a WM_NCACTIVATE to FindReplaceWndProc. } function FindReplaceWndProc(Wnd: HWND; Msg, WParam, LParam: Longint): Longint; stdcall; function CallDefWndProc: Longint; begin Result := CallWindowProc(Pointer(GetProp(Wnd, MakeIntAtom(WndProcPtrAtom))), Wnd, Msg, WParam, LParam); end; begin case Msg of WM_DESTROY: if Application.DialogHandle = Wnd then Application.DialogHandle := 0; WM_NCACTIVATE: if WParam <> 0 then begin if Application.DialogHandle = 0 then Application.DialogHandle := Wnd; end else begin if Application.DialogHandle = Wnd then Application.DialogHandle := 0; end; WM_NCDESTROY: begin Result := CallDefWndProc; RemoveProp(Wnd, MakeIntAtom(WndProcPtrAtom)); Exit; end; end; Result := CallDefWndProc; end; procedure TForm1.Button1Click(Sender: TObject); begin ReplaceDialog1.Execute; end; procedure TForm1.Button2Click(Sender: TObject); begin OpenDialog1.Execute; end; procedure TForm1.FormCreate(Sender: TObject); var AtomText: array[0..31] of Char; begin WndProcPtrAtom := GlobalAddAtom(StrFmt(AtomText, 'WndProcPtr%.8X%.8X', [HInstance, GetCurrentThreadID])); SetWindowLong(Application.Handle, GWL_WNDPROC, Longint(@FindReplaceWndProc));; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|