当前位置:网站首页>ELS register window class, create window class, display window

ELS register window class, create window class, display window

2022-07-26 03:15:00 joker_ 0030

#include<Windows.h>
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR ipCmdLine,int nCmdShow)
{
    // Initialize window class .
    WNDCLASSEX  db;//WNDCLASS An extension of .
    HWND hWnd;

    db.cbClsExtra = 0;
    db.cbSize = sizeof(WNDCLASSEX);
    db.cbWndExtra = 0;
    db.hbrBackground = (HBRUSH)COLOR_WINDOW;
    db.hCursor = NULL;
    db.hIcon = NULL;
    db.hIconSm = NULL;
    db.hInstance = hInstance;
    db.lpfnWndProc = NULL;
    db.lpszClassName = "els";
    db.lpszMenuName = NULL;
    db.style = CS_HREDRAW | CS_VREDRAW;

   // Register window class .
   //ATOM//unsigned short type .
    if(0==RegisterClassEx(&db));// Return to zero , Registration failed .
    {// Something went wrong , I don't know what the mistake is .
        int a = GetLastError();// The return value is 87, Through the tool -> Error finding can show that it is parameter error .
        return 0;
    }


    // create a window .hWnd Window handle Failure to return NULL.
   hWnd=CreateWindowEx(WS_EX_TOPMOST,"els","elsfangkuai",WS_OVERLAPPEDWINDOW,100,100,100,100,NULL,NULL,hInstance,NULL);
    // The first parameter dwExStyle Specifies a style of the window .
    // The second parameter lpClassName, The name of the window class , The system is visible .
    // The third parameter lpWindowName , The name of the window , People can see it .
    // Fourth parameter hWndParent , Parent window handle .
    // Fifth parameter dwStyle , Specify the style of creating the window .
    // Sixth parameter x,y , Specify the initial level of the window , Vertical position , Relative to the desktop .
    // Seventh parameter nWidth,nHeight: The width and height of the window .hWndParent: Parent window handle , Not set to NULL. 
    // Eighth parameter hMenu Menu handle , If not, set it NULL. 
    // The ninth parameter hinstance: Current real column handle .
    // The tenth parameter points to a pointer to a value , This value is passed to the window WM_CREATE news , This value is passed in IParam In the parameter CREATESTRUCT Structure transfer . If the application calls CreateWindow Create a MDI Customer window , be ipParam Must point to a CLIENTCREATESTRUCT structure ,MDI-- Multi document window style .
    if (NULL == hWnd)// Window handle . Unique identification of the window .
    {
        return 0;
    }

// Display window

ShowWindow(hWnd,nCmdShow);

// Return value : Visual return true, Hidden return false.

// Parameters 1: Window handle . Parameters 2: Specifies how the window is displayed , It can be for nCmdShow( The default is SW_SHOWNORAML).

    return 0;
}
   

原网站

版权声明
本文为[joker_ 0030]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207260309421173.html