Re: Checking for mouse press
May be you can handle your operations in WM_LBUTTONDOWN and WM_MOUSEMOVE... it might be easier to handle the functionality....
Thanks...
Re: Checking for mouse press
I tried that, and it still won't open up my other image. The mouse over works, it flips the image to highlight the option I am over, but when I click on it, nothing happens. Do I need to use mouse_event()? If so how would I use it.
Re: Checking for mouse press
What happens when you just execute:
Code:
VisualManager::Get()->Demo();
Create a menu item for it and a function for the menu item. Are you sure that VisualManager::Get()->Demo(); does something?
Re: Checking for mouse press
Yes,
VisualManager::Get()->Demo();
is my call to draw my new image. I have tested out, and it works fine when I don't use any mouse input. I am just having trouble making my code have mouse input.
Re: Checking for mouse press
All you have to do is use CWND::OnLButtonDown it determines if the left button is down so you don't have to get involved with VK_LBUTTON(?).
Code:
OnLButtonDown(UINT nFlags, CPoint point)
{
CPoint x;
x = point;
if((p.x > 8) && (p.x < 118))
{
// Checks to see if the mouse is within a certain range of x, y
if ((p.y > 66) && (p.y < 114))
{
// Display Demo image if button has been pressed
VisualManager::Get()->Demo();
}
}
....
}
Like said above, LeftButton is already flaged for you.
Re: Checking for mouse press
Quote:
Originally Posted by
Dex83
I tried that, and it still won't open up my other image. The mouse over works, it flips the image to highlight the option I am over, but when I click on it, nothing happens. Do I need to use mouse_event()? If so how would I use it.
As i said earlier.... Use the message events for the left mouse button click... you can find this in Class wizard of your project.... look for WM_LBUTTONDOWN and handle the functionality over there.... !!!:)
Hope this helps,
Thanks. ;)
Re: Checking for mouse press
I use these macros:
Code:
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? true : false)
#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? false : true)
so:
Code:
// Checks to see if the mouse is within a certain range of x, y
if((p.x > 8) && (p.x < 118))
{
// Checks to see if the mouse is within a certain range of x, y
if ((p.y > 66) && (p.y < 114))
{
// If mouse is within range, highlight the selected option
mml = MM_RESUME;
//Check to see if the left mouse has been pressed
if(KEY_DOWN(VK_LBUTTON))
{
// Display Demo image if button has been pressed
VisualManager::Get()->Demo();
}
}
}
This works fine for me. You might want to but a breakpoint at VisualManager::Get()->Demo(); to make sure that the problem is with the mouse detection and not your image-switching code.
Re: Checking for mouse press
Awesome thanks guys, that really helped a lot. I like defining the KEY_DOWN, and KEY_UP. Never thought to do it that way.
Re: Checking for mouse press
Quote:
Originally Posted by
Dex83
Awesome thanks guys, that really helped a lot. I like defining the KEY_DOWN, and KEY_UP. Never thought to do it that way.
:) Well there is a way to show your appreciation. ... that's what most of these guys and myself response to posters who are in bad situations or are stuck.
... it also keeps these posters helping you in the future if you get stuck or need help :)