[WinAPI] Come on, China

 

But I'm lazy hhhhhhh

// definition of data types and data structures windows.h file contains the desired application 
#include <windows.h> 
LRESULT CALLBACK the WndProc (the HWND, UINT, WPARAM, LPARAM); // Window Function Description
 // - ------- following initialization window class -------------- 
int WINAPI the WinMain (hInstance the hINSTANCE, the hINSTANCE hPrevInst, the lpszCmdLine LPSTR, int the nCmdShow)
{
    HWND hwnd;
    MSG Msg;
    WNDCLASS wndclass;
    char , lpszClassName [] = " window " ;      // window class name 
    char lpszTitle [] = " My_Windows " ;     // window title name

    // definition window class 
    wndclass.style the CS_HREDRAW = | CS_VREDRAW;                   // window type is the default type 
    wndclass.lpfnWndProc = the WndProc;       // window handler for the WndProc 
    wndclass.cbClsExtra = 0 ;              // window class with no extension 
    wndclass.cbWndExtra = 0 ;              // window instance no extension 
    wndclass.hInstance = hInstance;      // this instance handle 

    wndclass.hIcon = the LoadIcon (NULL, IDI_APPLICATION); // minimized icon in the window to the default icon 
    wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; // window using the cursor arrow
    = wndclass.hbrBackground (HBRUSH) the GetStockObject (WHITE_BRUSH); // window background is white 
    wndclass.lpszMenuName = NULL; // window no menu 
    wndclass.lpszClassName =, lpszClassName; // window class named "sample window"
 // - register window class --------- the following 
    IF (! the RegisterClass (& the WNDCLASS)) // If the registration fails then sound an alarm sounds Gao 
    {
        MessageBeep (0);
        return FALSE;
    }

// Create a window 
    hwnd = CreateWindow (
                        lpszClassName, // window class name 
                        lpszTitle,       // title name of the window instance 
                        WS_OVERLAPPEDWINDOW, // window style 
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,   // window coordinates of the upper left corner as the default value 
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,   // window of Gao and wide to the default value 
                        NULL,            // the window no parent window 
                        NULL,            // the window without the main menu 
                        hInstance,       // create the window of the application currently handle 
                        NULL             // do not use this value 
                        ) ;



    The ShowWindow (HWND, the nCmdShow);         // display window 
    the UpdateWindow (HWND);                  // draw a user area 
    the while (the GetMessage (& Msg, NULL, 0 , 0 )) // message loop 
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return msg.wParam;                   // program termination information back to the system 
}



#define LaR (rect.right+rect.left)
#define UaD (rect.top+rect.bottom)
//窗口函数
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hDC;
    HBRUSH hBrush;
    HPEN hPen;
    RECT rect;
    PAINTSTRUCT PtStr;
    POINT pt;

    switch(message)
    {
    case WM_PAINT:
        hDC = BeginPaint(hWnd, &PtStr);
        GetClientRect(hWnd, &rect);

        // Z
        hPen = CreatePen(PS_SOLID, 10, RGB(255,0,0));
        SelectObject(hDC, hPen);
        MoveToEx(hDC, LaR/16, UaD/3, NULL);
        LineTo(hDC, LaR/16*3, UaD/3);
        LineTo(hDC, LaR/16, UaD/3*2);
        LineTo(hDC, LaR/16*3, UaD/3*2);

        //G
        MoveToEx(hDC, LaR/16*7, UaD/3, NULL);
        LineTo(hDC, LaR/16*5, UaD/3);
        LineTo(hDC, LaR/16*5, UaD/3*2);
        LineTo(hDC, LaR/16*7, UaD/3*2);
        LineTo(hDC, LaR/16*7, UaD/2);
        LineTo(hDC, LaR/16*6, UaD/2);

        //J
        MoveToEx(hDC, LaR/16*9, UaD/3, NULL);
        LineTo(hDC, LaR/16*11, UaD/3);
        MoveToEx(hDC, LaR/16*10, UaD/3, NULL);
        LineTo(hDC, LaR/16*10, UaD/3*2);
        LineTo(hDC, LaR/16*9, UaD/3*2);
        LineTo(hDC, LaR/16*9, UaD/9*5);

        //Y
        MoveToEx(hDC, LaR/16*13, UaD/3, NULL);
        LineTo(hDC, LaR/16*14, UaD/9*4);
        LineTo(hDC, LaR/16*15, UaD/3);
        MoveToEx(hDC, LaR/16*14, UaD/9*4, NULL);
        LineTo(hDC, LaR/16*14, UaD/3*2);



        DeleteObject(hPen);
        EndPaint(hWnd, &PtStr);

        return 0;

    case WM_DESTROY:
        PostQuitMessage ( 0 );                  // calls PostQuitMessage WM_QUIT message sent 
        return  0 ;
     default :
         return the DefWindowProc (the hWnd, Message, the wParam, the lParam); // use the system default message handler default

    }

}

 

Guess you like

Origin www.cnblogs.com/Vikyanite/p/12448376.html