因为一种特别的需要 做了一个小程序主要三个功能
设置窗体透明
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); }
本文介绍了一个小型程序的三个核心功能:设置窗体透明度、全屏显示及隐藏任务栏的方法。通过具体的C++代码实现,展示了如何利用Windows API进行窗体属性的调整。
3608

被折叠的 条评论
为什么被折叠?



