因为一种特别的需要 做了一个小程序主要三个功能
设置窗体透明
- void CSetDlg::SetTransparent()
- {
- ::SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);//TopMost
- SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
- HINSTANCE hModule=LoadLibrary("User32.DLL");
- if(hModule==NULL)
- {
- return;
- }
- typedef BOOL (WINAPI *FN_SetColor)(HWND,COLORREF,BYTE,DWORD);
- FN_SetColor SetColor = NULL;
- SetColor=(FN_SetColor)GetProcAddress(hModule,"SetLayeredWindowAttributes");
- if (SetColor==NULL)
- {
- return;
- FreeLibrary(hModule);
- }
- SetColor(this->GetSafeHwnd(),0,50,2);
- FreeLibrary(hModule);
- }
全屏幕显示窗体
- void CSetDlg::SetFullScreen()
- {
- LONG style = ::GetWindowLong(this->m_hWnd,GWL_STYLE);
- style &= ~(WS_DLGFRAME | WS_THICKFRAME);
- SetWindowLong(this->m_hWnd,GWL_STYLE, style);
- this->ShowWindow(SW_SHOWMAXIMIZED);
- CRect rect;
- this->GetWindowRect(&rect);
- ::SetWindowPos(this->m_hWnd,HWND_NOTOPMOST,rect.left-1, rect.top-1, rect.right-rect.left + 3, rect.bottom-rect.top + 3, SWP_FRAMECHANGED);
- }
隐藏任务栏
- void CSetDlg::SetTaskBarHide()
- {
- ::SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE, WS_EX_TOOLWINDOW);
- }