Changeset 1801 for trunk/src


Ignore:
Timestamp:
Nov 21, 1999, 6:07:52 PM (26 years ago)
Author:
cbratschi
Message:

fixed window text handling

Location:
trunk/src/user32
Files:
4 edited

Legend:

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

    r1739 r1801  
    1 /* $Id: oslibwin.cpp,v 1.45 1999-11-14 16:35:54 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.46 1999-11-21 17:07:50 cbratschi Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    439439  hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
    440440  if(hwndClient) {
    441         WinEnableWindow(hwndClient, fEnable);
     441        WinEnableWindow(hwndClient, fEnable);
    442442  }
    443443  return rc;
     
    10581058                    OSWinStyle);
    10591059
    1060   //CB: bug: it doesn't work with child windows!
    1061 
    10621060  if(OSFrameStyle & FCF_TITLEBAR)
    10631061  {
  • trunk/src/user32/static.cpp

    r1797 r1801  
    1 /* $Id: static.cpp,v 1.10 1999-11-21 14:37:17 achimha Exp $ */
     1/* $Id: static.cpp,v 1.11 1999-11-21 17:07:51 cbratschi Exp $ */
    22/*
    33 * Static control
     
    1414
    1515#include <stdlib.h>
     16#include <string.h>
    1617#include <os2win.h>
    1718#include "controls.h"
     
    321322  UpdateWindow(hwnd);
    322323
    323   return 0;
     324  return TRUE;
     325}
     326
     327LRESULT STATIC_GetText(HWND hwnd,WPARAM wParam,LPARAM lParam)
     328{
     329  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
     330
     331  if (style == SS_ICON)
     332  {
     333    STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
     334
     335    if (wParam < 4 || !lParam) return 0;
     336    memcpy((VOID*)lParam,&infoPtr->hIcon,4);
     337
     338    return 4;
     339  } else return DefWindowProcA(hwnd,WM_GETTEXT,wParam,lParam);
     340}
     341
     342LRESULT STATIC_GetTextLength(HWND hwnd,WPARAM wParam,LPARAM lParam)
     343{
     344  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
     345
     346  if (style == SS_ICON) return 4;
     347  else return DefWindowProcA(hwnd,WM_GETTEXTLENGTH,wParam,lParam);
    324348}
    325349
     
    479503    case WM_SETTEXT:
    480504      return STATIC_SetText(hwnd,wParam,lParam);
     505
     506    case WM_GETTEXT:
     507      return STATIC_GetText(hwnd,wParam,lParam);
     508
     509    case WM_GETTEXTLENGTH:
     510      return STATIC_GetTextLength(hwnd,wParam,lParam);
    481511
    482512    case WM_SETFONT:
     
    722752    switch (dwStyle & SS_TYPEMASK)
    723753    {
    724         case SS_ETCHEDHORZ:
    725             DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
    726             break;
    727         case SS_ETCHEDVERT:
    728             DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
    729             break;
     754        case SS_ETCHEDHORZ:
     755            DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
     756            break;
     757        case SS_ETCHEDVERT:
     758            DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
     759            break;
    730760        case SS_ETCHEDFRAME:
    731761            DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);
  • trunk/src/user32/win32wbase.cpp

    r1786 r1801  
    1 /* $Id: win32wbase.cpp,v 1.86 1999-11-21 09:43:18 achimha Exp $ */
     1/* $Id: win32wbase.cpp,v 1.87 1999-11-21 17:07:51 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    12151215ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
    12161216{
    1217     if(isUnicode) {
    1218             return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
    1219     }
    1220     else    return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
     1217    return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
    12211218}
    12221219//******************************************************************************
     
    12311228char *Win32BaseWindow::MsgGetText()
    12321229{
    1233     if(isUnicode) {
    1234         SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
    1235     }
    1236     else {
    1237         SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
    1238     }
     1230    SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
    12391231    return windowNameA;
    12401232}
     
    15061498        return wndNameLength;
    15071499
    1508     case WM_GETTEXT:   //TODO: SS_ICON controls
     1500    case WM_GETTEXT:
     1501        if (!lParam) return 0;
    15091502        strncpy((LPSTR)lParam, windowNameA, wParam);
    15101503        return min(wndNameLength, wParam);
    15111504
    15121505    case WM_SETTEXT:
    1513         if(!fInternalMsg) {
    1514                 return SetWindowTextA((LPSTR)lParam);
    1515         }
    1516         else    return 0;
     1506    {
     1507        LPCSTR lpsz = (LPCSTR)lParam;
     1508
     1509        if(windowNameA) free(windowNameA);
     1510        if(windowNameW) free(windowNameW);
     1511
     1512        if (lParam)
     1513        {
     1514          windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
     1515          strcpy(windowNameA, lpsz);
     1516          windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
     1517          lstrcpyAtoW(windowNameW, windowNameA);
     1518          wndNameLength = strlen(windowNameA)+1; //including 0 terminator
     1519        } else
     1520        {
     1521          windowNameA = NULL;
     1522          windowNameW = NULL;
     1523          wndNameLength = 1;
     1524        }
     1525
     1526        if(OS2HwndFrame && dwStyle & WS_CAPTION)
     1527          return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
     1528
     1529        return TRUE;
     1530    }
    15171531
    15181532    case WM_SETREDRAW:
     
    17331747        return wndNameLength;
    17341748
    1735     case WM_GETTEXT:   //TODO: SS_ICON controls
    1736     {
    1737             LRESULT result;
    1738             char *str = (char *) malloc(wParam + 1);
    1739             result = DefWindowProcA(Msg, wParam, (LPARAM)str );
    1740             lstrcpynAtoW( (LPWSTR)lParam, str, wParam );
    1741             free(str);
    1742             return result;
    1743     }
     1749    case WM_GETTEXT:
     1750        if (!lParam) return 0;
     1751        lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
     1752        return min(wndNameLength,wParam);
    17441753
    17451754    case WM_SETTEXT:
    17461755    {
    1747         if(!fInternalMsg)
    1748         {
    1749            LRESULT result;
    1750            char *aText = (char *) malloc((lstrlenW((LPWSTR)lParam)+1)*sizeof(WCHAR));
    1751            *aText = 0;
    1752            lstrcpyWtoA(aText, (LPWSTR) lParam);
    1753            result = SetWindowTextA(aText);
    1754            free(aText);
    1755            return result;
    1756         }
    1757         else    return 0;
     1756        LPWSTR lpsz = (LPWSTR)lParam;
     1757
     1758        if(windowNameA) free(windowNameA);
     1759        if(windowNameW) free(windowNameW);
     1760
     1761        if (lParam)
     1762        {
     1763          windowNameA = (LPSTR)_smalloc(lstrlenW(lpsz)+1);
     1764          lstrcpyWtoA(windowNameA,lpsz);
     1765          windowNameW = (LPWSTR)_smalloc((lstrlenW(lpsz)+1)*sizeof(WCHAR));
     1766          lstrcpyW(windowNameW,lpsz);
     1767          wndNameLength = strlen(windowNameA)+1; //including 0 terminator
     1768        } else
     1769        {
     1770          windowNameA = NULL;
     1771          windowNameW = NULL;
     1772          wndNameLength = 1;
     1773        }
     1774
     1775        if(OS2HwndFrame && dwStyle & WS_CAPTION)
     1776          return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
     1777
     1778        return TRUE;
    17581779    }
    17591780
     
    19161937                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    19171938                break;
     1939
    19181940        default:
    19191941                rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
     
    26252647int Win32BaseWindow::GetWindowTextLength()
    26262648{
    2627     return wndNameLength;
     2649    return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
    26282650}
    26292651//******************************************************************************
     
    26312653int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
    26322654{
    2633     if(windowNameA == NULL) {
    2634         *lpsz = 0;
    2635         return 0;
    2636     }
    2637     strncpy(lpsz, windowNameA, cch);
    2638     return wndNameLength;
     2655    return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
    26392656}
    26402657//******************************************************************************
     
    26422659int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
    26432660{
    2644     if(windowNameW == NULL) {
    2645         *lpsz = 0;
    2646         return 0;
    2647     }
    2648     lstrcpynW((LPWSTR)lpsz, windowNameW, cch);
    2649     return wndNameLength;
     2661    return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
    26502662}
    26512663//******************************************************************************
     
    26532665BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
    26542666{
    2655     if(lpsz == NULL)
    2656         return FALSE;
    2657 
    2658     if(windowNameA) free(windowNameA);
    2659     if(windowNameW) free(windowNameW);
    2660 
    2661     windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
    2662     strcpy(windowNameA, lpsz);
    2663     windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
    2664     lstrcpyAtoW(windowNameW, windowNameA);
    2665     wndNameLength = strlen(windowNameA)+1; //including 0 terminator
    2666 
    2667     // Edit and static text controls also need a WM_SETTEXT message
    2668     if (getWindowClass()->hasClassName("EDIT", FALSE) ||
    2669         getWindowClass()->hasClassName("STATIC", FALSE))
    2670       SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)windowNameA);
    2671 
    2672     if(OS2HwndFrame)
    2673         return OSLibWinSetWindowText(OS2HwndFrame, (LPSTR)windowNameA);
    2674 
    2675     return TRUE;
     2667    return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
    26762668}
    26772669//******************************************************************************
     
    26792671BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
    26802672{
    2681     if(lpsz == NULL)
    2682         return FALSE;
    2683 
    2684     if(windowNameA) free(windowNameA);
    2685     if(windowNameW) free(windowNameW);
    2686 
    2687     windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
    2688     lstrcpyW(windowNameW, (LPWSTR)lpsz);
    2689     windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
    2690     lstrcpyWtoA(windowNameA, windowNameW);
    2691     wndNameLength = strlen(windowNameA)+1; //including 0 terminator
    2692 
    2693     // Edit and static text controls also need a WM_SETTEXT message
    2694     if (getWindowClass()->hasClassName("EDIT", FALSE) ||
    2695         getWindowClass()->hasClassName("STATIC", FALSE))
    2696       SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)windowNameA);
    2697 
    2698     if(OS2HwndFrame)
    2699         return OSLibWinSetWindowText(OS2HwndFrame, (LPSTR)windowNameA);
    2700 
    2701     return TRUE;
     2673    return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
     2674}
     2675//******************************************************************************
     2676//******************************************************************************
     2677VOID Win32BaseWindow::updateWindowStyle(DWORD oldExStyle,DWORD oldStyle)
     2678{
     2679  if(IsWindowDestroyed()) return;
     2680
     2681/*
     2682  if (isChild())
     2683  {
     2684    DWORD dwOSWinStyle,dwOSFrameStyle,newBorderWidth,newBorderHeight;
     2685
     2686    OSLibWinConvertStyle(dwStyle,&dwExStyle,&dwOSWinStyle,&dwOSFrameStyle,&newBorderWidth,&newBorderHeight);
     2687    if (newBorderWidth != borderWidth || newBorderHeight != borderHeight)
     2688    {
     2689      borderWidth = newBorderWidth;
     2690      borderHeight = newBorderHeight;
     2691      FrameSetBorderSize(this,TRUE);
     2692    }
     2693  }
     2694*/
     2695
     2696  if (dwStyle != oldStyle) OSLibSetWindowStyle(OS2HwndFrame,dwStyle);
    27022697}
    27032698//******************************************************************************
     
    27212716                SendMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
    27222717                setExStyle(ss.styleNew);
     2718                updateWindowStyle(ss.styleOld,dwStyle);
    27232719                SendMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
    27242720                return ss.styleOld;
     
    27362732                SendMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
    27372733                setStyle(ss.styleNew);
    2738                 if(!IsWindowDestroyed())
    2739                     OSLibSetWindowStyle(OS2HwndFrame, ss.styleNew);
     2734                updateWindowStyle(dwExStyle,ss.styleOld);
    27402735                SendMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
    27412736                return ss.styleOld;
  • trunk/src/user32/win32wbase.h

    r1704 r1801  
    1 /* $Id: win32wbase.h,v 1.43 1999-11-11 13:17:32 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.44 1999-11-21 17:07:52 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    9494         ULONG  MsgContextMenu(ULONG x,ULONG y);
    9595
     96         VOID   updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
     97
    9698virtual  LONG   SetWindowLongA(int index, ULONG value);
    9799virtual  ULONG  GetWindowLongA(int index);
     
    108110 Win32WndClass *getWindowClass()                { return windowClass; };
    109111
    110          DWORD  getWindowContextHelpId()        { return contextHelpId; };
     112         DWORD  getWindowContextHelpId()        { return contextHelpId; };
    111113         void   setWindowContextHelpId(DWORD id){ contextHelpId = id; };
    112114
     
    271273         HWND   hwndLinkAfter;
    272274        DWORD   flags;
    273         DWORD   contextHelpId;
     275        DWORD   contextHelpId;
    274276        LONG    lastHitTestVal;         //Last value returned by WM_NCHITTEST handler
    275277
Note: See TracChangeset for help on using the changeset viewer.