1.弹出窗口用
DWORD dwStyle = WS_POPUP | WS_SYSMENU;
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
就可以了
2.可以利用这个函数来保存额外数据
SetProp(m_hWnd,_T("CometClassPtr"),this);
3.取出桌面工作区
SystemParametersInfo(SPI_GETWORKAREA,NULL,&rc,NULL);
SetWindowPos(m_hWnd,NULL,rc.right-nWidth,rc.bottom-nHeight,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW);
4. 创建粗画笔
m_hFont= (HFONT)GetStockObject(DEFAULT_GUI_FONT);
LOGFONT lf;
GetObject (m_hFont,sizeof(LOGFONT), &lf);
lf.lfWeight=FW_BOLD;
m_hBoldFont=CreateFontIndirect(&lf);
5.获取ICON
//获取资源中的ICON图标
TCHAR szFileName[MAX_PATH]={0};
GetModuleFileName(NULL,szFileName,MAX_PATH);
SHFILEINFO shfi;
SHGetFileInfo (szFileName, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO),SHGFI_ICON|SHGFI_SMALLICON);
m_hAppSmallIcon=shfi.hIcon;
HICON hIcon=(HICON)SendMessage(m_hWnd,WM_GETICON,ICON_SMALL,NULL);
6.获取标题栏字符
int nLen=GetWindowTextLength(m_hWnd);
if(nLen){
CString strText;
GetWindowText(m_hWnd,strText.GetBuffer(nLen+1),nLen+1);
strText.ReleaseBuffer();
}
7.OnPaint里自行处理
LRESULT CNewsWindow::OnPaint(UINT message, WPARAM wParam, LPARAM lParam)
{
if(!m_hCacheDC){
if(!DrawWindow())
return DefWindowProc( message, wParam, lParam);
}
PAINTSTRUCT ps;
BeginPaint(m_hWnd,&ps);
int nWidth=ps.rcPaint.right-ps.rcPaint.left;
int nHeight=ps.rcPaint.bottom-ps.rcPaint.top;
BitBlt(ps.hdc,ps.rcPaint.left,ps.rcPaint.top,nWidth,nHeight,m_hCacheDC,ps.rcPaint.left,ps.rcPaint.top,SRCCOPY);
EndPaint(m_hWnd,&ps);
return 0;
}
8.发送标题栏按下消息
::SendMessage (m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);