CWnd::SendMessage
发送指定的信息放入此窗口。
LRESULT SendMessage(
UINT message,
WPARAM wParam = 0,
LPARAM lParam = 0
);
参数
message
指定要发送的消息。wParam
指定其他消息相关的信息。lParam
指定其他消息相关的信息。
返回值
消息处理结果;其值取决于发送的消息。
备注
SendMessage 成员直接函数调用windows程序而不是返回,直到该窗口过程处理消息。 与 PostMessage 成员函数不同,这是,将消息发送到窗口的消息队列并立即返回。
示例
void CAboutDlg::OnPaint()
{
// This code, normally emitted by the Application Wizard for a dialog-
// based project for the dialog's WM_PAINT handler, runs only if the
// window is iconic. The window erases the icon's area, then
// paints the icon referenced by m_hIcon.
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
要求
Header: afxwin.h