-
April 3rd, 2005, 07:10 PM
#1
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));
}
In C, you merely shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."
-
April 4th, 2005, 08:09 AM
#2
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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
April 4th, 2005, 01:15 PM
#3
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.
In C, you merely shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."
-
April 4th, 2005, 01:24 PM
#4
Re: button press recognized when window moved
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.
-
April 4th, 2005, 03:33 PM
#5
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
In C, you merely shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|