Recent

Author Topic: SendMessage with BM_CLICK not work with Delphi TntControls  (Read 3440 times)

wytwyt02

  • Jr. Member
  • **
  • Posts: 83
SendMessage with BM_CLICK not work with Delphi TntControls
« 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:


Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #1 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

This article says, that message can fail, if window is dialog box and it's not active.
« Last Edit: January 21, 2020, 12:01:53 pm by Mr.Madguy »
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

wytwyt02

  • Jr. Member
  • **
  • Posts: 83
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #2 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

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

thanks, but WM_CLICK seems not exists.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • Lebeau Software
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #3 on: January 21, 2020, 07:44:37 pm »
Try WM_LBUTTONDOWN and WM_LBUTTONUP instead.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #4 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.
The only true wisdom is knowing you know nothing

wytwyt02

  • Jr. Member
  • **
  • Posts: 83
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #5 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?
« Last Edit: January 22, 2020, 03:14:06 am by wytwyt02 »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #6 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #7 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?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • Lebeau Software
Re: SendMessage with BM_CLICK not work with Delphi TntControls
« Reply #8 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.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018