导航:[首页]->[wingui]->[工作区大小变化的相关消息]

分辨率改变WM_DISPLAYCHANGE

session改变WM_WTSSESSION_CHANGE

这个消息默认不会出发,需要显式地注册,见这里

    WTSRegisterSessionNotification(m_hWnd,NOTIFY_FOR_ALL_SESSIONS)
    Wtsapi32.h
    Wtsapi32.lib

工作区改变(任务栏/自动隐藏任务栏)

WM_SETTINGCHANGE

wParam == SPI_SETWORKAREA

获得工作区大小

    RECT rt;
    SystemParametersInfo(SPI_GETWORKAREA,   0,   &rt,   0) ;   // 获得工作区大小

全屏显示

    int full_x = GetSystemMetrics(SM_CXSCREEN);
    int full_y = GetSystemMetrics(SM_CYSCREEN);
    ::SetWindowPos(hWnd,HWND_TOPMOST,0,0,full_x,full_y,0 );

任务栏

    CRect   rect; 
    HWND hwnd=  ::FindWindow("Shell_TrayWnd", "");     // 调用Findwindow函数,返回窗口指针
    ::GetWindowRect(hwnd,&rect);

任务栏编程SHAppBarMessage

    void AutoHideTaskBar(BOOL bHide)
    {
          //这三句视情况加于不加
          #ifndef   ABM_SETSTATE  
          #define   ABM_SETSTATE             0x0000000a  
          #endif
           LPARAM lParam;
           if(bHide == TRUE)
           {
                  lParam = ABS_AUTOHIDE;//自动隐藏
           }
           else
           {
                  lParam = ABS_ALWAYSONTOP;//取消自动隐藏
           }
           APPBARDATA  apBar;  
           memset(&apBar,0,sizeof(apBar));  
           apBar.cbSize  =  sizeof(apBar);  
           apBar.hWnd  =  FindWindow("Shell_TrayWnd", NULL);
           if(apBar.hWnd  !=  NULL)  
           {  
                  apBar.lParam   =   lParam;  
                  SHAppBarMessage(ABM_SETSTATE,&apBar);  //设置任务栏自动隐藏
           }
    }

电源消息WM_POWERBROADCAST