Beispiel #1
0
void CAppBar::AppBar_Size()
{
    
    if (g_fAppRegistered)
    {
        //TODO: WHY GetWindowRect Return the old position ?????
        GetWindowRect(pHandler, &m_rc);
        AppBar_QuerySetPos(m_pOptions->uSide, &m_rc, &abd, TRUE);
    }
}
void Main_OnLButtonUp(HWND hwnd, int /* x */, int /* y */, UINT /* keyFlags */)
{
    if (!s_fMoving)
    {
        return;
    }

    // Update the global appbar rect used when we're autohiding.  This is
    // sloppy but it works for now.  It would be better to maintain two rects,
    // one for the hidden state and one for the unhidden state.
    g_rcAppBar = s_rcDrag;

    // Clean up the drag state info.
    ReleaseCapture();

    // Calculate the hidden rect if we need to and then tell the system about
    // our new area.
    APPBARDATA abd;
    abd.cbSize = sizeof(APPBARDATA);
    abd.hWnd = hwnd;

    POPTIONS pOpt = GetAppbarData(hwnd);
    if (pOpt->fAutoHide)
    {
        switch (pOpt->uSide)
        {
        case ABE_TOP:
            s_rcDrag.bottom = s_rcDrag.top + 2;
            break;
        case ABE_BOTTOM:
            s_rcDrag.top = s_rcDrag.bottom - 2;
            break;
        case ABE_LEFT:
            s_rcDrag.right = s_rcDrag.left + 2;
            break;
        case ABE_RIGHT:
            s_rcDrag.left = s_rcDrag.right - 2;
            break;
        }
    }

    AppBar_QuerySetPos(pOpt->uSide, &s_rcDrag, &abd, FALSE);

    s_fMoving = FALSE;
}
Beispiel #3
0
BOOL CAppBar::AppBar_SetSide(UINT uSide)
{
    
    if(!g_fAppRegistered)
        AppBar_Register();

    BOOL       fAutoHide = FALSE;
    // Calculate the size of the screen so we can occupy the full width or
    // height of the screen on the edge we request.
    m_rc.top = 0;
    m_rc.left = 0;
    m_rc.right = GetSystemMetrics(SM_CXSCREEN);   
    m_rc.bottom = GetSystemMetrics(SM_CYSCREEN);
    // Fill out the APPBARDATA struct with the basic information
    abd.cbSize = sizeof(APPBARDATA);
    abd.hWnd = pHandler;

    // If the appbar is autohidden, turn that off so we can move the bar
    if (m_pOptions->fAutoHide)
    {
        fAutoHide = m_pOptions->fAutoHide;

        // Turn off the redrawing of the desktop while we move things around.
        // If you put any breakpoints in this area you will lock up the desktop
        // Since turning off the desktop repaints turns it off for all the apps
        // in the system
        SetWindowRedraw(GetDesktopWindow(), FALSE);
        AppBar_SetAutoHide(FALSE);
    }

    // Adjust the rectangle to set our height or width depending on the
    // side we want.
    switch (uSide)
    {
     case ABE_TOP:
         m_rc.bottom = m_rc.top + m_pOptions->cyHeight;
          break;
        case ABE_BOTTOM:
          m_rc.top = m_rc.bottom - m_pOptions->cyHeight;
          break;
        case ABE_LEFT:
            m_rc.right = m_rc.left + m_pOptions->cxWidth;
           break;
        case ABE_RIGHT:
           m_rc.left = m_rc.right - m_pOptions->cxWidth;
           break;
    }
 
    // Move the appbar to the new screen space.
    AppBar_QuerySetPos(uSide, &m_rc, &abd, TRUE);

    // If the appbar was hidden, rehide it now
    if (fAutoHide)
    {
        AppBar_SetAutoHide(TRUE);

        SetWindowRedraw(GetDesktopWindow(), TRUE);
        RedrawWindow(GetDesktopWindow(), NULL, NULL, 
                  RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);         
    }

    return (TRUE);
}   
Beispiel #4
0
BOOL CAppBar::AppBar_AutoHide()
{
    HWND hwndAutoHide;
    BOOL fSuccess;  
    RECT rc;

    abd.cbSize = sizeof(APPBARDATA);
    abd.hWnd = pHandler;
    abd.uEdge = m_pOptions->uSide;
  
    // First figure out if someone already has this side for 
    // autohiding
    hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
    if (hwndAutoHide != NULL)
    {
         //DebugMsg(TEXT("ERROR: Another appbar is already hiding ")
          //        TEXT("on this edge.  Cannot set to autohide.\r\n"));
         return (FALSE);
    }

    // We can autohide on this edge.  Set the autohide style.
    abd.lParam = TRUE;          

    fSuccess = (BOOL) SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd);
    if (!fSuccess)
    {
         //DebugMsg(TEXT("ERROR: Error trying to set autohidebar.\r\n"));
        //ErrorHandler();
        return (FALSE);
      }
    else
    {
        // Since we're allowed to autohide, we need to adjust our screen 
        // rectangle to the autohidden position.  This will allow the system
        // to resize the desktop.
        m_pOptions->fAutoHide = TRUE;
        g_cxWidth = m_pOptions->cxWidth;
        g_cyHeight = m_pOptions->cyHeight;

        rc = g_rcAppBar;
        switch (m_pOptions->uSide)
        {
         case ABE_TOP:
             rc.bottom = rc.top + 2; 
              break;
            case ABE_BOTTOM:
              rc.top = rc.bottom - 2;
               break;
            case ABE_LEFT:
                rc.right = rc.left + 2;
               break;
            case ABE_RIGHT:
               rc.left = rc.right - 2;
               break;
        }

       AppBar_QuerySetPos(m_pOptions->uSide, &rc, &abd, TRUE);
    }

   return (TRUE);
}
Beispiel #5
0
void CAppBar::AppBar_PosChanged(PAPPBARDATA pabd)
{
    RECT rc;
    RECT rcWindow;
    int iHeight;
    int iWidth;
   
    // Start by getting the size of the screen.
    rc.top = 0;
    rc.left = 0;
    rc.right = GetSystemMetrics(SM_CXSCREEN);
    rc.bottom = GetSystemMetrics(SM_CYSCREEN);

  // Update the g_rcAppbar so when we slide (if hidden) we slide to the 
    // right place.
   if (m_pOptions->fAutoHide)
    {
        g_rcAppBar = rc;
        switch (m_pOptions->uSide)
        {
             case ABE_TOP:
                 g_rcAppBar.bottom = g_rcAppBar.top + g_cyHeight;
                  break;
    
              case ABE_BOTTOM:
                  g_rcAppBar.top = g_rcAppBar.bottom - g_cyHeight;
                  break;
    
              case ABE_LEFT:
                    g_rcAppBar.right = g_rcAppBar.left + g_cxWidth;
                   break;
    
              case ABE_RIGHT:
                   g_rcAppBar.left = g_rcAppBar.right - g_cxWidth;
                   break;
        }           
  }        

    // Now get the current window rectangle and find the height and width
    GetWindowRect(pabd->hWnd, &rcWindow);
    iHeight = rcWindow.bottom - rcWindow.top;
    iWidth = rcWindow.right - rcWindow.left;

    // Depending on which side we're on, try to preserve the thickness of
    // the window    
    switch (m_pOptions->uSide) 
    {
      case ABE_TOP:
         rc.bottom = rc.top + iHeight;
         break;

      case ABE_BOTTOM:
          rc.top = rc.bottom - iHeight;
         break;

      case ABE_LEFT:
            rc.right = rc.left + iWidth;
          break;

      case ABE_RIGHT:
           rc.left = rc.right - iWidth;
          break;
    }        

    // Move the appbar.
    AppBar_QuerySetPos(m_pOptions->uSide, &rc, pabd, TRUE);

}