|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionOne of the interesting things I found in the recent times about Windows programming was the popping up of status bar message windows when somebody logs in MSN messenger. Here is the code I would like to share with anyone out there who would also like to use it, but was not able to do so because of no direct API help for the following task. How to use the source codeInclude the following files in your project.
Following lines show how to create an object of CStatusBarMsgWnd* t_MsgWnd = CStatusBarMsgWnd::CreateObject(
_T("Some idiot has signed in !!"), // the message to be displayed
180, // width of the window
150, // height of window
4000, // time for the message to be displayed
10, // delay for animation, how fast the window opens and closes
CRect(30, 30, 130, 110), // rectangle in the window where the
//message will be displayed
this // parent of the message window
);
t_MsgWndMsg.PopMsg();
DetailsThe
The following code of void CStatusBarMsgWnd::PopMsg() { if (CheckIfStatusBarBottom()) // Most frequent case is status bar at bottom { PopWndForBottomStatusBar(); } else { if (CheckIfStatusBarTop()) { PopWndForTopStatusBar(); } else { if (CheckIfStatusBarLeft()) { PopWndForLeftStatusBar(); } else { PopWndForRightStatusBar(); } } } } The The real action occurs in the
There are three other constants namely The window is automatically deleted after collapsing in the Class Details The class Rewrite the int CStatusBarMsgWnd::OnCreate( LPCREATESTRUCT lpCreateStruct ) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; ModifyStyle(WS_CAPTION, 0, SWP_FRAMECHANGED); // removes title bar // Start creating two fonts, one underlined , // other non underlined // LOGFONT structure for font properties LOGFONT lf; ::ZeroMemory (&lf, sizeof (lf)); lf.lfHeight = 100; lf.lfWeight = FW_BOLD; lf.lfUnderline = TRUE; ::strcpy (lf.lfFaceName, _T("Arial")); // Prepare for an underlined font m_fontMessageUnderline.CreatePointFontIndirect(&lf); // Prepare an non underlined font lf.lfUnderline = FALSE; m_fontMessageNoUnderline.CreatePointFontIndirect(&lf); // Initialize the cursor. m_hCursor = ::LoadCursor(NULL, IDC_HAND); return 0; } How to use the demo project exeDouble click the popwnd.exe and use the "Message Menu" to pop up a message window Future Work to be done, in progress...
|
||||||||||||||||||||||