本文介绍了获取其他语言的窗口名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,正在Windows平台上用C语言创建一个项目.
我正在尝试使用winAPI 32开发一个小型应用程序.

我正在从winprog.org上获得在线教程,在我的教程中,我是根据给定的代码创建一个窗口,但是当我运行代码时,我的窗口名称似乎使用了不同的语言.
我使用的代码如下.我不明白为什么会这样.请帮帮我..

我会非常感谢你.

I am a newbie and creating a project in c language on windows platform.
I am trying to develop a small application using winAPI 32.

I am taking online tutorial from winprog.org, in my tutorial I am creating a window from a given code but when I run the code, my window name appears to be in different language.
The code I used is given below. I am not able to understand why this is happening. Please help me ..

I''ll be very thankful to you.

#include<"windows.h">

/* The name of your window class, can be used multiple
   times after registered. */
const char *ClassName = "MyWindow";

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
            WPARAM wParam, LPARAM lParam);

// When using the windows API you use WinMain instead of main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev,
                   LPSTR lpCmdLine, int nShowCmd) {

    // The window class struct.
    WNDCLASSEX wc;
    // Handle to our window.
    HWND hWnd;
    // Will hold messages sent to our window.
    MSG msg;

    // The size of the structure
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
    wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
    wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
    wc.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
    wc.hInstance = hInstance;
    wc.lpfnWndProc = WndProc;
    wc.lpszClassName = ClassName;
    wc.lpszMenuName = NULL;
    wc.style = 0;

    // Register the class to be used with CreateWindow.
    if(!RegisterClassEx(&wc)) {
        MessageBox(NULL, "Could not register window.", "Error",
            MB_ICONEXCLAMATION | MB_OK);
        return -1;
    }

    // Create the window using the "MyWindow" class.
    hWnd = CreateWindowEx(WS_EX_WINDOWEDGE, ClassName, "Basic Window",
        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 200, 150,
        NULL, NULL, hInstance, NULL);

    // If the window was not created show error and exit.
    if(hWnd == NULL) {
        MessageBox(NULL, "Could not create window.", "Error",
            MB_ICONEXCLAMATION | MB_OK);
        return -1;
    }

    // Set the windows show state, to show it.
    ShowWindow(hWnd, nShowCmd);
    // Draw the window.
    UpdateWindow(hWnd);

    // Retrieve messages from the message queue.
    while(GetMessage(&msg, NULL, 0, 0) > 0) {
        // Convert virtual key messages into a char
        TranslateMessage(&msg);
        // Send the message to our WndProc function
        DispatchMessage(&msg);
    }

    return msg.wParam;
}

// This will handle the messages.
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
                         WPARAM wParam, LPARAM lParam) {

    switch(uMsg) {
        // Recieved when the user hits the X box or alt-F4
        case WM_CLOSE:
            // Tell the program to end, and dispath WM_DESTROY
            DestroyWindow(hWnd);
            break;
        case WM_DESTROY:
            // End the program.
            PostQuitMessage(0);
            break;
        default:
            // DefWindowProc processes anything we don't.
            return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }

    return 0;
}

推荐答案


这篇关于获取其他语言的窗口名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:01
查看更多