[DUG] DLL Forms

Ross Levis ross at stationplaylist.com
Sun Aug 6 23:54:56 NZST 2006


Nevermind, I worked out what I need to do.  I should be using OnMessage rather than OnIdle for a start.

This is all that is needed to handle non-modal DLL dialog forms.

procedure TEngine.ApplicationEventsMessage(var Msg: tagMSG; var Handled: Boolean);
begin
  if not Local and IsDialogMessage(GetParent(Msg.hwnd),Msg) then Handled := True;
end;

The "Local" boolean is messy and there is likely to be a much better way to do this.  What I do is set Local to true when any local forms get the focus, and to false when leaving focus.  This way when a DLL form receives the focus, Local is false and all dialog messages are assumed to be coming from controls on the DLL dialog.  GetParent of the control where tab was pressed is the dialog window of course.

I also need to set Local to true before any modal dialog such as that created with MessageDlg or ShowMessage, which again is messy, but at least it works.

If anyone can suggest a better way of detecting if a local window or dialog has the focus then I would love to know.  I've learnt a lot about windows messaging the last few days, more than I hoped to ever know, but I still have little clues how to do this.

As I see it, the above code should enable tabs and other key messages to be processed for all non-modal DLL Forms.

Regards,
Ross.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ns3.123.co.nz/pipermail/delphi/attachments/20060806/3c405b50/attachment.html


More information about the Delphi mailing list