|
// CMBEdit.cpp : implementation file
//
#include "stdafx.h"
#include "CtrlMessageBarDemo.h"
#include "CMBEdit.h"
// CCMBEdit
IMPLEMENT_DYNAMIC(CCMBEdit, CEdit)
BEGIN_MESSAGE_MAP(CCMBEdit, CEdit)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CCMBEdit message handlers
void CCMBEdit::OnLButtonDown(UINT nFlags, CPoint point)
{
CEdit::OnLButtonDown(nFlags, point);
CCtrlMessageBar* pBar = CCtrlMessageBar::GetMessageBarCtrl(this);
if (pBar != NULL && ! pBar->IsShown())
{
pBar->SetText(_T("Got the message! Click here for options."), 2);
pBar->Show();
}
}
/*static*/BOOL CCMBEdit::CMB_ShowMenuCallback(CCtrlMessageBar* pBar, CWnd* pCtrl, UINT /*nHitTest*/, CPoint point)
{
// return TRUE if we do our menu, or FALSE to use the default
if (pCtrl == NULL || pBar == NULL)
return FALSE; // do default menu
ASSERT(AfxIsValidAddress(pCtrl, sizeof(CCMBEdit)));
CCMBEdit* pEdit = (CCMBEdit*)pCtrl;
if (pEdit == NULL)
return FALSE;
// show a context menu for the message bar
CMenu menu;
menu.CreatePopupMenu();
menu.AppendMenu(MF_STRING, 1, _T("Close Message Bar"));
menu.AppendMenu(MF_STRING, 2, _T("&Settings..."));
menu.AppendMenu(MF_SEPARATOR);
menu.AppendMenu(MF_STRING, 3, _T("Message Bar &Help"));
int nCmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, pEdit, NULL);
if (nCmd == 1)
pBar->Show(FALSE);
else if (nCmd == 2)
AfxMessageBox(_T("You can allow the user to configure the bar settings here"));
else if (nCmd == 3)
AfxMessageBox(_T("You can jump to the appropriate help topic here"));
return TRUE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Originally from an electronics background, I moved into software in 1996, partly as a result of being made redundant, and partly because I was very much enjoying the small amount of coding (in-at-the-deep-end-C) that I had been doing!
I swiftly moved from C to C++, and learned MFC, and then went on to real-time C on Unix. After this I moved to the company for which I currently work, which specialises in Configuration Management software, and currently program mainly in C/C++, for Windows. I have been gradually moving their legacy C code over to use C++ (with STL, MFC, ATL, and WTL). I have pulled in other technologies (Java, C#, VB, COM, SOAP) where appropriate, especially when integrating with third-party products.
In addition to that, I have overseen the technical side of the company website (ASP, VBScript, JavaScript, HTML, CSS), and have also worked closely with colleagues working on other products (Web-based, C#, ASP.NET, SQL, etc).
For developing, I mainly use Visual Studio 2010, along with an in-house-designed editor based on Andrei Stcherbatchenko's
syntax parsing classes, and various (mostly freeware) tools. For website design, I use Dreaweaver CS3.
When not developing software, I enjoy listening to and playing music, playing electric and acoustic guitars and mandolin.