代码之家  ›  专栏  ›  技术社区  ›  Abhineet

如何使窗口不透明?

  •  1
  • Abhineet  · 技术社区  · 14 年前

    我想使父窗口为非透明窗口,RGB值为(99,99,99)?以前我的窗口是透明的,但现在我需要使窗口成为非透明的。

    以下是与我的父窗口相关的函数:

    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
        LogEntry(L"Entered in myRegisterClass Function");
    
        WNDCLASS CLASS_NAME_ONE_SEG_APP;
        CLASS_NAME_ONE_SEG_APP.cbClsExtra = 0;
        CLASS_NAME_ONE_SEG_APP.cbWndExtra = 0;
        CLASS_NAME_ONE_SEG_APP.hbrBackground = 0;
        CLASS_NAME_ONE_SEG_APP.hCursor = 0;
        CLASS_NAME_ONE_SEG_APP.hIcon = 0;
        CLASS_NAME_ONE_SEG_APP.hInstance = hInstance;
        CLASS_NAME_ONE_SEG_APP.lpfnWndProc =  (WNDPROC) WndProc;
        CLASS_NAME_ONE_SEG_APP.lpszClassName = className;
        CLASS_NAME_ONE_SEG_APP.lpszMenuName = 0;
        CLASS_NAME_ONE_SEG_APP.style = 0;
    
        LogEntry(L"Exiting from myRegisterClass Function");
    
        return RegisterClass(&CLASS_NAME_ONE_SEG_APP); 
    }
    

    下面提到的是一个inittInstance函数,我在其中创建父窗口。

    handles.parent是我的父窗口。

    bool WINAPI InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
        LogEntry(L"Entered in InitInstance Function");
        handles.parent = CreateWindowEx(0,
                                        className,
                                        windowName, 
                                        WS_VISIBLE | WS_POPUP,
                                        0, 0, 
                                        coordinates.width, coordinates.height,
                                        NULL, 
                                        NULL, 
                                        hInstance, 
                                        NULL);
    
        if(handles.parent == NULL)
        {
            LogValue(L"Cannot Create Parent Window"
                L"\nInitInstance Function terminated abnormally");
            return false;
        }
        else
        {
            UpdateWindow(handles.parent);
            ShowWindow(handles.parent, nCmdShow);
            LogEntry(L"Exiting from InitInstance Function");
            return true;
        }
    }
    

    以下是wm_油漆的功能:

    case WM_PAINT:
            LogEntry(L"Entred in WM_PAINT");
            PaintWindow(); 
            SetFocus(handles.parent);
            LogEntry(L"Exited from WM_PAINT");
            break;
    

    这个油漆窗口执行以下操作…..

    void PaintWindow()
    {
        LogEntry(L"Entered in PaintWindow Function");
        HWND *handle = &handles.volUp;
    
        //Paint Buttons on the window
        for(register char i =  MIN_BUTTON; i <= MAX_BUTTON; i++)
        {
            PaintButton( (INITIAL_BUTTON + i) , *handle, btns, i);
            handle++;
        }
    
        //Paint the AXIS_VOL_ON_OFF Button According to its Status
        if(volumeStatus.status == VOLUME_ON)
            PaintButton(IDB_BTN_VOL_OFF, handles.volOnOff, btns, AXIS_VOL_ON_OFF);
        else if(volumeStatus.status = VOLUME_MUTE)
            PaintButton(IDB_BTN_VOL_ON, handles.volOnOff, btns, AXIS_VOL_ON_OFF);
    
        //Paint Images on the window
        if(handles.screenMode == SCREEN_MODE_OPERATION)
            InsertImages();
    
        LogEntry(L"Exited from PaintWindow Function");
    }
    

    提前谢谢……

    1 回复  |  直到 14 年前
        1
  •  1
  •   John Knoeller    14 年前

      CLASS_NAME_ONE_SEG_APP.hbrBackground = CreateSolidBrush(RGB((99,99,99));
    

    BeginPaint EndPaint

    case WM_PAINT:
        {
        LogEntry(L"Entred in WM_PAINT");
    
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(&ps);
        PaintWindow(hdc); 
        EndPaint(hwnd, &ps);
    
        LogEntry(L"Exited from WM_PAINT");
        }  
        break;
    

    Drawing in the Client Area