Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Jul : Re: Application.OnMessage receive the same message 3 times

www.cryer.info
Managed Newsgroup Archive

Re: Application.OnMessage receive the same message 3 times

Subject:Re: Application.OnMessage receive the same message 3 times
Posted by:"Daniel" (dani..@borland.com)
Date:Fri, 7 Jul 2006 11:38:27

"Rob Kennedy" <me3@privacy.net> Wrote
$1@newsgroups.borland.com...

> Under what circumstances would ViewRecordDlg already be assigned when the
> initialization section runs? You can probably remove that "Assigned"
> check. At most, I'd use an assertion:
>
> Assert(not Assigned(ViewRecordDlg));
>

  Because there are many forms will use ViewRecordDlg, and I want it to be
created only one time and  alive(not to be destoryed by any form) to keep
all values inside for all other form while calling it. Also I don't want add
it to project to be auto-created. Create it in initialization will make
things easy, all I have to do is to use its unit.

    Is there any way I can get the same mechanism? Automatically creating
ViewRecordDlg just after application begin and destorying it just before
application terminated?

>  The solution is to not handle the messages application-wide. Handle them
> at the window level, which is the same as how they arrive. Override the
> form's WndProc method. Handle the messages there. You can see an example
> with TCustomForm.

    Thanks, I will take a good look on it. For now, I check Msg.Hwnd to
solve my problem.

  if (Msg.message= WM_RefreshPaintBox) then
  begin
    Handled:=true;


    if (Msg.hwnd=Application.Handle) then
      pbEzf.Refresh;

  end;


  The Paintbox now refresh only 1 time. : )


Thanks a lot.

Daniel

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive