Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mouse clicking 1

Status
Not open for further replies.

Xantix

IS-IT--Management
Sep 18, 2002
25
BE
Hi,
What is the function that makes a click without actually touching the mouse in C++ builder 5 ?
I tried Click(); but nothing happens...
 
Try SendMessage(hWnd,WM_LBUTTONDOWN,wParam,lParam); John Fill
1c.bmp


ivfmd@mail.md
 
Assuming Button is a TButton * try this:

SendMessage(Button->Handle, WM_SETFOCUS, 0, 0);
SendMessage(Button->Handle, WM_KEYDOWN, VK_SPACE, 0);
SendMessage(Button->Handle, WM_KEYUP, VK_SPACE, 0);

PostMessage(Button->Handle, WM_SETFOCUS, 0, 0);
PostMessage(Button->Handle, WM_KEYDOWN, VK_SPACE, 0);
PostMessage(Button->Handle, WM_KEYUP, VK_SPACE, 0);

use PostMessage when you don't want window to handle your message directly (can be usefull sometimes)

 
All right, it works when you set the focus on a button.
But if you want to click anywhere on a window, does it works ?

I tried :
SendMessage(window->Handle, WM_LBUTTONDOWN, 530, 35);
Where window is the name of my Form and 530,35 the coordonate of a boutton but nothing happens...

In fact, I don't want to click on a button or any particular object. I want to be able to click anywhere on the screen like I would do with my mouse. I was told to use a windows'API but I don't know how.

Thank you anyway for the tips.
 
Just get the windows handle with needed coordinates and send both WM_LBUTTONDOWN and WM_LBUTTONUP. At the first you should set this window as foreground and after sending messages set the foreground the last active window. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top