Exemple #1
0
static BOOL FASTCALL
IntGetScrollBarInfo(HWND Wnd, INT Bar, PSCROLLBARINFO ScrollBarInfo)
{
  ScrollBarInfo->cbSize = sizeof(SCROLLBARINFO);

  return NtUserGetScrollBarInfo(Wnd, IntScrollGetObjectId(Bar), ScrollBarInfo);
}
Exemple #2
0
BOOL
IntIsScrollBarVisible(HWND hWnd, INT hBar)
{
  SCROLLBARINFO sbi;
  sbi.cbSize = sizeof(SCROLLBARINFO);
  if(!NtUserGetScrollBarInfo(hWnd, hBar, &sbi))
    return FALSE;

  return !(sbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN);
}
Exemple #3
0
/*
 * @implemented
 */
BOOL WINAPI GetScrollBarInfo( _In_ HWND hwnd, _In_ LONG idObject, _Inout_ LPSCROLLBARINFO info)
{
    BOOL Ret;
    PWND pWnd = ValidateHwnd(hwnd);
    TRACE("hwnd=%p idObject=%d info=%p\n", hwnd, idObject, info);
    if (!pWnd) return FALSE;
    Ret = NtUserGetScrollBarInfo(hwnd, idObject, info); // This will be fixed once SB is server side.
    /* rcScrollBar needs to be in screen coordinates */
    OffsetRect( &(info->rcScrollBar), pWnd->rcWindow.left, pWnd->rcWindow.top );
    return Ret;
}
Exemple #4
0
LRESULT
DefWndNCCalcSize(HWND hWnd, BOOL CalcSizeStruct, RECT *Rect)
{
   LRESULT Result = 0;
   DWORD Style = GetClassLongPtrW(hWnd, GCL_STYLE);
   DWORD ExStyle;
   SIZE WindowBorders;
   RECT OrigRect;

   if (Rect == NULL)
   {
      return Result;
   }
   OrigRect = *Rect;

   if (CalcSizeStruct)
   {
      if (Style & CS_VREDRAW)
      {
         Result |= WVR_VREDRAW;
      }
      if (Style & CS_HREDRAW)
      {
         Result |= WVR_HREDRAW;
      }
      Result |= WVR_VALIDRECTS;
   }

   Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
   ExStyle = GetWindowLongPtrW(hWnd, GWL_EXSTYLE);

   if (!(Style & WS_MINIMIZE))
   {
      HMENU menu = GetMenu(hWnd);

      if (UserHasWindowEdge(Style, ExStyle))
      {
         UserGetWindowBorders(Style, ExStyle, &WindowBorders, FALSE);
         InflateRect(Rect, -WindowBorders.cx, -WindowBorders.cy);
      } else
      if ((ExStyle & WS_EX_STATICEDGE) || (Style & WS_BORDER))
      {
         InflateRect(Rect, -1, -1);
      }

      if ((Style & WS_CAPTION) == WS_CAPTION)
      {
         if (ExStyle & WS_EX_TOOLWINDOW)
            Rect->top += GetSystemMetrics(SM_CYSMCAPTION);
         else
            Rect->top += GetSystemMetrics(SM_CYCAPTION);
      }

      if (menu && !(Style & WS_CHILD))
      {
         HDC hDC = GetWindowDC(hWnd);
         if(hDC)
         {
           RECT CliRect = *Rect;
           CliRect.bottom -= OrigRect.top;
           CliRect.right -= OrigRect.left;
           CliRect.left -= OrigRect.left;
           CliRect.top -= OrigRect.top;
           Rect->top += MenuDrawMenuBar(hDC, &CliRect, hWnd, TRUE);
           ReleaseDC(hWnd, hDC);
         }
      }

      if (ExStyle & WS_EX_CLIENTEDGE)
      {
         InflateRect(Rect, -2 * GetSystemMetrics(SM_CXBORDER),
            -2 * GetSystemMetrics(SM_CYBORDER));
      }

      if(Style & (WS_VSCROLL | WS_HSCROLL))
      {
        SCROLLBARINFO sbi;
        SETSCROLLBARINFO ssbi;

        sbi.cbSize = sizeof(SCROLLBARINFO);
        if((Style & WS_VSCROLL) && NtUserGetScrollBarInfo(hWnd, OBJID_VSCROLL, &sbi))
        {
          int i;
          LONG sx = Rect->right;

          sx -= GetSystemMetrics(SM_CXVSCROLL);
          for(i = 0; i <= CCHILDREN_SCROLLBAR; i++)
            ssbi.rgstate[i] = sbi.rgstate[i];
          if(sx <= Rect->left)
            ssbi.rgstate[0] |= STATE_SYSTEM_OFFSCREEN;
          else
            ssbi.rgstate[0] &= ~STATE_SYSTEM_OFFSCREEN;
          NtUserSetScrollBarInfo(hWnd, OBJID_VSCROLL, &ssbi);
          if(ssbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN)
            Style &= ~WS_VSCROLL;
        }
        else
          Style &= ~WS_VSCROLL;

        if((Style & WS_HSCROLL) && NtUserGetScrollBarInfo(hWnd, OBJID_HSCROLL, &sbi))
        {
          int i;
          LONG sy = Rect->bottom;

          sy -= GetSystemMetrics(SM_CYHSCROLL);
          for(i = 0; i <= CCHILDREN_SCROLLBAR; i++)
            ssbi.rgstate[i] = sbi.rgstate[i];
          if(sy <= Rect->top)
            ssbi.rgstate[0] |= STATE_SYSTEM_OFFSCREEN;
          else
            ssbi.rgstate[0] &= ~STATE_SYSTEM_OFFSCREEN;
          NtUserSetScrollBarInfo(hWnd, OBJID_HSCROLL, &ssbi);
          if(ssbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN)
            Style &= ~WS_HSCROLL;
        }
        else
          Style &= ~WS_HSCROLL;
      }

      if ((Style & WS_VSCROLL) && (Style & WS_HSCROLL))
      {
         if ((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
            Rect->left += GetSystemMetrics(SM_CXVSCROLL);
         else
            Rect->right -= GetSystemMetrics(SM_CXVSCROLL);
         Rect->bottom -= GetSystemMetrics(SM_CYHSCROLL);
      }
      else
      {
         if (Style & WS_VSCROLL)
         {
            if ((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
               Rect->left += GetSystemMetrics(SM_CXVSCROLL);
            else
               Rect->right -= GetSystemMetrics(SM_CXVSCROLL);
         }
         else if (Style & WS_HSCROLL)
            Rect->bottom -= GetSystemMetrics(SM_CYHSCROLL);
      }
      if (Rect->top > Rect->bottom)
         Rect->bottom = Rect->top;
      if (Rect->left > Rect->right)
         Rect->right = Rect->left;
   }
   else
   {
      Rect->right = Rect->left;
      Rect->bottom = Rect->top;
   }

   return Result;
}
Exemple #5
0
/***********************************************************************
 *           ScrollBarWndProc
 */
LRESULT WINAPI
ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
#ifdef __ODYSSEY__ // Do this now, remove after Server side is fixed.
  PWND pWnd;

  pWnd = ValidateHwnd(Wnd);
  if (pWnd)
  {
     if (!pWnd->fnid)
     {
        NtUserSetWindowFNID(Wnd, FNID_SCROLLBAR);
     }
  }    
#endif    

  if (! IsWindow(Wnd))
    {
      return 0;
    }

  switch (Msg)
    {
      case WM_CREATE:
        IntScrollCreateScrollBar(Wnd, (LPCREATESTRUCTW) lParam);
        break;

#ifdef __ODYSSEY__
      case WM_DESTROY:
        NtUserSetWindowFNID(Wnd, FNID_DESTROY);
        return DefWindowProc(Wnd, Msg, wParam, lParam );
#endif

//#if 0 /* FIXME */
      case WM_ENABLE:
        {
//          SCROLLBAR_INFO *infoPtr;
//          if ((infoPtr = SCROLL_GetScrollBarInfo( hwnd, SB_CTL )))
//            {
//              infoPtr->flags = wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH;
//              SCROLL_RefreshScrollBar(hwnd, SB_CTL, TRUE, TRUE);
//            }
          HDC hdc;
          DbgPrint("ScrollBarWndProc WM_ENABLE\n");
          NtUserEnableScrollBar(Wnd,SB_CTL,(wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH));
          /* Refresh Scrollbars. */
          hdc = GetDCEx( Wnd, 0, DCX_CACHE );
          if (!hdc) return 1;
          IntDrawScrollBar( Wnd, hdc, SB_CTL);
          ReleaseDC( Wnd, hdc );
	}
	return 0;
//#endif

      case WM_LBUTTONDBLCLK:
      case WM_LBUTTONDOWN:
        {
          POINT Pt;

          Pt.x = (short)LOWORD(lParam);
          Pt.y = (short)HIWORD(lParam);
          ScrollTrackScrollBar(Wnd, SB_CTL, Pt);
	}
        break;

      case WM_LBUTTONUP:
      case WM_MOUSEMOVE:
      case WM_SYSTIMER:
        {
          POINT Pt;

          Pt.x = (short)LOWORD(lParam);
          Pt.y = (short)HIWORD(lParam);
          IntScrollHandleScrollEvent(Wnd, SB_CTL, Msg, Pt);
        }
        break;

      case WM_KEYDOWN:
        IntScrollHandleKbdEvent(Wnd, wParam, lParam);
        break;

      case WM_KEYUP:
        ShowCaret(Wnd);
        break;

      case WM_SETFOCUS:
        {
          /* Create a caret when a ScrollBar get focus */
          RECT Rect;
          int ArrowSize, ThumbSize, ThumbPos, Vertical;

          Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect,
                                               &ArrowSize, &ThumbSize, &ThumbPos);
          if (! Vertical)
            {
              CreateCaret(Wnd, (HBITMAP) 1, ThumbSize - 2, Rect.bottom - Rect.top - 2);
              SetCaretPos(ThumbPos + 1, Rect.top + 1);
            }
          else
            {
              CreateCaret(Wnd, (HBITMAP) 1, Rect.right - Rect.left - 2, ThumbSize - 2);
              SetCaretPos(Rect.top + 1, ThumbPos + 1);
            }
          ShowCaret(Wnd);
        }
        break;

      case WM_KILLFOCUS:
        {
          RECT Rect;
          int ArrowSize, ThumbSize, ThumbPos, Vertical;

          Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect,
                                               &ArrowSize, &ThumbSize, &ThumbPos);
          if (! Vertical)
            {
              Rect.left = ThumbPos + 1;
              Rect.right = Rect.left + ThumbSize;
            }
          else
            {
              Rect.top = ThumbPos + 1;
              Rect.bottom = Rect.top + ThumbSize;
            }
          HideCaret(Wnd);
          InvalidateRect(Wnd, &Rect, FALSE);
          DestroyCaret();
        }
        break;

      case WM_ERASEBKGND:
         return 1;

      case WM_GETDLGCODE:
         return DLGC_WANTARROWS; /* Windows returns this value */

      case WM_PAINT:
        {
          PAINTSTRUCT Ps;
          HDC Dc;

          Dc = (0 != wParam ? (HDC) wParam : BeginPaint(Wnd, &Ps));

          if (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEGRIP)
            {
              IntScrollDrawSizeGrip(Wnd, Dc);
            }
          else if (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEBOX))
            {
              RECT Rect;
              GetClientRect(Wnd, &Rect);
              FillRect(Dc, &Rect, GetSysColorBrush(COLOR_SCROLLBAR));
            }
          else
            {
              IntDrawScrollBar(Wnd, Dc, SB_CTL/*, TRUE, TRUE*/);
            }

          if (0 == wParam)
            {
              EndPaint(Wnd, &Ps);
            }
        }
        break;

      case SBM_SETPOS:
        return SetScrollPos(Wnd, SB_CTL, wParam, (BOOL) lParam);

      case SBM_GETPOS:
        return IntScrollGetScrollPos(Wnd, SB_CTL);

      case SBM_SETRANGEREDRAW:
      case SBM_SETRANGE:
        {
          INT OldPos = IntScrollGetScrollPos(Wnd, SB_CTL);
          SetScrollRange(Wnd, SB_CTL, wParam, lParam, FALSE);
          if (Msg == SBM_SETRANGEREDRAW)
             SCROLL_RefreshScrollBar( Wnd, SB_CTL, TRUE, TRUE );
          if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) return OldPos;
        }
        return 0;

      case SBM_GETRANGE:
        return IntScrollGetScrollRange(Wnd, SB_CTL, (LPINT) wParam, (LPINT) lParam);

      case SBM_ENABLE_ARROWS:
        return EnableScrollBar(Wnd, SB_CTL, wParam);

      case SBM_SETSCROLLINFO:
        return NtUserSetScrollInfo(Wnd, SB_CTL, (SCROLLINFO *) lParam, wParam);

      case SBM_GETSCROLLINFO:
        return NtUserSBGetParms(Wnd, SB_CTL, NULL, (SCROLLINFO *) lParam);

      case SBM_GETSCROLLBARINFO:
        ((PSCROLLBARINFO)lParam)->cbSize = sizeof(SCROLLBARINFO);
        return NtUserGetScrollBarInfo(Wnd, OBJID_CLIENT, (PSCROLLBARINFO)lParam);

      case 0x00e5:
      case 0x00e7:
      case 0x00e8:
      case 0x00ec:
      case 0x00ed:
      case 0x00ee:
      case 0x00ef:
        WARN("unknown Win32 msg %04x wp=%08lx lp=%08lx\n",
		Msg, wParam, lParam );
        break;

      default:
        if (WM_USER <= Msg)
          {
            WARN("unknown msg %04x wp=%04lx lp=%08lx\n", Msg, wParam, lParam);
          }
        return DefWindowProc(Wnd, Msg, wParam, lParam );
    }

  return 0;
}
Exemple #6
0
/***********************************************************************
 *           ScrollBarWndProc
 */
LRESULT WINAPI
ScrollBarWndProc_common(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL unicode )
{
#ifdef __REACTOS__ // Do this now, remove after Server side is fixed.
  PWND pWnd;
  PSBWND pSBWnd;
  SCROLLINFO ScrollInfo;

  pWnd = ValidateHwnd(Wnd);
  if (pWnd)
  {
     if (!pWnd->fnid)
     {
        TRACE("ScrollBar CTL size %d\n", (sizeof(SBWND)-sizeof(WND)));
        if ( pWnd->cbwndExtra != (sizeof(SBWND)-sizeof(WND)) )
        {
           ERR("Wrong Extra bytes for Scrollbar!\n");
           return 0;
        }
     
        if (Msg != WM_CREATE)
        {
           return DefWindowProc(Wnd, Msg, wParam, lParam);
        }
        NtUserSetWindowFNID(Wnd, FNID_SCROLLBAR);
     }
     else
     {
        if (pWnd->fnid != FNID_SCROLLBAR)
        {
           ERR("Wrong window class for Scrollbar!\n");
           return 0;
        }
     }
  }    
#endif    

  if (! IsWindow(Wnd))
    {
      return 0;
    }

  // Must be a scroll bar control!
  pSBWnd = (PSBWND)pWnd;

  switch (Msg)
    {
      case WM_CREATE:
        IntScrollCreateScrollBar(Wnd, (LPCREATESTRUCTW) lParam);
        break;

      case WM_ENABLE:
        {
          return SendMessageW( Wnd, SBM_ENABLE_ARROWS, wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH, 0);
        }

      case WM_LBUTTONDBLCLK:
      case WM_LBUTTONDOWN:
        if (GetWindowLongW( Wnd, GWL_STYLE ) & SBS_SIZEGRIP)
        {
           SendMessageW( GetParent(Wnd), WM_SYSCOMMAND,
                         SC_SIZE + ((GetWindowLongW( Wnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) ?
                                   WMSZ_BOTTOMLEFT : WMSZ_BOTTOMRIGHT), lParam );
        }
        else
        {
          POINT Pt;
          Pt.x = (short)LOWORD(lParam);
          Pt.y = (short)HIWORD(lParam);
          ScrollTrackScrollBar(Wnd, SB_CTL, Pt);
	}
        break;

      case WM_LBUTTONUP:
      case WM_MOUSEMOVE:
      case WM_SYSTIMER:
        {
          POINT Pt;
          Pt.x = (short)LOWORD(lParam);
          Pt.y = (short)HIWORD(lParam);
          IntScrollHandleScrollEvent(Wnd, SB_CTL, Msg, Pt);
        }
        break;

      case WM_KEYDOWN:
        IntScrollHandleKbdEvent(Wnd, wParam, lParam);
        break;

      case WM_KEYUP:
        ShowCaret(Wnd);
        break;

      case WM_SETFOCUS:
        {
          /* Create a caret when a ScrollBar get focus */
          RECT Rect;
          int ArrowSize, ThumbSize, ThumbPos, Vertical;

          Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect,
                                               &ArrowSize, &ThumbSize, &ThumbPos);
          if (! Vertical)
            {
              CreateCaret(Wnd, (HBITMAP) 1, ThumbSize - 2, Rect.bottom - Rect.top - 2);
              SetCaretPos(ThumbPos + 1, Rect.top + 1);
            }
          else
            {
              CreateCaret(Wnd, (HBITMAP) 1, Rect.right - Rect.left - 2, ThumbSize - 2);
              SetCaretPos(Rect.top + 1, ThumbPos + 1);
            }
          ShowCaret(Wnd);
        }
        break;

      case WM_KILLFOCUS:
        {
          RECT Rect;
          int ArrowSize, ThumbSize, ThumbPos, Vertical;

          Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect,
                                               &ArrowSize, &ThumbSize, &ThumbPos);
          if (! Vertical)
            {
              Rect.left = ThumbPos + 1;
              Rect.right = Rect.left + ThumbSize;
            }
          else
            {
              Rect.top = ThumbPos + 1;
              Rect.bottom = Rect.top + ThumbSize;
            }
          HideCaret(Wnd);
          InvalidateRect(Wnd, &Rect, FALSE);
          DestroyCaret();
        }
        break;

      case WM_ERASEBKGND:
         return 1;

      case WM_GETDLGCODE:
         return DLGC_WANTARROWS; /* Windows returns this value */

      case WM_PAINT:
        {
          PAINTSTRUCT Ps;
          HDC Dc;

          Dc = (0 != wParam ? (HDC) wParam : BeginPaint(Wnd, &Ps));

          if (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEGRIP)
            {
              IntScrollDrawSizeGrip(Wnd, Dc);
            }
          else if (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEBOX))
            {
              RECT Rect;
              GetClientRect(Wnd, &Rect);
              FillRect(Dc, &Rect, GetSysColorBrush(COLOR_SCROLLBAR));
            }
          else
            {
              IntDrawScrollBar(Wnd, Dc, SB_CTL/*, TRUE, TRUE*/);
            }

          if (0 == wParam)
            {
              EndPaint(Wnd, &Ps);
            }
        }
        break;

      case SBM_GETPOS:
        return pSBWnd->SBCalc.pos;

      case SBM_GETRANGE:
        *(LPINT)wParam = pSBWnd->SBCalc.posMin;
        *(LPINT)lParam = pSBWnd->SBCalc.posMax;
        // This message does not return a value.
        return 0;
 
      case SBM_ENABLE_ARROWS:
        return EnableScrollBar( Wnd, SB_CTL, wParam );

      case SBM_SETPOS:
        {
           ScrollInfo.cbSize = sizeof(SCROLLINFO);
           ScrollInfo.fMask = SIF_POS|SIF_PREVIOUSPOS;
           ScrollInfo.nPos = wParam;
           return IntSetScrollInfo(Wnd, &ScrollInfo, lParam);
        }

      case SBM_SETRANGEREDRAW:
      case SBM_SETRANGE:
        {
           ScrollInfo.cbSize = sizeof(SCROLLINFO);
           ScrollInfo.fMask = SIF_RANGE|SIF_PREVIOUSPOS;
           ScrollInfo.nMin = wParam;
           ScrollInfo.nMax = lParam;
           return IntSetScrollInfo(Wnd, &ScrollInfo, Msg == SBM_SETRANGEREDRAW ? TRUE : FALSE);
        }

      case SBM_SETSCROLLINFO:
        return IntSetScrollInfo(Wnd, (LPCSCROLLINFO)lParam, wParam);

      case SBM_GETSCROLLINFO:
        {
         PSBDATA pSBData = (PSBDATA)&pSBWnd->SBCalc;
         DWORD ret = NtUserSBGetParms(Wnd, SB_CTL, pSBData, (SCROLLINFO *) lParam);
         if (!ret)
         {
            ERR("SBM_GETSCROLLINFO No ScrollInfo\n");
         }
         return ret;
        }
      case SBM_GETSCROLLBARINFO:
        ((PSCROLLBARINFO)lParam)->cbSize = sizeof(SCROLLBARINFO);
        return NtUserGetScrollBarInfo(Wnd, OBJID_CLIENT, (PSCROLLBARINFO)lParam);

      case 0x00e5:
      case 0x00e7:
      case 0x00e8:
      case 0x00ec:
      case 0x00ed:
      case 0x00ee:
      case 0x00ef:
        WARN("unknown Win32 msg %04x wp=%08lx lp=%08lx\n",
		Msg, wParam, lParam );
        break;

      default:
        if (WM_USER <= Msg)
          {
            WARN("unknown msg %04x wp=%04lx lp=%08lx\n", Msg, wParam, lParam);
          }
        if (unicode)
            return DefWindowProcW( Wnd, Msg, wParam, lParam );
        else
            return DefWindowProcA( Wnd, Msg, wParam, lParam );
    }

  return 0;
}