Lazarus

Programming => General => Topic started by: wytwyt02 on January 21, 2020, 09:57:09 am

Title: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: wytwyt02 on January 21, 2020, 09:57:09 am
I wanna to create an application to autmic install Mysql Server in Windows, So I wanna to use Win32 api with SendMessage to simulate install operation, I can get the HWND, But the Mysql Configruration is written by Delphi 7 with TntContols and cannot BM_CLICK the Next button with SendMessage, Spy++ screenshot below:

Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: Mr.Madguy on January 21, 2020, 12:00:10 pm
Tnt controls are rewritten from scratch, so may be they don't support standard messages. Try WM_CLICK or some other generic window messages.

https://docs.microsoft.com/en-us/windows/win32/controls/bm-click (https://docs.microsoft.com/en-us/windows/win32/controls/bm-click)

This article says, that message can fail, if window is dialog box and it's not active.
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: wytwyt02 on January 21, 2020, 01:54:18 pm
Tnt controls are rewritten from scratch, so may be they don't support standard messages. Try WM_CLICK or some other generic window messages.

https://docs.microsoft.com/en-us/windows/win32/controls/bm-click (https://docs.microsoft.com/en-us/windows/win32/controls/bm-click)

This article says, that message can fail, if window is dialog box and it's not active.

thanks, but WM_CLICK seems not exists.
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: Remy Lebeau on January 21, 2020, 07:44:37 pm
Try WM_LBUTTONDOWN and WM_LBUTTONUP instead.
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: jamie on January 21, 2020, 11:00:33 pm
if you send two messages back to back then you need to use the PostMessage not sendmessage so they will get qued in proper time sequence. Some apps I've seen do not like that to have the message system of it's own internal handling by past in that manner.

 But never the less, you still need to ensure the window is focused.
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: wytwyt02 on January 22, 2020, 03:02:38 am
if you send two messages back to back then you need to use the PostMessage not sendmessage so they will get qued in proper time sequence. Some apps I've seen do not like that to have the message system of it's own internal handling by past in that manner.

 But never the less, you still need to ensure the window is focused.

what's the mean of send two messages back to back? Is it send a message and wait it response?
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: lucamar on January 22, 2020, 11:54:39 am
what's the mean of send two messages back to back? Is it send a message and wait it response?

No, it's to send one message after another so they arrive as if "joined", i.e. back of one to back of the other. The important thing here is that to mimic a click the destination program must receive first the "button down" message and then the "buton up", i.e. they must be in the proper order in the message queue, which can only be guaranteed if you "post" the message rather than just "send" it.
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: Zvoni on January 22, 2020, 02:06:52 pm
if you send two messages back to back then you need to use the PostMessage not sendmessage so they will get qued in proper time sequence. Some apps I've seen do not like that to have the message system of it's own internal handling by past in that manner.

 But never the less, you still need to ensure the window is focused.
Why would it need to be focused, if he can get the Window-Handle?
Title: Re: SendMessage with BM_CLICK not work with Delphi TntControls
Post by: Remy Lebeau on January 22, 2020, 06:37:18 pm
The important thing here is that to mimic a click the destination program must receive first the "button down" message and then the "buton up", i.e. they must be in the proper order in the message queue, which can only be guaranteed if you "post" the message rather than just "send" it.

That, and also because the message queue processes queued mouse/keyboard messages to update thread-local state information, for instance the table used by GetKeyState().  If you send a message rather than post it, you bypass the message queue of the target window.
TinyPortal © 2005-2018