API 1 363p~366p Childs 帳ϴ. ¥:2023-12-10 5:17:29 ȸ:386
ۼ : Ȳݰġ
Ʈ : 86
: 2022-05-06 15:33:18
湮Ƚ : 67
12, 13
Ұ : ȳϼ. api ϱϿ ߽ϴ. Ź帳ϴ.
ۼ

#include<Windows.h>

HINSTANCE g_hInst;
LPCTSTR MyClassName = TEXT("FistClass");

HWND hWndMain,hC1,hC2,hC3;
HBRUSH hRedBrush, hBlueBrush, hGreenBrush;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChildLeftProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChildTopProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChildBottomProc(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) {
    
    WNDCLASS wndclass{};
    HWND hWnd{};
    MSG msg{};
    g_hInst = hInstance;

    hRedBrush = (HBRUSH)CreateSolidBrush(RGB(255,0,0));
    hGreenBrush = (HBRUSH)CreateSolidBrush(RGB(0,255,0));
    hBlueBrush = (HBRUSH)CreateSolidBrush(RGB(0,0,255));


    wndclass.lpfnWndProc = WndProc;
    wndclass.lpszClassName = MyClassName;
    wndclass.hInstance = hInstance;
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wndclass.cbWndExtra = 0;
    wndclass.cbClsExtra = 0;
    wndclass.lpszMenuName = NULL;
    wndclass.hbrBackground = NULL;
    wndclass.style = CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndclass);

    wndclass.hbrBackground = hRedBrush;
    wndclass.lpfnWndProc = ChildLeftProc;
    wndclass.lpszClassName = TEXT("ChildLeft");
    RegisterClass(&wndclass);

    wndclass.hbrBackground = hGreenBrush;
    wndclass.lpfnWndProc = ChildTopProc;
    wndclass.lpszClassName = TEXT("ChildTop");
    RegisterClass(&wndclass);

    wndclass.hbrBackground = hBlueBrush;
    wndclass.lpfnWndProc = ChildBottomProc;
    wndclass.lpszClassName = TEXT("ChildBottom");
    RegisterClass(&wndclass);

    hWnd = CreateWindowExW(NULL, MyClassName, MyClassName,WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT, NULL,(HMENU)NULL,hInstance,NULL);

    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);

    hWndMain = hWnd;

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

    DeleteObject(hRedBrush);
    DeleteObject(hGreenBrush);
    DeleteObject(hBlueBrush);

    
    return((int)msg.wParam);
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {

    RECT crt{};

    switch (iMessage){
    case WM_CREATE:
        hC1 = CreateWindowExW(NULL, TEXT("ChildLeft"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
            0, 0, 0, 0, hWnd, (HMENU)0, g_hInst, NULL);
        hC2 = CreateWindowExW(NULL, TEXT("ChildTop"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
            0, 0, 0, 0, hWnd, (HMENU)0, g_hInst, NULL);
        hC3 = CreateWindowExW(NULL, TEXT("ChildBottom"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
            0, 0, 0, 0, hWnd, (HMENU)0, g_hInst, NULL);
        return(0);
    case WM_SIZE:
        if (wParam != SIZE_MINIMIZED) {
            GetClientRect(hWnd, &crt);
            MoveWindow(hC1,0,0,300,crt.bottom,TRUE);
            MoveWindow(hC2,300,0,crt.right-300,150,TRUE);
            MoveWindow(hC3,300,150,crt.right-300,crt.bottom-150,TRUE);
        }
        return(0);
    case WM_DESTROY:
        PostQuitMessage(0);
        return(0);
    }
    return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}

------------------------------------------------------------------------------------------------------------

1) hRedBrush, hBlueBrush, hGreenBrush wWinMainԼ ڵ ȵǴ ? ڵ ȵDZ⿡
    DeleteObject ϴ ñմϴ.
2) hRedBrush, hBlueBrush, hGreenBrush DeleteObject ϴ ´ ñմϴ. hdc Ͽ selectobject
    ٸ OldhRedBrush Ͽ 缱 ϴ° ƴ ñմϴ. å 164pó ؾ ϴ ó
   µ ⼭ ٷ ϴ ñմϴ. hdc Ͽ ʾ ޸ ⿡ ġ
   ϴ ñմϴ.
3) hC1,hC2,hC3 hParent(θ) WndProc hWnd ϴ ´ ñմϴ. տ
   ش hWnd ޽ Է ڷ µ ش ڰ θ ڷ ϸ Ǵ ñմϴ. hInstance
   wWinMainڷ θ WndProc ؼ ñմϴ. hWndMain θ ڷ
  ߴµ ƿ ׷ ʰ ñմϴ.
4) wParam!=SIZE_MINIMIZED ϴ ñմϴ. ˷ֽñ ٶϴ.



μ
동탄맛집 일상그램 증권 per 부업 자격증 고수익 농작물 6개월아기 쇼핑몰부업,대출못갚으면,재테크 팟캐스트 투잡 회사에서✓라이브재테크재택부업추천✓초기비용없는 부업 부업 하는법✓가정주부✓재테크 site womad.life 소액펀드 월미도맛집 피부진정

Ϻ Ű ũ

۰K 1210 11:39:11  

1) ϴ Ͱ ϴ ü ϴ ٸϴ. hRedBrush ü WinMain Ǹ 귯ô ʽϴ. ׷ ü մϴ.

2) ׸⿡ ü DC ϴ ½ϴ. ׷ 귯ô DC Ѱ ƴ϶ Ŭ 귯÷ ̹Ƿ ϴ. ı ̰ Ŭ ̹Ƿ ׳ ϸ ˴ϴ.

3) WM_CREATE ޽ ü ̹Ƿ WndProc μ ޵ hWnd θ ½ϴ. 츦 ϴ ߿ ϵ带 ϴ ̴ϴ. hWndMain θ 찡 𼭳 ִ Դϴ. ׷ ϴ CreateWindowEx ʱ WM_CREATE ޽ óϴ ߿ Ե Դϴ. CreateWindowEx ڵ ؾ 츦 Ƿ ߿ WndProc ޵Ǵ hWnd ۿ ϴ.

4) ũⰡ Ǹ WM_SIZE ޽ ̶ ϵ ϵ ߽ϴ. ٸ, 찡 ּȭ ̱ ʿ ʿ䰡 ϴ. ص ϴٸ θ ũⰡ 0 ǹǷ ĩϸ 0 ߻ ֽϴ. 

Ȳݰġ 1212 12:07:50  

1, 2, 3 ش ּż մϴ. 4 wParam Ű Է ˰ ִµ 򰥸׿.
ٽ 帮 ϰڽϴ.

gcyong 1226 4:04:15  

4 wParam Ű Է ƴմϴ. ޵Ǵ ޽ (iMessage) ٸ, iMessage WM_SIZE ũⰡ û ŸԴϴ. (https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-size)

, ũ ̺Ʈ ߻ ϵ ũ⸦ ϵ, ּȭ ȭ ׷ Ƿ ʿ Ǿ ʵ üũ Դϴ.

wParam Է Ű iMessage WM_KEYDOWN ޽ ´ Դϴ.


αϼž ֽϴ.