同样 使用XP风格,VC6成功,VC2008失败

序员 2011-05-01 02:08:47
我的代码

main.cpp

#include <windows.h>
#include <commctrl.h>
#include "resource.h"
BOOL CALLBACK AboutDlgProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hwnd,0);
return TRUE;
}

}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE prev,
LPSTR CmdLine, int nCmdShow)
{

InitCommonControls();
MessageBox(NULL,TEXT("Content内容"),TEXT("Caption标题"),MB_OK);
DialogBox(hInstance,MAKEINTRESOURCE(IDD_ABOUT),NULL,AboutDlgProc);

return 0;
}



绘制了一个最简单的对话框,,IDD_ABOUT,,只有确定和取消两个按钮,
comctl32.lib 均已连接。

在VC6中,,

insert->resource->customize: 24
拷贝了如下到右边编辑框中

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="test.exe"/>
<description>Test Application</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>



然后ID 改为1

编译运行成功,,,xp的效果


在VC2008我也如法炮制(unicode工程)
在资源视图,,myapp.rc 右击---- 添加资源-----自定义-----输入24 ,
拷贝上面xml代码,改ID为1,,

最后的效果还是win98 风格,,

求解。。。。
...全文
168 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
序员 2011-05-01
  • 打赏
  • 举报
回复
nope,,那个恐怖的stdafx

老邓 2011-05-01
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 cuiy0001 的回复:]

运气真好,,,
发现了解决方案,
根本不需要什么添加manifest代码,,
不要什么 commctrl


下面代码直接OK,
当然 .rc要写好加进去。。。


C/C++ code
#include <windows.h>

#include "resource.h"
#pragma comment(linker,"/manifestdependency:\"typ……
[/Quote]
聊了半天,你也没看我在 1 楼 的 回 复 啊?
序员 2011-05-01
  • 打赏
  • 举报
回复
运气真好,,,
发现了解决方案,
根本不需要什么添加manifest代码,,
不要什么 commctrl


下面代码直接OK,
当然 .rc要写好加进去。。。


#include <windows.h>

#include "resource.h"
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
BOOL CALLBACK AboutDlgProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hwnd,0);
return TRUE;
}

}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE prev,
LPSTR CmdLine, int nCmdShow)
{


MessageBox(NULL,TEXT("Content内容"),TEXT("Caption标题"),MB_OK);
DialogBox(hInstance,MAKEINTRESOURCE(IDD_ABOUT),NULL,AboutDlgProc);

return 0;
}
序员 2011-05-01
  • 打赏
  • 举报
回复
关闭UAC,,,还是不行
序员 2011-05-01
  • 打赏
  • 举报
回复


我又重新做了一下,,
如图,,请问到这一步的时候,
您改如何使用manifest呢?可否简述下步骤?
老邓 2011-05-01
  • 打赏
  • 举报
回复
看看你5楼的命令行参数:
/MANIFESTUAC:"level='asInvoker' uiAccess='false'"

这里启用了UAC。
而XP下是没有UAC的。
你可以关掉它,具体选项可以自己找找。
序员 2011-05-01
  • 打赏
  • 举报
回复
xp系统,不知道UAC为啥?


清理后重新生成,,还是不成功
老邓 2011-05-01
  • 打赏
  • 举报
回复
1. 清理后重新生成
2. 关掉UAC试试
序员 2011-05-01
  • 打赏
  • 举报
回复
/OUT:"D:\My Documents\Visual Studio 2008\Projects\Win32\Release\dialog.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Release\dialog.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"d:\My Documents\Visual Studio 2008\Projects\Win32\Release\dialog.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
老邓 2011-05-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 cuiy0001 的回复:]

我没有用stdafx

使用了你的XML还是不行啊。。。
[/Quote]
试了1楼了?
而且你确认已经启用了:
/MANIFEST
选项?
看看命令行里的参数,帖上来。
序员 2011-05-01
  • 打赏
  • 举报
回复
我没有用stdafx

使用了你的XML还是不行啊。。。
老邓 2011-05-01
  • 打赏
  • 举报
回复
或将XML改成:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
老邓 2011-05-01
  • 打赏
  • 举报
回复
去掉资源,把这个代码回到stdafx.h,或任意代码中。
#if defined _M_IX86
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif

64,650

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧