button press recognized when window moved
when I click on the title bar and drage my window to a new location, once it left go of the mouse buton it thinks I've hit the sutek button:
Code:
long FAR PASCAL WndProc (HWND myhwnd, UINT message, WPARAM wParam, LPARAM lParam)//Message Handling
{
switch (message)
{
case WM_CHAR:
if (wParam == 27)
PostQuitMessage(0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
if((LOWORD(wParam) == StopB)&&(message == BN_SETFOCUS))
windowswitch = 0;
switch (LOWORD(wParam))
{
case CancelB://if wParam is == button then the button associated was clicked
PostQuitMessage(0);
break;
case AdverB:
if(windowswitch!=1)
windowswitch = 1;
break;
case BankB:
if(windowswitch!=2)
windowswitch = 2;
break;
case BlockB:
if(windowswitch!=3)
windowswitch = 3;
break;
case SutekB:
if(windowswitch!=4)
windowswitch = 4;
break;
case StopB:
DestroyWindow(H);
windowswitch = 0;
break;
}
return(DefWindowProc(myhwnd,message,wParam,lParam));
}
Re: button press recognized when window moved
Was there a question in there somewhere? Just kidding. :)
It looks like you've got two different SWITCH statements. The second one is run no matter what the message is! You are just testing a parameter of the message but you have no idea what that message even is.
So, for every message Windows sends your WndProc, you test the low word of its WPARAM. Eventually (as you found out) you're bound to get a message with a similar parameter as your button click.
I think you want:
Code:
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
// Button cases here
}
...
}
Better yet, combine it all under the first switch statement you're using.
Re: button press recognized when window moved
I'll try that once I get home thanks :)
oh and I created a static window that fills the main window, and when this is done the program looks to see if the main window is brought ot the foreground but for some reason clicking in the static window does not trigger this, I have to click on the title bar, do you know why?
I'm detecting this with
if(GetForgroundWindow() == mainwindow)
windowswitch = 0;
when window switch is zero it resets the menu display.
Re: button press recognized when window moved
Quote:
oh and I created a static window that fills the main window, and when this is done the program looks to see if the main window is brought ot the foreground but for some reason clicking in the static window does not trigger this, I have to click on the title bar, do you know why?
Because you must explicity say the window subsystem that you want to be notified when user clickes into a static window. This get's enabled by passing SS_NOTIFY as a flag of the static control when using CreateWindow() or switching the proper flag in the resource editor when using resource based dialogs/windows.
Re: button press recognized when window moved
lol I've seen that style too! just the name was a bit missleading, I thought it made the button flash or something.... didn't read what the SDK docs said :)