Results 1 to 5 of 5

Thread: why won't it pick up my click

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    why won't it pick up my click

    Code:
    case WM_LBUTTONDOWN:
    //MEMORY
          if(LOWORD(wParam) == BN_CLICKED && (HWND)lParam == board[x2][y2])
    i also tried

    if ((HWND)lParam == board[x2][y2])

    but niether works when I click on board[x2][y2] (its a static control)

    the wm_lbuttondown is working, i checked with a messagebox, but a messagebox won't go inside my if....this should be easy, but im stumped sorry about the stupid question

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    try this

    Code:
    case WM_LBUTTONDOWN:
          if(MK_LBUTTON == wParam) && (hWnd == board[x2][y2])
    as wparam is holding this value.
    wParam
    MK_CONTROL The CTRL key is down.
    MK_LBUTTON The left mouse button is down.
    MK_MBUTTON The middle mouse button is down.
    MK_RBUTTON The right mouse button is down.
    MK_SHIFT The SHIFT key is down.
    MK_XBUTTON1 Windows 2000/XP: The first X button is down.
    MK_XBUTTON2 Windows 2000/XP: The second X button is down.

    and lParam is holding the current mouse position.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    thank you so much for the reply...im sorry about just asking you like that...but nothing happens still when i click the static controls

    Code:
    case WM_LBUTTONDOWN:
    				//MEMORY
    				for(int y2=0; y2<2; y2++)
    				{
    					for(int x2=0; x2<5; x2++)
    					{
    						if((MK_LBUTTON == wParam) && (hWnd == board[x2][y2]))
    						{
    							MessageBox(ghWnd_Main, "TEST", "Warning!", MB_OK);
    							clicknum++;
    							if(bmatrix[x2][y2]=="Green" || bmatrix[x2][y2]=="Red" || bmatrix[x2][y2]=="Blue" || bmatrix[x2][y2]=="Yellow" || bmatrix[x2][y2]=="Cyan")
    								SetWindowText(board[x2][y2], bmatrix[x2][y2].c_str());
    							if(bmatrix[x2][y2]=="green" || bmatrix[x2][y2]=="red" || bmatrix[x2][y2]=="blue" || bmatrix[x2][y2]=="yellow" || bmatrix[x2][y2]=="cyan")
    							{
    								SetFont(board[x2][y2], 50, "Terminal");
    								//SetWindowText(board[x2][y2], "Û");
    							}
    
    							if(clicknum==1)
    							{
    								one = bmatrix[x2][y2];
    								xold = x2;
    								yold = y2;
    							}
    							else if(clicknum==2)
    							{
    								if(x2==xold && y2==yold)
    								{
    									MessageBox(ghWnd_Main, "Please Chose A Valid Square", "Warning!", MB_OK);
    									clicknum--;
    								}
    								else
    								{
    									two = bmatrix[x2][y2];
    									
    									Sleep(500); //wait for half a second
    									MemoryCheck(one, two, x2, y2, xold, yold);
    									clicknum=0;
    									SetWindowText(board[xold][yold], " ");
    									SetWindowText(board[x2][y2], " ");
    								}
    							}						
    						}
    					}
    				}
    			return 0;

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    or you can capture the event via WM_COMMAND message as below:

    PHP Code:
            case WM_COMMAND:
                if ((
    HWND)lParam == board[x2][y2])
                    if (
    HIWORD(wParam) == BN_CLICKED)
                        
    MessageBox(hWnd"Bingo!"""MB_OK);

                break; 
    Also, ensure the static control have the style of SS_NOTIFY flag set.


  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    WM_LBUTTONDOWN is sent to you when the user clicks your window, not when he clicks a child window.
    And your decoding of wParam and lParam only applies to WM_COMMAND messages.

    Chris' second post should work.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width