MFC: Button press and release?
-
Hello! I'm just a basic MFC user. Mostly I do my UIs in resource editor in VS.NET 2003. I know how to handle BN_CLICKED message from button and do something with it (trough message map). But now I have a problem. I should do something on button "press" and something different on button "release". It's the situation when event is dispatched on press and release not just release like it is the case with BN_CLICKED. Is it even possible? Thank you for all the help. Best regards, Rostfrei
do you mean LButtonDown?? Regards, FarPointer
-
do you mean LButtonDown?? Regards, FarPointer
-
What do you mean by LButtonDown? I just want do something on button down and something else on button up. Rostfrei
-
What do you mean by LButtonDown? I just want do something on button down and something else on button up. Rostfrei
Which means you need to supply handlers for the
WM_LBUTTONDOWN
andWM_LBUTTONUP
messages.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Which means you need to supply handlers for the
WM_LBUTTONDOWN
andWM_LBUTTONUP
messages.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
I managed to supply the handlers. I have the Dialog based application. If I press the mouse anywhere on the dialog I can detect it and can read the coordinates. The problem is when I click on the button. Click is not detected and I guess its intercepted by button. I want to detect the button down and check if mouse down happened in the area where button is. I don't have any method registered with the button. All I want to use it for now is button press/release shadow effect. What can I do? I don't want to draw custom button pictures and place them on the button region. Regards, Rostfrei
-
I managed to supply the handlers. I have the Dialog based application. If I press the mouse anywhere on the dialog I can detect it and can read the coordinates. The problem is when I click on the button. Click is not detected and I guess its intercepted by button. I want to detect the button down and check if mouse down happened in the area where button is. I don't have any method registered with the button. All I want to use it for now is button press/release shadow effect. What can I do? I don't want to draw custom button pictures and place them on the button region. Regards, Rostfrei
One way is to derive your own class from
CButton
and put the message handlers in it. If that does not work, perhaps message reflection will.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
One way is to derive your own class from
CButton
and put the message handlers in it. If that does not work, perhaps message reflection will.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
I already tried that but it is not possible to declare message map in there
class CCustomButton : public CButton { private: DECLARE_MESSAGE_MAP () }; BEGIN_MESSAGE_MAP(CCustomButton, CDialog) END_MESSAGE_MAP()
because I get errormainAppDlg.cpp(106): error C2248: 'CDialog::GetThisMessageMap' : cannot access protected member declared in class 'CDialog' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2864) : see declaration of 'CDialog::GetThisMessageMap' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2767) : see declaration of 'CDialog'
What is message reflection? Regards, Rostfrei -
I already tried that but it is not possible to declare message map in there
class CCustomButton : public CButton { private: DECLARE_MESSAGE_MAP () }; BEGIN_MESSAGE_MAP(CCustomButton, CDialog) END_MESSAGE_MAP()
because I get errormainAppDlg.cpp(106): error C2248: 'CDialog::GetThisMessageMap' : cannot access protected member declared in class 'CDialog' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2864) : see declaration of 'CDialog::GetThisMessageMap' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2767) : see declaration of 'CDialog'
What is message reflection? Regards, RostfreiRostfrei wrote:
I already tried that but it is not possible to declare message map in there
Sure it is. MFC would not be worth a whole lot otherwise.
Rostfrei wrote:
class CCustomButton : public CButton ... BEGIN_MESSAGE_MAP(CCustomButton, CDialog)
Notice the discrepancy?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Rostfrei wrote:
I already tried that but it is not possible to declare message map in there
Sure it is. MFC would not be worth a whole lot otherwise.
Rostfrei wrote:
class CCustomButton : public CButton ... BEGIN_MESSAGE_MAP(CCustomButton, CDialog)
Notice the discrepancy?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb