一次显示CAxDialogImpl和CWindowImpl. [英] Display a CAxDialogImpl and a CWindowImpl at once.

查看:131
本文介绍了一次显示CAxDialogImpl和CWindowImpl.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的ATL员工,

我有一个可能是新手的问题,对此深表歉意.我有一个
CAtlExeModuleT(请参见下面的代码),并且想要调整一个我得到的样本.首先,在CAtlExeModuleT的PreMessageLoop中创建模式CAxDialogImpl对象.我想做的是使对话框无模式,以便我可以另外显示CWindowImpl
(可以选择稍后使其全屏显示jpeg).
因此可以创建一个CAxDialogImpl和CWindowImpl哪个都以桌面为父级(在Create调用中将NULL作为第一个参数)?还是它们必须彼此关联(形成一个父子链)?当我执行下面的代码时,程序
运行一会儿,然后结束而不显示任何内容.在创建窗口之后添加了
Sleep(5000),并且该窗口可见.
所以这似乎是范围的问题.但是对话框不可见.
如何正确创建窗口和无模式对话框并且不会超出范围,以便事件
处理正常?我是否必须将它们放入PreMessageLoop
(我尝试过,但是效果是相同的;我是否需要
PreMessageLoop)? -我希望使用_tWinMain解决方案仅在可能的情况下摆脱PreMessageLoop.

请帮助,对于那些对ATL有一定经验的人来说,这不是一个难题.您确实会极大地帮助我,因为尽管有两本关于ATL和Web的书,我还是被完全卡住了(我只发现在他们的考试中,他们使用较旧的CCom东西,并在
_tWinMain和
而不是如何在CAtlExeModuleT的上下文中使用ATL窗口,就像在这种情况下我需要的那样(ATL 8.0,Visual Studio 2005).

希望能给我带来帮助

最诚挚的问候,
Peter.


以下是代码:

>

Dear ATL people,

I have a maybe-newbie question, so sorry for that. I have a
CAtlExeModuleT (see code below) and want to adjust a sample that I
got. It started by creating a modal CAxDialogImpl object in the
PreMessageLoop of the CAtlExeModuleT. What I wanted to do is to make
the dialog modeless so that I can display additionally a CWindowImpl
(with the option to make it fullsceen later, to display jpegs).
So is it possible to create a CAxDialogImpl and a CWindowImpl which
both have the desktop as parent (giving NULL as first parameter in
the Create call)? Or do they have to be related to each other (forming
a chain of parent-child)? When I execute the code below the program
runs for short and then ends without displaying anything. I added
a Sleep(5000) after the window creation and the window was visible.
So it seems to be a matter of scope. But the dialog wasn't visible.
How could I get it work that the window AND the modeless dialog are
created correctly and do not go out of scope so that the event
handling works properly? Do I have to put them in PreMessageLoop
(I tried this, but the effect was the same; do I need
PreMessageLoop)? - I would prefer a solution with _tWinMain only to
get rid of the PreMessageLoop if possible.

Please help, I think it's not a hard problem for someone who has some
experience with the ATL. You would really help me greatly because I am
totally stuck despite two books on ATL and the web (I only found exam-
ples where they use the older CCom stuff with a main message loop in
_tWinMain and TranslateMessage(&msg) and DispatchMessage(&ms) into it)
but not how to use ATL windows in context of the CAtlExeModuleT like
I need in this case (ATL 8.0, Visual Studio 2005).

So with the hope on help I send you

Best regards,

Peter.


Here comes the code:

代码段

推荐答案

在//Sleep之后放入消息循环(5000)条评论

味精味精;

Put a message loop in after the //Sleep(5000) comment

MSG msg;

 

//主消息循环:

 

同时 (GetMessage(& msg,NULL,0,0))

{

while (GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(& msg);

TranslateMessage(&msg);

DispatchMessage(& msg);

DispatchMessage(&msg);

}


这篇关于一次显示CAxDialogImpl和CWindowImpl.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆