Changeset 3584 for trunk/src


Ignore:
Timestamp:
May 22, 2000, 7:21:11 PM (25 years ago)
Author:
cbratschi
Message:

merged controls with Corel WINE 20000513, maximize/minimize fix

Location:
trunk/src/user32
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/button.cpp

    r3153 r3584  
    1 /* $Id: button.cpp,v 1.34 2000-03-18 16:13:25 cbratschi Exp $ */
     1/* $Id: button.cpp,v 1.35 2000-05-22 17:21:06 cbratschi Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    77 * Copyright (c) 1999 Christoph Bratschi
    88 *
    9  * Corel version: 20000317
     9 * Corel version: 20000513
    1010 * (WINE version: 20000130)
    1111 *
     
    924924    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    925925    RECT rbox, rtext, client;
    926     HBRUSH hBrush;
     926    HBRUSH hBrush, hOldBrush;
     927    HPEN hPen, hOldPen;
     928    COLORREF colour;
    927929    int textLen, delta;
    928930    char* text = NULL;
     
    960962
    961963    hBrush = GetSysColorBrush(COLOR_BTNFACE);
     964
     965    /* In order to make things right, draw the rectangle background! */
     966    if ( !(infoPtr->state & BUTTON_HASFOCUS) && (action == ODA_DRAWENTIRE) )
     967    {
     968        colour = GetBkColor(hDC);
     969        hPen = CreatePen( PS_SOLID, 1, colour );
     970        if ( hPen )
     971        {
     972            hOldBrush = SelectObject( hDC, hBrush );
     973            hOldPen = SelectObject( hDC, hPen );
     974            Rectangle( hDC, client.left, client.top, client.right, client.bottom );
     975            SelectObject( hDC, hOldPen );
     976            SelectObject( hDC, hOldBrush );
     977            DeleteObject( hPen );
     978        }
     979    }
    962980
    963981    if (dwStyle & BS_LEFTTEXT)
  • trunk/src/user32/combo.cpp

    r3261 r3584  
    1 /* $Id: combo.cpp,v 1.30 2000-03-28 17:13:46 sandervl Exp $ */
     1/* $Id: combo.cpp,v 1.31 2000-05-22 17:21:07 cbratschi Exp $ */
    22/*
    33 * Combo controls
     
    88 * FIXME: roll up in Netscape 3.01.
    99 *
    10  * Corel version: 20000317
     10 * Corel version: 20000513
    1111 * (WINE version: 991212)
    1212 *
     
    419419    if (posChanging->cy != newComboHeight)
    420420    {
    421       lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
    422 
     421      if (posChanging->cy > newComboHeight)
     422         lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
    423423      posChanging->cy = newComboHeight;
    424424    }
     
    495495      /* create listbox popup */
    496496
    497       lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS) |
     497      lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS | WS_CHILD) |
    498498                 (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE));
    499499
     
    509509      if( CB_GETTYPE(lphc) == CBS_SIMPLE )      /* child listbox */
    510510      {
    511         lbeStyle |= WS_CHILD | WS_VISIBLE;
     511        lbeStyle |= WS_VISIBLE;
    512512
    513513        /*
     
    518518        lbeExStyle |= WS_EX_CLIENTEDGE;
    519519      }
    520       else                                      /* popup listbox */
    521       {
    522         lbeStyle |= WS_POPUP;
    523         lbeStyle |= WS_EX_TOOLWINDOW;
    524       }
    525 
    526      /* Dropdown ComboLBox is not a child window and we cannot pass
    527       * ID_CB_LISTBOX directly because it will be treated as a menu handle.
    528       */
     520
    529521      lphc->hWndLBox = CreateWindowExA(lbeExStyle,
    530522                                       clbName,
     
    536528                                       lphc->droppedRect.bottom - lphc->droppedRect.top,
    537529                                       lphc->hwndself,
    538                                        (lphc->dwStyle & CBS_DROPDOWN)? (HMENU)0 : (HMENU)ID_CB_LISTBOX,
     530                                       (HMENU)ID_CB_LISTBOX,
    539531                                       GetWindowLongA(lphc->hwndself,GWL_HINSTANCE),
    540532                                       (LPVOID)lphc );
    541 
    542       /*
    543        * The ComboLBox is a strange little beast (when it's not a CBS_SIMPLE)...
    544        * It's a popup window but, when you get the window style, you get WS_CHILD.
    545        * When created, it's parent is the combobox but, when you ask for it's parent
    546        * after that, you're supposed to get the desktop. (see MFC code function
    547        * AfxCancelModes)
    548        * To achieve this in Wine, we have to create it as a popup and change
    549        * it's style to child after the creation.
    550        */
    551       if ( (lphc->hWndLBox!= 0) &&
    552            (CB_GETTYPE(lphc) != CBS_SIMPLE) )
    553       {
    554         /*  Not using SetWindowLongA here because it doesn't allow us to
    555          *  change the WS_CHILD style. This code should be equivalent (excluding
    556          *  the change in owner) to:
    557          *       SetWindowLongA(lphc->hWndLBox, GWL_STYLE,
    558          *      (GetWindowLongA(lphc->hWndLBox,GWL_STYLE) | WS_CHILD) & ~WS_POPUP);
    559          */
    560         STYLESTRUCT style;
    561         Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(lphc->hWndLBox);
    562 
    563         if (!win32wnd)
    564         {
    565           /* Is this the right error? */
    566           SetLastError( ERROR_INVALID_WINDOW_HANDLE );
    567           return 0;
    568         }
    569 
    570         /* save old style, set new style */
    571         style.styleOld = win32wnd->getStyle();
    572         style.styleNew = (style.styleOld | WS_CHILD) & ~WS_POPUP;
    573 
    574         SendMessageA(lphc->hWndLBox,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
    575 #if 0 //CB: our code doesn't work with this style change
    576         win32wnd->setStyle(style.styleNew);
    577 #endif
    578         SendMessageA(lphc->hWndLBox,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style);
    579 
    580         /* Set owner to NULL - it seems to be what Windows does to a ComboLBox
    581          * after creation.
    582          */
    583         win32wnd->setOwner(NULL);
    584       }
    585533
    586534      if( lphc->hWndLBox )
    587535      {
    588536          BOOL  bEdit = TRUE;
    589           lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT;
     537          lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT | ES_COMBO;
    590538
    591539          /*
     
    622570          if( bEdit )
    623571          {
    624             /*
    625              * If the combo is a dropdown, we must resize the control to fit only
    626              * the text area and button. To do this, we send a dummy resize and the
    627              * WM_WINDOWPOSCHANGING message will take care of setting the height for
    628              * us.
    629              */
    630             if( CB_GETTYPE(lphc) != CBS_SIMPLE )
    631             {
     572            if( CB_GETTYPE(lphc) != CBS_SIMPLE )
     573            {
     574              /* Now do the trick with parent */
     575              SetParent(lphc->hWndLBox, HWND_DESKTOP);
     576
     577              /*
     578               * If the combo is a dropdown, we must resize the control to fit only
     579               * the text area and button. To do this, we send a dummy resize and the
     580               * WM_WINDOWPOSCHANGING message will take care of setting the height for
     581               * us.
     582               */
     583
    632584              CBForceDummyResize(lphc);
    633585            }
     
    918870static LRESULT COMBO_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam)
    919871{
    920   return DLGC_WANTARROWS | DLGC_WANTCHARS;
     872  LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
     873  LRESULT result = DLGC_WANTARROWS | DLGC_WANTCHARS;
     874
     875  if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
     876  {
     877    int vk = (int)((LPMSG)lParam)->wParam;
     878
     879    if ((vk == VK_RETURN || vk == VK_ESCAPE) && (lphc->wState & CBF_DROPPED))
     880      result |= DLGC_WANTMESSAGE;
     881  }
     882  return  result;
    921883}
    922884
     
    985947 * Select listbox entry according to the contents of the edit control.
    986948 */
    987 static INT CBUpdateLBox( LPHEADCOMBO lphc )
     949static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect )
    988950{
    989951   INT  length, idx;
     
    1007969   }
    1008970
    1009    if( idx >= 0 )
    1010    {
    1011        /* the LB_SETCARETINDEX message should scroll the list box if required
    1012           and sending LB_SETTOPINDEX can generate annoying behaviors  */
    1013        /* probably superfluous but Windows sends this too */
    1014        SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 );
    1015    }
     971   SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)(bSelect ? idx : -1), 0 );
     972
     973   /* the LB_SETCARETINDEX message should scroll the list box if required
     974      and sending LB_SETTOPINDEX can generate annoying behaviors  */
     975   /* probably superfluous but Windows sends this too */
     976   SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0 );
     977   SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0 );
     978
    1016979   return idx;
    1017980}
     
    10451008
    10461009   SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" );
     1010
     1011   lphc->wState &= ~CBF_NOEDITNOTIFY;
     1012
    10471013   if( lphc->wState & CBF_FOCUSED )
    10481014     SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
     
    10621028   RECT rect;
    10631029   int nItems = 0;
    1064    int i;
    1065    int nHeight;
    1066    int nDroppedHeight,nTempDroppedHeight;
    1067    int screenH
     1030   int nDroppedHeight;
     1031
     1032   HWND hWnd = 0;
     1033   RECT DesktopRect;
    10681034
    10691035   //TRACE("[%04x]: drop down\n", CB_HWND(lphc));
     
    10761042   if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
    10771043   {
    1078        lphc->droppedIndex = CBUpdateLBox( lphc );
     1044       lphc->droppedIndex = CBUpdateLBox( lphc,TRUE );
    10791045
    10801046       if( !(lphc->wState & CBF_CAPTURE) )
     
    10881054         lphc->droppedIndex = 0;
    10891055
    1090        SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)lphc->droppedIndex, 0 );
     1056       SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX,
     1057                     (WPARAM)(lphc->droppedIndex == LB_ERR ? 0 : lphc->droppedIndex), 0 );
    10911058       SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
    10921059   }
     
    11081075   nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
    11091076   nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
    1110    nHeight = COMBO_YBORDERSIZE();
    1111    nTempDroppedHeight = 0;
    1112    for (i = 0; i < nItems; i++)
    1113    {
    1114      nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
    1115 
    1116      /* Did we pass the limit of what can be displayed */
    1117      if (nHeight > nDroppedHeight)
    1118      {
    1119        break;
     1077
     1078   if (nItems > 0)
     1079   {
     1080      int nHeight;
     1081
     1082      nHeight = (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, 0, 0);
     1083      nHeight *= nItems;
     1084
     1085      if (nHeight < nDroppedHeight - COMBO_YBORDERSIZE())
     1086         nDroppedHeight = nHeight + COMBO_YBORDERSIZE();
    11201087   }
    1121      nTempDroppedHeight = nHeight;
     1088
     1089   /*Now we should know screen size. */
     1090   hWnd = GetDesktopWindow();
     1091
     1092   if( hWnd )
     1093   {
     1094     GetClientRect( hWnd, &DesktopRect );
    11221095   }
    11231096
    1124    nDroppedHeight = nTempDroppedHeight;
    11251097
    11261098   /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
    1127    screenH = GetSystemMetrics(SM_CYSCREEN);
    1128    if((rect.bottom + nDroppedHeight) >= screenH)
    1129    {
    1130      SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.top - nDroppedHeight,
    1131                  lphc->droppedRect.right - lphc->droppedRect.left,
    1132                  nDroppedHeight,
    1133                  SWP_NOACTIVATE | SWP_NOREDRAW);
    1134    }
    1135    else
    1136    {
    1137      SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
    1138                  lphc->droppedRect.right - lphc->droppedRect.left,
    1139                  nDroppedHeight,
    1140                  SWP_NOACTIVATE | SWP_NOREDRAW);
    1141    }
     1099   if((rect.bottom + nDroppedHeight) >= DesktopRect.bottom)
     1100      rect.bottom = rect.top - nDroppedHeight;
     1101
     1102   SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
     1103                 lphc->droppedRect.right - lphc->droppedRect.left,
     1104                 nDroppedHeight,
     1105                 SWP_NOACTIVATE | SWP_SHOWWINDOW);
     1106
    11421107
    11431108   if( !(lphc->wState & CBF_NOREDRAW) )
    11441109     RedrawWindow( lphc->hwndself, NULL, 0, RDW_INVALIDATE |
    1145                            RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
     1110                           RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
    11461111
    11471112   EnableWindow( lphc->hWndLBox, TRUE );
    1148    //SvL: Don't activate combo listbox window or else focus will change
    1149    //     (this window's parent is the desktop)
    1150    ShowWindow( lphc->hWndLBox, SW_SHOWNOACTIVATE);
    1151 
     1113   if (GetCapture() != lphc->hwndself)
     1114      SetCapture(lphc->hWndLBox);
    11521115}
    11531116
     
    11731136
    11741137           lphc->wState &= ~CBF_DROPPED;
     1138           /* By hiding the window, the capture by lphc->hWndLBox will be released too */
     1139       
    11751140           ShowWindow( lphc->hWndLBox, SW_HIDE );
    1176            if(GetCapture() == lphc->hWndLBox)
    1177            {
    1178                ReleaseCapture();
    1179            }
    11801141
    11811142           if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
    11821143           {
    1183                INT index = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
    1184                CBUpdateEdit( lphc, index );
    1185                rect = lphc->buttonRect;
     1144               rect = lphc->buttonRect;
    11861145           }
    11871146           else
     
    12121171 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
    12131172 */
    1214 BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL bRedrawButton )
     1173BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton )
    12151174{
    12161175   if( lphc->wState & CBF_DROPPED )
    12171176   {
    1218        CBRollUp( lphc, TRUE, bRedrawButton );
     1177       CBRollUp( lphc, ok, bRedrawButton );
    12191178       return FALSE;
    12201179   }
     
    12231182   return TRUE;
    12241183}
    1225 
    1226 /***********************************************************************
    1227  *           COMBO_GetLBWindow
    1228  *
    1229  * Edit control helper.
    1230  */
    1231 HWND COMBO_GetLBWindow( HWND hwnd )
    1232 {
    1233   LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
    1234 
    1235   return lphc ? lphc->hWndLBox:0;
    1236 }
    1237 
    12381184
    12391185/***********************************************************************
     
    13791325                else
    13801326                {
    1381                   CBUpdateLBox( lphc );
     1327                  CBUpdateLBox( lphc, lphc->wState & CBF_DROPPED );
    13821328                }
    13831329                break;
     
    14281374                 * by arrowkeys in the dropdown listbox */
    14291375
    1430                 if( (lphc->dwStyle & CBS_SIMPLE) ||
     1376                if( (CB_GETTYPE(lphc) == CBS_SIMPLE) ||
    14311377                    ((lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP)) )
    14321378                {
     
    14351381                else lphc->wState &= ~CBF_NOROLLUP;
    14361382
    1437                 if( lphc->wState & CBF_EDIT )
    1438                 {
    1439                     INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
    1440 
    1441                     lphc->wState |= CBF_NOLBSELECT;
    1442                     CBUpdateEdit( lphc, index );
    1443                     /* select text in edit, as Windows does */
    1444                     SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
     1383                CB_NOTIFY( lphc, CBN_SELCHANGE );
     1384
     1385                if( HIWORD(wParam) == LBN_SELCHANGE)
     1386                {
     1387                  if( lphc->wState & CBF_EDIT )
     1388                  {
     1389                      INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
     1390
     1391                      lphc->wState |= CBF_NOLBSELECT;
     1392                      CBUpdateEdit( lphc, index );
     1393                      /* select text in edit, as Windows does */
     1394                      SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
     1395                  }
     1396                  else
     1397                      InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
    14451398                }
    1446                 else
    1447                     InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
    1448 
    1449                 CB_NOTIFY( lphc, CBN_SELCHANGE );
     1399
    14501400                /* fall through */
    14511401
     
    15481498}
    15491499
     1500static LRESULT COMBO_GetTextLength(HWND hwnd,WPARAM wParam,LPARAM lParam)
     1501{
     1502  LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
     1503
     1504  if (!(lphc->wState & CBF_EDIT))
     1505  {
     1506    int idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
     1507
     1508    if (idx == -1) return 0;
     1509    return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, idx, 0 );
     1510  } else if (lphc->wState & CBF_EDIT)
     1511  {
     1512    /* Don't bother turning on CBF_NOEDITNOTIFY. */
     1513    return SendMessageA( lphc->hWndEdit, WM_GETTEXTLENGTH, wParam, lParam );
     1514  } else return CB_ERR;
     1515}
     1516
    15501517static LRESULT COMBO_HandleText(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
    15511518{
     
    15581525  }
    15591526
    1560   if ((message == WM_GETTEXTLENGTH) && !(lphc->wState & CBF_EDIT))
    1561   {
    1562     int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
    1563 
    1564     if (j == -1) return 0;
    1565     return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
    1566   } else if( lphc->wState & CBF_EDIT )
    1567   {
     1527  if (lphc->wState & CBF_EDIT)
     1528  {
     1529    LRESULT res;
     1530
    15681531    lphc->wState |= CBF_NOEDITNOTIFY;
    1569 
    1570     return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
    1571   } else return  CB_ERR;
     1532    res = SendMessageA( lphc->hWndEdit, message, wParam, lParam );
     1533    lphc->wState &= ~CBF_NOEDITNOTIFY;
     1534    return res;
     1535  } else return CB_ERR;
    15721536}
    15731537
     
    17281692
    17291693           lphc->wState |= CBF_CAPTURE;
     1694           SetCapture( hwnd );
    17301695           CBDropDown( lphc );
    1731            SetCapture( hwnd );
    17321696       }
    17331697       if( bButton ) CBRepaintButton( lphc );
     
    17511715       if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
    17521716       {
    1753            INT index = CBUpdateLBox( lphc );
    1754            CBUpdateEdit( lphc, index );
     1717           INT index = CBUpdateLBox( lphc, TRUE );
     1718
     1719           lphc->wState |= CBF_NOLBSELECT;
     1720           CBUpdateEdit( lphc, index );
     1721           lphc->wState &= ~CBF_NOLBSELECT;
    17551722       }
    1756        ReleaseCapture();
    1757 //SvL: Don't set the capture here. Otherwise other controls don't respond the first time!
    1758 //       SetCapture(lphc->hWndLBox);
     1723       SetCapture(lphc->hWndLBox);
    17591724   }
    17601725
     
    18041769       lphc->wState &= ~CBF_CAPTURE;
    18051770       ReleaseCapture();
    1806        if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
     1771       if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc,TRUE );
    18071772
    18081773       /* hand over pointer tracking */
     
    18601825  if( KEYDATA_ALT & HIWORD(lParam) )
    18611826    if( wParam == VK_UP || wParam == VK_DOWN )
    1862       COMBO_FlipListbox( lphc, TRUE );
    1863 
    1864   return DefWindowProcA(hwnd,WM_SYSKEYDOWN,wParam,lParam);
     1827      COMBO_FlipListbox( lphc,FALSE,FALSE );
     1828
     1829  return 0;
    18651830}
    18661831
     
    18681833{
    18691834  LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
     1835
     1836  if (((CHAR)wParam == VK_RETURN || (CHAR)wParam == VK_ESCAPE) && (lphc->wState & CBF_DROPPED))
     1837  {
     1838    CBRollUp( lphc, (CHAR)wParam == VK_RETURN, FALSE );
     1839    return TRUE;
     1840  }
    18701841
    18711842  if( lphc->wState & CBF_EDIT )
     
    22722243          return COMBO_GetText(hwnd,wParam,lParam);
    22732244
     2245        case WM_GETTEXTLENGTH:
     2246          return COMBO_GetTextLength(hwnd,wParam,lParam);
     2247
    22742248        case WM_SETTEXT:
    2275         case WM_GETTEXTLENGTH:
    22762249        case WM_CLEAR:
    22772250        case WM_CUT:
  • trunk/src/user32/edit.cpp

    r3153 r3584  
    1 /* $Id: edit.cpp,v 1.38 2000-03-18 16:13:26 cbratschi Exp $ */
     1/* $Id: edit.cpp,v 1.39 2000-05-22 17:21:07 cbratschi Exp $ */
    22/*
    33 *      Edit control
     
    99 *      Copyright  1999 Christoph Bratschi
    1010 *
    11  * Corel version: 20000317
     11 * Corel version: 20000513
    1212 * (WINE version: 991212)
    1313 *
     
    109109        BOOL bCaptureState; /* flag indicating whether mouse was captured */
    110110        BOOL bEnableState;             /* flag keeping the enable state */
     111        HWND hwndListBox;              /* handle of ComboBox's listbox or NULL */
    111112        /*
    112113         *      only for multi line controls
     
    590591        case WM_GETDLGCODE:
    591592                //DPRINTF_EDIT_MSG32("WM_GETDLGCODE");
    592                 result = DLGC_HASSETSEL | DLGC_WANTCHARS | DLGC_WANTARROWS;
    593                 if (es->style & ES_WANTRETURN)
     593                result = DLGC_HASSETSEL | DLGC_WANTCHARS | DLGC_WANTARROWS;
     594
     595                if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
    594596                {
    595                    LPMSG msg = (LPMSG)lParam;
    596                    if (msg && (msg->message == WM_KEYDOWN) && (msg->wParam == VK_RETURN))
     597                   int vk = (int)((LPMSG)lParam)->wParam;
     598
     599                   if ((GetWindowLongA(hwnd,GWL_STYLE) & ES_WANTRETURN) && vk == VK_RETURN)
     600                   {
    597601                      result |= DLGC_WANTMESSAGE;
     602                   }
     603                   else if (es->hwndListBox && (vk == VK_RETURN || vk == VK_ESCAPE))
     604                   {
     605                      if (SendMessageA(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0))
     606                         result |= DLGC_WANTMESSAGE;
     607                   }
    598608                }
    599609                break;
     
    601611        case WM_CHAR:
    602612                //DPRINTF_EDIT_MSG32("WM_CHAR");
     613                if (((CHAR)wParam == VK_RETURN || (CHAR)wParam == VK_ESCAPE) && es->hwndListBox)
     614                {
     615                   HWND hwndParent = GetParent(hwnd);
     616               
     617                   if (SendMessageA(hwndParent, CB_GETDROPPEDSTATE, 0, 0))
     618                      SendMessageA(hwndParent, WM_KEYDOWN, wParam, 0);
     619                   break;
     620                }
    603621                EDIT_WM_Char(hwnd, es, (CHAR)wParam, (DWORD)lParam);
    604622                break;
     
    33693387 *
    33703388 */
    3371 static BOOL EDIT_CheckCombo(HWND hwnd, UINT msg, INT key, DWORD key_data)
    3372 {
    3373         HWND hLBox;
    3374 
    3375         /********************************************************************
    3376          * This if statement used to check to see if the parent of the
    3377          * edit control was a 'combobox' by comparing the ATOM of the parent
    3378          * to a table of internal window control ATOMs.  However, this check
    3379          * would fail if the parent was a superclassed combobox (Although
    3380          * having the same basic functionality of a combobox, it has a
    3381          * different name and ATOM, thus defeating this check.)
    3382          *
    3383          * The safe way to determine if the parent is a combobox is to send it
    3384          * a message only a combo box would understand.  I send it a message
    3385          * CB_GETCOUNT, if I get 0 then the parent is not a combobox -
    3386          * return FALSE.  If I get > 0, then the parent IS a combobox
    3387          * (or sub/super classed derrivative thereof)
    3388          ********************************************************************/
    3389 #if 0 //CB: our code
    3390         if (GetClassWord(GetParent(hwnd),GCW_ATOM) ==  GlobalFindAtomA(COMBOBOXCLASSNAME) &&
    3391                         (hLBox = COMBO_GetLBWindow(GetParent(hwnd))))
    3392 #else
    3393         if (
    3394              ((SendMessageA(GetParent(hwnd), CB_GETCOUNT, 0, 0)) > 0) &&
    3395              (hLBox = COMBO_GetLBWindow(GetParent(hwnd)))
    3396            )
    3397 #endif
    3398         {
    3399                 HWND hCombo = GetParent(hwnd);
    3400                 BOOL bUIFlip = TRUE;
    3401 
    3402                 //TRACE_(combo)("[%04x]: handling msg %04x (%04x)\n",
    3403                 //             wnd->hwndSelf, (UINT16)msg, (UINT16)key);
    3404 
    3405                 switch (msg) {
    3406                 case WM_KEYDOWN: /* Handle F4 and arrow keys */
    3407                         if (key != VK_F4) {
    3408                                 bUIFlip = (BOOL)SendMessageA(hCombo, CB_GETEXTENDEDUI, 0, 0);
    3409                                 if (SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0))
    3410                                         bUIFlip = FALSE;
    3411                         }
    3412                         if (!bUIFlip)
    3413                                 SendMessageA(hLBox, WM_KEYDOWN, (WPARAM)key, 0);
    3414                         else {
    3415                                 /* make sure ComboLBox pops up */
    3416                                 SendMessageA(hCombo, CB_SETEXTENDEDUI, 0, 0);
    3417                                 SendMessageA(hLBox, WM_KEYDOWN, VK_F4, 0);
    3418                                 SendMessageA(hCombo, CB_SETEXTENDEDUI, 1, 0);
    3419                         }
    3420                         break;
    3421                 case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
    3422                         bUIFlip = (BOOL)SendMessageA(hCombo, CB_GETEXTENDEDUI, 0, 0);
    3423                         if (bUIFlip) {
    3424                                 bUIFlip = (BOOL)SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
    3425                                 SendMessageA(hCombo, CB_SHOWDROPDOWN, (bUIFlip) ? FALSE : TRUE, 0);
    3426                         } else
    3427                                 SendMessageA(hLBox, WM_KEYDOWN, VK_F4, 0);
    3428                         break;
    3429                 }
    3430                 return TRUE;
    3431         }
    3432         return FALSE;
    3433 }
    3434 
     3389static BOOL EDIT_CheckCombo(HWND hwnd, EDITSTATE *es, UINT msg, INT key, DWORD key_data)
     3390{
     3391   HWND hLBox = es->hwndListBox;
     3392   HWND hCombo;
     3393   BOOL bDropped;
     3394   int  nEUI;
     3395
     3396   if (!hLBox)
     3397      return FALSE;
     3398
     3399   hCombo   = GetParent(hwnd);
     3400   bDropped = TRUE;
     3401   nEUI     = 0;
     3402
     3403   //TRACE_(combo)("[%04x]: handling msg %04x (%04x)\n",
     3404   //                        wnd->hwndSelf, (UINT16)msg, (UINT16)key);
     3405
     3406   if (key == VK_UP || key == VK_DOWN)
     3407   {
     3408      if (SendMessageA(hCombo, CB_GETEXTENDEDUI, 0, 0))
     3409         nEUI = 1;
     3410
     3411      if (msg == WM_KEYDOWN || nEUI)
     3412          bDropped = (BOOL)SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
     3413   }
     3414
     3415   switch (msg)
     3416   {
     3417      case WM_KEYDOWN:
     3418         if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
     3419         {
     3420            /* make sure ComboLBox pops up */
     3421            SendMessageA(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
     3422            key = VK_F4;
     3423            nEUI = 2;
     3424         }
     3425
     3426         SendMessageA(hLBox, WM_KEYDOWN, (WPARAM)key, 0);
     3427         break;
     3428
     3429      case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
     3430         if (nEUI)
     3431            SendMessageA(hCombo, CB_SHOWDROPDOWN, bDropped ? FALSE : TRUE, 0);
     3432         else
     3433            SendMessageA(hLBox, WM_KEYDOWN, (WPARAM)VK_F4, 0);
     3434         break;
     3435   }
     3436
     3437   if(nEUI == 2)
     3438      SendMessageA(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
     3439
     3440   return TRUE;
     3441}
    34353442
    34363443/*********************************************************************
     
    34563463        case VK_F4:
    34573464        case VK_UP:
    3458                 if (EDIT_CheckCombo(hwnd, WM_KEYDOWN, key, key_data))
    3459                         break;
    3460                 if (key == VK_F4)
     3465                if (EDIT_CheckCombo(hwnd,es, WM_KEYDOWN, key, key_data) || key == VK_F4)
    34613466                        break;
    34623467                /* fall through */
     
    34713476                break;
    34723477        case VK_DOWN:
    3473                 if (EDIT_CheckCombo(hwnd, WM_KEYDOWN, key, key_data))
     3478                if (EDIT_CheckCombo(hwnd,es, WM_KEYDOWN, key, key_data))
    34743479                        break;
    34753480                /* fall through */
     
    34913496                if (es->style & ES_MULTILINE)
    34923497                        EDIT_MovePageUp_ML(hwnd, es, shift);
     3498                else
     3499                        EDIT_CheckCombo(hwnd, es, WM_KEYDOWN, key, key_data);
    34933500                break;
    34943501        case VK_NEXT:
    34953502                if (es->style & ES_MULTILINE)
    34963503                        EDIT_MovePageDown_ML(hwnd, es, shift);
     3504                else
     3505                        EDIT_CheckCombo(hwnd, es, WM_KEYDOWN, key, key_data);
    34973506                break;
    34983507        case VK_DELETE:
     
    37093718        }
    37103719
     3720        if (es->style & ES_COMBO)
     3721           es->hwndListBox = GetDlgItem(cs->hwndParent, ID_CB_LISTBOX);
     3722
    37113723        if (es->style & ES_MULTILINE) {
    37123724                es->buffer_size = BUFSTART_MULTI;
     
    40764088                return 0;
    40774089        } else if ((key == VK_UP) || (key == VK_DOWN))
    4078                 if (EDIT_CheckCombo(hwnd, WM_SYSKEYDOWN, key, key_data))
     4090        {
     4091                if (EDIT_CheckCombo(hwnd,es, WM_SYSKEYDOWN, key, key_data))
    40794092                        return 0;
     4093         }
    40804094        return DefWindowProcA(hwnd, WM_SYSKEYDOWN, (WPARAM)key, (LPARAM)key_data);
    40814095}
  • trunk/src/user32/listbox.cpp

    r3153 r3584  
    1 /* $Id: listbox.cpp,v 1.24 2000-03-18 16:13:30 cbratschi Exp $ */
     1/* $Id: listbox.cpp,v 1.25 2000-05-22 17:21:08 cbratschi Exp $ */
    22/*
    33 * Listbox controls
     
    66 * Copyright 1999 Christoph Bratschi (ported from WINE)
    77 *
    8  * Corel version: 20000317
     8 * Corel version: 20000513
    99 * (WINE version: 991212)
    1010 *
     
    3434 - VK_LINEDOWN -> bottom most item not always visible
    3535 - performance not optimized
    36  - ownerdraw is broken -> toolbar customize dialog
    3736 - first item selection mark not redrawn on new selection
     37 - LISTBOX_HandleLButtonDownCombo fails, bug in GetWindowRect or ClientToScreen!
     38   I clicked on the vertical scrollbar, this happens:
     39    t1: SendInternalMessageA WM_LBUTTONDOWN for 68000009 1 1d00c6
     40    t1: GetClientRect of 68000009 returned (0,0) (191,110)
     41    t1: USER32: GetCapture returned 68000009
     42    t1: GetWindowRect 68000009 (450,130) (657,242)
     43    t1: ClientToScreen 68000009 (198,29) -> (424,108)
     44   mouse position is ok, but screen point is outside window rect!!!
     45   the new point is left-top and not on the right!!!
    3846 */
    3947
     
    112120#define SEND_NOTIFICATION(hwnd,descr,code) \
    113121    (SendMessageA( (descr)->owner, WM_COMMAND, \
    114      MAKEWPARAM((((descr)->lphc)?ID_CB_LISTBOX:GetWindowLongA(hwnd,GWL_ID)), (code) ), hwnd ))
     122     MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID), (code)), hwnd ))
    115123
    116124/* Current timer status */
     
    482490    {
    483491        DRAWITEMSTRUCT dis;
    484         UINT           id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     492        UINT           id = GetWindowLongA(hwnd,GWL_ID);
    485493
    486494        if (!item)
     
    714722        {
    715723            COMPAREITEMSTRUCT cis;
    716             UINT                id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     724            UINT                id = GetWindowLongA(hwnd,GWL_ID);
    717725
    718726            cis.CtlType    = ODT_LISTBOX;
     
    887895    INT focusItem;
    888896
     897    if (descr->style & LBS_NOREDRAW) return 0;
     898
    889899    SetRect( &rect, 0, 0, descr->width, descr->height );
    890     if (descr->style & LBS_NOREDRAW) return 0;
    891900    if (descr->style & LBS_MULTICOLUMN)
    892901        rect.right = rect.left + descr->column_width;
     
    966975    /* Paint the focus item now */
    967976    descr->focus_item = focusItem;
    968     if (focusRect.top != focusRect.bottom)
     977    if (focusRect.top != focusRect.bottom && descr->caret_on)
    969978        LISTBOX_DrawItem( hwnd, descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS );
    970979
     
    12811290    {
    12821291        INT oldsel = descr->selected_item;
    1283         //SvL: Why was this commented out??? (enabled in latest wine code)
    1284         if (index == oldsel) return LB_OKAY;
    1285 
    1286         if (oldsel != -1) descr->items[oldsel].selected = FALSE;
    1287         if (index != -1) descr->items[index].selected = TRUE;
    1288         descr->selected_item = index;
    1289         if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
    1290         if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
    1291         if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr,
    1292                                (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL );
    1293         else
    1294             if( descr->lphc ) /* set selection change flag for parent combo */
    1295                 descr->lphc->wState |= CBF_SELCHANGE;
    1296     }
    1297     return LB_OKAY;
     1292
     1293        if (index != oldsel)
     1294        {
     1295          if (oldsel != -1) descr->items[oldsel].selected = FALSE;
     1296          if (index != -1) descr->items[index].selected = TRUE;
     1297
     1298          descr->selected_item = index;
     1299
     1300          if (oldsel != -1)
     1301            LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
     1302          if (index != -1)
     1303            LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
     1304
     1305          if (send_notify && descr->nb_items)
     1306            SEND_NOTIFICATION( hwnd, descr, (index != -1)
     1307                               ? LBN_SELCHANGE : LBN_SELCANCEL );
     1308          else
     1309            if( descr->lphc )
     1310              /* set selection change flag for parent combo */
     1311              descr->lphc->wState |= CBF_SELCHANGE;
     1312        }
     1313    }
     1314
     1315    /* "If the index parameter is -1, the return value is LB_ERR even though
     1316     * no error occurred." (At least for single selection boxes.) */
     1317    return (index == -1) ? LB_ERR : LB_OKAY;
    12981318}
    12991319
     
    13961416    {
    13971417        MEASUREITEMSTRUCT mis;
    1398         UINT                id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     1418        UINT              id = GetWindowLongA(hwnd,GWL_ID);
    13991419
    14001420        mis.CtlType    = ODT_LISTBOX;
     
    14901510    {
    14911511        DELETEITEMSTRUCT dis;
    1492         UINT               id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     1512        UINT             id = GetWindowLongA(hwnd,GWL_ID);
    14931513
    14941514        dis.CtlType  = ODT_LISTBOX;
     
    19771997
    19781998static LRESULT LISTBOX_HandleLButtonDownCombo( HWND hwnd, LB_DESCR *pDescr,
    1979                                                WPARAM wParam, INT x, INT y)
     1999                                               UINT msg,WPARAM wParam, INT x, INT y)
    19802000{
    19812001    RECT clientRect, screenRect;
     
    19892009    if(PtInRect(&clientRect, mousePos))
    19902010    {
    1991         /* MousePos is in client, resume normal processing */
    1992         return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y);
     2011      /* MousePos is in client, resume normal processing */
     2012      if (msg == WM_LBUTTONDOWN)
     2013      {
     2014         pDescr->lphc->droppedIndex = pDescr->nb_items ? pDescr->selected_item : -1;
     2015         return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y);
     2016      }
     2017      else if (pDescr->style & LBS_NOTIFY)
     2018        SEND_NOTIFICATION( hwnd, pDescr, LBN_DBLCLK );
     2019      return 0;
    19932020    }
    19942021    else
    19952022    {
    1996         POINT screenMousePos;
    1997         HWND hWndOldCapture;
    1998 
    1999         /* Check the Non-Client Area */
    2000         screenMousePos = mousePos;
    2001         hWndOldCapture = GetCapture();
     2023      POINT screenMousePos;
     2024      RECT screenRect;
     2025      HWND hWndOldCapture;
     2026//CB: read buglist
     2027      /* Check the Non-Client Area */
     2028      screenMousePos = mousePos;
     2029      hWndOldCapture = GetCapture();
     2030      GetWindowRect(hwnd,&screenRect);
     2031      ClientToScreen(hwnd,&screenMousePos);
     2032
     2033      if (!PtInRect(&screenRect,screenMousePos))
     2034      {
    20022035        ReleaseCapture();
    2003         GetWindowRect(hwnd, &screenRect);
    2004         ClientToScreen(hwnd, &screenMousePos);
    2005 
    2006         if(!PtInRect(&screenRect, screenMousePos))
    2007         {
    2008             /* Close The Drop Down */
    2009             SEND_NOTIFICATION( hwnd, pDescr, LBN_SELCANCEL );
    2010             return 0;
    2011         }
    2012         else
    2013         {
    2014             /* Check to see the NC is a scrollbar */
    2015             INT nHitTestType=0;
    2016             DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    2017             /* Check Vertical scroll bar */
    2018             if (dwStyle & WS_VSCROLL)
    2019             {
    2020                 clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
    2021                 if (PtInRect( &clientRect, mousePos ))
    2022                 {
    2023                     nHitTestType = HTVSCROLL;
    2024                 }
    2025             }
    2026               /* Check horizontal scroll bar */
    2027             if (dwStyle & WS_HSCROLL)
    2028             {
    2029                 clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
    2030                 if (PtInRect( &clientRect, mousePos ))
    2031                 {
    2032                     nHitTestType = HTHSCROLL;
    2033                 }
    2034             }
    2035             /* Windows sends this message when a scrollbar is clicked
    2036              */
    2037 
    2038             if(nHitTestType != 0)
    2039             {
    2040                 SendMessageA(hwnd, WM_NCLBUTTONDOWN, nHitTestType,
    2041                     MAKELONG(screenMousePos.x, screenMousePos.y));
    2042             }
    2043             /* Resume the Capture after scrolling is complete
    2044              */
    2045             if(hWndOldCapture != 0)
    2046             {
    2047                 SetCapture(hWndOldCapture);
    2048             }
    2049         }
     2036        LISTBOX_SetSelection( hwnd, pDescr, pDescr->lphc->droppedIndex, FALSE, FALSE );
     2037        COMBO_FlipListbox( pDescr->lphc, FALSE, FALSE );
     2038
     2039        return 0;
     2040      } else
     2041      {
     2042        /* Check to see the NC is a scrollbar */
     2043        INT nHitTestType = SendMessageA(hwnd,WM_NCHITTEST,0,MAKELONG(screenMousePos.x,screenMousePos.y));
     2044
     2045        /* Windows sends this message when a scrollbar is clicked
     2046         */
     2047        if (nHitTestType != HTCLIENT)
     2048        {
     2049          SendMessageA(hwnd,(msg == WM_LBUTTONDOWN) ? WM_NCLBUTTONDOWN:WM_NCLBUTTONDBLCLK,nHitTestType,MAKELONG(screenMousePos.x,screenMousePos.y));
     2050        }
     2051
     2052        /* Resume the Capture after scrolling is complete
     2053         */
     2054        if (hWndOldCapture)
     2055        {
     2056          SetCapture(hWndOldCapture);
     2057        }
     2058      }
    20502059    }
    20512060    return 0;
     
    21352144{
    21362145    INT index;
    2137     TIMER_DIRECTION dir;
     2146    TIMER_DIRECTION dir = LB_TIMER_NONE;
    21382147
    21392148    if (GetCapture() != hwnd) return 0;
     
    21562165            x = descr->width - 1;
    21572166        }
    2158         else dir = LB_TIMER_NONE;  /* inside */
    21592167    }
    21602168    else
     
    21622170        if (y < 0) dir = LB_TIMER_UP;  /* above */
    21632171        else if (y >= descr->height) dir = LB_TIMER_DOWN;  /* below */
    2164         else dir = LB_TIMER_NONE;  /* inside */
    21652172    }
    21662173
     
    23562363    descr->nb_tabs       = 0;
    23572364    descr->tabs          = NULL;
    2358     descr->caret_on      = TRUE;
     2365    descr->caret_on      = lphc ? FALSE:TRUE;
    23592366    descr->in_focus      = FALSE;
    23602367    descr->captured      = FALSE;
     
    23882395        else
    23892396        {
    2390             UINT        id = (descr->lphc ) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     2397            UINT        id = GetWindowLongA(hwnd,GWL_ID);
    23912398
    23922399            mis.CtlType    = ODT_LISTBOX;
     
    30623069            }
    30633070            case WM_LBUTTONDOWN:
    3064                  return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam,
     3071            case WM_LBUTTONDBLCLK:
     3072                 return LISTBOX_HandleLButtonDownCombo( hwnd, descr,msg, wParam,
    30653073                         (INT16)LOWORD(lParam), (INT16)HIWORD(lParam));
    30663074            case WM_MOUSEACTIVATE:
     
    30773085                           && (wParam == VK_DOWN || wParam == VK_UP)) )
    30783086                     {
    3079                          COMBO_FlipListbox( lphc, FALSE );
     3087                         COMBO_FlipListbox( lphc, FALSE, FALSE );
    30803088                         return 0;
    30813089                     }
  • trunk/src/user32/menu.cpp

    r3501 r3584  
    1 /* $Id: menu.cpp,v 1.21 2000-05-09 18:56:56 sandervl Exp $*/
     1/* $Id: menu.cpp,v 1.22 2000-05-22 17:21:09 cbratschi Exp $*/
    22/*
    33 * Menu functions
     
    99 * Copyright 1999 Christoph Bratschi
    1010 *
    11  * Corel version: 20000317
     11 * Corel version: 200005313
    1212 * (WINE version: 20000130)
    1313 *
     
    837837        lpitem->rect.right  += mis.itemWidth;
    838838
    839         //SvL: Add size of space between two menu items (fixes RealPlayer 7 menu)
     839        //SvL: Add size of space between two menu items (fixes RealPlayer 7 menu)
    840840        if(menuBar)
    841841        {
     
    15991599            if (!pTopPopupWnd)
    16001600            {
    1601                 DebugInt3();
     1601                DebugInt3();
    16021602                return FALSE;
    16031603            }
     
    16161616                if( !menu->hWnd )
    16171617                {
    1618                     DebugInt3();
     1618                    DebugInt3();
    16191619                    return FALSE;
    16201620                }
     
    21872187        if(win32wnd==NULL) {
    21882188            //SvL: This happens in Moraff's YourJongg 2.0, return here
    2189             //TODO: Check if this is supposed to happen at all...
     2189            //TODO: Check if this is supposed to happen at all...
    21902190            return (HMENU)0;
    2191         }
     2191        }
    21922192
    21932193        ht = win32wnd->HandleNCHitTest(pt);
     
    24332433              functionality.
    24342434            */
    2435             pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,hPtMenu,FALSE,wFlags,&pmt->pt);
     2435            pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,hPtMenu,FALSE,wFlags,&pmt->pt);
    24362436            return TRUE;
    24372437         }
     
    27842784                    goto buttondown;
    27852785                case WM_LBUTTONDBLCLK:
    2786                     if (bSysMenu && (hmenu == mt.hTopMenu))
    2787                     {
    2788                         fEndMenu = TRUE;
    2789                         break;
    2790                     }
    2791                     /* fall through */
     2786                    if (bSysMenu && (hmenu == mt.hTopMenu))
     2787                    {
     2788                        fEndMenu = TRUE;
     2789                        break;
     2790                    }
     2791                    /* fall through */
    27922792                case WM_LBUTTONDOWN:
    27932793                    /* If the message belongs to the menu, removes it from the queue */
    27942794                    /* Else, end menu tracking */
    27952795
    2796                 buttondown:
     2796                buttondown:
    27972797                    /* Forcing mouse popup NOW - Ensure timer doesn't popup menu also */
    2798                     mouseOverMenuID = -1;
     2798                    mouseOverMenuID = -1;
    27992799                    fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
    28002800                    fEndMenu = !fRemove;
     
    28092809                    {
    28102810                        /* Forcing mouse popup NOW - Ensure timer doesn't popup menu also */
    2811                         mouseOverMenuID = -1;
     2811                        mouseOverMenuID = -1;
    28122812                        executedMenuId = MENU_ButtonUp( &mt, hmenu, wFlags);
    28132813
     
    28522852                   MENU_FindItemByCoords( ptmenu, mt.pt, &id );
    28532853
    2854                  /* If it is over the same item that set up the timer originally .... */
    2855                  if (mouseOverMenuID != -1 && mouseOverMenuID == id)
    2856                  {
    2857                    /* .... Pop up the menu */
     2854                 /* If it is over the same item that set up the timer originally .... */
     2855                 if (mouseOverMenuID != -1 && mouseOverMenuID == id)
     2856                 {
     2857                   /* .... Pop up the menu */
    28582858                   mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, hmenu, FALSE, wFlags,&mt.pt);
    2859                   }
     2859                  }
    28602860              }
    28612861
     
    29682968            }  /* switch(msg.message) - kbd */
    29692969        }
    2970         else if (msg.message == WM_SYSCOMMAND)
    2971         {
    2972                 /* The user clicked on the system menu/button */
     2970        else if (msg.message == WM_SYSCOMMAND)
     2971        {
     2972                /* The user clicked on the system menu/button */
    29732973        fEndMenu = TRUE;
    29742974        break;
    2975         }
     2975        }
    29762976        else
    29772977        {
     
    34823482    //TRACE("menu=%04x item=%04x ptr=%p len=%d flags=%04x\n",
    34833483    //             hMenu, wItemID, str, nMaxSiz, wFlags );
    3484     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
    3485     if (!IS_STRING_ITEM(item->fType)) return 0;
    3486     if (!str || !nMaxSiz) return strlen(item->text);
     3484
     3485    item = MENU_FindItem( &hMenu, &wItemID, wFlags );
     3486
     3487    if (!str || !nMaxSiz)
     3488    {
     3489        if (item && IS_STRING_ITEM(item->fType))
     3490            return strlen(item->text);
     3491        else
     3492            return 0;
     3493    }
     3494
    34873495    str[0] = '\0';
    3488     lstrcpynA( str, item->text, nMaxSiz );
    3489     //TRACE("returning '%s'\n", str );
     3496
     3497    if (item)
     3498    {
     3499        if (!IS_STRING_ITEM(item->fType)) return 0;
     3500        lstrcpynA( str, item->text, nMaxSiz );
     3501    }
     3502
    34903503    return strlen(str);
    34913504}
     
    35043517    //TRACE("menu=%04x item=%04x ptr=%p len=%d flags=%04x\n",
    35053518    //             hMenu, wItemID, str, nMaxSiz, wFlags );
    3506     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
    3507     if (!IS_STRING_ITEM(item->fType)) return 0;
    3508     if (!str || !nMaxSiz) return strlen(item->text);
     3519
     3520    item = MENU_FindItem( &hMenu, &wItemID, wFlags );
     3521
     3522    if (!str || !nMaxSiz)
     3523    {
     3524        if (item && IS_STRING_ITEM(item->fType))
     3525            return strlen(item->text);
     3526        else
     3527            return 0;
     3528    }
     3529
    35093530    str[0] = '\0';
    3510     lstrcpynAtoW( str, item->text, nMaxSiz );
     3531
     3532    if (item)
     3533    {
     3534        if (!IS_STRING_ITEM(item->fType)) return 0;
     3535        lstrcpynAtoW( str, item->text, nMaxSiz );
     3536    }
     3537
    35113538    return lstrlenW(str);
    35123539}
     
    47274754 *         IsMenuActive    (Internal)
    47284755 */
    4729 BOOL IsMenuActive()
     4756BOOL IsMenuActive(void)
    47304757{
    47314758    return pTopPopupWnd &&  (GetWindowLongA(pTopPopupWnd,GWL_STYLE) & WS_VISIBLE);
  • trunk/src/user32/pmframe.cpp

    r3525 r3584  
    1 /* $Id: pmframe.cpp,v 1.53 2000-05-12 18:09:41 sandervl Exp $ */
     1/* $Id: pmframe.cpp,v 1.54 2000-05-22 17:21:10 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    168168    case WM_HITTEST:
    169169    {
    170         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    171                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    172         }
     170        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     171                win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     172        }
    173173        if(win32wnd && win32wnd->IsWindowCreated())
    174174        {
     
    192192    case WM_BUTTON3DBLCLK:
    193193    {
    194         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    195                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    196         }
     194        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     195                win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     196        }
    197197        if(win32wnd && win32wnd->IsWindowCreated())
    198198        {
     
    217217    case WM_MOUSEMOVE:
    218218    {
    219         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    220                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    221         }
     219        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     220                win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     221        }
    222222        if(win32wnd && win32wnd->IsWindowCreated())
    223                 win32wnd->MsgMouseMove(pWinMsg);
     223                win32wnd->MsgMouseMove(pWinMsg);
    224224        RestoreOS2TIB();
    225225        return (MRESULT)TRUE;
     
    230230        dprintf(("PMFRAME: WM_PAINT"));
    231231        if(win32wnd->getStyle() & WS_MINIMIZE_W)
    232                 goto RunDefFrameProc;
     232                goto RunDefFrameProc;
    233233        if(win32wnd->IsWindowCreated())
    234                 win32wnd->MsgNCPaint();
     234                win32wnd->MsgNCPaint();
    235235
    236236        goto RunDefWndProc;
     
    441441
    442442    case WM_SHOW:
    443         dprintf(("PMFRAME: WM_SHOW"));
     443        dprintf(("PMFRAME: WM_SHOW"));
    444444        break;
    445445
     
    497497
    498498    case WM_VRNENABLED:
    499         if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
    500         {
    501                 HWND hwndrelated;
    502                 Win32BaseWindow *topwindow;
    503 
    504                 win32wnd->setComingToTop(TRUE);
    505 
    506                 hwndrelated = WinQueryWindow(hwnd, QW_PREV);
    507                 dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
    508                 topwindow = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndrelated);
    509                 if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
    510                         //put window at the top of z order
    511                         WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
    512                 }
    513 
    514                 win32wnd->setComingToTop(FALSE);
    515                 break;
    516         }
    517         goto RunDefFrameProc;
     499        if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
     500        {
     501                HWND hwndrelated;
     502                Win32BaseWindow *topwindow;
     503
     504                win32wnd->setComingToTop(TRUE);
     505
     506                hwndrelated = WinQueryWindow(hwnd, QW_PREV);
     507                dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
     508                topwindow = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndrelated);
     509                if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
     510                        //put window at the top of z order
     511                        WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
     512                }
     513
     514                win32wnd->setComingToTop(FALSE);
     515                break;
     516        }
     517        goto RunDefFrameProc;
    518518
    519519    default:
  • trunk/src/user32/win32wbase.cpp

    r3581 r3584  
    1 /* $Id: win32wbase.cpp,v 1.191 2000-05-20 14:57:24 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.192 2000-05-22 17:21:11 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    208208    }
    209209    if(propertyList) {
    210         removeWindowProps();
     210        removeWindowProps();
    211211    }
    212212}
     
    503503#if 0
    504504  if(((dwStyle & (WS_CAPTION|WS_POPUP)) == WS_CAPTION) && (getParent() == NULL || getParent() == windowDesktop)) {
    505         fTaskList = TRUE;
     505        fTaskList = TRUE;
    506506  }
    507507#else
     
    867867    //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
    868868    if(fDestroyWindowCalled) {
    869         return 0;
     869        return 0;
    870870    }
    871871
     
    916916    //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
    917917    if(fDestroyWindowCalled) {
    918         return 0;
     918        return 0;
    919919    }
    920920
     
    927927    //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
    928928    if(fDestroyWindowCalled) {
    929         return 0;
     929        return 0;
    930930    }
    931931    return  SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
     
    10561056    RECT client = rectClient;
    10571057
    1058         if ((rect.left >= client.left) && (rect.left < client.right) &&
     1058        if ((rect.left >= client.left) && (rect.left < client.right) &&
    10591059           (rect.right >= client.left) && (rect.right < client.right) &&
    10601060           (rect.top  >= client.top) && (rect.top < client.bottom) &&
    10611061           (rect.bottom >= client.top) && (rect.bottom < client.bottom))
    10621062        {
    1063                 return 0;
    1064         }
    1065 
    1066         dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom));
    1067         hrgn = CreateRectRgnIndirect(&rect);
    1068         if (!hrgn) return 0;
    1069 
    1070         rc = SendInternalMessageA(WM_NCPAINT,hrgn,0);
    1071 
    1072         DeleteObject(hrgn);
    1073 
    1074         return rc;
    1075   }
    1076   else  return 0;
     1063                return 0;
     1064        }
     1065
     1066        dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom));
     1067        hrgn = CreateRectRgnIndirect(&rect);
     1068        if (!hrgn) return 0;
     1069
     1070        rc = SendInternalMessageA(WM_NCPAINT,hrgn,0);
     1071
     1072        DeleteObject(hrgn);
     1073
     1074        return rc;
     1075  }
     1076  else  return 0;
    10771077}
    10781078//******************************************************************************
     
    13291329        if ((dwStyle & WS_CAPTION) == WS_CAPTION)
    13301330        {
    1331 //          HandleNCPaint((HRGN)1);
     1331          HandleNCPaint((HRGN)1);
    13321332          OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
    13331333        }
     
    16381638        if((HIWORD(lParam) & KEYDATA_ALT) && wParam)
    16391639        {
    1640                 if (wParam == VK_TAB || wParam == VK_ESCAPE) 
    1641                         break;
     1640                if (wParam == VK_TAB || wParam == VK_ESCAPE)
     1641                        break;
    16421642                if (wParam == VK_SPACE && (getStyle() & WS_CHILD)) {
    1643                         getParent()->SendMessageA(Msg, wParam, lParam );
    1644                 }
     1643                        getParent()->SendMessageA(Msg, wParam, lParam );
     1644                }
    16451645                else    SendMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
    16461646        }
    16471647        else /* check for Ctrl-Esc */
    1648                 if (wParam != VK_ESCAPE) MessageBeep(0);
    1649                         break;
     1648                if (wParam != VK_ESCAPE) MessageBeep(0);
     1649                        break;
    16501650    }
    16511651
     
    20372037 ULONG showstate = 0;
    20382038 HWND  hWinAfter;
    2039  BOOL  rc;
     2039 BOOL  rc,wasVisible,showFlag;
    20402040
    20412041    dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
     
    20482048        break;
    20492049    case SW_HIDE:
     2050        if (!wasVisible) return wasVisible;
     2051         if(GetCapture() == getWindowHandle() || IsChild(GetCapture()))
     2052           ReleaseCapture();
     2053
    20502054        showstate = SWPOS_HIDE;
    20512055        break;
     
    20772081
    20782082    /* We can't activate a child window (WINE) */
    2079     if(getStyle() & WS_CHILD)
     2083    if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_MDICHILD))
    20802084        showstate &= ~SWPOS_ACTIVATE;
    20812085
     
    20852089    else    setStyle(getStyle() & ~WS_VISIBLE);
    20862090
     2091    showFlag = (nCmdShow != SW_HIDE);
     2092
    20872093    rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
    20882094    OSLibWinShowWindow(OS2Hwnd, showstate);
    20892095
    2090     SendInternalMessageA(WM_SHOWWINDOW, (showstate & SWPOS_SHOW) ? 1 : 0, 0);
     2096    //CB: PMFrame: WM_MINMAXFRAME SWP_* handling isn't always successful!
     2097    if ((showstate & SWPOS_MAXIMIZE) == SWPOS_MAXIMIZE)
     2098      setStyle((getStyle() & ~WS_MINIMIZE) | WS_MAXIMIZE);
     2099    else if ((showstate & SWPOS_MINIMIZE) == SWPOS_MINIMIZE)
     2100      setStyle((getStyle() & ~WS_MAXIMIZE) | WS_MINIMIZE);
     2101    else if ((showstate & SWPOS_RESTORE) == SWPOS_RESTORE)
     2102      setStyle(getStyle() & ~(WS_MINIMIZE | WS_MAXIMIZE));
    20912103
    20922104    if (flags & WIN_NEED_SIZE)
     
    21402152    else
    21412153    {
    2142         if (!(fuFlags & SWP_SHOWWINDOW))
    2143               fuFlags |= SWP_NOREDRAW;
    2144         fuFlags &= ~SWP_HIDEWINDOW;
    2145     }
    2146 
    2147     if(cx < 0) cx = 0; 
     2154        if (!(fuFlags & SWP_SHOWWINDOW))
     2155              fuFlags |= SWP_NOREDRAW;
     2156        fuFlags &= ~SWP_HIDEWINDOW;
     2157    }
     2158
     2159    if(cx < 0) cx = 0;
    21482160    if(cy < 0) cy = 0;
    21492161
     
    21592171        fuFlags |= SWP_NOACTIVATE;   /* Already active */
    21602172    }
    2161     else 
     2173    else
    21622174    if((getStyle() & (WS_POPUP | WS_CHILD)) != WS_CHILD )
    21632175    {
     
    21652177        {
    21662178            fuFlags &= ~SWP_NOZORDER;
    2167             hwndInsertAfter = HWND_TOP;           
     2179            hwndInsertAfter = HWND_TOP;
    21682180        }
    21692181    }
     
    22192231
    22202232    if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible()) {
    2221         setStyle(getStyle() | WS_VISIBLE);
    2222         //SvL: TODO: Send WM_SHOWWINDOW??
    2223         OSLibWinShowWindow(OS2Hwnd, SWPOS_SHOW);
     2233        setStyle(getStyle() | WS_VISIBLE);
     2234        //SvL: TODO: Send WM_SHOWWINDOW??
     2235        OSLibWinShowWindow(OS2Hwnd, SWPOS_SHOW);
    22242236    }
    22252237    else
    22262238    if(fuFlags & SWP_HIDEWINDOW && IsWindowVisible()) {
    2227         setStyle(getStyle() & ~WS_VISIBLE);
    2228         //SvL: TODO: Send WM_SHOWWINDOW??
    2229         OSLibWinShowWindow(OS2Hwnd, SWPOS_HIDE);
     2239        setStyle(getStyle() & ~WS_VISIBLE);
     2240        //SvL: TODO: Send WM_SHOWWINDOW??
     2241        OSLibWinShowWindow(OS2Hwnd, SWPOS_HIDE);
    22302242    }
    22312243    rc = OSLibWinSetMultWindowPos(&swp, 1);
     
    22332245#ifdef DEBUG
    22342246    if(fShow) {
    2235         dprintf(("Frame style 0x%08x, client style 0x%08x", OSLibQueryWindowStyle(OS2HwndFrame), OSLibQueryWindowStyle(OS2Hwnd)));
     2247        dprintf(("Frame style 0x%08x, client style 0x%08x", OSLibQueryWindowStyle(OS2HwndFrame), OSLibQueryWindowStyle(OS2Hwnd)));
    22362248    }
    22372249#endif
     
    23062318    {
    23072319        SetWindowPos(0, 0, 0, 0, 0, SWP_HIDEWINDOW |
    2308                      SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
     2320                     SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
    23092321        if(!::IsWindow(hwnd))
    23102322        {
    2311                 return TRUE;
     2323                return TRUE;
    23122324        }
    23132325    }
     
    26742686  rc = (getStyle() & WS_DISABLED) != 0;
    26752687  if(rc && !fEnable) {
    2676         SendMessageA(WM_CANCELMODE, 0, 0);
     2688        SendMessageA(WM_CANCELMODE, 0, 0);
    26772689  }
    26782690  OSLibWinEnableWindow(OS2HwndFrame, fEnable);
    26792691  if(fEnable == FALSE) {
    2680         //SvL: No need to clear focus as PM already does this
    2681         if(getWindowHandle() == GetCapture()) {
    2682                 ReleaseCapture();  /* A disabled window can't capture the mouse */
    2683                 dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
    2684         }
     2692        //SvL: No need to clear focus as PM already does this
     2693        if(getWindowHandle() == GetCapture()) {
     2694                ReleaseCapture();  /* A disabled window can't capture the mouse */
     2695                dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
     2696        }
    26852697  }
    26862698  return rc;
     
    29842996}
    29852997//******************************************************************************
    2986 //Note: Should return NULL if window is frame window! (IsOS2FrameWindowHandle depends on this 
     2998//Note: Should return NULL if window is frame window! (IsOS2FrameWindowHandle depends on this
    29872999//      behaviour)
    29883000//******************************************************************************
     
    30603072
    30613073    if(window->getOS2FrameWindowHandle() == hwndOS2) {
    3062         return TRUE;
     3074        return TRUE;
    30633075    }
    30643076    return FALSE;
Note: See TracChangeset for help on using the changeset viewer.