怎么给应用程序的窗口加上系统的样式
我用的是win7系统
直接用API  CreateWindow创建的窗口和按钮等等
太朴素了,和WIN98一样,我想要让它用上系统主题

解决方案 »

  1.   

    在stdafx.h中加入manifest
    #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
      

  2.   

    warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'"; ignored出警告了
      

  3.   

    效果没有变,还是经典主题,我想要WIN7的主题效果
      

  4.   

    #ifdef _UNICODE
    #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_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
    #endif使用 UNICODE 字符集编译工程
      

  5.   

    同意ls,你的工程是Unicode编码的吗?
      

  6.   

    我已经按照网上说的
    把_MBCS那个选项改成_UNICODE了,编译环境应该是UNICODE了把
    可是还是没有样式
    我在学WIN SDK,是直接用API建立的窗口,全部代码如下
    #include <Windows.h>#ifdef _UNICODE
    #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_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
    #endif
    int main(int args, char **argc)
    {
    void wintest2();
    wintest2(); return 0;
    }LRESULT WINAPI WinProc2(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        switch (msg)
        {
    case WM_KEYUP:
    MessageBox(hWnd, "hehe", "cap", MB_YESNO);
    break;
    case WM_CREATE:
    break;
        case WM_PAINT:
            break;
    case WM_CLOSE:
    break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        }

        return DefWindowProc(hWnd, msg, wParam, lParam);
    }void wintest2()
    {
    WNDCLASSEX wndclsex;
    HANDLE hWnd, hWnd2;
    MSG msg;

    wndclsex.cbSize = sizeof(WNDCLASSEX);
    wndclsex.cbClsExtra = 0;
    wndclsex.cbWndExtra = 0;
    wndclsex.lpszClassName = "Stardust Window Class";
    wndclsex.lpszMenuName = NULL;
    wndclsex.lpfnWndProc = WinProc2;
    wndclsex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wndclsex.hIconSm = NULL;
    wndclsex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclsex.hbrBackground = (HBRUSH) COLOR_WINDOW;
    wndclsex.style = CS_HREDRAW | CS_VREDRAW;
    RegisterClassEx(&wndclsex); hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "Stardust Window Class", "TEST", WS_OVERLAPPEDWINDOW ^ WS_MAXIMIZEBOX ^ WS_THICKFRAME ^ WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, NULL, NULL);
    ShowWindow(hWnd, SW_SHOW); CreateWindowEx(0, "STATIC", "名称:", WS_CHILD | WS_VISIBLE, 30, 80, 48, 48, hWnd, NULL, NULL, NULL);
    CreateWindowEx(0, "EDIT", "", WS_BORDER | WS_CHILD | WS_VISIBLE, 30 + 48 + 10, 80, 128, 24, hWnd, NULL, NULL, NULL); CreateWindowEx(0, "BUTTON", "hehe", WS_CHILD | WS_VISIBLE, 80, 180, 128, 48, hWnd, NULL, NULL, NULL);

    while(GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }
      

  7.   

    我换成VS2010版本用了上面的方法就有效果了
    VC6却没用,一模一样的代码啊
    诡~~~~
    谁能帮我解释一下啊