RE: BM_GETSTATE/BM_SETSTATE?????
Hello,
I got the first part of my post to work by doing:
=====================================================
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static HWND hdMW_btC1;
static BState; //////////////Variable is added in
switch(message)
{
case WM_CREATE:
//Create controls
hdMW_btC1 = CreateWindow( //Create application exit button
TEXT ("button"),szMW_btC1_Name,
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON ,
850,490,80,40, hwnd,(HMENU)MW_btC1_ID,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
return 0;
case WM_COMMAND:
if (LOWORD(wParam) == MW_btC1_ID)
{
if (bBState) //Breakpoint here!
{
SendMessage((HWND)lParam,BM_SETSTATE,0,0);
b_BState = false;
}
else
{
SendMessage((HWND)lParam,BM_SETSTATE,1,0);
b_BState = true;
}
.....other code....
===============================================
So now the button actually toggles from pressed to depressed everytime I
click on it!
But why is it that if I put a break point on the following line:
if (bBState)
and when I click on the button on the client area (see button id:
MW_btC1_ID), the debugger stops at this line right ! so, I continue the
program by stepping through one line at a time right...
at this point the coresponding SendMessage gets executed based on the value
of bBState in the "if" statement right! and then when I stepped through all
of the above code, the debugger asks me if I want to continue by showing me a
dialog box which says:
"There is no source code available for the current location."
So I say "OK" and this dialog box closes, and then I click on "Debug" menu
and "Continue" to actually continue my line by line debugging right...!
At this very point, why does the debugger bring me back a second time to the
same break point? If this is the SendMessage that is re-occuring(which would
be normal!), then it shouldn't fall back into WM_COMMAND handler since this
time around its message is BM_SETSTATE and not WM_COMMAND?
So basically my question is, why the breakpoint two times?
All help is appreciated!
--
Very kind regards
Robert
"Robby" wrote:
Hello,
I am trying to toggle a pushbutton using the following code:
================================================
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static HWND hdMW_btC1;
switch(message)
{
case WM_CREATE:
//Create controls
hdMW_btC1 = CreateWindow( //Create application exit button
TEXT ("button"),szMW_btC1_Name,
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON ,
850,490,80,40, hwnd,(HMENU)MW_btC1_ID,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
return 0;
case WM_COMMAND:
if (LOWORD(wParam) == MW_btC1_ID)
{
SendMessage((HWND)lParam,BM_SETSTATE,(WPARAM)
!SendMessage((HWND)lParam,BM_GETSTATE,0,0),0);
....other code....
===============================================
Shouldn't the above code set the button in a depressed state when I click on
it, and when I click on it again it sets the button to unpressed state?
Any help is appreciated!
--
Best regards
Robert