用SDK如何实现窗体的透明?

解决方案 »

  1.   

    用AppWizard建立“A typical "Hello World!" application”类型的Win32 Application,
    修改其中的InitInstance函数为BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
       HWND hWnd;   hInst = hInstance; // Store instance handle in our global variable   hWnd = CreateWindowEx(WS_EX_LAYERED, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
                             CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);   if (!hWnd)
       {
          return FALSE;
       }   ::SetLayeredWindowAttributes(hWnd, 0, 128, LWA_ALPHA); //128为透明度
       ShowWindow(hWnd, nCmdShow);
       UpdateWindow(hWnd);   return TRUE;
    }在stdafx.h里开头处加上
    #define _WIN32_WINNT 0x0500