限制对话框的 ShowWindow()
我在MFC(Wince平台)中有一个对话框,上面有一个列表框。我需要在对话框可见后生成一个线程。但有时线程似乎是在 ShowWindow() 完全执行之前启动的。我如何限制线程的执行,直到对话框在屏幕上完全可见。
问候,
穆克什
i have one dialog box in MFC(Wince platform),and one list box over it. I need to spawn a thread after dialog box become visible. But some times it seems like the thread is started before complete execution of ShowWindow(). How i can restrict the the execution of thread untill Dialog box fully visible on screen.
Regards,
Mukesh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应该使用第二个线程来进行绘图(正如其他人所说)。
如果您想在另一个线程中发生操作时更新窗口,则在另一个线程中使窗口无效以强制重新绘制,然后在重新绘制发生时使用任何新值更新窗口。这样,您就不必执行任何您遇到问题的可怕的绘制操作同步。
You shouldn't use a second thread to do drawing (as others have said).
If you want to update the window when an action occurs in another thread, then in the other thread invalidate the window to force a repaint, then when the repaint occurs update the window with whatever new values there are. This way you wont have to do any of the horrible synchronizing of paint operations that you're having a problem with.
您可能希望在第一次激活对话框时生成一个线程。您需要使用这些 WM_ACTIVATE 消息之一
You may want to spawn a thread when the dialog gets activated for the first time. You would need to use one of those WM_ACTIVATE message
为了绝对确保线程在对话框可见的同时启动,只需将线程作为第一次处理 WM_PAINT 时执行的最后一件事启动即可。
To be absolutely sure that the thread starts at the same time the dialog becomes visible, just start the thread as the last thing you do the first time WM_PAINT is processed.