Programming - cpueblo.com

윈도우 Event 만을 처리하기 위한 창문 없는 윈도우 생성 및 제거 함수 (VCL 의 AllocateHWnd 구현) - CreateWindowEx()


글쓴이 : 유광희 날짜 : 2004-12-15 (수) 10:47 조회 : 8954

HWND                        AllocateHWnd(HINSTANCE hInstance, WNDPROC WndMethod);
void                        DeallocateHWnd(HWND hWnd);

HWND TDownloader :: AllocateHWnd(HINSTANCE hInstance, WNDPROC WndMethod)
{
        char sClassName[5];

        sprintf(sClassName, "%d", GetTickCount());

        HWND hWndResult;

        WNDCLASS WndClass;

        WndClass.cbClsExtra = 0;
        WndClass.cbWndExtra = 0;
        WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
        WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        WndClass.hInstance = hInstance;
        WndClass.lpfnWndProc = WndMethod;
        WndClass.lpszClassName = sClassName;
        WndClass.lpszMenuName = NULL;
        WndClass.style = CS_HREDRAW | CS_VREDRAW;
        RegisterClass(&WndClass);


        hWndResult = CreateWindowEx(
                WS_EX_TOOLWINDOW,
                sClassName,
                "",
                WS_POPUP,
                0,
                0,
                0,
                0,
                0,
                0,
                hInstance,
                NULL);


        if (!hWndResult)
        {
                int ErrorCode = GetLastError();
                ASSERT(0);
        }

        SetWindowLong(hWndResult, GWL_WNDPROC, (LONG)WndMethod);

        return hWndResult;
}

void TDownloader :: DeallocateHWnd(HWND hWnd)
{
        DestroyWindow(hWnd);
}
잘 쓰십시요!!!!!

   
QR CODE