Board index » delphi » Form Handle changing when form style changed

Form Handle changing when form style changed

Hi all,
        My app registers itself with another app to get messages about
what's going on.

I recently added a check box to allow the user to make the application
stay on top. When this check box is checked the application receives
no more messages!

I traced it to the fact that the window handle of the main form (which
is currently processing all the messages) gets changed.

Is there something wrong with saving the old window handle and then
resetting the new window handle to be the old after it has changed? I
can't seem to work out how to do it so if you have any pointers that
would good.

If changing the handle is a bad idea then how can I trap messages sent
to the application handle? (as that doesn't change)

Thanks,

    ____
  /    /___ ___ ___ ___
 / ___/   /   / __/ __/
/ /  / / / / /__ / _/
____/___/___/___/___/
Go...@goose-soft.demon.co.uk

 

Re:Form Handle changing when form style changed


Angus Herron <an...@goose-soft.demon.co.uk> skrev i en
nyhedsmeddelelse:37a07e0d.11263...@news.demon.co.uk...

Quote
> I recently added a check box to allow the user to make the application
> stay on top. When this check box is checked the application receives
> no more messages!
> I traced it to the fact that the window handle of the main form (which
> is currently processing all the messages) gets changed.

That seem reasonably.
The help has this to say about FormStyle:
"Note: It is not advisable to change FormStyle at runtime."

Quote
> If changing the handle is a bad idea then how can I trap messages sent
> to the application handle? (as that doesn't change)

One way of solving the problem could be to send a message to the other app
with the new handle when it changes.

Re:Form Handle changing when form style changed


Quote
>I recently added a check box to allow the user to make the application
>stay on top. When this check box is checked the application receives
>no more messages!

>I traced it to the fact that the window handle of the main form (which
>is currently processing all the messages) gets changed.

If your just making it always ontop you should use the windows api function
SetWindowPos, because delphi's TForm assumes that you don't even mess with
the handle property.
Put SetWindowPos(Handle,-1,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
-Gordy

Re:Form Handle changing when form style changed


Quote
On Thu, 29 Jul 1999 19:59:52 -0700, "Gordy" <gf...@jps.net> wrote:
>>I recently added a check box to allow the user to make the application
>>stay on top. When this check box is checked the application receives
>>no more messages!

>>I traced it to the fact that the window handle of the main form (which
>>is currently processing all the messages) gets changed.

>If your just making it always ontop you should use the windows api function
>SetWindowPos, because delphi's TForm assumes that you don't even mess with
>the handle property.
>Put SetWindowPos(Handle,-1,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
>-Gordy

Thanks! Works perfectly!

    ____
  /    /___ ___ ___ ___
 / ___/   /   / __/ __/
/ /  / / / / /__ / _/
____/___/___/___/___/
Go...@goose-soft.demon.co.uk

Other Threads