开发者

How to show a window before processing in MFC

How can I get a window visible before processing?

I'm trying to do something like this:

void CMyClass::OnButton1Clicked()
{
 CString class_str = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL,IDC_ARROW),(HBRUSH)::GetStockObject(WHITE_B开发者_如何学JAVARUSH),::LoadIcon(NULL, IDI_APPLICATION));
 CWnd* wnd = new CWnd();
 wnd->Create(class_str,"Test",WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(0,0,100,100), AfxGetMainWnd(), 1432);

 //AfxMessageBox("test"); // <- if this is executed wnd gets visible before sleep()

 Sleep(5000);  //this would be processing

 wnd->DestroyWindow();
 delete wnd;

 return;
}

The window doesn't show at all. I've tried displaying it in an UI thread but it doesn't show either. If I do a message loop until window is created, it shows up but after a while the main message loop asserts.

I know it shouldn't be made like this but rather processing in worker thread, but with current code I'm working with it would require changes too big.


Disclaimer: I don't know MFC, but I know the windows API, which is what MFC was built on top of.

Perhaps you need to make a call to ShowWindow(). Also, are you handling the WM_CREATE message? If so, perhaps you are returning the wrong value.

If the above doesn't apply or make sense, disregard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜