Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CWnd::PostMessage()
BOOL CMyDoc::OnNewDocument()
{
// Get a pointer to the main frame window
CWnd* pMainFrame = ::AfxGetMainWnd();
// Now post a message to the main frame
pMainFrame->PostMessage(WM_USER,NULL,NULL);
}
BOOL MainFrame::PreTranslateMessage(MSG* pMsg)
{
// catch any WM_USER messages
if (pMsg->message == WM_USER)
{
// we know a new doc has been created!
}
}
PostMessage()
// Defines go in the header file!
#define kMsg_Open 1234
#define kMsg_Save 1235
#define kMsg_New 1236
// An example would be to send this message from the
// document's OnSaveDocument() override
pMainFrame->PostMessage(WM_USER,kMsg_Save,NULL);
BOOL MainFrame::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_USER &&
pMsg->wParam == kMsg_Save &&
pMsg->lParam == NULL)
{
// We know a doc has been saved
}
}
MyClass
OnSaveDocument()
BOOL CMyDoc::OnSaveDocument()
{
MyClass anObject;
pMainFrame->PostMessage(WM_USER,kMsg_Save,(int)&anObject);
}
BOOL MainFrame::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_USER &&
pMsg->wParam == kMsg_Save)
{
MyClass* pAnObject = (MyClass*)pMsg->lParam;
}
}
m_DBDialog
BOOL MainFrame::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_USER &&
pMsg->wParam == kMsg_Save)
{
MyClass* pAnObject = (MyClass*)pMsg->lParam;
// relay the message and pointer to database dialog
m_DBDialog->PostMessage(WM_USER,kMsg_Save,(int)pAnObject);
}
}
PreTranslateMessage()