Changeset 4686 for trunk/src


Ignore:
Timestamp:
Nov 24, 2000, 11:30:36 AM (25 years ago)
Author:
sandervl
Message:

Dialog message fixes

Location:
trunk/src/user32
Files:
2 edited

Legend:

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

    r4444 r4686  
    1 /* $Id: win32dlg.cpp,v 1.53 2000-10-06 15:15:00 sandervl Exp $ */
     1/* $Id: win32dlg.cpp,v 1.54 2000-11-24 10:30:36 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    4949    idResult     = 0;
    5050    dialogFlags  = 0;
     51    fDialogInit  = FALSE;
    5152    memset(&dlgInfo, 0, sizeof(dlgInfo));
    5253
     
    7677    if (dlgInfo.style & DS_SETFONT)
    7778    {
    78           /* The font height must be negative as it is a point size */
    79           /* and must be converted to pixels first */
    80           /* (see CreateFont() documentation in the Windows SDK).   */
    81         HDC dc = GetDC(0);
    82         int pixels = dlgInfo.pointSize * GetDeviceCaps(dc , LOGPIXELSY)/72;
    83         ReleaseDC(0, dc);
     79        /* The font height must be negative as it is a point size */
     80        /* and must be converted to pixels first */
     81        /* (see CreateFont() documentation in the Windows SDK).   */
     82        HDC dc = GetDC(0);
     83        int pixels = dlgInfo.pointSize * GetDeviceCaps(dc , LOGPIXELSY)/72;
     84        ReleaseDC(0, dc);
    8485
    8586        hUserFont = CreateFontW(-pixels, 0, 0, 0,
     
    238239        dprintf(("dlg ctor: GetNextDlgTabItem returned %x, capture hwnd = %x", hwndFocus, GetCapture()));
    239240
    240         HWND hwndPreInitFocus = GetFocus();
     241        fDialogInit = TRUE; //WM_NCCALCSIZE can now be sent to dialog procedure
     242
     243        HWND hwndPreInitFocus = GetFocus();
    241244        if(SendInternalMessageA(WM_INITDIALOG, (WPARAM)hwndFocus, param)) {
    242                 SetFocus(hwndFocus);
    243         }
    244         else
    245         {
    246                 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
    247                    but the focus has not changed, set the focus where we expect it. */
    248                 if ( (getStyle() & WS_VISIBLE) && ( GetFocus() == hwndPreInitFocus ) )
    249                         SetFocus( hwndFocus );
    250         }
     245            SetFocus(hwndFocus);
     246        }
     247        else
     248        {
     249            /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
     250               but the focus has not changed, set the focus where we expect it. */
     251                if ( (getStyle() & WS_VISIBLE) && ( GetFocus() == hwndPreInitFocus ) )
     252                    SetFocus( hwndFocus );
     253        }
    251254
    252255        if (dlgInfo.style & WS_VISIBLE && !(getStyle() & WS_VISIBLE))
     
    255258            UpdateWindow( getWindowHandle() );
    256259        }
    257         SetLastError(0);
     260        SetLastError(ERROR_SUCCESS);
    258261        dprintf(("********* DIALOG CREATED ************"));
    259262        return TRUE;
     
    858861    msgResult = 0;
    859862
     863    //Dialogs never receive these messages
     864    if (Msg == WM_CREATE || Msg == WM_NCCREATE) {
     865        return (LRESULT)1;
     866    }
     867    //Never send a WM_NCCALCSIZE to a dialog before it has received it's WM_INITDIALOG message
     868    //(causes problems for sysinf32.exe)
     869    if(!fDialogInit && Msg == WM_NCCALCSIZE) {
     870        return DefWindowProcA(Msg, wParam, lParam );
     871    }
     872
    860873    if (Win32DlgProc) {      /* Call dialog procedure */
    861874        result = Win32DlgProc(getWindowHandle(), Msg, wParam, lParam);
     
    902915    msgResult = 0;
    903916
     917    //Dialogs never receive these messages
     918    if (Msg == WM_CREATE || Msg == WM_NCCREATE) {
     919        return (LRESULT)1;
     920    }
     921    //Never send a WM_NCCALCSIZE to a dialog before it has received it's WM_INITDIALOG message
     922    //(causes problems for sysinf32.exe)
     923    if(!fDialogInit && Msg == WM_NCCALCSIZE) {
     924        return DefWindowProcW(Msg, wParam, lParam );
     925    }
     926
    904927    if (Win32DlgProc) {      /* Call dialog procedure */
    905928        result = Win32DlgProc(getWindowHandle(), Msg, wParam, lParam);
     
    10691092    case DWL_DLGPROC:
    10701093    {
    1071         //Note: Type of SetWindowLong determines new window proc type
     1094    //Note: Type of SetWindowLong determines new window proc type
    10721095        //      UNLESS the new window proc has already been registered
    10731096        //      (use the old type in that case)
    10741097        //      (VERIFIED in NT 4, SP6)
    10751098        WINDOWPROCTYPE type = WINPROC_GetProcType((HWINDOWPROC)value);
    1076         if(type == WIN_PROC_INVALID) {
    1077                 type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
    1078         }
     1099    if(type == WIN_PROC_INVALID) {
     1100        type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
     1101    }
    10791102        oldval = (LONG)WINPROC_GetProc(Win32DlgProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
    10801103        WINPROC_SetProc((HWINDOWPROC *)&Win32DlgProc, (WNDPROC)value, type, WIN_PROC_WINDOW);
  • trunk/src/user32/win32dlg.h

    r3662 r4686  
    1 /* $Id: win32dlg.h,v 1.11 2000-06-07 14:51:30 sandervl Exp $ */
     1/* $Id: win32dlg.h,v 1.12 2000-11-24 10:30:36 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    7575virtual  ULONG  MsgCreate(HWND hwndOS2);
    7676
    77 virtual  LONG   SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
    78 virtual  ULONG  GetWindowLongA(int index, BOOL fUnicode = FALSE);
     77virtual  LONG   SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
     78virtual  ULONG  GetWindowLongA(int index, BOOL fUnicode = FALSE);
    7979
    80 static  ULONG  GetDialogBaseUnits()  { return MAKELONG(xBaseUnit, yBaseUnit); };
     80static  ULONG  GetDialogBaseUnits()  { return MAKELONG(xBaseUnit, yBaseUnit); };
    8181
    82            INT  doDialogBox();
     82       INT  doDialogBox();
    8383
    8484protected:
    85         BOOL    DIALOG_Init(void);
    86         BOOL    getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize );
    87         BOOL    getCharSize( HFONT hFont, SIZE * pSize);
    88         LPCSTR  parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result);
     85    BOOL    DIALOG_Init(void);
     86    BOOL    getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize );
     87    BOOL    getCharSize( HFONT hFont, SIZE * pSize);
     88    LPCSTR  parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result);
    8989        WORD   *getControl(const WORD *p, DLG_CONTROL_INFO *info, BOOL dialogEx);
    90         BOOL    createControls(LPCSTR dlgtemplate, HINSTANCE hInst);
    91        
    92         LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam);
     90    BOOL    createControls(LPCSTR dlgtemplate, HINSTANCE hInst);
     91
     92    LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam);
    9393        LRESULT DefDlg_Epilog(UINT msg, BOOL fResult);
    9494
    95         BOOL    setDefButton(HWND hwndNew );
    96         HWND    findDefButton();
    97         BOOL    saveFocus();
    98         BOOL    restoreFocus();
    99         void    setFocus(HWND hwndCtrl );
     95    BOOL    setDefButton(HWND hwndNew );
     96    HWND    findDefButton();
     97    BOOL    saveFocus();
     98    BOOL    restoreFocus();
     99    void    setFocus(HWND hwndCtrl );
    100100
    101         // values normally contained in the standard dialog words
    102       DLGPROC   Win32DlgProc;   //DWL_WNDPROC
    103         ULONG   msgResult;      //DWL_MSGRESULT
    104         ULONG   userDlgData;    //DWL_USER
     101    // values normally contained in the standard dialog words
     102    DLGPROC Win32DlgProc;   //DWL_WNDPROC
     103    ULONG   msgResult;  //DWL_MSGRESULT
     104    ULONG   userDlgData;    //DWL_USER
    105105
    106106   DLG_TEMPLATE dlgInfo;
    107         WORD    xUnit;
    108         WORD    yUnit;
    109         HWND    hwndFocus;
    110         HFONT   hUserFont;
    111         HMENU   hMenu;
    112         DWORD   idResult;
    113         DWORD   dialogFlags;
     107    WORD    xUnit;
     108    WORD    yUnit;
     109    HWND    hwndFocus;
     110    HFONT   hUserFont;
     111    HMENU   hMenu;
     112    DWORD   idResult;
     113    DWORD   dialogFlags;
     114    BOOL    fDialogInit;
    114115
    115         DWORD   tmpParam;       //set in ctor, used in MsgCreate method
    116         LPSTR   tmpDlgTemplate; //set in ctor, used in MsgCreate method
     116    DWORD   tmpParam;       //set in ctor, used in MsgCreate method
     117    LPSTR   tmpDlgTemplate; //set in ctor, used in MsgCreate method
     118
    117119private:
    118120 static BOOL    fInitialized;
Note: See TracChangeset for help on using the changeset viewer.