Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_pre.php on line 387

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_pre.php on line 387

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 337

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 339

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 341

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 343
[Q] Responding to mouse click

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    25

    [Q] Responding to mouse click

    I'm trying to respond to a mouse click when the mouse is on top of a certain area. I tried two approaches, and neither worked..

    area1 is a handle to the child window (a button) that I want the mouse to be on for the prog to react.

    My first try was responding to the WM_LBUTTONDOWN message:

    Code:
    case WM_LBUTTONDOWN:
    	  curArea = GetCapture();
    	  if (curArea == area1) DoSomething();
    	  break;
    That didn't work; curArea was never equal to area1 (or any other window handle =/ ). The only time control passed to DoSomething was when I took the if out.

    I also tried WM_COMMAND:
    Code:
    case WM_COMMAND:
    	 curArea = (HWND)lParam;
    	 if (curArea == area1) DoSomething();
    	 break;
    That didn't work either .

    Any suggestions?

  2. #2
    VIP
    Join Date
    Apr 2006
    Posts
    439

    Re: [Q] Responding to mouse click

    Every control is a window, all windows generate messages, if you want to know if a button is clicked on you check if a message is generated for the button not the mouse (its possible but pointless)

    so you search msdn for button control: http://msdn2.microsoft.com/en-us/library/ms673340.aspx
    you check button messages: http://msdn2.microsoft.com/en-us/library/ms673328.aspx

    you see for button messages it says "the low-order word of the wParam parameter contains the control identifier, the high-order word of wParam contains the notification code, and the lParam parameter contains the control window handle."

    and then you find the msg your interested in: "BN_CLICKED The user clicked a button." (http://msdn2.microsoft.com/en-us/library/ms673572.aspx)

    "The parent window of the button receives the BN_CLICKED notification code through the WM_COMMAND message.

    wParam
    The low-order word contains the button's control identifier. The high-order word specifies the notification message.
    lParam
    A handle to the button."

    ok so:

    Code:
    if(msg == WM_COMMAND)
    {
    
    }
    next you need to check if its the button your intereseted in, if its from a resource ID:

    "The low-order word contains the button's control identifier"

    so:

    Code:
    if(LOWORD(wParam) == MY_BUTTON)
    or if you created the button then you will have a handle to it:

    "lParam - A handle to the button."

    Code:
    if((HWND)lParam == hWndMyButton)
    So now you wanna check if the button is clicked -

    "The high-order word specifies the notification message"

    Code:
    if(HIWORD(wParam) == BN_CLICKED)
    so to sum up:

    Code:
    if(msg == WM_COMMAND)
    {
    	if(LOWORD(wParam) == MY_BUTTON)
    	{
    		if(HIWORD(wParam) == BN_CLICKED)
    		{
    			// Wah the button was clicked!
    		}
    	}
    }

  3. #3
    Junior Member
    Join Date
    Feb 2007
    Posts
    25

    Re: [Q] Responding to mouse click

    Thanks . I was forgetting to check BN_CLICKED.. However, that's not my real problem (which I just figured out).

    Correct me if I'm wrong, but if a window isn't visible then it can't be clicked..

Similar Threads

  1. Click please!!!!! Need Help!come
    By olaftouw321 in forum Call of Duty 2 Cheats
    Replies: 3
    Last Post: March 30th, 2011, 19:31
  2. Replies: 4
    Last Post: March 2nd, 2009, 01:10
  3. Click nao
    By Kittie in forum Spam
    Replies: 1
    Last Post: October 30th, 2008, 20:03
  4. click here!
    By |F|H|PAC-MAN in forum Non-Gaming Related
    Replies: 4
    Last Post: June 4th, 2008, 19:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •