简介本文向大家介绍一个C++实战项目:设计Duilib中通用提示框等待框窗口,以便在实际项目中重复使用,具有一定的C++实战价值,感兴趣的朋友可以参考一下。
// 通用弹窗窗口 1:提示 2:询问 3:成功 4:失败 5:警告
bool CUIProInterface::GenericPromptWnd(HWND hwnd, CString strMsg, int nType)
{
CGenericPromptWnd GenericPromptWnd;
GenericPromptWnd.Create(hwnd, _T("GenericPromptWnd"), UI_WNDSTYLE_DIALOG, UI_WNDSTYLE_EX_DIALOG);
GenericPromptWnd.InitWnd(strMsg, nType);
// 屏幕居中
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
::SetWindowPos(GenericPromptWnd.GetHWND(), HWND_TOPMOST, (cx - 400) / 2, (cy - 180) / 2, 400, 180, SWP_SHOWWINDOW);
UINT nRet = GenericPromptWnd.ShowModal();
if (nRet == IDOK)
{
return true;
}
else
{
return false;
}
}
CUIProInterface::GenericPromptWnd(NULL, _T("弹出提示框!"), 1);
if (CUIProInterface::GenericPromptWnd(NULL, _T("确定退出系统?"), 2))
{
Close(IDOK);
}
// 通用等待窗口
void CUIProInterface::GenericWaitingWnd(HWND hwnd, CString strMsg)
{
WAITING* stWaiting = new WAITING;
stWaiting->hwnd = hwnd;
stWaiting->strMsg = strMsg;
unsigned int threadid;
HANDLE hThread = (HANDLE)::_beginthreadex(NULL, 0, &Waiting, stWaiting, 0, &threadid);
CloseHandle(hThread);
HWND wnd = ::FindWindow(NULL, L"GenericWaitingWnd");
while (wnd == NULL)
{
wnd = ::FindWindow(NULL, L"GenericWaitingWnd");
Sleep(10);
}
}
unsigned __stdcall Waiting(LPVOID nlps)
{
WAITING* stWaiting = (WAITING *)nlps;
CGenericWaitingWnd *pGenericPromptWnd = new CGenericWaitingWnd(stWaiting->strMsg);
if (pGenericPromptWnd == NULL) { return 0; }
pGenericPromptWnd->Create(stWaiting->hwnd, _T("GenericWaitingWnd"), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
pGenericPromptWnd->CenterWindow();
::SetWindowPos(pGenericPromptWnd->GetHWND(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
pGenericPromptWnd->ShowModal();
delete stWaiting;
return 0;
}
HANDLE hThread = CreateThread(NULL, 0, InitThread, (LPVOID)this, 0, NULL);
CloseHandle(hThread);
// 主界面初始化线程
DWORD WINAPI InitThread(void* pVoid)
{
CMainWnd* pMainWnd = (CMainWnd*)pVoid;
if (pMainWnd)
{
pMainWnd->InitThreadFun();
}
return 0;
}
void CMainWnd::InitThreadFun()
{
CUIProInterface::GenericWaitingWnd(m_hWnd, L"正在初始化系统,请稍后...");
::Sleep(3000);
CUIProInterface::CloseUserWnd(L"GenericWaitingWnd");
}
本文向大家介绍C++界面开发之Skin++界面库使用例子,感兴趣的朋友可以参考一下。
本文向大家介绍C++SkinSharp界面库使用例子,感兴趣的朋友可以参考一下。
本文向大家介绍一个C++实战项目:Duilib实现一个圆形进度统计控件,感兴趣的朋友可以参考一下。
本文向大家介绍SOUI+LUA实现一个跑马机,感兴趣的朋友可以参考一下。
本文向大家介绍SOUI模仿360软件管家,感兴趣的朋友可以参考一下。
本文向大家介绍基于SOUI模拟Apple桌面,感兴趣的朋友可以参考一下。