Lazarus
Programming => General => Topic started 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:
-
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.
-
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.
-
Try WM_LBUTTONDOWN and WM_LBUTTONUP instead.
-
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.
-
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?
-
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.
-
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?
-
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.