封装一个Win32弹出提示框的函数
VOID CreateToolTip(
HWND hDlg,
DWORD dwIdNum,
LPBYTE lpbyTipMsg )
{
TOOLINFO tinfo;
HWND hWndTip;
hWndTip = CreateWindowEx(
0,
TOOLTIPS_CLASS,
(LPSTR)NULL,
TTS_ALWAYSTIP | TTS_NOPREFIX ,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hDlg,
NULL,
ghInst,
NULL );
if( !hWndTip ){
return;
}
tinfo.cbSize = sizeof( TOOLINFO );
tinfo.uId = (UINT)GetDlgItem( hDlg, dwIdNum );
tinfo.lpszText = (LPTSTR)lpbyTipMsg;
tinfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
tinfo.hwnd = hDlg;
tinfo.hinst = ghInst;
SendMessage(
hWndTip,
TTM_SETMAXTIPWIDTH,
0,
(LPARAM)(INT)500);
SendMessage(
hWndTip,
TTM_ADDTOOL,
0,
(LPARAM)( (LPTOOLINFO)&tinfo ));
return;
}
注意两点:1、STATIC控件ID不能是默认的ID(IDC_STATIC) 2、在设计器中将STATIC Notify通知消息设置为TRUE (属性面板)