|
Use a CBitmapButton .
Nibu thomas
Software Developer
|
|
|
|
|
|
FooButton^ for everything you need with a Button
VuNic
|
|
|
|
|
|
no need to repost
the previous answer were good already. if can't do it, it is because of you, not the inconsistent answers...
|
|
|
|
|
Please let me know how to change the color of the button at runtime i.e How to handle such events at runtime.
Please Reply soon
Ashok Reddy(ashokbngr@gmail.com)
|
|
|
|
|
You will have to ownerdraw the button.
Here[^] is a demo.
Nibu thomas
Software Developer
|
|
|
|
|
u have to change the property of button to BS_OWNERDRAW, overide the function DrawItem .You can now draw the button from that function.
There are many article in code project that describes owner draw button. Simply Search...
nave
|
|
|
|
|
you need to class derived from CButton and use WM_DRAWITEM
if you want to change CButton
and in the Codeproject you found your answer
|
|
|
|
|
If you want to change background color you can override OnEraseBackGround Func.
else you override OnDrawItem to draw on your button.
You can capture message CTLCOLOR_BTN to handle such events at runtime.
|
|
|
|
|
|
Hi
How to capture System Shutdown/Restart/Stand By messeges from a Visual C/C++ Program
thanx in advance
by
KK
|
|
|
|
|
Take a look at WM_QUERYENDSESSION and WM_ENDSESSION .
Nibu thomas
Software Developer
|
|
|
|
|
Hold on!, i've been trying to capture these messages in the PreTranslateMessage, but i dont know what mistake i'm making. its not getting trapped. can you help me out?
<code>
BOOL CTESTMFC2Dlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_QUERYENDSESSION)
{
if(pMsg->lParam==0x80000000)
{
}
}
if(pMsg->message==WM_ENDSESSION)
{
}
return CDialog::PreTranslateMessage(pMsg);
}
</code>
Actually the 0x80000000 is to check if its a LogOff. the owner of this thread may also like to see your reply.
VuNic
|
|
|
|
|
BOOL CMainFrame::OnQueryEndSession()
{
if (!CFrameWnd::OnQueryEndSession())
return FALSE;
AfxMessageBox("I caught System ShutDown");
return TRUE;
}
also c WM_ENDSESSION
|
|
|
|
|
If its a dialog based application?
VuNic
|
|
|
|
|
afx_msg void CShutWindowDlg::OnEndSession( BOOL bEnding )
{
AfxMessageBox("Shut Down Message Caught");
}
|
|
|
|
|
Did you chage your post?? what's that afx_msg void?? it only returns a BOOL right?
Btw, still its not working.
I tried both ::OnEndSession(BOOL b) and ::OnQueryEndSession()
BOOL CTESTMFC2Dlg::OnEndSession(BOOL bEnding)
{
//Not entering here
}
BOOL CTESTMFC2Dlg::OnQueryEndSession()
{
// Not entering here
}
What'd have gone wrong?
VuNic
|
|
|
|
|
afx_msg void CShutWindowDlg::OnEndSession( BOOL bEnding )
{
AfxMessageBox("System ShutDown Message Caught");
}
Handel WM_ENDSESSION Message
|
|
|
|
|
Handle it again?? then what's the need for ::OnEndSession ??
VuNic
|
|
|
|
|
Don't try adding those functions. Instead, go to your dialog view (where you can manipulate the button/textbox fields) click on the dialog somewhere. From there, go to the Properties tab. This is the place where you would normally set the button/textbox name, readonly, etc. Instead, click on the button next to the little Lightning bolt that is labeled "Messages." From there, scroll down until you see "WM_QUERYENDSESSION", click on that, and add OnQueryEndSession. From there your function will be added and implimented, and you can change what you're testing for inside of that.
da Big_R
|
|
|
|
|
are you talking about the class wizard?
VuNic
|
|
|
|
|
Dear C++ gurus...
I would like to know how to declare a global function in VC++. I would want to call that function from any class just by calling the function. A similar comparision would be like declaring a global function in a module and calling it from anywhere, incase of VB.
Urgent help needed.
Thanks.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Declare it in stdafx.h and define it in stdafx.cpp .
Nibu thomas
Software Developer
|
|
|
|
|
But won't doing that affect other projects using "stdafx"? By Global, I meant global to my particular project so that calling that function from within my project would not need an instantiation of a class. Just call the function using its name alone. Can it be done ? What would happen if I used a static Function?
Thanks for replying.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|