Programming Guide |
Install a message handler to be called by Panther's Windows message loop
void sm_mw_install_msg_callback(PiMwMsgCbFunc_t callback, LPVOID context);
callback
- A callback function that will be called when Panther gets a Windows message from its message queue. If
NULL
is passed, the current callback function (if any) will be uninstalled.When callback is called, it is passed two parameters, an LPMSG structure containing the Windows message and context. It should return
TRUE
if no more processing should take place on the message, elseFALSE
so that Panther can continue normal message processing.context
- Information to pass when callback is called It can be a Window handle; a structure or some other useful pointer. If not needed, you should pass
NULL
.
Windows C/C++
sm_mw_install_msg_callback
installs a function that is called when Panther gets a message from its message queue. It should be used, for example, when an application opens windows outside of the Panther framework.
#include <smdefs.h>
#include <smmwuser.h>
extern "C"
{
void OpenMyDialog()
{
HWND hParent = GetParent(sm_mw_drawingarea());
CMyDialog* myDialog = new CMyDialog(CWnd::FromHandle(hParent));
}
BOOL CALLBACK
MsgCallback (LPMSG pMsg, LPVOID context)
{
if (context) // process messages for our dialog
{
CMyDialog* d = (CMyDialog*)context;
if (IsDialogMessage(d->m_hWnd, pMsg))
return TRUE;
}
return FALSE;
}
CMyDialog::CMyDialog(CWnd* pParent)
: CDialog(CMyDialog::IDD, pParent)
{
Create(CMyDialog::IDD, pParent);
ShowWindow(SW_SHOW);
}
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyDialog::OnActivate(UINT nState, CWnd* pWndOther,
BOOL bMinimized)
{
if (nState == WA_INACTIVE)
{
sm_mw_install_msg_callback(NULL, NULL);
}
else
{
sm_mw_install_msg_callback(MsgCallback, (LPVOID)this);
}
CDialog::OnActivate(nState, pWndOther, bMinimized);
}
}