分享
 
 
 

对话框的属性设为了无title bar,任务栏中没有了图标怎么办

王朝vc·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

在基于对话框的应用程序中,对话框的属性设为了无title bar,则生成的程序就在任务栏中没有了图标,我在做一个界面程序中遇到了这个问题。

在csdn的论谈上经过sam1111)、 chief、 2ndboy、 waiwaiwai等朋友的帮忙终于得出了结论。

在OnInitDialog()中加入:

ModifyStyle(0, WS_SYSMENU);

SetWindowText("MyTitle");

就可以了。

究其原因见waiwaiwai(我总不明白) 给出的英文资料

BUG: Dialog Editor Doesn't Permit a Taskbar Icon if the Titlebar Is Off

ID: Q249291

--------------------------------------------------------------------------------

The information in this article applies to:

Microsoft Visual C++, 32-bit Editions, versions 5.0, 6.0

--------------------------------------------------------------------------------

SYMPTOMS

It is possible to create an MFC dialog box-based application with no title bar by turning off the dialog box's standard Title bar style. However, when the application runs, the shell taskbar displays a blank button with no icon and no text, even though the icon resource exists.

CAUSE

For the shell's taskbar to display an icon, the dialog template needs the System menu style WS_SYSMENU. The resource editor automatically disables that style and others if the Title bar style is not turned on.

RESOLUTION

Manually add the WS_SYSMENU style by editing the resource as text. If you will be editing any resources afterwards, you will also need to move the dialog resource to the res\<projname>.rc2 file. This prevents the resource editor from overwriting your change, but it also prevents you from being able to edit the dialog box with the resource editor.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

For some applications, a dialog box functions conveniently as a main window. Visual C++ provides a dialog-based option in the MFC AppWizard (exe) for that purpose. If you want a main dialog window without a standard title bar in such an application, you must edit the dialog properties in ResourceView. To do this, follow these steps in your open project:

From the File menu, select New. Select the MFC AppWizard (exe). Name it NoTitle and click OK.

In Step 1 of the AppWizard, select Dialog-based. Click Finish, then click OK on the confirmation dialog box.

In ResourceView, expand the Dialog resources. Double-click IDD_NOTITLE_DIALOG.

Right-click an unused area of the dialog box, and select Properties.

In the Properties editor, click the Styles tab, and clear the Title bar check box.

If you build and run the project at this point, you will notice that the button that the shell normally displays in the taskbar for your running application is completely blank. There is no icon, and there is no text.

If you go back to the Properties editor for the main dialog box at this point, you will notice that various items in the Styles tab are disabled. One of those items is the System menu check box. That check box controls adding the WS_SYSMENU style to the dialog resource. The dialog needs this style in order for the application icon to appear in the taskbar. For additional information on how to display an icon in the title bar, click the article number below to view the article in the Microsoft Knowledge Base:

Q179582 HOWTO: Set the Title Bar Icon in a Dialog Box

Though the resource editor prevents adding the WS_SYSMENU style to a dialog box with no title, the combination is possible. You can manually edit the <projname>.rc file to put the WS_SYSMENU style in and verify that it causes an icon to appear in the taskbar button:

In the open project created earlier, from the File menu, select Open.

In the Open as dropdown list, select Text.

Type NoTitle.rc in the File name edit box, then click Open. If the ResourceView is open for the project, you will see a warning dialog box that the resource editor will be closed. Click OK to allow that.

Move down to the Dialog section of the .rc file. Locate the IDD_NOTITLE_DIALOG DIALOGEX resource.

On the line labeled STYLE following the dialog name, append:

| WS_SYSMENU

Now, select the lines defining the dialog resource, starting with the resource name down to and including the END tag. Using the standard editor, select by dragging the mouse over those lines.

From the Edit menu, select Cut. The selected resource disappears.

Open the NoTitle.rc2 resource file. On the workspace pane, click the FileView tab. Expand the project's Resource Files folder, and double-click the NoTitle.rc2 file.

Position the cursor at the end of any text in the NoTitle.rc2 file (or at another convenient location), then from the Edit menu, click Paste. The dialog resource has now been transferred to the manually edited resource file.

Press CTRL+F5 to build and run the project. Note that an icon now appears on the taskbar button associated with your application.

Clearing the Title bar check box also disables the Caption field in the dialog resource General properties. If you add a CAPTION entry in the resource with or without a WS_CAPTION style, you will get a title bar anyway. To display text in the taskbar button, you must call SetWindowText() in the OnCreate() handler or some other appropriate place:

From the View menu, select ClassWizard.

On the Message Maps tab, select the main dialog class from the Class name drop down list.

In the Messages list, double-click the WM_CREATE message. Click the Edit code button.

Under the TODO line, just before the return from the function, add:

SetWindowText("MyTitle");

Press CTRL+F5 to build and run the project. Notice that the application has no title bar, but an icon and the text you entered in the SetWindowText() call appear on the taskbar button.

Additional query words:

Keywords : kbEditor kbide kbResourceEd kbVC600bug kbDSupport kbGrpDSTools

Version : winnt:5.0,6.0

Platform : winnt

Issue type : kbbug

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有