Hi
I wanna do something when the user place the mouse on a static control...is there a Message i can capture(can't find one)...if not how would i do it? thnx
Hi
I wanna do something when the user place the mouse on a static control...is there a Message i can capture(can't find one)...if not how would i do it? thnx
Time for TOTAL WAR
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
Hmm..but the user has to click a button
WM_LBUTTONDOWN WM_MBUTTONDOWN
WM_RBUTTONDOWN
As far as i understood it...the user has to put the Mouse over the control AND click....i want it without the click..... can someone help??
thnx
Time for TOTAL WAR
Try
TrackMouseEvent()
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
hmmm i don't know...what about responding to WM_LBUTTONUP
and checking the mouse position with GetCursorPos()
and checking it wether it is within the boundaries of the static
with GetWindowRect()
Is there some easier or better way then this???
hehehe....is this even possible?
thnx
Time for TOTAL WAR
Is this possible?
No
Not without SetCapture() and a WM_LBUTTONDOWN first
MSDN
"The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor."
It may work on a WM_MOUSEMOVE msg after a call to SetCapture()
Use PtInRect() to test teh point is in the contols area. You may need to convert using ScreenToClient() or ClientToScreen()
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
hmmm...ok then i think i;ll do the following :
1.get the WM_MOUSEMOVE
2.Determine Mouse Position GetCursorPos()
3.The Point i get from 2 will be used in PtInrect()
possible?
case WM_MOUSEMOVE:
POINT pt; // Current mouse point
GetCursorPos(&pt); // Coords of cursor
// Check x position
if ((pt.x >= STATIC_X) && (pt.x <= STATIC_WIDTH)) {
if ((pt.y >= STATIC_Y) && (pt.y <= STATIC_HEIGHT)) {
// This is where you handle the mouse over
// the static control
}
}
break;
STATIC_X and STATIC_Y are the X and Y-Axis that the static control is on and STATIC_WIDTH and STATIC_HEIGHT are the width and height of the static control. This should do what you are wanting to =).
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
That was exactly what i had in mind....glad that that is doible hehehehe
Well thaks SyntaxBubble and all the others helping me out
if i did it via Syntax bubbles way it would be abit tedious...i am trying to do this:
GetWindowRect(Button_Up,&Up_Rect);
GetWindowRect(Button_Down,&Down_Rect);
GetWindowRect(Button_Left,&Left_Rect);
GetWindowRect(Button_Right,&Right_Rect);
break;
case WM_MOUSEMOVE:
POINT p;
GetCursorPos(&p);
if(PtInRect(&Up_Rect,p)!=0)
{
CPosUp();
}
else if(PtInRect(&Up_Rect,p)==0)
{
MessageBox(NULL,"asd","asd",MB_OK);
}
else if(PtInRect(&Down_Rect,p)!=0)
{
CPosDown();
}
else if(PtInRect(&Right_Rect,p)!=0)
{
CPosRight();
}
else if(PtInRect(&Left_Rect,p)!=0)
{
CPosLeft();
}
break;
But it doesn't work....argggg the msgbox always popsup help..
have tried GetClientRect() but still no go ahhhh!!
Your if else logic is wrong. It can never get to the third if statement as the point is either in the UP rect or not.
Call the getClientRect() under the mouse move msg or make them static. As many msg's are passing thru the callback the rects will have lost scope unless you do.
If you want to make cleaner code try this;
If you create the buttons then create them with consecutive resource IDs.
Or edit the resource.h file so all the buttons have consecutive ID numbers.
Then use a for loop.
Code:for(i=ID_FIRST_CTRL;i<ID_LAST_CTRL;i++) { GetClientRect( GetDlgItem(hDlg,i) ,&Rect); if(PtInRect(&Rect,Point)) iButtonClicked=i; }
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill