【发布时间】:2015-05-11 06:48:28
【问题描述】:
我有一个检查 dotnet 框架的小应用程序,如果没有安装它会安装它
现在,当应用程序启动时,我想弹出一个 gif 图像,并在后台检查框架并安装。
这里的问题是它不能有任何先决条件来运行应用程序
这是我目前所拥有的
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
int exitCode = -1;
showPic(hInstance);
MessageBox(0L, L"Dotnet will installed", L"Alert", 0);
auto fut = std::async(std::launch::async, DoWork, hInstance, lpCmdLine);
fut.wait();
exitCode = fut.get();
return exitCode;
}
showPic()
void showPic(HINSTANCE hInstance)
{
loadImage(hInstance);
// create window
wnd = createWindow(hInstance);
SetWindowLong(wnd, GWL_STYLE, 0);
ShowWindow(wnd, SW_SHOW);
}
loadImage(HINSTANCE hInstance)
void loadImage(HINSTANCE hInstance)
{
imageDC = CreateCompatibleDC(NULL);
imageBmp = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
imageBmpOld = (HBITMAP)SelectObject(imageDC, imageBmp);
}
现在这里发生的情况是,如果我不显示消息框,则图片不会加载到窗口中,并且窗口仍然进入无响应模式,我也无法使用 gif,只能使用 bmp 图像 任何帮助都会得到帮助
现在因为我等待 fut 很明显它会阻止 ui 直到它具有值,解决方法是什么
【问题讨论】:
标签: c++ multithreading winapi