본문 바로가기
IT창고/API

반투명 윈도우 만들기....플랫폼 SDK

by 창구창고 2007. 1. 22.

📑 목차

    반응형
    #define _WIN32_WINNT 0x0501
    #define WINVER  0x0501

    #pragma comment(linker, "/subsystem:windows")

    #include <windows.h>

    LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    switch( msg )
    {
    case WM_CREATE:
      // 윈도우의 특정색을 투명하게 처리하고, 윈도우 전체에 반투명 효과를 준다.

      SetLayeredWindowAttributes(hwnd, 0, //투명처리할 색,
             200, //불투명 정도(0, 255)
             LWA_ALPHA);
      return 0;

    case WM_LBUTTONDOWN:
      return 0;


    case WM_DESTROY:
      PostQuitMessage(0);
      return 0;
    }
    return DefWindowProc( hwnd, msg, wParam, lParam);
    }

    int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
         LPSTR   lpCmdLine, int nShowCmd )
    {
    ATOM atom;
    WNDCLASS wc;
    HWND hwnd;
    MSG msg;

    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hbrBackground= (HBRUSH)GetStockObject( WHITE_BRUSH );
    wc.hCursor  = LoadCursor( 0, IDC_ARROW );
    wc.hIcon  = LoadIcon( 0, IDI_APPLICATION);
    wc.hInstance = hInstance;
    wc.lpfnWndProc  = WndProc;
    wc.lpszClassName= "First";
    wc.lpszMenuName = 0;
    wc.style  = 0;

    atom = RegisterClass( &wc);

    if ( atom == 0 )
    {
      MessageBox( 0, "Fail To RegisterClass", "Error", MB_OK);
      return 0;
    }

    hwnd = CreateWindowEx( WS_EX_LAYERED, "first", "Hello", WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, 0, CW_USEDEFAULT,0, 0, 0,
            hInstance, 0);
    ShowWindow( hwnd, nShowCmd);
    UpdateWindow( hwnd );

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

    return 0;
    }
    반응형

    "이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."