Changeset 6709 for trunk/src/comdlg32


Ignore:
Timestamp:
Sep 15, 2001, 11:26:26 AM (24 years ago)
Author:
sandervl
Message:

restored old version

Location:
trunk/src/comdlg32
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comdlg32/colordlg.c

    r6708 r6709  
    7474 int nextuserdef;     /* next free place in user defined color array */
    7575 HDC hdcMem;        /* color graph used for BitBlt() */
    76  HBITMAP hbmMem;    /* color graph bitmap */
     76 HBITMAP hbmMem;    /* color graph bitmap */   
    7777 RECT fullsize;     /* original dialog window size */
    7878 UINT msetrgb;        /* # of SETRGBSTRING message (today not used)  */
     
    155155  /* lum */
    156156  case 'L': mmsum *= 120;              /* 0...61200=(255+255)*120 */
    157        result = mmsum / 255;        /* 0...240 */
    158        break;
     157           result = mmsum / 255;        /* 0...240 */
     158           break;
    159159  /* saturation */
    160160  case 'S': if (!mmsum)
    161         result = 0;
    162        else
    163         if (!mini || maxi == 255)
    164          result = 240;
    165        else
    166        {
    167         result = mmdif * 240;       /* 0...61200=255*240 */
    168         result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
    169        }
    170        break;
     161            result = 0;
     162           else
     163            if (!mini || maxi == 255)
     164             result = 240;
     165           else
     166           {
     167            result = mmdif * 240;       /* 0...61200=255*240 */
     168            result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
     169           }
     170           break;
    171171  /* hue */
    172172  case 'H': if (!mmdif)
    173         result = 160;
    174        else
    175        {
    176         if (maxi == r)
    177         {
    178          iresult = 40 * (g - b);       /* -10200 ... 10200 */
    179          iresult /= (int) mmdif;    /* -40 .. 40 */
    180          if (iresult < 0)
    181           iresult += 240;          /* 0..40 and 200..240 */
    182         }
    183         else
    184          if (maxi == g)
    185          {
    186           iresult = 40 * (b - r);
    187           iresult /= (int) mmdif;
    188           iresult += 80;           /* 40 .. 120 */
    189          }
    190          else
    191           if (maxi == b)
    192           {
    193            iresult = 40 * (r - g);
    194            iresult /= (int) mmdif;
    195            iresult += 160;         /* 120 .. 200 */
    196           }
    197         result = iresult;
    198        }
    199        break;
     173            result = 160;
     174           else
     175           {
     176            if (maxi == r)
     177            {
     178             iresult = 40 * (g - b);       /* -10200 ... 10200 */
     179             iresult /= (int) mmdif;    /* -40 .. 40 */
     180             if (iresult < 0)
     181              iresult += 240;          /* 0..40 and 200..240 */
     182            }
     183            else
     184             if (maxi == g)
     185             {
     186              iresult = 40 * (b - r);
     187              iresult /= (int) mmdif;
     188              iresult += 80;           /* 40 .. 120 */
     189             }
     190             else
     191              if (maxi == b)
     192              {
     193               iresult = 40 * (r - g);
     194               iresult /= (int) mmdif;
     195               iresult += 160;         /* 120 .. 200 */
     196              }
     197            result = iresult;
     198           }
     199           break;
    200200 }
    201201 return result;    /* is this integer arithmetic precise enough ? */
     
    249249 */
    250250static int CC_MouseCheckPredefColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
    251         LPARAM lParam )
     251            LPARAM lParam )
    252252{
    253253 HWND hwnd;
     
    283283 */
    284284static int CC_MouseCheckUserColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
    285         LPARAM lParam )
     285            LPARAM lParam )
    286286{
    287287 HWND hwnd;
     
    317317
    318318/*  240  ^......        ^^ 240
    319     |     .        ||
     319        |     .        ||
    320320    SAT  |     .        || LUM
    321     |     .        ||
    322     +-----> 239   ----
    323        HUE
     321        |     .        ||
     322        +-----> 239   ----
     323           HUE
    324324*/
    325325/***********************************************************************
     
    464464 RECT rect;
    465465 HWND hwnd = GetDlgItem(hDlg, 0x2be);
    466  LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER);
     466 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER); 
    467467
    468468 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6)))   /* if full size */
     
    476476   ScreenToClient(hDlg, points);    /*  |<  |  */
    477477   oben = points[0].y;                 /*  | \ |  */
    478                      /*  |  \|  */
     478                                     /*  |  \|  */
    479479   temp = (long)height * (long)y;
    480480   points[0].y = oben + height - temp / (long)MAXVERT;
     
    502502 int w = GetDialogBaseUnits();
    503503 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
    504  LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER );
     504 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER ); 
    505505 RECT rect;
    506506 POINT point, p;
     
    524524   lpp->oldcross.right  = point.x + w + 1;
    525525   lpp->oldcross.top    = point.y - w - 1;
    526    lpp->oldcross.bottom = point.y + w + 1;
    527 
    528    MoveToEx(hDC, point.x - w, point.y, &p);
     526   lpp->oldcross.bottom = point.y + w + 1; 
     527
     528   MoveToEx(hDC, point.x - w, point.y, &p); 
    529529   LineTo(hDC, point.x + w, point.y);
    530    MoveToEx(hDC, point.x, point.y - w, &p);
     530   MoveToEx(hDC, point.x, point.y - w, &p); 
    531531   LineTo(hDC, point.x, point.y + w);
    532532   DeleteObject( SelectObject(hDC, hPen)) ;
     
    543543 *                    CC_PrepareColorGraph                    [internal]
    544544 */
    545 static void CC_PrepareColorGraph( HWND hDlg )
     545static void CC_PrepareColorGraph( HWND hDlg )   
    546546{
    547547 int sdif, hdif, xdif, ydif, r, g, b, hue, sat;
    548548 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
    549  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     549 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    550550 HBRUSH hbrush;
    551551 HDC hdc ;
     
    590590{
    591591 HWND hwnd = GetDlgItem( hDlg, 0x2c6 );
    592  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     592 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    593593 HDC  hDC;
    594594 RECT rect;
     
    650650{
    651651 char buffer[10];
    652  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     652 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    653653 int r = GetRValue(cr);
    654654 int g = GetGValue(cr);
     
    695695{
    696696 int i;
    697  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    698 
     697 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     698 
    699699 EnableWindow( GetDlgItem(hDlg, 0x2cf), FALSE);
    700700 CC_PrepareColorGraph(hDlg);
     
    743743 for ( j = 0; j < rows; j++ )
    744744 {
    745   for ( i = 0; i < cols; i++ )
     745  for ( i = 0; i < cols; i++ ) 
    746746  {
    747747   hBrush = CreateSolidBrush(predefcolors[j][i]);
     
    764764/***********************************************************************
    765765 *                             CC_PaintUserColorArray         [internal]
    766  *               Paint the 16 user-selected colors
     766 *               Paint the 16 user-selected colors 
    767767 */
    768768static void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, COLORREF* lpcr )
     
    782782
    783783 hdc = GetDC(hwnd);
    784  if (hdc)
     784 if (hdc) 
    785785 {
    786786  FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND) );
     
    791791    hBrush = CreateSolidBrush(lpcr[i+j*cols]);
    792792    if (hBrush)
    793     {
     793    { 
    794794     hBrush = SelectObject(hdc, hBrush) ;
    795795     Rectangle(hdc, rect.left, rect.top,
     
    826826 *                              CC_WMInitDialog                  [internal]
    827827 */
    828 static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 )
     828static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ) 
    829829{
    830830   int i, res;
     
    833833   RECT rect;
    834834   POINT point;
    835    LCCPRIV lpp;
    836 
     835   LCCPRIV lpp; 
     836   
    837837   TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
    838838   lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
     
    851851       }
    852852       ch32->lStructSize = sizeof(CHOOSECOLORW);
    853        ch32->hwndOwner = ch16->hwndOwner;
     853       ch32->hwndOwner = ch16->hwndOwner; 
    854854       ch32->hInstance = ch16->hInstance;
    855855       ch32->lpCustColors = PTR_SEG_TO_LIN(ch16->lpCustColors);
     
    866866      return FALSE;
    867867   }
    868    SetWindowLongA(hDlg, DWL_USER, (LONG)lpp);
     868   SetWindowLongA(hDlg, DWL_USER, (LONG)lpp); 
    869869
    870870   if (!(lpp->lpcc->Flags & CC_SHOWHELP))
     
    876876   if (lpp->lpcc->Flags & CC_RGBINIT)
    877877   {
    878      for (i = 0; i < 6; i++)
     878     for (i = 0; i < 6; i++) 
    879879       for (j = 0; j < 8; j++)
    880880        if (predefcolors[i][j] == lpp->lpcc->rgbResult)
     
    930930          res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
    931931   }
    932 
     932   
    933933   /* Set the initial values of the color chooser dialog */
    934934   r = GetRValue(lpp->lpcc->rgbResult);
     
    959959 *                              CC_WMCommand                  [internal]
    960960 */
    961 static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl )
     961static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) 
    962962{
    963963    int  r, g, b, i, xx;
     
    965965    HDC hdc;
    966966    COLORREF *cr;
    967     LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     967    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    968968    TRACE("CC_WMCommand wParam=%x lParam=%lx\n", wParam, lParam);
    969969    switch (wParam)
    970970    {
    971971          case 0x2c2:  /* edit notify RGB */
    972       case 0x2c3:
    973       case 0x2c4:
    974            if (notifyCode == EN_UPDATE && !lpp->updating)
    975             {
    976                i = CC_CheckDigitsInEdit(hwndCtl, 255);
    977                r = GetRValue(lpp->lpcc->rgbResult);
    978                g = GetGValue(lpp->lpcc->rgbResult);
    979                b= GetBValue(lpp->lpcc->rgbResult);
    980                xx = 0;
    981                switch (wParam)
    982                {
    983                 case 0x2c2: if ((xx = (i != r))) r = i; break;
    984                 case 0x2c3: if ((xx = (i != g))) g = i; break;
    985                 case 0x2c4: if ((xx = (i != b))) b = i; break;
    986                }
    987                if (xx) /* something has changed */
    988                {
    989                 lpp->lpcc->rgbResult = RGB(r, g, b);
    990                 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
    991                 lpp->h = CC_RGBtoHSL('H', r, g, b);
    992                 lpp->s = CC_RGBtoHSL('S', r, g, b);
    993                 lpp->l = CC_RGBtoHSL('L', r, g, b);
    994                 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
    995                 CC_PaintCross(hDlg, lpp->h, lpp->s);
    996                 CC_PaintTriangle(hDlg, lpp->l);
    997                }
    998             }
    999         break;
    1000 
    1001       case 0x2bf:  /* edit notify HSL */
    1002       case 0x2c0:
    1003       case 0x2c1:
    1004            if (notifyCode == EN_UPDATE && !lpp->updating)
    1005             {
    1006                i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
    1007                xx = 0;
    1008                switch (wParam)
    1009                {
    1010                 case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
    1011                 case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
    1012                 case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
    1013                }
    1014                if (xx) /* something has changed */
    1015                {
    1016                 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
    1017                 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
    1018                 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
    1019                 lpp->lpcc->rgbResult = RGB(r, g, b);
    1020                 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
    1021                 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
    1022                 CC_PaintCross(hDlg, lpp->h, lpp->s);
    1023                 CC_PaintTriangle(hDlg, lpp->l);
    1024                }
    1025             }
    1026            break;
    1027 
     972          case 0x2c3:
     973          case 0x2c4:
     974               if (notifyCode == EN_UPDATE && !lpp->updating)
     975                        {
     976                           i = CC_CheckDigitsInEdit(hwndCtl, 255);
     977                           r = GetRValue(lpp->lpcc->rgbResult);
     978                           g = GetGValue(lpp->lpcc->rgbResult);
     979                           b= GetBValue(lpp->lpcc->rgbResult);
     980                           xx = 0;
     981                           switch (wParam)
     982                           {
     983                            case 0x2c2: if ((xx = (i != r))) r = i; break;
     984                            case 0x2c3: if ((xx = (i != g))) g = i; break;
     985                            case 0x2c4: if ((xx = (i != b))) b = i; break;
     986                           }
     987                           if (xx) /* something has changed */
     988                           {
     989                            lpp->lpcc->rgbResult = RGB(r, g, b);
     990                            CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     991                            lpp->h = CC_RGBtoHSL('H', r, g, b);
     992                            lpp->s = CC_RGBtoHSL('S', r, g, b);
     993                            lpp->l = CC_RGBtoHSL('L', r, g, b);
     994                            CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
     995                            CC_PaintCross(hDlg, lpp->h, lpp->s);
     996                            CC_PaintTriangle(hDlg, lpp->l);
     997                           }
     998                        }
     999                break;
     1000                 
     1001          case 0x2bf:  /* edit notify HSL */
     1002          case 0x2c0:
     1003          case 0x2c1:
     1004               if (notifyCode == EN_UPDATE && !lpp->updating)
     1005                        {
     1006                           i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
     1007                           xx = 0;
     1008                           switch (wParam)
     1009                           {
     1010                            case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
     1011                            case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
     1012                            case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
     1013                           }
     1014                           if (xx) /* something has changed */
     1015                           {
     1016                            r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
     1017                            g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
     1018                            b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
     1019                            lpp->lpcc->rgbResult = RGB(r, g, b);
     1020                            CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     1021                            CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
     1022                            CC_PaintCross(hDlg, lpp->h, lpp->s);
     1023                            CC_PaintTriangle(hDlg, lpp->l);
     1024                           }
     1025                        }
     1026               break;
     1027               
    10281028          case 0x2cf:
    10291029               CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, &lpp->fullsize);
    1030            SetFocus( GetDlgItem(hDlg, 0x2bf));
    1031            break;
     1030               SetFocus( GetDlgItem(hDlg, 0x2bf));
     1031               break;
    10321032
    10331033          case 0x2c8:    /* add colors ... column by column */
     
    10351035               cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult;
    10361036               if (++lpp->nextuserdef == 16)
    1037            lpp->nextuserdef = 0;
    1038            CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
    1039            break;
     1037                   lpp->nextuserdef = 0;
     1038               CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
     1039               break;
    10401040
    10411041          case 0x2c9:              /* resulting color */
    1042            hdc = GetDC(hDlg);
    1043            lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
    1044            ReleaseDC(hDlg, hdc);
    1045            CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
    1046            CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
    1047            r = GetRValue(lpp->lpcc->rgbResult);
    1048            g = GetGValue(lpp->lpcc->rgbResult);
    1049            b = GetBValue(lpp->lpcc->rgbResult);
    1050            lpp->h = CC_RGBtoHSL('H', r, g, b);
    1051            lpp->s = CC_RGBtoHSL('S', r, g, b);
    1052            lpp->l = CC_RGBtoHSL('L', r, g, b);
    1053            CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
    1054            CC_PaintCross(hDlg, lpp->h, lpp->s);
    1055            CC_PaintTriangle(hDlg, lpp->l);
    1056            break;
    1057 
    1058       case 0x40e:           /* Help! */ /* The Beatles, 1965  ;-) */
    1059            i = RegisterWindowMessageA(HELPMSGSTRINGA);
     1042               hdc = GetDC(hDlg);
     1043               lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
     1044               ReleaseDC(hDlg, hdc);
     1045               CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
     1046               CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     1047               r = GetRValue(lpp->lpcc->rgbResult);
     1048               g = GetGValue(lpp->lpcc->rgbResult);
     1049               b = GetBValue(lpp->lpcc->rgbResult);
     1050               lpp->h = CC_RGBtoHSL('H', r, g, b);
     1051               lpp->s = CC_RGBtoHSL('S', r, g, b);
     1052               lpp->l = CC_RGBtoHSL('L', r, g, b);
     1053               CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
     1054               CC_PaintCross(hDlg, lpp->h, lpp->s);
     1055               CC_PaintTriangle(hDlg, lpp->l);
     1056               break;
     1057
     1058          case 0x40e:           /* Help! */ /* The Beatles, 1965  ;-) */
     1059               i = RegisterWindowMessageA(HELPMSGSTRINGA);
    10601060#ifndef __WIN32OS2__
    10611061               if (lpp->lpcc16)
    10621062               {
    10631063                   if (lpp->lpcc->hwndOwner)
    1064                SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
     1064                       SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
    10651065                   if ( CC_HookCallChk(lpp->lpcc))
    1066                CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,
    1067                   WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);
     1066                       CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,
     1067                          WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);
    10681068               }
    10691069               else
     
    10711071#endif //!__WIN32OS2__
    10721072                   if (lpp->lpcc->hwndOwner)
    1073                SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
     1073                       SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
    10741074                   if ( CC_HookCallChk(lpp->lpcc))
    1075                CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
    1076                   WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
     1075                       CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
     1076                          WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
    10771077#ifndef __WIN32OS2__
    10781078               }
    10791079#endif //!__WIN32OS2__
    1080            break;
     1080               break;
    10811081
    10821082          case IDOK :
    1083         cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
     1083                cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
    10841084#ifndef __WIN32OS2__
    10851085                if (lpp->lpcc16)
    10861086                {
    1087             if (lpp->lpcc->hwndOwner)
    1088             if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
    1089                break;    /* do NOT close */
     1087                    if (lpp->lpcc->hwndOwner)
     1088                        if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
     1089                           break;    /* do NOT close */
    10901090                }
    10911091                else
    10921092                {
    10931093#endif //!__WIN32OS2__
    1094             if (lpp->lpcc->hwndOwner)
    1095             if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
    1096                break;    /* do NOT close */
     1094                    if (lpp->lpcc->hwndOwner)
     1095                        if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
     1096                           break;    /* do NOT close */
    10971097#ifndef __WIN32OS2__
    10981098                }
     
    11041104                }
    11051105#endif
    1106         EndDialog(hDlg, 1) ;
    1107         return TRUE ;
    1108 
    1109       case IDCANCEL :
    1110         EndDialog(hDlg, 0) ;
    1111         return TRUE ;
     1106                EndDialog(hDlg, 1) ;
     1107                return TRUE ;
     1108       
     1109          case IDCANCEL :
     1110                EndDialog(hDlg, 0) ;
     1111                return TRUE ;
    11121112
    11131113       }
     
    11181118 *                              CC_WMPaint                    [internal]
    11191119 */
    1120 static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam )
     1120static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ) 
    11211121{
    11221122    HDC hdc;
    11231123    PAINTSTRUCT ps;
    1124     LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     1124    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    11251125
    11261126    hdc = BeginPaint(hDlg, &ps);
     
    11511151       CC_PaintCross(hDlg, lpp->h, lpp->s);
    11521152       return 1;
    1153    }
     1153   } 
    11541154   return 0;
    11551155}
     
    11591159 *                              CC_WMMouseMove              [internal]
    11601160 */
    1161 static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam )
    1162 {
    1163    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     1161static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ) 
     1162{
     1163   LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    11641164   int r, g, b;
    11651165
     
    11671167   {
    11681168      int *ptrh = NULL, *ptrs = &lpp->l;
    1169       if (lpp->capturedGraph == 0x2c6)
     1169      if (lpp->capturedGraph == 0x2c6) 
    11701170      {
    11711171          ptrh = &lpp->h;
     
    11961196 *                              CC_WMLButtonDown              [internal]
    11971197 */
    1198 static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam )
    1199 {
    1200    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     1198static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ) 
     1199{
     1200   LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    12011201   int r, g, b, i;
    12021202   i = 0;
     
    12081208         i = 1;
    12091209      else
    1210     if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
     1210        if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
    12111211         {
    1212         i = 2;
     1212            i = 2;
    12131213            lpp->capturedGraph = 0x2c6;
    12141214         }
    1215     else
    1216         if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
     1215        else
     1216            if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
    12171217            {
    1218            i = 2;
     1218               i = 2;
    12191219               lpp->capturedGraph = 0x2be;
    12201220            }
     
    12761276
    12771277 switch (message)
    1278     {
    1279       case WM_INITDIALOG:
    1280                     return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
    1281       case WM_NCDESTROY:
    1282                     DeleteDC(lpp->hdcMem);
    1283                     DeleteObject(lpp->hbmMem);
     1278        {
     1279          case WM_INITDIALOG:
     1280                        return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
     1281          case WM_NCDESTROY:
     1282                        DeleteDC(lpp->hdcMem);
     1283                        DeleteObject(lpp->hbmMem);
    12841284                        HeapFree(GetProcessHeap(), 0, lpp);
    1285                     SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
    1286                     break;
    1287       case WM_COMMAND:
    1288                     if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
    1289                        return TRUE;
    1290                     break;
    1291       case WM_PAINT:
    1292                     if ( CC_WMPaint(hDlg, wParam, lParam))
    1293                        return TRUE;
    1294                     break;
    1295       case WM_LBUTTONDBLCLK:
    1296                     if (CC_MouseCheckResultWindow(hDlg, lParam))
    1297               return TRUE;
    1298             break;
    1299       case WM_MOUSEMOVE:
    1300                     if (CC_WMMouseMove(hDlg, lParam))
    1301               return TRUE;
    1302             break;
    1303       case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
     1285                        SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
     1286                        break;
     1287          case WM_COMMAND:
     1288                        if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
     1289                           return TRUE;
     1290                        break;     
     1291          case WM_PAINT:
     1292                        if ( CC_WMPaint(hDlg, wParam, lParam))
     1293                           return TRUE;
     1294                        break;
     1295          case WM_LBUTTONDBLCLK:
     1296                        if (CC_MouseCheckResultWindow(hDlg, lParam))
     1297                          return TRUE;
     1298                        break;
     1299          case WM_MOUSEMOVE:
     1300                        if (CC_WMMouseMove(hDlg, lParam))
     1301                          return TRUE;
     1302                        break;
     1303          case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
    13041304                        if (CC_WMLButtonUp(hDlg, wParam, lParam))
    13051305                           return TRUE;
    1306             break;
    1307       case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
    1308                     if (CC_WMLButtonDown(hDlg, wParam, lParam))
    1309                        return TRUE;
    1310                     break;
    1311     }
     1306                        break;
     1307          case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
     1308                        if (CC_WMLButtonDown(hDlg, wParam, lParam))
     1309                           return TRUE;
     1310                        break;     
     1311        }
    13121312     return FALSE ;
    13131313}
     
    13211321{
    13221322 int res;
    1323  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     1323 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    13241324 if (message != WM_INITDIALOG)
    13251325 {
     
    13391339
    13401340 switch (message)
    1341     {
    1342       case WM_INITDIALOG:
    1343                     return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
    1344       case WM_NCDESTROY:
    1345                     DeleteDC(lpp->hdcMem);
    1346                     DeleteObject(lpp->hbmMem);
     1341        {
     1342          case WM_INITDIALOG:
     1343                        return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
     1344          case WM_NCDESTROY:
     1345                        DeleteDC(lpp->hdcMem);
     1346                        DeleteObject(lpp->hbmMem);
    13471347                        HeapFree(GetProcessHeap(), 0, lpp->lpcc);
    13481348                        HeapFree(GetProcessHeap(), 0, lpp);
    1349                     SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
    1350                     break;
    1351       case WM_COMMAND:
    1352                     if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam)))
    1353                        return TRUE;
    1354                     break;
    1355       case WM_PAINT:
    1356                     if (CC_WMPaint(hDlg, wParam, lParam))
    1357                        return TRUE;
    1358                     break;
    1359       case WM_LBUTTONDBLCLK:
    1360                     if (CC_MouseCheckResultWindow(hDlg,lParam))
    1361               return TRUE;
    1362             break;
    1363       case WM_MOUSEMOVE:
    1364                     if (CC_WMMouseMove(hDlg, lParam))
    1365               return TRUE;
    1366             break;
    1367       case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
     1349                        SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
     1350                        break;
     1351          case WM_COMMAND:
     1352                        if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam)))
     1353                           return TRUE;
     1354                        break;     
     1355          case WM_PAINT:
     1356                        if (CC_WMPaint(hDlg, wParam, lParam))
     1357                           return TRUE;
     1358                        break;
     1359          case WM_LBUTTONDBLCLK:
     1360                        if (CC_MouseCheckResultWindow(hDlg,lParam))
     1361                          return TRUE;
     1362                        break;
     1363          case WM_MOUSEMOVE:
     1364                        if (CC_WMMouseMove(hDlg, lParam))
     1365                          return TRUE;
     1366                        break;
     1367          case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
    13681368                        if (CC_WMLButtonUp(hDlg, wParam, lParam))
    13691369                           return TRUE;
    1370             break;
    1371       case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
    1372                     if (CC_WMLButtonDown(hDlg, wParam, lParam))
    1373                        return TRUE;
    1374                     break;
    1375     }
     1370                        break;
     1371          case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
     1372                        if (CC_WMLButtonDown(hDlg, wParam, lParam))
     1373                           return TRUE;
     1374                        break;     
     1375        }
    13761376     return FALSE ;
    13771377}
     
    13901390    LPCVOID template;
    13911391    FARPROC16 ptr;
    1392 
     1392 
    13931393    TRACE("ChooseColor\n");
    1394     if (!lpChCol) return FALSE;
     1394    if (!lpChCol) return FALSE;   
    13951395
    13961396    if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
     
    14151415    else
    14161416    {
    1417     HANDLE hResInfo, hDlgTmpl32;
     1417        HANDLE hResInfo, hDlgTmpl32;
    14181418        LPCVOID template32;
    14191419        DWORD size;
    1420     if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
    1421     {
    1422         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    1423         return FALSE;
    1424     }
    1425     if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
    1426         !(template32 = LockResource(hDlgTmpl32)))
    1427     {
    1428         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1429         return FALSE;
    1430     }
     1420        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
     1421        {
     1422            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     1423            return FALSE;
     1424        }
     1425        if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
     1426            !(template32 = LockResource(hDlgTmpl32)))
     1427        {
     1428            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1429            return FALSE;
     1430        }
    14311431        size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
    14321432        hGlobal16 = GlobalAlloc16(0, size);
     
    14381438        }
    14391439        template = GlobalLock16(hGlobal16);
    1440         if (!template)
     1440        if (!template) 
    14411441        {
    14421442            COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
     
    14751475
    14761476    TRACE("ChooseColor\n");
    1477     if (!lpChCol) return FALSE;
     1477    if (!lpChCol) return FALSE;   
    14781478
    14791479    if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
     
    15041504    else
    15051505    {
    1506     HANDLE hResInfo, hDlgTmpl;
    1507     if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
    1508     {
    1509         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    1510         return FALSE;
    1511     }
    1512     if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
    1513         !(template = LockResource(hDlgTmpl)))
    1514     {
    1515         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1516         return FALSE;
    1517     }
     1506        HANDLE hResInfo, hDlgTmpl;
     1507        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
     1508        {
     1509            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     1510            return FALSE;
     1511        }
     1512        if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
     1513            !(template = LockResource(hDlgTmpl)))
     1514        {
     1515            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1516            return FALSE;
     1517        }
    15181518    }
    15191519
     
    15411541  if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
    15421542      if (HIWORD(lpChCol->lpTemplateName))
    1543       lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);
     1543          lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);
    15441544      else
    1545       lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
     1545          lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
    15461546  }
    15471547
  • trunk/src/comdlg32/filedlg.c

    r6708 r6709  
    2828#define GlobalLock16 GlobalLock
    2929#define GlobalUnlock16 GlobalUnlock
    30 #define GlobalAlloc16   GlobalAlloc
    31 #define FreeResource16  FreeResource
     30#define GlobalAlloc16   GlobalAlloc
     31#define FreeResource16  FreeResource
    3232#define LoadResource16  LoadResourceA
    3333#define FindResource16  FindResourceA
    34 #define MapSL(a)    a
     34#define MapSL(a)        a
    3535#define CallWindowProc16 CallWindowProcA
    3636
     
    4242
    4343#define BUFFILE 512
    44 #define BUFFILEALLOC 512 * sizeof(WCHAR)
    45 
    46 struct FSPRIVATE
     44#define BUFFILEALLOC 512 * sizeof(WCHAR)   
     45
     46struct FSPRIVATE 
    4747{
    4848    HWND hwnd; /* file dialog window handle */
     
    7575#define LFS32A 2
    7676#define LFS32W 3
    77 
     77 
    7878static const WCHAR FILE_star[] = {'*','.','*', 0};
    7979static const WCHAR FILE_bslash[] = {'\\', 0};
     
    111111
    112112LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    113                 LPARAM lParam);
     113                                LPARAM lParam);
    114114LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    115                 LPARAM lParam);
     115                                LPARAM lParam);
    116116
    117117static LRESULT WINAPI FileOpenDlgProc(HWND hDlg, UINT msg,
     
    119119
    120120/***********************************************************************
    121  *              FileDlg_Init            [internal]
     121 *                              FileDlg_Init                    [internal]
    122122 */
    123123static BOOL FileDlg_Init(void)
     
    125125    static BOOL initialized = 0;
    126126    CURSORICONINFO *fldrInfo;
    127 
     127   
    128128    if (!initialized) {
    129129#ifdef __WIN32OS2__
    130     if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED);
    131     if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED);
    132     if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED);
    133     if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED);
    134     if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED);
    135     if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED);
     130        if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED);
     131        if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED);
     132        if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED);
     133        if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED);
     134        if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED);
     135        if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED);
    136136#else
    137137        HINSTANCE inst = GetModuleHandleA( "comdlg32.dll" );
     
    148148        hNet     = LoadImageA( inst, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED );
    149149#endif
    150     if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
    151         hHDisk == 0 || hCDRom == 0 || hNet == 0)
    152     {
    153         ERR("Error loading icons !\n");
    154         return FALSE;
    155     }
     150        if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
     151            hHDisk == 0 || hCDRom == 0 || hNet == 0)
     152        {
     153            ERR("Error loading icons !\n");
     154            return FALSE;
     155        }
    156156#ifdef __WIN32OS2__
    157     fldrHeight = 16;
    158     fldrWidth = 16;
     157        fldrHeight = 16;
     158        fldrWidth = 16;
    159159#else
    160     fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
    161     if (!fldrInfo)
    162     {
    163         ERR("Error measuring icons !\n");
    164         return FALSE;
    165     }
    166     fldrHeight = fldrInfo -> nHeight;
    167     fldrWidth = fldrInfo -> nWidth;
    168     GlobalUnlock16( hFolder2 );
    169 #endif
    170     initialized = TRUE;
     160        fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
     161        if (!fldrInfo)
     162        {       
     163            ERR("Error measuring icons !\n");
     164            return FALSE;
     165        }
     166        fldrHeight = fldrInfo -> nHeight;
     167        fldrWidth = fldrInfo -> nWidth;
     168        GlobalUnlock16( hFolder2 );
     169#endif
     170        initialized = TRUE;
    171171    }
    172172    return TRUE;
     
    188188    if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
    189189    {
    190     if (!(lfs->template = LockResource( ofnW->hInstance )))
    191     {
    192         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    193         return FALSE;
    194     }
     190        if (!(lfs->template = LockResource( ofnW->hInstance )))
     191        {
     192            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     193            return FALSE;
     194        }
    195195    }
    196196    else if (ofnW->Flags & OFN_ENABLETEMPLATE)
    197197    {
    198     HANDLE hResInfo;
     198        HANDLE hResInfo;
    199199        if (lfs->ofnA)
    200         hResInfo = FindResourceA(lfs->ofnA->hInstance,
    201                 lfs->ofnA->lpTemplateName,
     200            hResInfo = FindResourceA(lfs->ofnA->hInstance,
     201                                lfs->ofnA->lpTemplateName,
    202202                                 RT_DIALOGA);
    203203        else
    204         hResInfo = FindResourceW(ofnW->hInstance,
    205                 ofnW->lpTemplateName,
     204            hResInfo = FindResourceW(ofnW->hInstance,
     205                                ofnW->lpTemplateName,
    206206                                 RT_DIALOGW);
    207207        if (!hResInfo)
    208     {
    209         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    210         return FALSE;
    211     }
    212     if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
    213                 hResInfo)) ||
    214             !(lfs->template = LockResource(hDlgTmpl)))
    215     {
    216         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    217         return FALSE;
    218     }
     208        {
     209            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     210            return FALSE;
     211        }
     212        if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
     213                                hResInfo)) ||
     214                    !(lfs->template = LockResource(hDlgTmpl)))
     215        {
     216            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     217            return FALSE;
     218        }
    219219    } else { /* get it from internal Wine resource */
    220     HANDLE hResInfo;
    221     if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
     220        HANDLE hResInfo;
     221        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    222222             lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
    223     {
    224         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    225         return FALSE;
     223        {
     224            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     225            return FALSE;
    226226        }
    227227        if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
     
    253253    else if (ofn16->Flags & OFN_ENABLETEMPLATE)
    254254    {
    255     HANDLE16 hResInfo;
    256     if (!(hResInfo = FindResource16(ofn16->hInstance,
    257                     MapSL(ofn16->lpTemplateName),
     255        HANDLE16 hResInfo;
     256        if (!(hResInfo = FindResource16(ofn16->hInstance,
     257                                        MapSL(ofn16->lpTemplateName),
    258258                                        RT_DIALOGA)))
    259     {
    260         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    261         return FALSE;
    262     }
    263     if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
    264     {
    265         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    266         return FALSE;
    267     }
     259        {
     260            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     261            return FALSE;
     262        }
     263        if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
     264        {
     265            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     266            return FALSE;
     267        }
    268268        lfs->hResource16 = lfs->hDlgTmpl16;
    269269    }
    270270    else
    271271    { /* get resource from (32 bits) own Wine resource; convert it to 16 */
    272     HANDLE hResInfo, hDlgTmpl32;
     272        HANDLE hResInfo, hDlgTmpl32;
    273273        LPCVOID template32;
    274274        DWORD size;
    275275
    276     if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
     276        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    277277               lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
    278     {
    279         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    280         return FALSE;
    281     }
    282     if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
    283         !(template32 = LockResource( hDlgTmpl32 )))
    284     {
    285         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    286         return FALSE;
    287     }
     278        {
     279            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     280            return FALSE;
     281        }
     282        if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
     283            !(template32 = LockResource( hDlgTmpl32 )))
     284        {
     285            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     286            return FALSE;
     287        }
    288288        size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
    289289        hGlobal16 = GlobalAlloc16(0, size);
     
    321321    cp = strrchrW(temp, '\\');
    322322    if (cp != NULL) {
    323     strcpyW(temp, cp+1);
     323        strcpyW(temp, cp+1);
    324324    }
    325325    cp = strrchrW(temp, ':');
    326326    if (cp != NULL) {
    327     strcpyW(temp, cp+1);
     327        strcpyW(temp, cp+1);
    328328    }
    329329    /* FIXME: shouldn't we do something with the result here? ;-) */
     
    366366
    367367/***********************************************************************
    368  *              FILEDLG_ScanDir                 [internal]
     368 *                              FILEDLG_ScanDir                 [internal]
    369369 */
    370370static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
    371371{
    372     WCHAR       buffer[BUFFILE];
    373     HWND        hdlg, hdlgDir;
     372    WCHAR               buffer[BUFFILE];
     373    HWND                hdlg, hdlgDir;
    374374    LRESULT             lRet = TRUE;
    375375    HCURSOR             hCursorWait, oldCursor;
     
    387387    /* list of files */
    388388    if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) {
    389         WCHAR*  scptr; /* ptr on semi-colon */
    390     WCHAR*  filter = buffer;
    391 
    392     TRACE("Using filter %s\n", debugstr_w(filter));
    393     SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
    394     while (filter) {
    395         scptr = strchrW(filter, ';');
    396         if (scptr)  *scptr = 0;
     389        WCHAR*  scptr; /* ptr on semi-colon */
     390        WCHAR*  filter = buffer;
     391
     392        TRACE("Using filter %s\n", debugstr_w(filter));
     393        SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
     394        while (filter) {
     395            scptr = strchrW(filter, ';');
     396            if (scptr)  *scptr = 0;
    397397            while (*filter == ' ') filter++;
    398         TRACE("Using file spec %s\n", debugstr_w(filter));
    399         if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
    400             return FALSE;
    401         if (scptr) *scptr = ';';
    402             filter = (scptr) ? (scptr + 1) : 0;
    403     }
     398            TRACE("Using file spec %s\n", debugstr_w(filter));
     399            if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
     400                return FALSE;
     401            if (scptr) *scptr = ';';
     402                filter = (scptr) ? (scptr + 1) : 0;
     403        }
    404404    }
    405405
     
    416416
    417417/***********************************************************************
    418  *              FILEDLG_GetFileType     [internal]
     418 *                              FILEDLG_GetFileType             [internal]
    419419 */
    420420
     
    424424  i = 0;
    425425  if (cfptr)
    426     for ( ;(n = lstrlenW(cfptr)) != 0; i++)
     426    for ( ;(n = lstrlenW(cfptr)) != 0; i++) 
    427427      {
    428     cfptr += n + 1;
    429     if (i == index)
    430       return cfptr;
    431     cfptr += lstrlenW(cfptr) + 1;
     428        cfptr += n + 1;
     429        if (i == index)
     430          return cfptr;
     431        cfptr += lstrlenW(cfptr) + 1;
    432432      }
    433433  if (fptr)
    434     for ( ;(n = lstrlenW(fptr)) != 0; i++)
     434    for ( ;(n = lstrlenW(fptr)) != 0; i++) 
    435435      {
    436     fptr += n + 1;
    437     if (i == index)
    438       return fptr;
    439     fptr += lstrlenW(fptr) + 1;
     436        fptr += n + 1;
     437        if (i == index)
     438          return fptr;
     439        fptr += lstrlenW(fptr) + 1;
    440440    }
    441441  return (LPWSTR) FILE_star; /* FIXME */
     
    455455    {
    456456        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE;
    457     SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
     457        SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
    458458                      (LPARAM)str);
    459459
    460     if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
    461     {
    462         oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
    463         oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    464     }
    465     if (savedlg)
    466         SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
    467 
    468     ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
     460        if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
     461        {
     462            oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
     463            oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     464        }
     465        if (savedlg)
     466            SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
     467
     468        ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
    469469                  lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
    470470                  &(lpdis->rcItem), str, lstrlenW(str), NULL);
    471471
    472     if (lpdis->itemState & ODS_SELECTED)
    473         DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
    474 
    475     if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
    476     {
    477         SetBkColor( lpdis->hDC, oldBk );
    478         SetTextColor( lpdis->hDC, oldText );
    479     }
     472        if (lpdis->itemState & ODS_SELECTED)
     473            DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
     474
     475        if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
     476        {
     477            SetBkColor( lpdis->hDC, oldBk );
     478            SetTextColor( lpdis->hDC, oldText );
     479        }
    480480        HeapFree(GetProcessHeap(), 0, str);
    481     return TRUE;
     481        return TRUE;
    482482    }
    483483
     
    486486        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
    487487            return FALSE;
    488     SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
     488        SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
    489489                      (LPARAM)str);
    490490
    491     if (lpdis->itemState & ODS_SELECTED)
    492     {
    493         oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
    494         oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    495     }
    496     ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
     491        if (lpdis->itemState & ODS_SELECTED)
     492        {
     493            oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
     494            oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     495        }
     496        ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
    497497                  lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
    498498                  &(lpdis->rcItem), str, lstrlenW(str), NULL);
    499499
    500     if (lpdis->itemState & ODS_SELECTED)
    501         DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
    502 
    503     if (lpdis->itemState & ODS_SELECTED)
    504     {
    505         SetBkColor( lpdis->hDC, oldBk );
    506         SetTextColor( lpdis->hDC, oldText );
    507     }
    508     DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
     500        if (lpdis->itemState & ODS_SELECTED)
     501            DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
     502
     503        if (lpdis->itemState & ODS_SELECTED)
     504        {
     505            SetBkColor( lpdis->hDC, oldBk );
     506            SetTextColor( lpdis->hDC, oldText );
     507        }
     508        DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
    509509        HeapFree(GetProcessHeap(), 0, str);
    510     return TRUE;
     510        return TRUE;
    511511    }
    512512    if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
     
    515515        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
    516516            return FALSE;
    517     SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
     517        SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
    518518                      (LPARAM)str);
    519519        root[0] += str[2] - 'a';
     
    526526        default:           hIcon = hHDisk; break;
    527527        }
    528     if (lpdis->itemState & ODS_SELECTED)
    529     {
    530         oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
    531         oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    532     }
    533     ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
     528        if (lpdis->itemState & ODS_SELECTED)
     529        {
     530            oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
     531            oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     532        }
     533        ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
    534534                  lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
    535535                  &(lpdis->rcItem), str, lstrlenW(str), NULL);
    536536
    537     if (lpdis->itemState & ODS_SELECTED)
    538     {
    539         SetBkColor( lpdis->hDC, oldBk );
    540         SetTextColor( lpdis->hDC, oldText );
    541     }
    542     DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
     537        if (lpdis->itemState & ODS_SELECTED)
     538        {
     539            SetBkColor( lpdis->hDC, oldBk );
     540            SetTextColor( lpdis->hDC, oldText );
     541        }
     542        DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
    543543        HeapFree(GetProcessHeap(), 0, str);
    544     return TRUE;
     544        return TRUE;
    545545    }
    546546    return FALSE;
     
    550550 *                              FILEDLG_WMMeasureItem           [internal]
    551551 */
    552 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
     552static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 
    553553{
    554554    LPMEASUREITEMSTRUCT lpmeasure;
    555 
     555   
    556556    lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
    557557    lpmeasure->itemHeight = fldrHeight;
     
    562562 */
    563563#ifdef __WIN32OS2__
    564 static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam)
     564static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam) 
    565565{
    566566    LPMEASUREITEMSTRUCT lpmeasure;
    567 
     567   
    568568    lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
    569569    lpmeasure->itemHeight = fldrHeight;
     
    571571}
    572572#else
    573 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
     573static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
    574574{
    575575    LPMEASUREITEMSTRUCT16 lpmeasure;
    576 
     576   
    577577    lpmeasure = MapSL(lParam);
    578578    lpmeasure->itemHeight = fldrHeight;
     
    608608      TRACE("lpstrCustomFilter = %p\n", pstr);
    609609      while(*pstr)
    610     {
    611       old_pstr = pstr;
     610        {
     611          old_pstr = pstr;
    612612          i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
    613613                                   (LPARAM)(ofn->lpstrCustomFilter) + n );
    614614          n += lstrlenW(pstr) + 1;
    615       pstr += lstrlenW(pstr) + 1;
    616       TRACE("add str='%s' "
    617       "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
     615          pstr += lstrlenW(pstr) + 1;
     616          TRACE("add str='%s' "
     617          "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
    618618          SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
    619619          n += lstrlenW(pstr) + 1;
    620       pstr += lstrlenW(pstr) + 1;
    621     }
     620          pstr += lstrlenW(pstr) + 1;
     621        }
    622622    }
    623623  /* read filter information */
    624624  if (ofn->lpstrFilter) {
    625     pstr = (LPWSTR) ofn->lpstrFilter;
    626     n = 0;
    627     while(*pstr) {
    628       old_pstr = pstr;
    629       i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
    630                        (LPARAM)(ofn->lpstrFilter + n) );
    631       n += lstrlenW(pstr) + 1;
    632       pstr += lstrlenW(pstr) + 1;
    633       TRACE("add str='%s' "
    634           "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
    635       SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
    636       n += lstrlenW(pstr) + 1;
    637       pstr += lstrlenW(pstr) + 1;
    638     }
     625        pstr = (LPWSTR) ofn->lpstrFilter;
     626        n = 0;
     627        while(*pstr) {
     628          old_pstr = pstr;
     629          i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
     630                                       (LPARAM)(ofn->lpstrFilter + n) );
     631          n += lstrlenW(pstr) + 1;
     632          pstr += lstrlenW(pstr) + 1;
     633          TRACE("add str='%s' "
     634                  "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
     635          SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
     636          n += lstrlenW(pstr) + 1;
     637          pstr += lstrlenW(pstr) + 1;
     638        }
    639639  }
    640640  /* set default filter */
    641641  if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
    642     ofn->nFilterIndex = 1;
    643   SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
     642        ofn->nFilterIndex = 1;
     643  SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);   
    644644  lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
    645          (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
    646   TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n",
    647             ofn->nFilterIndex, debugstr_w(tmpstr));
     645             (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
     646  TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n", 
     647                        ofn->nFilterIndex, debugstr_w(tmpstr));
    648648  SetDlgItemTextW( hWnd, edt1, tmpstr );
    649649  /* get drive list */
     
    651651  DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
    652652  /* read initial directory */
    653   if (ofn->lpstrInitialDir != NULL)
     653  if (ofn->lpstrInitialDir != NULL) 
    654654    {
    655655      int len;
     
    690690      {
    691691          str[0] = 'a' + i;
    692           if(drives & (1 << i)) n++;
     692          if(drives & (1 << i)) n++;
    693693
    694694          if (toupper(str[0]) == toupper(dir[0])) break;
     
    720720/***********************************************************************
    721721 *                              FILEDLG_UpdateResult            [internal]
    722  *      update the displayed file name (with path)
     722 *      update the displayed file name (with path) 
    723723 */
    724724void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr)
     
    747747    if (lfs->ofn16)
    748748    { /* we have to convert to short (8.3) path */
    749     char tmp[1024]; /* MAX_PATHNAME_LEN */
    750     LPOPENFILENAME16 ofn16 = lfs->ofn16;
     749        char tmp[1024]; /* MAX_PATHNAME_LEN */
     750        LPOPENFILENAME16 ofn16 = lfs->ofn16;
    751751        char *dest = MapSL(ofn16->lpstrFile);
    752752        if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
    753753                                  tmp, ofnW->nMaxFile, NULL, NULL ))
    754754            tmp[ofnW->nMaxFile-1] = 0;
    755     GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
    756 
    757     /* the same procedure as every year... */
     755        GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
     756
     757        /* the same procedure as every year... */
    758758        ofn16->nFileOffset = strrchr(dest,'\\') - dest +1;
    759759        ofn16->nFileExtension = 0;
     
    779779/***********************************************************************
    780780 *                              FILEDLG_UpdateFileTitle         [internal]
    781  *      update the displayed file name (without path)
     781 *      update the displayed file name (without path) 
    782782 */
    783783void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs)
     
    785785  LONG lRet;
    786786  LPOPENFILENAMEW ofnW = lfs->ofnW;
    787   if (ofnW->lpstrFileTitle != NULL)
     787  if (ofnW->lpstrFileTitle != NULL) 
    788788  {
    789789    lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
     
    825825  pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
    826826  SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
    827              (LPARAM)pstr);
     827                     (LPARAM)pstr);
    828828  strcpyW( tmpstr, pstr );
    829829  HeapFree(GetProcessHeap(), 0, pstr);
     
    897897    pBeginFileName = strrchrW(path, '\\');
    898898    if (pBeginFileName == NULL)
    899     pBeginFileName = strrchrW(path, ':');
     899        pBeginFileName = strrchrW(path, ':');
    900900
    901901    if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL)
     
    904904        if (pBeginFileName != NULL)
    905905        {
    906         lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
    907         *(pBeginFileName + 1) = 0;
    908     }
    909     else
    910     {
    911         strcpyW(tmpstr2, path);
    912         *path = 0;
     906            lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
     907            *(pBeginFileName + 1) = 0;
     908        }
     909        else
     910        {
     911            strcpyW(tmpstr2, path);
     912            *path = 0;
    913913        }
    914914
     
    997997        lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring,
    998998                  0, lfs->lParam );
    999         if (lRet)
     999        if (lRet)       
    10001000        {
    10011001            *ofnW = ofnsav; /* restore old state */
     
    10091009            LPWSTR str = (LPWSTR)ofnW->lpstrFile;
    10101010            LPWSTR ptr = strrchrW(str, '\\');
    1011         str[lstrlenW(str) + 1] = '\0';
    1012         *ptr = 0;
     1011            str[lstrlenW(str) + 1] = '\0';
     1012            *ptr = 0;
    10131013        }
    10141014    }
     
    10351035                         (LPARAM)pstr);
    10361036    wsprintfW(diskname, FILE_specc, pstr[2]);
    1037     HeapFree(GetProcessHeap(), 0, pstr);
     1037    HeapFree(GetProcessHeap(), 0, pstr);   
    10381038
    10391039    return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE );
     
    10671067 */
    10681068static LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
    1069        UINT control, LFSPRIVATE lfs )
     1069       UINT control, LFSPRIVATE lfs ) 
    10701070{
    10711071    switch (control)
     
    10901090
    10911091        case cmb1: /* file type drop list */
    1092         if (notification == CBN_SELCHANGE)
     1092        if (notification == CBN_SELCHANGE) 
    10931093            return FILEDLG_FileTypeChange( lfs );
    10941094        break;
     
    12151215    if (ofnA->lpstrTitle)
    12161216        str = ofnA->lpstrTitle;
    1217     else
     1217    else 
    12181218        /* Allocates default title (FIXME : get it from resource) */
    12191219        str = open ? defaultopen:defaultsave;
     
    12721272/************************************************************************
    12731273 *                              FILEDLG_DestroyPrivate            [internal]
    1274  *      destroys the private object
     1274 *      destroys the private object 
    12751275 */
    12761276void FILEDLG_DestroyPrivate(LFSPRIVATE lfs)
     
    13111311/************************************************************************
    13121312 *                              FILEDLG_AllocPrivate            [internal]
    1313  *      allocate a private object to hold 32 bits Unicode
     1313 *      allocate a private object to hold 32 bits Unicode 
    13141314 *      structure that will be used throughtout the calls, while
    13151315 *      keeping available the original structures and a few variables
     
    13691369                FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
    13701370        }
    1371         else
     1371        else 
    13721372            ret = NULL;
    13731373    }
     
    13901390 * Creates a win31 style dialog box for the user to select a file to open/save.
    13911391 */
    1392 BOOL WINAPI GetFileName31A(
     1392BOOL WINAPI GetFileName31A( 
    13931393                           LPOPENFILENAMEA lpofn, /* addess of structure with data*/
    13941394                           UINT dlgType /* type dialogue : open/save */
     
    14051405    {
    14061406        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    1407         bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner,
     1407        bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner, 
    14081408             (DLGPROC) FileOpenDlgProc, (DWORD) lfs);
    14091409        FILEDLG_DestroyPrivate(lfs);
     
    14201420 * Creates a win31 style dialog box for the user to select a file to open/save
    14211421 */
    1422 BOOL WINAPI GetFileName31W(
     1422BOOL WINAPI GetFileName31W( 
    14231423                           LPOPENFILENAMEW lpofn, /* addess of structure with data*/
    14241424                           UINT dlgType /* type dialogue : open/save */
     
    14351435    {
    14361436        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    1437         bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner,
     1437        bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner, 
    14381438             (DLGPROC) FileOpenDlgProc, (DWORD) lfs);
    14391439        FILEDLG_DestroyPrivate(lfs);
     
    14531453LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    14541454                               LPARAM lParam)
    1455 {
     1455{ 
    14561456    LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
    14571457    DRAWITEMSTRUCT dis;
    1458 
     1458 
    14591459    TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
    14601460    if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
    14611461        {
    14621462            LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
    1463             if (lRet)
     1463            if (lRet)   
    14641464                return lRet;         /* else continue message processing */
    14651465        }
     
    14831483         switch (HIWORD(lParam))
    14841484         {
    1485     case CTLCOLOR_BTN:
    1486          SetTextColor((HDC16)wParam, 0x00000000);
     1485        case CTLCOLOR_BTN:
     1486             SetTextColor((HDC16)wParam, 0x00000000);
    14871487             return hGRAYBrush;
    1488     case CTLCOLOR_STATIC:
     1488        case CTLCOLOR_STATIC:
    14891489             SetTextColor((HDC16)wParam, 0x00000000);
    14901490             return hGRAYBrush;
    1491     }
     1491        }
    14921492      break;
    14931493#endif
     
    15101510   LRESULT  lRet;
    15111511   lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
    1512    if (lRet)
     1512   if (lRet)   
    15131513    return lRet;         /* else continue message processing */
    1514   }
     1514  }             
    15151515  switch (wMsg) {
    15161516   case WM_INITDIALOG:
    15171517      return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
    1518 
     1518     
    15191519   case WM_MEASUREITEM:
    15201520      return FILEDLG_WMMeasureItem16(hWnd, wParam, lParam);
    1521 
     1521   
    15221522   case WM_DRAWITEM:
    15231523      FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis);
     
    15271527      return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam), wParam, lfs);
    15281528  }
    1529 
     1529 
    15301530  /*
    15311531  case WM_CTLCOLOR:
     
    15411541   }
    15421542   return FALSE;
    1543 
     1543   
    15441544   */
    15451545  return FALSE;
     
    15491549/***********************************************************************
    15501550 *           FileOpenDlgProc                                    [internal]
    1551  *      Used for open and save, in fact.
     1551 *      Used for open and save, in fact.   
    15521552 */
    15531553static LRESULT WINAPI FileOpenDlgProc(HWND hWnd, UINT wMsg,
     
    15611561            LRESULT lRet;
    15621562            lRet  = (BOOL)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
    1563             if (lRet)
     1563            if (lRet)   
    15641564                return lRet;         /* else continue message processing */
    15651565        }
     
    15821582         switch (HIWORD(lParam))
    15831583         {
    1584     case CTLCOLOR_BTN:
    1585          SetTextColor((HDC16)wParam, 0x00000000);
     1584        case CTLCOLOR_BTN:
     1585             SetTextColor((HDC16)wParam, 0x00000000);
    15861586             return hGRAYBrush;
    1587     case CTLCOLOR_STATIC:
     1587        case CTLCOLOR_STATIC:
    15881588             SetTextColor((HDC16)wParam, 0x00000000);
    15891589             return hGRAYBrush;
    1590     }
     1590        }
    15911591      break;
    15921592#endif
     
    15951595}
    15961596
    1597 /* ------------------ APIs ---------------------- */
     1597/* ------------------ APIs ---------------------- */ 
    15981598#ifndef __WIN32OS2__
    15991599/***********************************************************************
     
    16091609 *    unknown, there are some FIXME's left.
    16101610 */
    1611 BOOL16 WINAPI GetOpenFileName16(
    1612                 SEGPTR ofn /* [in/out] address of structure with data*/
    1613                 )
     1611BOOL16 WINAPI GetOpenFileName16( 
     1612                                SEGPTR ofn /* [in/out] address of structure with data*/
     1613                                )
    16141614{
    16151615    HINSTANCE hInst;
     
    16261626        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    16271627        ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6);
    1628         bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
     1628        bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 
    16291629             (DLGPROC16) ptr, (DWORD) lfs);
    16301630        FILEDLG_DestroyPrivate(lfs);
     
    16471647 *    unknown. There are some FIXME's left.
    16481648 */
    1649 BOOL16 WINAPI GetSaveFileName16(
    1650                 SEGPTR ofn /* [in/out] addess of structure with data*/
    1651                 )
     1649BOOL16 WINAPI GetSaveFileName16( 
     1650                                SEGPTR ofn /* [in/out] addess of structure with data*/
     1651                                )
    16521652{
    16531653    HINSTANCE hInst;
     
    16641664        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    16651665        ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7);
    1666         bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
     1666        bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 
    16671667             (DLGPROC16) ptr, (DWORD) lfs);
    16681668        FILEDLG_DestroyPrivate(lfs);
    1669     }
     1669    } 
    16701670
    16711671    TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
     
    16851685 */
    16861686BOOL WINAPI GetOpenFileNameA(
    1687     LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
     1687        LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
    16881688{
    16891689    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    17211721 */
    17221722BOOL WINAPI GetOpenFileNameW(
    1723     LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
     1723        LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
    17241724{
    17251725    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    17571757 */
    17581758BOOL WINAPI GetSaveFileNameA(
    1759     LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
     1759        LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
    17601760{
    17611761    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    17751775    {
    17761776        return GetFileDialog95A(ofn, SAVE_DIALOG);
    1777     }
     1777    } 
    17781778    else
    17791779    {
     
    17931793 */
    17941794BOOL WINAPI GetSaveFileNameW(
    1795     LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
     1795        LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
    17961796{
    17971797    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    18111811    {
    18121812        return GetFileDialog95W(ofn, SAVE_DIALOG);
    1813     }
     1813    } 
    18141814    else
    18151815    {
  • trunk/src/comdlg32/filedlgbrowser.c

    r6708 r6709  
    11/*
    22 *  Implementation of IShellBrowser for the File Open common dialog
    3  *
     3 * 
    44 *
    55 */
     
    5959*   External Prototypes
    6060*/
    61 extern const char *FileOpenDlgInfosStr;
     61extern const char *FileOpenDlgInfosStr; 
    6262
    6363extern HRESULT          GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
     
    9191static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
    9292{
    93     TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
    94 
    95     switch (src->uType)
    96     {
    97       case STRRET_WSTR:
    98         lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
    99         COMDLG32_SHFree(src->u.pOleStr);
    100         break;
    101 
    102       case STRRET_CSTRA:
     93        TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
     94
     95        switch (src->uType)
     96        {
     97          case STRRET_WSTR:
     98            lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
     99            COMDLG32_SHFree(src->u.pOleStr);
     100            break;
     101
     102          case STRRET_CSTRA:
    103103            if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
    104104                ((LPWSTR)dest)[len-1] = 0;
    105         break;
    106 
    107       case STRRET_OFFSETA:
    108         if (pidl)
    109         {
     105            break;
     106
     107          case STRRET_OFFSETA:
     108            if (pidl)
     109            {
    110110                if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
    111111                                                 -1, (LPWSTR)dest, len ))
    112112                    ((LPWSTR)dest)[len-1] = 0;
    113         }
    114         break;
    115 
    116       default:
    117         FIXME("unknown type!\n");
    118         if (len)
    119         { *(LPWSTR)dest = '\0';
    120         }
    121         return(FALSE);
    122     }
    123     return S_OK;
     113            }
     114            break;
     115
     116          default:
     117            FIXME("unknown type!\n");
     118            if (len)
     119            { *(LPWSTR)dest = '\0';
     120            }
     121            return(FALSE);
     122        }
     123        return S_OK;
    124124}
    125125
    126126/*
    127  *  IShellBrowser
     127 *      IShellBrowser
    128128 */
    129 
     129 
    130130/**************************************************************************
    131131*  IShellBrowserImpl_Construct
     
    158158*/
    159159HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
    160                                             REFIID riid,
     160                                            REFIID riid, 
    161161                                            LPVOID *ppvObj)
    162162{
     
    168168
    169169    if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
    170     { *ppvObj = This;
     170    { *ppvObj = This; 
    171171    }
    172172    else if(IsEqualIID(riid, &IID_IOleWindow))  /*IOleWindow*/
     
    215215    TRACE("(%p)\n", This);
    216216
    217     if (!--(This->ref))
    218     {
     217    if (!--(This->ref)) 
     218    { 
    219219      HeapFree(GetProcessHeap(),0, This);
    220220      return 0;
     
    235235*
    236236*  Note : We will never be window less in the File Open dialog
    237 *
    238 */
    239 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
     237* 
     238*/
     239HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 
    240240                                           HWND * phwnd)
    241241{
     
    249249    *phwnd = This->hwndOwner;
    250250
    251     return (*phwnd) ? S_OK : E_UNEXPECTED;
     251    return (*phwnd) ? S_OK : E_UNEXPECTED; 
    252252
    253253}
     
    276276*  See Windows documentation on IShellBrowser::BrowseObject for more details
    277277*
    278 *  This function will override user specified flags and will always
    279 *  use SBSP_DEFBROWSER and SBSP_DEFMODE.
    280 */
    281 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
    282                                               LPCITEMIDLIST pidl,
     278*  This function will override user specified flags and will always 
     279*  use SBSP_DEFBROWSER and SBSP_DEFMODE. 
     280*/
     281HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, 
     282                                              LPCITEMIDLIST pidl, 
    283283                                              UINT wFlags)
    284284{
     
    301301    if(wFlags & SBSP_RELATIVE)
    302302    {
    303 
     303       
    304304        /* SBSP_RELATIVE  A relative pidl (relative from the current folder) */
    305305        if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
     
    307307        {
    308308            ERR("bind to object failed\n");
    309         return hRes;
     309            return hRes;
    310310        }
    311311        /* create an absolute pidl */
     
    326326        psfTmp = GetShellFolderFromPidl(pidlTmp);
    327327    }
    328 
     328   
    329329    if(!psfTmp)
    330330    {
     
    333333    }
    334334
    335     /* If the pidl to browse to is equal to the actual pidl ...
     335    /* If the pidl to browse to is equal to the actual pidl ... 
    336336       do nothing and pretend you did it*/
    337337    if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
    338338    {
    339339        IShellFolder_Release(psfTmp);
    340     COMDLG32_SHFree(pidlTmp);
     340        COMDLG32_SHFree(pidlTmp);
    341341        TRACE("keep current folder\n");
    342342        return NOERROR;
     
    395395
    396396    /* changes the tab order of the ListView to reflect the window's File Dialog */
    397     hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
     397    hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 
    398398    SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
    399399
     
    402402      SetFocus(fodInfos->ShellInfos.hwndView);
    403403
    404     return hRes;
     404    return hRes; 
    405405error:
    406406    ERR("Failed with error 0x%08lx\n", hRes);
     
    411411*  IShellBrowserImpl_EnableModelessSB
    412412*/
    413 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
     413HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,   
    414414                                              BOOL fEnable)
    415 
     415                                             
    416416{
    417417    ICOM_THIS(IShellBrowserImpl, iface);
     
    426426*  IShellBrowserImpl_GetControlWindow
    427427*/
    428 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
    429                                               UINT id,
     428HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,   
     429                                              UINT id,   
    430430                                              HWND *lphwnd)
    431 
     431                                             
    432432{
    433433    ICOM_THIS(IShellBrowserImpl, iface);
     
    442442*/
    443443HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
    444                                                 DWORD grfMode,
     444                                                DWORD grfMode,   
    445445                                                LPSTREAM *ppStrm)
    446 
     446                                             
    447447{
    448448    ICOM_THIS(IShellBrowserImpl, iface);
     
    452452    /* Feature not implemented */
    453453    return E_NOTIMPL;
    454 }
     454}       
    455455/**************************************************************************
    456456*  IShellBrowserImpl_InsertMenusSB
     
    459459                                           HMENU hmenuShared,
    460460                                           LPOLEMENUGROUPWIDTHS lpMenuWidths)
    461 
     461                                             
    462462{
    463463    ICOM_THIS(IShellBrowserImpl, iface);
     
    473473HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
    474474                                                IShellView *ppshv)
    475 
    476 {
    477     ICOM_THIS(IShellBrowserImpl, iface);
    478 
    479     TRACE("(%p)\n", This);
    480 
    481     /* Feature not implemented */
    482     return E_NOTIMPL;
    483 }
     475                                             
     476{
     477    ICOM_THIS(IShellBrowserImpl, iface);
     478
     479    TRACE("(%p)\n", This);
     480
     481    /* Feature not implemented */
     482    return E_NOTIMPL;
     483}   
    484484/**************************************************************************
    485485*  IShellBrowserImpl_QueryActiveShellView
     
    487487HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
    488488                                                  IShellView **ppshv)
    489 
     489                                             
    490490{
    491491    ICOM_THIS(IShellBrowserImpl, iface);
     
    503503    IShellView_AddRef(fodInfos->Shell.FOIShellView);
    504504    return NOERROR;
    505 }
     505}   
    506506/**************************************************************************
    507507*  IShellBrowserImpl_RemoveMenusSB
     
    509509HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
    510510                                           HMENU hmenuShared)
    511 
    512 {
    513     ICOM_THIS(IShellBrowserImpl, iface);
    514 
    515     TRACE("(%p)\n", This);
    516 
    517     /* Feature not implemented */
    518     return E_NOTIMPL;
    519 }
     511                                             
     512{
     513    ICOM_THIS(IShellBrowserImpl, iface);
     514
     515    TRACE("(%p)\n", This);
     516
     517    /* Feature not implemented */
     518    return E_NOTIMPL;
     519}   
    520520/**************************************************************************
    521521*  IShellBrowserImpl_SendControlMsg
    522522*/
    523 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
    524                                             UINT id,
    525                                             UINT uMsg,
    526                                             WPARAM wParam,
     523HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,   
     524                                            UINT id,   
     525                                            UINT uMsg,   
     526                                            WPARAM wParam,   
    527527                                            LPARAM lParam,
    528528                                            LRESULT *pret)
    529 
     529                                             
    530530{
    531531    ICOM_THIS(IShellBrowserImpl, iface);
    532532    LRESULT lres;
    533 
     533   
    534534    TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
    535535
     
    538538      case FCW_TOOLBAR:
    539539        lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
    540     break;
     540        break;
    541541      default:
    542542        FIXME("ctrl id: %x\n", id);
     
    550550*/
    551551HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
    552                                        HMENU hmenuShared,
     552                                       HMENU hmenuShared,   
    553553                                       HOLEMENU holemenuReserved,
    554554                                       HWND hwndActiveObject)
    555 
    556 {
    557     ICOM_THIS(IShellBrowserImpl, iface);
    558 
    559     TRACE("(%p)\n", This);
    560 
    561     /* Feature not implemented */
    562     return E_NOTIMPL;
    563 }
     555                                             
     556{
     557    ICOM_THIS(IShellBrowserImpl, iface);
     558
     559    TRACE("(%p)\n", This);
     560
     561    /* Feature not implemented */
     562    return E_NOTIMPL;
     563}   
    564564/**************************************************************************
    565565*  IShellBrowserImpl_SetStatusTextSB
     
    567567HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
    568568                                             LPCOLESTR lpszStatusText)
    569 
    570 {
    571     ICOM_THIS(IShellBrowserImpl, iface);
    572 
    573     TRACE("(%p)\n", This);
    574 
    575     /* Feature not implemented */
    576     return E_NOTIMPL;
    577 }
     569                                             
     570{
     571    ICOM_THIS(IShellBrowserImpl, iface);
     572
     573    TRACE("(%p)\n", This);
     574
     575    /* Feature not implemented */
     576    return E_NOTIMPL;
     577}   
    578578/**************************************************************************
    579579*  IShellBrowserImpl_SetToolbarItems
    580580*/
    581581HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
    582                                              LPTBBUTTON lpButtons,
    583                                              UINT nButtons,
     582                                             LPTBBUTTON lpButtons,   
     583                                             UINT nButtons,   
    584584                                             UINT uFlags)
    585 
    586 {
    587     ICOM_THIS(IShellBrowserImpl, iface);
    588 
    589     TRACE("(%p)\n", This);
    590 
    591     /* Feature not implemented */
    592     return E_NOTIMPL;
    593 }
     585                                             
     586{
     587    ICOM_THIS(IShellBrowserImpl, iface);
     588
     589    TRACE("(%p)\n", This);
     590
     591    /* Feature not implemented */
     592    return E_NOTIMPL;
     593}   
    594594/**************************************************************************
    595595*  IShellBrowserImpl_TranslateAcceleratorSB
    596596*/
    597597HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
    598                                                     LPMSG lpmsg,
     598                                                    LPMSG lpmsg,   
    599599                                                    WORD wID)
    600 
     600                                             
    601601{
    602602    ICOM_THIS(IShellBrowserImpl, iface);
     
    644644*/
    645645HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
    646     ICommDlgBrowser *iface,
    647     REFIID riid,
    648     LPVOID *ppvObj)
     646        ICommDlgBrowser *iface,
     647        REFIID riid,
     648        LPVOID *ppvObj)
    649649{
    650650    _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
     
    693693    TRACE("(%p)\n", This);
    694694
    695     fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    696 
     695    fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 
     696   
    697697    /* If the selected object is not a folder, send a IDOK command to parent window */
    698698    if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
     
    702702        ULONG  ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
    703703        IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    704     if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
    705     {
     704        if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
     705        {
    706706          hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
    707     }
     707        }
    708708        else
    709     {
     709        {
    710710          /* Tell the dialog that the user selected a file */
    711       hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
    712     }
     711          hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
     712        }
    713713
    714714        /* Free memory used by pidl */
     
    737737        case CDBOSC_SETFOCUS:
    738738             /* FIXME: Reset the default button.
    739             This should be taken care of by defdlg. If control
    740             other than button receives focus the default button
    741             should be restored. */
     739                This should be taken care of by defdlg. If control
     740                other than button receives focus the default button
     741                should be restored. */
    742742             SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
    743743
    744744            break;
    745         case CDBOSC_KILLFOCUS:
    746         {
    747         FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    748         if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
    749             SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
     745        case CDBOSC_KILLFOCUS: 
     746            {
     747                FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
     748                if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
     749                    SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
    750750            }
    751751            break;
     
    753753            return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
    754754        case CDBOSC_RENAME:
    755         /* nothing to do */
     755            /* nothing to do */
    756756            break;
    757757    }
    758758
    759     return NOERROR;
     759    return NOERROR;     
    760760}
    761761
     
    763763*  IShellBrowserImpl_ICommDlgBrowser_IncludeObject
    764764*/
    765 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
     765HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 
    766766                                                               IShellView * ppshv,
    767767                                                               LPCITEMIDLIST pidl)
     
    780780    ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
    781781    IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    782 
     782   
    783783    if( (ulAttr & SFGAO_HIDDEN)                                         /* hidden */
    784784      | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
     
    786786
    787787    /* always include directorys and links */
    788     if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
     788    if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 
    789789        return S_OK;
    790790
     
    797797      if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
    798798      {
    799       if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
     799          if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
    800800          return S_OK;
    801801      }
     
    807807/**************************************************************************
    808808*  IShellBrowserImpl_ICommDlgBrowser_OnSelChange
    809 */
     809*/ 
    810810HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
    811811{
     
    816816    fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    817817    TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
    818 
     818   
    819819    /* release old selections */
    820820    if (fodInfos->Shell.FOIDataObject)
    821821      IDataObject_Release(fodInfos->Shell.FOIDataObject);
    822 
     822   
    823823    /* get a new DataObject from the ShellView */
    824824    if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
    825825                              &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
    826826      return E_FAIL;
    827 
     827                                         
    828828    FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
    829829
     
    856856*/
    857857HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
    858     IServiceProvider *iface,
    859     REFIID riid,
    860     LPVOID *ppvObj)
     858        IServiceProvider *iface,
     859        REFIID riid,
     860        LPVOID *ppvObj)
    861861{
    862862    _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
     
    895895*
    896896* NOTES
    897 *  the w2k shellview asks for
     897*  the w2k shellview asks for 
    898898*   guidService = SID_STopLevelBrowser
    899899*   riid = IShellBrowser
     
    904904
    905905HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
    906     IServiceProvider * iface,
    907     REFGUID guidService,
    908     REFIID riid,
    909     void** ppv)
     906        IServiceProvider * iface,
     907        REFGUID guidService,
     908        REFIID riid,
     909        void** ppv)
    910910{
    911911    _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
  • trunk/src/comdlg32/filetitle.c

    r6708 r6709  
    1313#include "debugtools.h"
    1414
    15 #include "heap.h"   /* Has to go */
     15#include "heap.h"       /* Has to go */
    1616
    1717DEFAULT_DEBUG_CHANNEL(commdlg)
     
    2020
    2121/***********************************************************************
    22  *  GetFileTitleA       (COMDLG32.8)
     22 *      GetFileTitleA           (COMDLG32.8)
    2323 *
    2424 */
    2525short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
    2626{
    27     int i, len;
     27        int i, len;
    2828
    29     TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
     29        TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
    3030
    31     if(lpFile == NULL || lpTitle == NULL)
    32         return -1;
     31        if(lpFile == NULL || lpTitle == NULL)
     32                return -1;
    3333
    34     len = strlen(lpFile);
     34        len = strlen(lpFile);
    3535
    36     if (len == 0)
    37         return -1;
     36        if (len == 0)
     37                return -1;
    3838
    39     if(strpbrk(lpFile, "*[]"))
    40         return -1;
     39        if(strpbrk(lpFile, "*[]"))
     40                return -1;
    4141
    42     len--;
     42        len--;
    4343
    44     if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
    45         return -1;
     44        if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
     45                return -1;
    4646
    47     for(i = len; i >= 0; i--)
    48     {
    49         if (lpFile[i] == '/' ||  lpFile[i] == '\\' ||  lpFile[i] == ':')
    50         {
    51             i++;
    52             break;
    53         }
    54     }
     47        for(i = len; i >= 0; i--)
     48        {
     49                if (lpFile[i] == '/' ||  lpFile[i] == '\\' ||  lpFile[i] == ':')
     50                {
     51                        i++;
     52                        break;
     53                }
     54        }
    5555
    56     if(i == -1)
    57         i++;
     56        if(i == -1)
     57                i++;
    5858
    59     TRACE("---> '%s' \n", &lpFile[i]);
     59        TRACE("---> '%s' \n", &lpFile[i]);
     60   
     61        len = strlen(lpFile+i)+1;
     62        if(cbBuf < len)
     63                return len;
    6064
    61     len = strlen(lpFile+i)+1;
    62     if(cbBuf < len)
    63         return len;
    64 
    65     strncpy(lpTitle, &lpFile[i], len);
    66     return 0;
     65        strncpy(lpTitle, &lpFile[i], len);
     66        return 0;
    6767}
    6868
    6969
    7070/***********************************************************************
    71  *  GetFileTitleW       (COMDLG32.9)
     71 *      GetFileTitleW           (COMDLG32.9)
    7272 *
    7373 */
    7474short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
    7575{
    76     LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile);  /* Has to go */
    77     LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
    78     short   ret;
     76        LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile);      /* Has to go */
     77        LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
     78        short   ret;
    7979
    80     ret = GetFileTitleA(file, title, cbBuf);
     80        ret = GetFileTitleA(file, title, cbBuf);
    8181
    82     lstrcpynAtoW(lpTitle, title, cbBuf);
    83     HeapFree(GetProcessHeap(), 0, file);
    84     HeapFree(GetProcessHeap(), 0, title);
    85     return ret;
     82        lstrcpynAtoW(lpTitle, title, cbBuf);
     83        HeapFree(GetProcessHeap(), 0, file);
     84        HeapFree(GetProcessHeap(), 0, title);
     85        return ret;
    8686}
    8787
     
    8989#ifndef __WIN32OS2__
    9090/***********************************************************************
    91  *  GetFileTitle16      (COMMDLG.27)
     91 *      GetFileTitle16          (COMMDLG.27)
    9292 */
    9393short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
    9494{
    95     return GetFileTitleA(lpFile, lpTitle, cbBuf);
     95        return GetFileTitleA(lpFile, lpTitle, cbBuf);
    9696}
    9797#endif
  • trunk/src/comdlg32/finddlg32.c

    r6708 r6709  
    2424/*-----------------------------------------------------------------------*/
    2525
    26 static UINT     FindReplaceMessage;
    27 static UINT     HelpMessage;
    28 
    29 #define FR_MASK (FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_REPLACEALL | FR_REPLACE | FR_FINDNEXT | FR_DIALOGTERM)
     26static UINT             FindReplaceMessage;
     27static UINT             HelpMessage;
     28
     29#define FR_MASK (FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_REPLACEALL | FR_REPLACE | FR_FINDNEXT | FR_DIALOGTERM)
    3030/* CRITICAL_SECTION COMDLG32_CritSect; */
    3131
     
    4949
    5050/***********************************************************************
    51  *  COMDLG32_FR_GetFlags            [internal]
     51 *      COMDLG32_FR_GetFlags                    [internal]
    5252 * Returns the button state that needs to be reported to the caller.
    53  *  RETURNS
    54  *      Current state of check and radio buttons
     53 *      RETURNS
     54 *              Current state of check and radio buttons
    5555 */
    5656static DWORD COMDLG32_FR_GetFlags(HWND hDlgWnd)
    5757{
    58     DWORD flags = 0;
    59     if(IsDlgButtonChecked(hDlgWnd, rad2) == BST_CHECKED)
    60             flags |= FR_DOWN;
    61     if(IsDlgButtonChecked(hDlgWnd, chx1) == BST_CHECKED)
    62             flags |= FR_WHOLEWORD;
    63     if(IsDlgButtonChecked(hDlgWnd, chx2) == BST_CHECKED)
    64             flags |= FR_MATCHCASE;
     58        DWORD flags = 0;
     59        if(IsDlgButtonChecked(hDlgWnd, rad2) == BST_CHECKED)
     60                flags |= FR_DOWN;
     61        if(IsDlgButtonChecked(hDlgWnd, chx1) == BST_CHECKED)
     62                flags |= FR_WHOLEWORD;
     63        if(IsDlgButtonChecked(hDlgWnd, chx2) == BST_CHECKED)
     64                flags |= FR_MATCHCASE;
    6565        return flags;
    6666}
    6767
    6868/***********************************************************************
    69  *  COMDLG32_FR_HandleWMCommand     [internal]
     69 *      COMDLG32_FR_HandleWMCommand             [internal]
    7070 * Handle WM_COMMAND messages...
    7171 */
    7272static void COMDLG32_FR_HandleWMCommand(HWND hDlgWnd, COMDLG32_FR_Data *pData, int Id, int NotifyCode)
    7373{
    74     DWORD flag;
    75 
    76     pData->user_fr.fra->Flags &= ~FR_MASK;  /* Clear return flags */
    77     if(pData->fr.Flags & FR_WINE_REPLACE)   /* Replace always goes down... */
    78         pData->user_fr.fra->Flags |= FR_DOWN;
    79 
    80     if(NotifyCode == BN_CLICKED)
    81         {
    82             switch(Id)
    83         {
    84         case IDOK: /* Find Next */
    85             if(GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
     74        DWORD flag;
     75
     76        pData->user_fr.fra->Flags &= ~FR_MASK;  /* Clear return flags */
     77        if(pData->fr.Flags & FR_WINE_REPLACE)   /* Replace always goes down... */
     78                pData->user_fr.fra->Flags |= FR_DOWN;
     79
     80        if(NotifyCode == BN_CLICKED)
     81        {
     82                switch(Id)
     83                {
     84                case IDOK: /* Find Next */
     85                        if(GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
    8686                        {
    87                 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT;
     87                                pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT;
    8888                                if(pData->fr.Flags & FR_WINE_UNICODE)
    8989                                {
     
    9494                                else
    9595                                {
    96                                     strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
     96                                        strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
    9797                                }
    98                 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
     98                                SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
    9999                        }
    100             break;
    101 
    102         case IDCANCEL:
    103             pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_DIALOGTERM;
    104             SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
    105                     DestroyWindow(hDlgWnd);
    106             break;
     100                        break;
     101
     102                case IDCANCEL:
     103                        pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_DIALOGTERM;
     104                        SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
     105                        DestroyWindow(hDlgWnd);
     106                        break;
    107107
    108108                case psh2: /* Replace All */
    109                     flag = FR_REPLACEALL;
     109                        flag = FR_REPLACEALL;
    110110                        goto Replace;
    111111
    112112                case psh1: /* Replace */
    113                     flag = FR_REPLACE;
     113                        flag = FR_REPLACE;
    114114Replace:
    115             if((pData->fr.Flags & FR_WINE_REPLACE)
     115                        if((pData->fr.Flags & FR_WINE_REPLACE)
    116116                        && GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
    117117                        {
    118                 pData->fr.lpstrReplaceWith[0] = 0; /* In case the next GetDlgItemText Fails */
    119                 GetDlgItemTextA(hDlgWnd, edt2, pData->fr.lpstrReplaceWith, pData->fr.wReplaceWithLen);
    120                 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag;
     118                                pData->fr.lpstrReplaceWith[0] = 0; /* In case the next GetDlgItemText Fails */
     119                                GetDlgItemTextA(hDlgWnd, edt2, pData->fr.lpstrReplaceWith, pData->fr.wReplaceWithLen);
     120                                pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag;
    121121                                if(pData->fr.Flags & FR_WINE_UNICODE)
    122122                                {
     
    130130                                else
    131131                                {
    132                                     strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
    133                                     strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith);
     132                                        strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
     133                                        strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith);
    134134                                }
    135                 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
     135                                SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
    136136                        }
    137             break;
    138 
    139         case pshHelp:
    140             pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd);
    141             SendMessageA(pData->fr.hwndOwner, HelpMessage, (WPARAM)hDlgWnd, (LPARAM)pData->user_fr.fra);
    142             break;
     137                        break;
     138
     139                case pshHelp:
     140                        pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd);
     141                        SendMessageA(pData->fr.hwndOwner, HelpMessage, (WPARAM)hDlgWnd, (LPARAM)pData->user_fr.fra);
     142                        break;
    143143                }
    144144        }
    145145        else if(NotifyCode == EN_CHANGE && Id == edt1)
    146     {
    147         BOOL enable = SendDlgItemMessageA(hDlgWnd, edt1, WM_GETTEXTLENGTH, 0, 0) > 0;
    148         EnableWindow(GetDlgItem(hDlgWnd, IDOK), enable);
     146        {
     147                BOOL enable = SendDlgItemMessageA(hDlgWnd, edt1, WM_GETTEXTLENGTH, 0, 0) > 0;
     148                EnableWindow(GetDlgItem(hDlgWnd, IDOK), enable);
    149149                if(pData->fr.Flags & FR_WINE_REPLACE)
    150150                {
    151             EnableWindow(GetDlgItem(hDlgWnd, psh1), enable);
    152             EnableWindow(GetDlgItem(hDlgWnd, psh2), enable);
     151                        EnableWindow(GetDlgItem(hDlgWnd, psh1), enable);
     152                        EnableWindow(GetDlgItem(hDlgWnd, psh2), enable);
    153153                }
    154     }
    155 }
    156 
    157 /***********************************************************************
    158  *  COMDLG32_FindReplaceDlgProc     [internal]
     154        }
     155}
     156
     157/***********************************************************************
     158 *      COMDLG32_FindReplaceDlgProc             [internal]
    159159 * [Find/Replace]Text32[A/W] window procedure.
    160160 */
    161161static BOOL CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    162162{
    163     COMDLG32_FR_Data *pdata = (COMDLG32_FR_Data *)GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
    164     BOOL retval = TRUE;;
    165 
    166     if(iMsg == WM_INITDIALOG)
     163        COMDLG32_FR_Data *pdata = (COMDLG32_FR_Data *)GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
     164        BOOL retval = TRUE;;
     165
     166        if(iMsg == WM_INITDIALOG)
    167167        {
    168168                pdata = (COMDLG32_FR_Data *)lParam;
    169             if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata))
     169                if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata))
    170170                {
    171             ERR("Could not Set prop; invent a gracefull exit?...\n");
    172                     DestroyWindow(hDlgWnd);
     171                        ERR("Could not Set prop; invent a gracefull exit?...\n");
     172                        DestroyWindow(hDlgWnd);
    173173                        return FALSE;
    174174                }
    175             SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wFindWhatLen, 0);
    176             SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat);
     175                SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wFindWhatLen, 0);
     176                SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat);
    177177                if(pdata->fr.Flags & FR_WINE_REPLACE)
    178178                {
    179                 SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wReplaceWithLen, 0);
    180                 SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith);
     179                        SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wReplaceWithLen, 0);
     180                        SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith);
    181181                }
    182182
    183             if(!(pdata->fr.Flags & FR_SHOWHELP))
    184             ShowWindow(GetDlgItem(hDlgWnd, pshHelp), SW_HIDE);
    185             if(pdata->fr.Flags & FR_HIDEUPDOWN)
    186             {
    187             ShowWindow(GetDlgItem(hDlgWnd, rad1), SW_HIDE);
    188             ShowWindow(GetDlgItem(hDlgWnd, rad2), SW_HIDE);
    189             ShowWindow(GetDlgItem(hDlgWnd, grp1), SW_HIDE);
    190             }
    191             else if(pdata->fr.Flags & FR_NOUPDOWN)
    192             {
    193             EnableWindow(GetDlgItem(hDlgWnd, rad1), FALSE);
    194             EnableWindow(GetDlgItem(hDlgWnd, rad2), FALSE);
    195             EnableWindow(GetDlgItem(hDlgWnd, grp1), FALSE);
    196             }
     183                if(!(pdata->fr.Flags & FR_SHOWHELP))
     184                        ShowWindow(GetDlgItem(hDlgWnd, pshHelp), SW_HIDE);
     185                if(pdata->fr.Flags & FR_HIDEUPDOWN)
     186                {
     187                        ShowWindow(GetDlgItem(hDlgWnd, rad1), SW_HIDE);
     188                        ShowWindow(GetDlgItem(hDlgWnd, rad2), SW_HIDE);
     189                        ShowWindow(GetDlgItem(hDlgWnd, grp1), SW_HIDE);
     190                }
     191                else if(pdata->fr.Flags & FR_NOUPDOWN)
     192                {
     193                        EnableWindow(GetDlgItem(hDlgWnd, rad1), FALSE);
     194                        EnableWindow(GetDlgItem(hDlgWnd, rad2), FALSE);
     195                        EnableWindow(GetDlgItem(hDlgWnd, grp1), FALSE);
     196                }
    197197                else
    198198                {
    199             SendDlgItemMessageA(hDlgWnd, rad1, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? 0 : BST_CHECKED, 0);
    200             SendDlgItemMessageA(hDlgWnd, rad2, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? BST_CHECKED : 0, 0);
     199                        SendDlgItemMessageA(hDlgWnd, rad1, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? 0 : BST_CHECKED, 0);
     200                        SendDlgItemMessageA(hDlgWnd, rad2, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? BST_CHECKED : 0, 0);
    201201                }
    202202
    203             if(pdata->fr.Flags & FR_HIDEMATCHCASE)
    204             ShowWindow(GetDlgItem(hDlgWnd, chx2), SW_HIDE);
    205             else if(pdata->fr.Flags & FR_NOMATCHCASE)
    206             EnableWindow(GetDlgItem(hDlgWnd, chx2), FALSE);
     203                if(pdata->fr.Flags & FR_HIDEMATCHCASE)
     204                        ShowWindow(GetDlgItem(hDlgWnd, chx2), SW_HIDE);
     205                else if(pdata->fr.Flags & FR_NOMATCHCASE)
     206                        EnableWindow(GetDlgItem(hDlgWnd, chx2), FALSE);
    207207                else
    208             SendDlgItemMessageA(hDlgWnd, chx2, BM_SETCHECK, pdata->fr.Flags & FR_MATCHCASE ? BST_CHECKED : 0, 0);
    209 
    210             if(pdata->fr.Flags & FR_HIDEWHOLEWORD)
    211             ShowWindow(GetDlgItem(hDlgWnd, chx1), SW_HIDE);
    212             else if(pdata->fr.Flags & FR_NOWHOLEWORD)
    213             EnableWindow(GetDlgItem(hDlgWnd, chx1), FALSE);
     208                        SendDlgItemMessageA(hDlgWnd, chx2, BM_SETCHECK, pdata->fr.Flags & FR_MATCHCASE ? BST_CHECKED : 0, 0);
     209
     210                if(pdata->fr.Flags & FR_HIDEWHOLEWORD)
     211                        ShowWindow(GetDlgItem(hDlgWnd, chx1), SW_HIDE);
     212                else if(pdata->fr.Flags & FR_NOWHOLEWORD)
     213                        EnableWindow(GetDlgItem(hDlgWnd, chx1), FALSE);
    214214                else
    215             SendDlgItemMessageA(hDlgWnd, chx1, BM_SETCHECK, pdata->fr.Flags & FR_WHOLEWORD ? BST_CHECKED : 0, 0);
    216 
    217         /* We did the init here, now call the hook if requested */
    218 
    219         /* We do not do ShowWindow if hook exists and is FALSE  */
    220         /*   per MSDN Article Q96135                            */
    221                 if((pdata->fr.Flags & FR_ENABLEHOOK)
    222                  && ! pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, (LPARAM) &pdata->fr))
     215                        SendDlgItemMessageA(hDlgWnd, chx1, BM_SETCHECK, pdata->fr.Flags & FR_WHOLEWORD ? BST_CHECKED : 0, 0);
     216
     217                /* We did the init here, now call the hook if requested */
     218
     219                /* We do not do ShowWindow if hook exists and is FALSE  */
     220                /*   per MSDN Article Q96135                            */
     221                if((pdata->fr.Flags & FR_ENABLEHOOK)
     222                     && ! pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, (LPARAM) &pdata->fr))
     223                        return TRUE;
     224                ShowWindow(hDlgWnd, SW_SHOWNORMAL);
     225                UpdateWindow(hDlgWnd);
    223226                return TRUE;
    224         ShowWindow(hDlgWnd, SW_SHOWNORMAL);
    225         UpdateWindow(hDlgWnd);
    226                 return TRUE;
    227         }
    228 
    229     if(pdata && (pdata->fr.Flags & FR_ENABLEHOOK))
    230     {
    231         retval = pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, lParam);
    232     }
    233     else
    234         retval = FALSE;
    235 
    236         if(pdata && !retval)
    237         {
    238             retval = TRUE;
    239         switch(iMsg)
    240             {
    241             case WM_COMMAND:
    242             COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, LOWORD(wParam), HIWORD(wParam));
    243                     break;
    244 
    245             case WM_CLOSE:
    246             COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, IDCANCEL, BN_CLICKED);
    247                 break;
    248 
    249             case WM_HELP:
    250                 /* Heeeeelp! */
    251                 FIXME("Got WM_HELP. Who is gonna supply it?\n");
    252                     break;
    253 
    254             case WM_CONTEXTMENU:
    255                 /* Heeeeelp! */
    256                 FIXME("Got WM_CONTEXTMENU. Who is gonna supply it?\n");
    257                     break;
    258         /* FIXME: Handle F1 help */
    259 
    260             default:
    261                 retval = FALSE; /* We did not handle the message */
    262             }
     227        }
     228
     229        if(pdata && (pdata->fr.Flags & FR_ENABLEHOOK))
     230        {
     231                retval = pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, lParam);
     232        }
     233        else
     234                retval = FALSE;
     235
     236        if(pdata && !retval)
     237        {
     238                retval = TRUE;
     239                switch(iMsg)
     240                {
     241                case WM_COMMAND:
     242                        COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, LOWORD(wParam), HIWORD(wParam));
     243                        break;
     244
     245                case WM_CLOSE:
     246                        COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, IDCANCEL, BN_CLICKED);
     247                        break;
     248
     249                case WM_HELP:
     250                        /* Heeeeelp! */
     251                        FIXME("Got WM_HELP. Who is gonna supply it?\n");
     252                        break;
     253
     254                case WM_CONTEXTMENU:
     255                        /* Heeeeelp! */
     256                        FIXME("Got WM_CONTEXTMENU. Who is gonna supply it?\n");
     257                        break;
     258                /* FIXME: Handle F1 help */
     259
     260                default:
     261                        retval = FALSE; /* We did not handle the message */
     262                }
    263263        }
    264264
     
    269269        if(iMsg == WM_DESTROY)
    270270        {
    271             RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
    272             HeapFree(GetProcessHeap(), 0, pdata);
     271                RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
     272                HeapFree(GetProcessHeap(), 0, pdata);
    273273        }
    274274
     
    277277
    278278/***********************************************************************
    279  *  COMDLG32_FR_CheckPartial        [internal]
     279 *      COMDLG32_FR_CheckPartial                [internal]
    280280 * Check various fault conditions in the supplied parameters that
    281281 * cause an extended error to be reported.
    282  *  RETURNS
    283  *      TRUE: Success
    284  *      FALSE: Failure
     282 *      RETURNS
     283 *              TRUE: Success
     284 *              FALSE: Failure
    285285 */
    286286static BOOL COMDLG32_FR_CheckPartial(
    287     LPFINDREPLACEA pfr, /* [in] Find structure */
    288         BOOL Replace        /* [in] True if called as replace */
     287        LPFINDREPLACEA pfr,     /* [in] Find structure */
     288        BOOL Replace            /* [in] True if called as replace */
    289289) {
    290     if(!pfr)
    291         {
    292             COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES);
    293                 return FALSE;
    294     }
     290        if(!pfr)
     291        {
     292                COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES);
     293                return FALSE;
     294        }
    295295
    296296        if(pfr->lStructSize != sizeof(FINDREPLACEA))
    297297        {
    298             COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    299             return FALSE;
     298                COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     299                return FALSE;
    300300        }
    301301
    302302        if(!IsWindow(pfr->hwndOwner))
    303303        {
    304             COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE);
    305             return FALSE;
    306         }
    307 
    308     if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat)
     304                COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE);
     305                return FALSE;
     306        }
     307
     308        if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat)
    309309        ||(Replace && (pfr->wReplaceWithLen < 1 || !pfr->lpstrReplaceWith)))
    310310        {
    311             COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO);
    312                 return FALSE;
    313         }
    314 
    315     if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0)
    316         {
    317             COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    318                 return FALSE;
    319         }
    320     if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0)
    321         {
    322             COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     311                COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO);
     312                return FALSE;
     313        }
     314
     315        if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0)
     316        {
     317                COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     318                return FALSE;
     319        }
     320        if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0)
     321        {
     322                COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    323323                return FALSE;
    324324        }
     
    326326        if((pfr->Flags & FR_ENABLEHOOK) && !pfr->lpfnHook)
    327327        {
    328             COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
     328                COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
    329329                return FALSE;
    330330        }
     
    332332        if((pfr->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE)) && !pfr->hInstance)
    333333        {
    334             COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE);
     334                COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE);
    335335                return FALSE;
    336336        }
     
    338338        if((pfr->Flags & FR_ENABLETEMPLATE) && !pfr->lpTemplateName)
    339339        {
    340             COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE);
    341                 return FALSE;
    342         }
    343 
    344     return TRUE;
    345 }
    346 
    347 /***********************************************************************
    348  *  COMDLG32_FR_DoFindReplace       [internal]
     340                COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE);
     341                return FALSE;
     342        }
     343
     344        return TRUE;
     345}
     346
     347/***********************************************************************
     348 *      COMDLG32_FR_DoFindReplace               [internal]
    349349 * Actual load and creation of the Find/Replace dialog.
    350  *  RETURNS
    351  *      Window handle to created dialog:Success
    352  *      NULL:Failure
     350 *      RETURNS
     351 *              Window handle to created dialog:Success
     352 *              NULL:Failure
    353353 */
    354354static HWND COMDLG32_FR_DoFindReplace(
    355     COMDLG32_FR_Data *pdata /* [in] Internal data structure */
     355        COMDLG32_FR_Data *pdata /* [in] Internal data structure */
    356356) {
    357     HWND hdlgwnd = 0;
     357        HWND hdlgwnd = 0;
    358358        HGLOBAL loadrc;
    359359        DWORD error;
    360360        LPDLGTEMPLATEW rcs;
    361361
    362     TRACE("hInst=%08x, Flags=%08lx\n", pdata->fr.hInstance, pdata->fr.Flags);
     362        TRACE("hInst=%08x, Flags=%08lx\n", pdata->fr.hInstance, pdata->fr.Flags);
    363363
    364364        if(!(pdata->fr.Flags & FR_ENABLETEMPLATEHANDLE))
    365365        {
    366             HMODULE hmod = COMDLG32_hInstance;
    367         HRSRC htemplate;
    368             if(pdata->fr.Flags & FR_ENABLETEMPLATE)
    369             {
    370                 hmod = (HMODULE)pdata->fr.hInstance;
     366                HMODULE hmod = COMDLG32_hInstance;
     367                HRSRC htemplate;
     368                if(pdata->fr.Flags & FR_ENABLETEMPLATE)
     369                {
     370                        hmod = (HMODULE)pdata->fr.hInstance;
    371371                        if(pdata->fr.Flags & FR_WINE_UNICODE)
    372372                        {
    373                 htemplate = FindResourceW(hmod, (LPWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOGA);
     373                                htemplate = FindResourceW(hmod, (LPWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOGA);
    374374                        }
    375375                        else
    376376                        {
    377                 htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOGA);
     377                                htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOGA);
    378378                        }
    379             }
     379                }
     380                else
     381                {
     382                        int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD
     383                                                                     : FINDDLGORD;
     384                        htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOGA);
     385                }
     386                if(!htemplate)
     387                {
     388                        error = CDERR_FINDRESFAILURE;
     389                        goto cleanup;
     390                }
     391
     392                loadrc = LoadResource(hmod, htemplate);
     393        }
    380394        else
    381             {
    382             int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD
    383                                      : FINDDLGORD;
    384             htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOGA);
    385         }
    386         if(!htemplate)
    387                 {
    388                     error = CDERR_FINDRESFAILURE;
    389                         goto cleanup;
    390                 }
    391 
    392             loadrc = LoadResource(hmod, htemplate);
    393         }
    394         else
    395         {
    396             loadrc = (HGLOBAL)pdata->fr.hInstance;
     395        {
     396                loadrc = (HGLOBAL)pdata->fr.hInstance;
    397397        }
    398398
    399399        if(!loadrc)
    400400        {
    401         error = CDERR_LOADRESFAILURE;
    402         goto cleanup;
    403     }
     401                error = CDERR_LOADRESFAILURE;
     402                goto cleanup;
     403        }
    404404
    405405        if((rcs = (LPDLGTEMPLATEW)LockResource(loadrc)) == NULL)
    406406        {
    407         error = CDERR_LOCKRESFAILURE;
    408         goto cleanup;
     407                error = CDERR_LOCKRESFAILURE;
     408                goto cleanup;
    409409        }
    410410
    411411        hdlgwnd = CreateDialogIndirectParamA(COMDLG32_hInstance,
    412                              rcs,
     412                                             rcs,
    413413                                             pdata->fr.hwndOwner,
    414414                                             (DLGPROC)COMDLG32_FindReplaceDlgProc,
    415415                                             (LPARAM)pdata);
    416     if(!hdlgwnd)
    417         {
    418             error = CDERR_DIALOGFAILURE;
     416        if(!hdlgwnd)
     417        {
     418                error = CDERR_DIALOGFAILURE;
    419419cleanup:
    420             COMDLG32_SetCommDlgExtendedError(error);
     420                COMDLG32_SetCommDlgExtendedError(error);
    421421                HeapFree(GetProcessHeap(), 0, pdata);
    422422        }
     
    425425
    426426/***********************************************************************
    427  *  FindTextA               [COMDLG32.6]
    428  *  RETURNS
    429  *      Window handle to created dialog: Success
    430  *      NULL: Failure
     427 *      FindTextA                               [COMDLG32.6]
     428 *      RETURNS
     429 *              Window handle to created dialog: Success
     430 *              NULL: Failure
    431431 */
    432432HWND WINAPI FindTextA(
    433     LPFINDREPLACEA pfr  /* [in] Find/replace structure*/
     433        LPFINDREPLACEA pfr      /* [in] Find/replace structure*/
    434434) {
    435     COMDLG32_FR_Data *pdata;
     435        COMDLG32_FR_Data *pdata;
    436436
    437437        TRACE("LPFINDREPLACE=%p\n", pfr);
    438438
    439     if(!COMDLG32_FR_CheckPartial(pfr, FALSE))
    440             return 0;
    441 
    442     if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
    443             return 0; /* Error has been set */
     439        if(!COMDLG32_FR_CheckPartial(pfr, FALSE))
     440                return 0;
     441
     442        if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
     443                return 0; /* Error has been set */
    444444
    445445        pdata->user_fr.fra = pfr;
    446446        pdata->fr = *pfr;
    447     return COMDLG32_FR_DoFindReplace(pdata);
    448 }
    449 
    450 /***********************************************************************
    451  *  ReplaceTextA                [COMDLG32.19]
    452  *  RETURNS
    453  *      Window handle to created dialog: Success
    454  *      NULL: Failure
     447        return COMDLG32_FR_DoFindReplace(pdata);
     448}
     449
     450/***********************************************************************
     451 *      ReplaceTextA                            [COMDLG32.19]
     452 *      RETURNS
     453 *              Window handle to created dialog: Success
     454 *              NULL: Failure
    455455 */
    456456HWND WINAPI ReplaceTextA(
    457     LPFINDREPLACEA pfr  /* [in] Find/replace structure*/
     457        LPFINDREPLACEA pfr      /* [in] Find/replace structure*/
    458458) {
    459     COMDLG32_FR_Data *pdata;
     459        COMDLG32_FR_Data *pdata;
    460460
    461461        TRACE("LPFINDREPLACE=%p\n", pfr);
    462462
    463     if(!COMDLG32_FR_CheckPartial(pfr, TRUE))
    464             return 0;
    465 
    466     if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
    467             return 0; /* Error has been set */
     463        if(!COMDLG32_FR_CheckPartial(pfr, TRUE))
     464                return 0;
     465
     466        if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
     467                return 0; /* Error has been set */
    468468
    469469        pdata->user_fr.fra = pfr;
    470470        pdata->fr = *pfr;
    471     pdata->fr.Flags |= FR_WINE_REPLACE;
    472     return COMDLG32_FR_DoFindReplace(pdata);
    473 }
    474 
    475 /***********************************************************************
    476  *  FindTextW               [COMDLG32.7]
    477  *  RETURNS
    478  *      Window handle to created dialog: Success
    479  *      NULL: Failure
     471        pdata->fr.Flags |= FR_WINE_REPLACE;
     472        return COMDLG32_FR_DoFindReplace(pdata);
     473}
     474
     475/***********************************************************************
     476 *      FindTextW                               [COMDLG32.7]
     477 *      RETURNS
     478 *              Window handle to created dialog: Success
     479 *              NULL: Failure
    480480 */
    481481HWND WINAPI FindTextW(
    482     LPFINDREPLACEW pfr  /* [in] Find/replace structure*/
     482        LPFINDREPLACEW pfr      /* [in] Find/replace structure*/
    483483) {
    484     COMDLG32_FR_Data *pdata;
     484        COMDLG32_FR_Data *pdata;
    485485        DWORD len;
    486486
    487487        TRACE("LPFINDREPLACE=%p\n", pfr);
    488488
    489     if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
    490             return 0;
     489        if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
     490                return 0;
    491491
    492492        len = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
     
    496496
    497497        pdata->user_fr.frw = pfr;
    498         pdata->fr = *(LPFINDREPLACEA)pfr;   /* FINDREPLACEx have same size */
    499     pdata->fr.Flags |= FR_WINE_UNICODE;
     498        pdata->fr = *(LPFINDREPLACEA)pfr;       /* FINDREPLACEx have same size */
     499        pdata->fr.Flags |= FR_WINE_UNICODE;
    500500        pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1);  /* Set string pointer */
    501501        WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
     
    505505
    506506/***********************************************************************
    507  *  ReplaceTextW                [COMDLG32.20]
    508  *  RETURNS
    509  *      Window handle to created dialog: Success
    510  *      NULL: Failure
     507 *      ReplaceTextW                            [COMDLG32.20]
     508 *      RETURNS
     509 *              Window handle to created dialog: Success
     510 *              NULL: Failure
    511511 */
    512512HWND WINAPI ReplaceTextW(
    513     LPFINDREPLACEW pfr  /* [in] Find/replace structure*/
     513        LPFINDREPLACEW pfr      /* [in] Find/replace structure*/
    514514) {
    515     COMDLG32_FR_Data *pdata;
     515        COMDLG32_FR_Data *pdata;
    516516        DWORD len1, len2;
    517517
    518518        TRACE("LPFINDREPLACE=%p\n", pfr);
    519519
    520     if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
    521             return 0;
     520        if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
     521                return 0;
    522522
    523523        len1 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
     
    525525        len2 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen,
    526526                                    NULL, 0, NULL, NULL );
    527     if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data)
     527        if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data)
    528528                                                          + len1 + len2)) == NULL)
    529529            return 0; /* Error has been set */
    530530
    531531        pdata->user_fr.frw = pfr;
    532         pdata->fr = *(LPFINDREPLACEA)pfr;   /* FINDREPLACEx have same size */
    533     pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE;
     532        pdata->fr = *(LPFINDREPLACEA)pfr;       /* FINDREPLACEx have same size */
     533        pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE;
    534534        pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1);  /* Set string pointer */
    535535        pdata->fr.lpstrReplaceWith = pdata->fr.lpstrFindWhat + len1;
  • trunk/src/comdlg32/fontdlg.c

    r6708 r6709  
    4545
    4646#ifdef __WIN32OS2__
    47 static HBITMAP hBitmapTT = 0;
     47static HBITMAP hBitmapTT = 0; 
    4848#else
    49 static HBITMAP16 hBitmapTT = 0;
     49static HBITMAP16 hBitmapTT = 0; 
    5050#endif
    5151
    5252LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    53                   LPARAM lParam);
     53                                  LPARAM lParam);
    5454LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
    55                   LPARAM lParam);
     55                                  LPARAM lParam);
    5656
    5757#ifndef __WIN32OS2__
     
    7979
    8080/***********************************************************************
    81  *                        ChooseFont16   (COMMDLG.15)
     81 *                        ChooseFont16   (COMMDLG.15)     
    8282 */
    8383BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
     
    9292    LOGFONTA lf32a;
    9393    SEGPTR lpTemplateName;
    94 
     94   
    9595    cf32a.lpLogFont=&lf32a;
    9696    CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
    9797
    9898    TRACE("ChooseFont\n");
    99     if (!lpChFont) return FALSE;
     99    if (!lpChFont) return FALSE;   
    100100
    101101    if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
     
    157157        }
    158158        ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
    159         hDlgTmpl16 = hGlobal16;
     159        hDlgTmpl16 = hGlobal16;         
    160160
    161161    }
     
    204204  if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
    205205    CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
    206   return DialogBoxIndirectParamA(COMMDLG_hInstance32, template,
     206  return DialogBoxIndirectParamA(COMMDLG_hInstance32, template, 
    207207            lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcA, (LPARAM)lpChFont );
    208208}
     
    239239  cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
    240240  lpChFont->lpTemplateName=(LPWSTR)&cf32a;
    241   bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template,
     241  bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, 
    242242            lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcW, (LPARAM)lpChFont );
    243243  HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
     
    288288 *              AddFontFamily                               [internal]
    289289 */
    290 static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType,
     290static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType, 
    291291                           LPCHOOSEFONTA lpcf, HWND hwnd)
    292292{
     
    304304  if (lpcf->Flags & CF_TTONLY)
    305305   if (!(nFontType & TRUETYPE_FONTTYPE))
    306      return 1;
     306     return 1;   
    307307
    308308  i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
     
    327327 *              FontFamilyEnumProc32                           [internal]
    328328 */
    329 static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont,
    330       LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)
     329static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont, 
     330          LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)
    331331{
    332332  LPCFn_ENUMSTRUCT e;
     
    344344  HWND16 hwnd=LOWORD(lParam);
    345345  HWND hDlg=GetParent(hwnd);
    346   LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
     346  LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 
    347347  LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
    348348  LOGFONTA lf32a;
     
    362362   #define FSTYLES 4
    363363   struct FONTSTYLE
    364           { int italic;
     364          { int italic; 
    365365            int weight;
    366366            char stname[20]; };
    367    static struct FONTSTYLE fontstyles[FSTYLES]={
     367   static struct FONTSTYLE fontstyles[FSTYLES]={ 
    368368          { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
    369369          { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
     
    389389       j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str );
    390390       if (j==CB_ERR) return 1;
    391        j=SendMessageA(hwnd, CB_SETITEMDATA, j,
     391       j=SendMessageA(hwnd, CB_SETITEMDATA, j, 
    392392                                 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
    393393#else
     
    396396       SEGPTR_FREE(str);
    397397       if (j==CB_ERR) return 1;
    398        j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
     398       j=SendMessage16(hwnd, CB_SETITEMDATA16, j, 
    399399                                 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
    400400#endif
    401        if (j==CB_ERR) return 1;
     401       if (j==CB_ERR) return 1;                                 
    402402     }
    403    }
     403   } 
    404404  return 0;
    405405}
     
    417417    {
    418418        sprintf(buffer, "%2d", h);
    419     j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
    420     if (j==CB_ERR)
    421     {
    422             j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
    423             if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
    424             if (j==CB_ERR) return 1;
    425     }
     419        j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
     420        if (j==CB_ERR)
     421        {
     422            j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);     
     423            if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
     424            if (j==CB_ERR) return 1;
     425        }
    426426    }
    427427    return 0;
    428 }
    429 
     428} 
     429 
    430430/*************************************************************************
    431431 *              SetFontSizesToCombo3                           [internal]
     
    444444 *                 AddFontStyle                          [internal]
    445445 */
    446 static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType,
     446static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType, 
    447447    LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
    448448{
    449449  int i;
    450 
     450 
    451451  TRACE("(nFontType=%d)\n",nFontType);
    452452  TRACE("  %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
    453            " ch=%d op=%d cp=%d q=%d pf=%xh\n",
    454            lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
    455            lplf->lfEscapement,lplf->lfOrientation,
    456            lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
    457            lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
    458            lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
     453               " ch=%d op=%d cp=%d q=%d pf=%xh\n",
     454               lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
     455               lplf->lfEscapement,lplf->lfOrientation,
     456               lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
     457               lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
     458               lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
    459459  if (nFontType & RASTER_FONTTYPE)
    460460  {
     
    473473  return 1 ;
    474474
    475 }
     475}   
    476476
    477477#ifndef __WIN32OS2__
     
    485485  HWND16 hcmb3=HIWORD(lParam);
    486486  HWND hDlg=GetParent(hcmb3);
    487   LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
     487  LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 
    488488  LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
    489489  LOGFONTA lf32a;
     
    497497 *                 FontStyleEnumProc32                     [internal]
    498498 */
    499 static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont,
     499static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont, 
    500500          LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam )
    501501{
     
    520520  HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
    521521
    522   SetWindowLongA(hDlg, DWL_USER, lParam);
     522  SetWindowLongA(hDlg, DWL_USER, lParam); 
    523523  lpxx=lpcf->lpLogFont;
    524524  TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
     
    527527  {
    528528    ERR("structure size failure !!!\n");
    529     EndDialog (hDlg, 0);
     529    EndDialog (hDlg, 0); 
    530530    return FALSE;
    531531  }
     
    536536  SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,
    537537     CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
    538 
     538                         
    539539  if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
    540540    ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
     
    582582      {
    583583        SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
    584     SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
     584        SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
    585585                       GetDlgItem(hDlg,cmb1));
    586586        init=1;
     
    592592            SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
    593593        }
    594 
     594     
    595595        /* look for fitting font size in combobox3 */
    596596        j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
     
    607607      SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
    608608                       GetDlgItem(hDlg,cmb1));
    609     }
     609    }   
    610610    if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
    611611    {
     
    622622  {
    623623    WARN("HDC failure !!!\n");
    624     EndDialog (hDlg, 0);
     624    EndDialog (hDlg, 0); 
    625625    return FALSE;
    626626  }
     
    628628  if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
    629629    ReleaseDC(hDlg,hdc);
    630   SetCursor(hcursor);
     630  SetCursor(hcursor);   
    631631  return TRUE;
    632632}
     
    659659  COLORREF cr, oldText=0, oldBk=0;
    660660  RECT rect;
    661 #if 0
     661#if 0 
    662662  HDC hMemDC;
    663663  int nFontType;
    664664  HBITMAP hBitmap; /* for later TT usage */
    665 #endif
     665#endif 
    666666  LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
    667667
    668   if (lpdi->itemID == 0xFFFF)           /* got no items */
     668  if (lpdi->itemID == 0xFFFF)                   /* got no items */
    669669    DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
    670670  else
     
    685685   }
    686686   else
    687      return TRUE;   /* this should never happen */
     687     return TRUE;       /* this should never happen */
    688688
    689689   rect=lpdi->rcItem;
    690690   switch (lpdi->CtlID)
    691691   {
    692     case cmb1:  /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
    693         SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
    694                    (LPARAM)buffer);
    695         GetObjectA( hBitmapTT, sizeof(bm), &bm );
    696         TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
     692    case cmb1:  /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
     693                SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     694                               (LPARAM)buffer);           
     695                GetObjectA( hBitmapTT, sizeof(bm), &bm );
     696                TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
    697697                           lpdi->rcItem.top, buffer, strlen(buffer));
    698698#if 0
    699         nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
    700           /* FIXME: draw bitmap if truetype usage */
    701         if (nFontType&TRUETYPE_FONTTYPE)
    702         {
    703           hMemDC = CreateCompatibleDC(lpdi->hDC);
    704           hBitmap = SelectObject(hMemDC, hBitmapTT);
    705           BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
     699                nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
     700                  /* FIXME: draw bitmap if truetype usage */
     701                if (nFontType&TRUETYPE_FONTTYPE)
     702                {
     703                  hMemDC = CreateCompatibleDC(lpdi->hDC);
     704                  hBitmap = SelectObject(hMemDC, hBitmapTT);
     705                  BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
    706706                           bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
    707           SelectObject(hMemDC, hBitmap);
    708           DeleteDC(hMemDC);
    709         }
     707                  SelectObject(hMemDC, hBitmap);
     708                  DeleteDC(hMemDC);
     709                }
    710710#endif
    711         break;
     711                break;
    712712    case cmb2:
    713     case cmb3:  /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
    714         SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
    715                        (LPARAM)buffer);
    716         TextOutA(lpdi->hDC, lpdi->rcItem.left,
     713    case cmb3:  /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
     714                SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     715                               (LPARAM)buffer);
     716                TextOutA(lpdi->hDC, lpdi->rcItem.left,
    717717                           lpdi->rcItem.top, buffer, strlen(buffer));
    718         break;
    719 
    720     case cmb4:  /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
    721         SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
    722                            (LPARAM)buffer);
    723         TextOutA(lpdi->hDC, lpdi->rcItem.left +  25+5,
     718                break;
     719
     720    case cmb4:  /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
     721                SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     722                               (LPARAM)buffer);
     723                TextOutA(lpdi->hDC, lpdi->rcItem.left +  25+5,
    724724                           lpdi->rcItem.top, buffer, strlen(buffer));
    725         cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
    726         hBrush = CreateSolidBrush(cr);
    727         if (hBrush)
    728         {
    729           hBrush = SelectObject (lpdi->hDC, hBrush) ;
    730           rect.right=rect.left+25;
    731           rect.top++;
    732           rect.left+=5;
    733           rect.bottom--;
    734           Rectangle( lpdi->hDC, rect.left, rect.top,
     725                cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
     726                hBrush = CreateSolidBrush(cr);
     727                if (hBrush)
     728                {
     729                  hBrush = SelectObject (lpdi->hDC, hBrush) ;
     730                  rect.right=rect.left+25;
     731                  rect.top++;
     732                  rect.left+=5;
     733                  rect.bottom--;
     734                  Rectangle( lpdi->hDC, rect.left, rect.top,
    735735                               rect.right, rect.bottom );
    736           DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
    737         }
    738         rect=lpdi->rcItem;
    739         rect.left+=25+5;
    740         break;
    741 
    742     default:    return TRUE;    /* this should never happen */
     736                  DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
     737                }
     738                rect=lpdi->rcItem;
     739                rect.left+=25+5;
     740                break;
     741
     742    default:    return TRUE;    /* this should never happen */
    743743   }
    744744   if (lpdi->itemState == ODS_SELECTED)
     
    777777  HDC hdc;
    778778  LPLOGFONTA lpxx=lpcf->lpLogFont;
    779 
     779 
    780780  TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
    781781  switch (LOWORD(wParam))
    782782  {
    783     case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
    784           {
    785             hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
    786             if (hdc)
    787             {
     783        case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
     784                  {
     785                    hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
     786                    if (hdc)
     787                    {
    788788#ifdef __WIN32OS2__
    789                       SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0);
    790               SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
    791               i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
     789                      SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0); 
     790                      SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
     791                      i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
    792792#else
    793                       SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
    794               SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
    795               i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
     793                      SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0); 
     794                      SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
     795                      i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
    796796#endif
    797               if (i!=CB_ERR)
    798               {
    799                 HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
    800             CFn_ENUMSTRUCT s;
     797                      if (i!=CB_ERR)
     798                      {
     799                        HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
     800                        CFn_ENUMSTRUCT s;
    801801                        char str[256];
    802802                        SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
    803803                                              (LPARAM)str);
    804                     TRACE("WM_COMMAND/cmb1 =>%s\n",str);
    805             s.hWnd1=GetDlgItem(hDlg, cmb2);
    806             s.hWnd2=GetDlgItem(hDlg, cmb3);
    807             s.lpcf32a=lpcf;
    808                     EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
    809                 SetCursor(hcursor);
    810               }
    811               if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
    812                 ReleaseDC(hDlg,hdc);
    813             }
    814             else
     804                        TRACE("WM_COMMAND/cmb1 =>%s\n",str);
     805                        s.hWnd1=GetDlgItem(hDlg, cmb2);
     806                        s.hWnd2=GetDlgItem(hDlg, cmb3);
     807                        s.lpcf32a=lpcf;
     808                        EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
     809                        SetCursor(hcursor);
     810                      }
     811                      if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
     812                        ReleaseDC(hDlg,hdc);
     813                    }
     814                    else
    815815                    {
    816816                      WARN("HDC failure !!!\n");
    817                       EndDialog (hDlg, 0);
     817                      EndDialog (hDlg, 0); 
    818818                      return TRUE;
    819819                    }
    820               }
    821     case chx1:
    822     case chx2:
    823     case cmb2:
    824     case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
    825               {
     820                  }
     821        case chx1:
     822        case chx2:
     823        case cmb2:
     824        case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
     825                  {
    826826                    char str[256];
    827827                    TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
    828             i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
    829             if (i==CB_ERR)
     828                    i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
     829                    if (i==CB_ERR)
    830830                      i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
    831831                    else
    832832                    {
    833               SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
    834                                     (LPARAM)str);
    835               l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
    836               j=HIWORD(l);
    837               lpcf->nFontType = LOWORD(l);
    838               /* FIXME:   lpcf->nFontType |= ....  SIMULATED_FONTTYPE and so */
    839               /* same value reported to the EnumFonts
    840                call back with the extra FONTTYPE_...  bits added */
    841               lpxx->lfPitchAndFamily=j&0xff;
    842               lpxx->lfCharSet=j>>8;
     833                      SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
     834                                            (LPARAM)str);
     835                      l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
     836                      j=HIWORD(l);
     837                      lpcf->nFontType = LOWORD(l);
     838                      /* FIXME:   lpcf->nFontType |= ....  SIMULATED_FONTTYPE and so */
     839                      /* same value reported to the EnumFonts
     840                       call back with the extra FONTTYPE_...  bits added */
     841                      lpxx->lfPitchAndFamily=j&0xff;
     842                      lpxx->lfCharSet=j>>8;
    843843                    }
    844844                    strcpy(lpxx->lfFaceName,str);
    845             i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
    846             if (i!=CB_ERR)
    847             {
    848               l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
    849               if (0!=(lpxx->lfItalic=HIWORD(l)))
    850                 lpcf->nFontType |= ITALIC_FONTTYPE;
    851               if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
    852                 lpcf->nFontType |= BOLD_FONTTYPE;
    853             }
    854             i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
    855             if (i!=CB_ERR)
    856               lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
    857             else
    858               lpxx->lfHeight=0;
    859             lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
    860             lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
    861             lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
    862             lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
    863             lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
    864             lpxx->lfQuality=DEFAULT_QUALITY;
     845                    i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
     846                    if (i!=CB_ERR)
     847                    {
     848                      l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
     849                      if (0!=(lpxx->lfItalic=HIWORD(l)))
     850                        lpcf->nFontType |= ITALIC_FONTTYPE;
     851                      if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
     852                        lpcf->nFontType |= BOLD_FONTTYPE;
     853                    }
     854                    i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
     855                    if (i!=CB_ERR)
     856                      lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
     857                    else
     858                      lpxx->lfHeight=0;
     859                    lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
     860                    lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
     861                    lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
     862                    lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
     863                    lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
     864                    lpxx->lfQuality=DEFAULT_QUALITY;
    865865                    lpcf->iPointSize= -10*lpxx->lfHeight;
    866866
    867             hFont=CreateFontIndirectA(lpxx);
    868             if (hFont)
    869             {
    870               HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
    871                   WM_GETFONT, 0, 0);
    872               SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
    873               DeleteObject(oldFont);
    874             }
     867                    hFont=CreateFontIndirectA(lpxx);
     868                    if (hFont)
     869                    {
     870                      HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
     871                          WM_GETFONT, 0, 0);
     872                      SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
     873                      DeleteObject(oldFont);
     874                    }
    875875                  }
    876876                  break;
    877877
    878     case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
    879           if (i!=CB_ERR)
    880           {
    881            lpcf->rgbColors=textcolors[i];
    882            InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
    883           }
    884           break;
    885 
    886     case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
    887           if (lpcf->hwndOwner)
    888             SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
    889 /*        if (CFn_HookCallChk(lpcf))
    890             CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
    891           break;
    892 
    893     case IDOK:if (  (!(lpcf->Flags & CF_LIMITSIZE))  ||
    894                      ( (lpcf->Flags & CF_LIMITSIZE) &&
    895                       (-lpxx->lfHeight >= lpcf->nSizeMin) &&
     878        case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
     879                  if (i!=CB_ERR)
     880                  {
     881                   lpcf->rgbColors=textcolors[i];
     882                   InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
     883                  }
     884                  break;
     885       
     886        case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
     887                  if (lpcf->hwndOwner)
     888                    SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
     889/*                if (CFn_HookCallChk(lpcf))
     890                    CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
     891                  break;
     892
     893        case IDOK:if (  (!(lpcf->Flags & CF_LIMITSIZE))  ||
     894                     ( (lpcf->Flags & CF_LIMITSIZE) && 
     895                      (-lpxx->lfHeight >= lpcf->nSizeMin) && 
    896896                      (-lpxx->lfHeight <= lpcf->nSizeMax)))
    897                  EndDialog(hDlg, TRUE);
    898               else
    899               {
     897                     EndDialog(hDlg, TRUE);
     898                  else
     899                  {
    900900                   char buffer[80];
    901                sprintf(buffer,"Select a font size between %d and %d points.",
     901                   sprintf(buffer,"Select a font size between %d and %d points.",
    902902                           lpcf->nSizeMin,lpcf->nSizeMax);
    903                MessageBoxA(hDlg, buffer, NULL, MB_OK);
    904               }
    905           return(TRUE);
    906     case IDCANCEL:EndDialog(hDlg, FALSE);
    907           return(TRUE);
    908     }
     903                   MessageBoxA(hDlg, buffer, NULL, MB_OK);
     904                  }
     905                  return(TRUE);
     906        case IDCANCEL:EndDialog(hDlg, FALSE);
     907                  return(TRUE);
     908        }
    909909      return(FALSE);
    910910}
     
    930930  UINT uMsg32;
    931931  WPARAM wParam32;
    932   LRESULT res=0;
     932  LRESULT res=0; 
    933933  if (message!=WM_INITDIALOG)
    934934  {
    935    lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
     935   lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);   
    936936   if (!lpcf)
    937937      return FALSE;
     
    945945    lpcf=(LPCHOOSEFONT16)lParam;
    946946    lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
    947     if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
     947    if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 
    948948    {
    949949      TRACE("CFn_WMInitDialog returned FALSE\n");
    950950      return FALSE;
    951     }
     951    } 
    952952    if (CFn_HookCallChk(lpcf))
    953953      return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
     
    959959      case WM_MEASUREITEM:
    960960                        res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
    961             break;
     961                        break;
    962962      case WM_DRAWITEM:
    963963                        res=CFn_WMDrawItem(hDlg, wParam32, lParam);
    964             break;
     964                        break;
    965965      case WM_CTLCOLORSTATIC:
    966966                        res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
    967             break;
     967                        break;
    968968      case WM_COMMAND:
    969969                        res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
    970             break;
     970                        break;
    971971      case WM_DESTROY:
    972972                        res=CFn_WMDestroy(hDlg, wParam32, lParam);
    973             break;
    974       case WM_CHOOSEFONT_GETLOGFONT:
     973                        break;
     974      case WM_CHOOSEFONT_GETLOGFONT: 
    975975                         TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
    976                       lParam);
    977             FIXME("current logfont back to caller\n");
     976                                      lParam);
     977                        FIXME("current logfont back to caller\n");
    978978                        break;
    979979    }
    980   WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);
     980  WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);   
    981981  return res;
    982982}
     
    993993  if (uMsg!=WM_INITDIALOG)
    994994  {
    995    lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
     995   lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);   
    996996   if (!lpcf)
    997997     return FALSE;
     
    10041004  {
    10051005    lpcf=(LPCHOOSEFONTA)lParam;
    1006     if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
     1006    if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf)) 
    10071007    {
    10081008      TRACE("CFn_WMInitDialog returned FALSE\n");
    10091009      return FALSE;
    1010     }
     1010    } 
    10111011    if (CFn_HookCallChk32(lpcf))
    10121012      return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
     
    10261026      case WM_CHOOSEFONT_GETLOGFONT:
    10271027                         TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
    1028                       lParam);
    1029             FIXME("current logfont back to caller\n");
     1028                                      lParam);
     1029                        FIXME("current logfont back to caller\n");
    10301030                        break;
    10311031    }
     
    10441044  if (uMsg!=WM_INITDIALOG)
    10451045  {
    1046    lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
     1046   lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);   
    10471047   if (!lpcf32w)
    10481048     return FALSE;
     
    10561056    lpcf32w=(LPCHOOSEFONTW)lParam;
    10571057    lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
    1058     if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
     1058    if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 
    10591059    {
    10601060      TRACE("CFn_WMInitDialog returned FALSE\n");
    10611061      return FALSE;
    1062     }
     1062    } 
    10631063    if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
    10641064      return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
     
    10771077      case WM_DESTROY:
    10781078                        return CFn_WMDestroy(hDlg, wParam, lParam);
    1079       case WM_CHOOSEFONT_GETLOGFONT:
     1079      case WM_CHOOSEFONT_GETLOGFONT: 
    10801080                         TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
    1081                       lParam);
    1082             FIXME("current logfont back to caller\n");
     1081                                      lParam);
     1082                        FIXME("current logfont back to caller\n");
    10831083                        break;
    10841084    }
  • trunk/src/comdlg32/printdlg.c

    r6708 r6709  
    3030/* This PRINTDLGA internal structure stores
    3131 * pointers to several throughout useful structures.
    32  *
    33  */
    34 typedef struct
     32 * 
     33 */
     34typedef struct 
    3535{
    3636  LPDEVMODEA        lpDevMode;
    3737  struct {
    3838      LPPRINTDLGA       lpPrintDlg;
    39       LPPRINTDLG16  lpPrintDlg16;
     39      LPPRINTDLG16      lpPrintDlg16;
    4040  } dlg;
    4141  LPPRINTER_INFO_2A lpPrinterInfo;
     
    108108 *
    109109 * Returns the default printer name in buf.
    110  * Even under WinNT/2000 default printer is retrieved via GetProfileString -
     110 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 
    111111 * these entries are mapped somewhere in the registry rather than win.ini.
    112112 *
     
    118118
    119119    if(!GetProfileStringA("windows", "device", "", buf, len)) {
    120     TRACE("No profile entry for default printer found.\n");
    121     return FALSE;
     120        TRACE("No profile entry for default printer found.\n");
     121        return FALSE;
    122122    }
    123123    if((ptr = strchr(buf, ',')) == NULL) {
    124     FIXME("bad format for default printer (%s)!\n",buf);
    125     return FALSE;
     124        FIXME("bad format for default printer (%s)!\n",buf);
     125        return FALSE;
    126126    }
    127127    *ptr = '\0';
     
    145145    res = OpenPrinterA(buf, hprn, NULL);
    146146    if (!res)
    147     FIXME("Could not open printer %s?!\n",buf);
     147        FIXME("Could not open printer %s?!\n",buf);
    148148    return res;
    149149}
     
    169169    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
    170170    pi = HeapAlloc(GetProcessHeap(), 0, needed);
    171     EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
    172           &num);
     171    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 
     172                  &num);
    173173
    174174    for(i = 0; i < num; i++) {
    175175        SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
    176                 (LPARAM)pi[i].pPrinterName );
     176                            (LPARAM)pi[i].pPrinterName );
    177177    }
    178178    HeapFree(GetProcessHeap(), 0, pi);
    179179    if(!name ||
    180180       (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1,
    181                 (LPARAM)name)) == CB_ERR) {
     181                                (LPARAM)name)) == CB_ERR) {
    182182
    183183        char buf[260];
    184184        FIXME("Can't find '%s' in printer list so trying to find default\n",
    185           name);
    186     if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))
    187         return num;
    188     i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
    189     if(i == CB_ERR)
    190         FIXME("Can't find default printer in printer list\n");
     185              name);
     186        if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))
     187            return num;
     188        i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
     189        if(i == CB_ERR)
     190            FIXME("Can't find default printer in printer list\n");
    191191    }
    192192    SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0);
     
    202202 *  (NB. when we handle unicode the offsets will be in wchars).
    203203 */
    204 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName,
    205                     char* DeviceName, char* OutputPort)
     204static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 
     205                                    char* DeviceName, char* OutputPort)
    206206{
    207207    long size;
     
    215215            + strlen(OutputPort) + 1
    216216            + sizeof(DEVNAMES);
    217 
     217           
    218218    if(*hmem)
    219219        *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
     
    233233    strcpy(pTempPtr, DeviceName);
    234234    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
    235 
     235       
    236236    pTempPtr += strlen(DeviceName) + 1;
    237237    strcpy(pTempPtr, OutputPort);
     
    244244}
    245245#ifndef __WIN32OS2__
    246 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName,
    247                       char* DeviceName, char* OutputPort)
     246static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 
     247                                      char* DeviceName, char* OutputPort)
    248248{
    249249    long size;
     
    257257            + strlen(OutputPort) + 1
    258258            + sizeof(DEVNAMES);
    259 
     259           
    260260    if(*hmem)
    261261        *hmem = GlobalReAlloc16(*hmem, size, GMEM_MOVEABLE);
     
    275275    strcpy(pTempPtr, DeviceName);
    276276    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
    277 
     277       
    278278    pTempPtr += strlen(DeviceName) + 1;
    279279    strcpy(pTempPtr, OutputPort);
     
    292292 *
    293293 *   updates the PrintDlg structure for returnvalues.
    294  *
     294 *     
    295295 * RETURNS
    296296 *   FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
    297297 *   TRUE  if succesful.
    298298 */
    299 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg,
    300                     PRINT_PTRA* PrintStructures)
     299static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 
     300                                    PRINT_PTRA* PrintStructures)
    301301{
    302302    LPPRINTDLGA       lppd = PrintStructures->dlg.lpPrintDlg;
     
    306306
    307307    if(!lpdm) {
    308     FIXME("No lpdm ptr?\n");
    309     return FALSE;
     308        FIXME("No lpdm ptr?\n");
     309        return FALSE;
    310310    }
    311311
     
    313313    if(!(lppd->Flags & PD_PRINTSETUP)) {
    314314        /* check whether nFromPage and nToPage are within range defined by
    315     * nMinPage and nMaxPage
    316     */
     315        * nMinPage and nMaxPage
     316        */
    317317        if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */
    318         WORD nToPage;
    319         WORD nFromPage;
    320         nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
    321         nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
    322         if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
    323         nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
    324             char resourcestr[256];
    325         char resultstr[256];
    326         LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
    327                 resourcestr, 255);
    328         sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
    329         LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE,
    330                 resourcestr, 255);
    331         MessageBoxA(hDlg, resultstr, resourcestr,
    332                 MB_OK | MB_ICONWARNING);
    333         return FALSE;
    334         }
    335         lppd->nFromPage = nFromPage;
    336         lppd->nToPage   = nToPage;
    337     }
    338 
    339     if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
    340         lppd->Flags |= PD_PRINTTOFILE;
    341         pi->pPortName = "FILE:";
    342     }
    343 
    344     if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
    345         FIXME("Collate lppd not yet implemented as output\n");
    346     }
    347 
    348     /* set PD_Collate and nCopies */
    349     if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
    350       /*  The application doesn't support multiple copies or collate...
    351        */
    352         lppd->Flags &= ~PD_COLLATE;
    353         lppd->nCopies = 1;
    354       /* if the printer driver supports it... store info there
    355        * otherwise no collate & multiple copies !
    356        */
    357         if (lpdm->dmFields & DM_COLLATE)
    358             lpdm->dmCollate =
    359           (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
    360         if (lpdm->dmFields & DM_COPIES)
    361             lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    362     } else {
    363         if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
    364             lppd->Flags |= PD_COLLATE;
     318            WORD nToPage;
     319            WORD nFromPage;
     320            nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
     321            nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
     322            if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
     323                nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
     324                char resourcestr[256];
     325                char resultstr[256];
     326                LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
     327                            resourcestr, 255);
     328                sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
     329                LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE,
     330                            resourcestr, 255);
     331                MessageBoxA(hDlg, resultstr, resourcestr,
     332                            MB_OK | MB_ICONWARNING);
     333                return FALSE;
     334            }
     335            lppd->nFromPage = nFromPage;
     336            lppd->nToPage   = nToPage;
     337        }
     338
     339        if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
     340            lppd->Flags |= PD_PRINTTOFILE;
     341            pi->pPortName = "FILE:";
     342        }
     343
     344        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
     345            FIXME("Collate lppd not yet implemented as output\n");
     346        }
     347
     348        /* set PD_Collate and nCopies */
     349        if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
     350          /*  The application doesn't support multiple copies or collate...
     351           */
     352            lppd->Flags &= ~PD_COLLATE;
     353            lppd->nCopies = 1;
     354          /* if the printer driver supports it... store info there
     355           * otherwise no collate & multiple copies !
     356           */
     357            if (lpdm->dmFields & DM_COLLATE)
     358                lpdm->dmCollate =
     359                  (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
     360            if (lpdm->dmFields & DM_COPIES)
     361                lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
     362        } else {
     363            if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
     364                lppd->Flags |= PD_COLLATE;
    365365            else
    366366               lppd->Flags &= ~PD_COLLATE;
    367367            lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    368     }
     368        }
    369369    }
    370370    return TRUE;
     
    372372
    373373static BOOL PRINTDLG_PaperSize(
    374     PRINTDLGA   *pdlga,const char *PaperSize,LPPOINT size
     374        PRINTDLGA       *pdlga,const char *PaperSize,LPPOINT size
    375375) {
    376     DEVNAMES    *dn;
    377     DEVMODEA    *dm;
    378     LPSTR   devname,portname;
    379     int     i;
    380     DWORD   NrOfEntries,ret;
    381     char    *Names = NULL;
    382     POINT   *points = NULL;
    383     BOOL    retval = FALSE;
    384 
     376    DEVNAMES    *dn;
     377    DEVMODEA    *dm;
     378    LPSTR       devname,portname;
     379    int         i;
     380    DWORD       NrOfEntries,ret;
     381    char        *Names = NULL;
     382    POINT       *points = NULL;
     383    BOOL        retval = FALSE;
     384   
    385385    dn = GlobalLock(pdlga->hDevNames);
    386386    dm = GlobalLock(pdlga->hDevMode);
    387     devname = ((char*)dn)+dn->wDeviceOffset;
    388     portname    = ((char*)dn)+dn->wOutputOffset;
     387    devname     = ((char*)dn)+dn->wDeviceOffset;
     388    portname    = ((char*)dn)+dn->wOutputOffset;
    389389
    390390
    391391    NrOfEntries = DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,NULL,dm);
    392392    if (!NrOfEntries) {
    393     FIXME("No papernames found for %s/%s\n",devname,portname);
    394     goto out;
     393        FIXME("No papernames found for %s/%s\n",devname,portname);
     394        goto out;
    395395    }
    396396    Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64);
    397397    if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) {
    398     FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret);
    399     goto out;
     398        FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret);
     399        goto out;
    400400    }
    401401    for (i=0;i<NrOfEntries;i++)
    402     if (!strcmp(PaperSize,Names+(64*i)))
    403         break;
     402        if (!strcmp(PaperSize,Names+(64*i)))
     403            break;
    404404    HeapFree(GetProcessHeap(),0,Names);
    405405    if (i==NrOfEntries) {
    406     FIXME("Papersize %s not found in list?\n",PaperSize);
    407     goto out;
     406        FIXME("Papersize %s not found in list?\n",PaperSize);
     407        goto out;
    408408    }
    409409    points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries);
    410410    if (NrOfEntries!=(ret=DeviceCapabilitiesA(devname,portname,DC_PAPERSIZE,(LPBYTE)points,dm))) {
    411     FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret);
    412     goto out;
     411        FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret);
     412        goto out;
    413413    }
    414414    /* this is _10ths_ of a millimeter */
     
    434434 */
    435435static BOOL PRINTDLG_SetUpPaperComboBox(HWND hDlg,
    436                     int   nIDComboBox,
    437                     char* PrinterName,
    438                     char* PortName,
    439                     LPDEVMODEA dm)
     436                                        int   nIDComboBox,
     437                                        char* PrinterName,
     438                                        char* PortName,
     439                                        LPDEVMODEA dm)
    440440{
    441441    int     i;
     
    448448    int     fwCapability_Names;
    449449    int     fwCapability_Words;
    450 
     450   
    451451    TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox);
    452 
     452   
    453453    /* query the dialog box for the current selected value */
    454454    Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
     
    498498         fwCapability_Words = DC_BINS;
    499499    }
    500 
    501     /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
     500   
     501    /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 
    502502     * paper settings. As Wine doesn't allow VXDs, this results in a crash.
    503503     */
     
    511511       != NrOfEntries) {
    512512        ERR("Number of caps is different\n");
    513     NrOfEntries = 0;
     513        NrOfEntries = 0;
    514514    }
    515515
     
    519519                                      fwCapability_Names, Names, dm);
    520520    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
    521                       fwCapability_Words, (LPSTR)Words, dm);
     521                                      fwCapability_Words, (LPSTR)Words, dm);
    522522
    523523    /* reset any current content in the combobox */
    524524    SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
    525 
     525   
    526526    /* store new content */
    527527    for (i = 0; i < NrOfEntries; i++) {
    528528        DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0,
    529                     (LPARAM)(&Names[i*NamesSize]) );
    530     SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
    531                 Words[i]);
     529                                        (LPARAM)(&Names[i*NamesSize]) );
     530        SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
     531                            Words[i]);
    532532    }
    533533
     
    537537    for (i = 0; i < NrOfEntries; i++) {
    538538        if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
    539        oldWord) {
    540         Sel = i;
    541         break;
    542     }
     539           oldWord) {
     540            Sel = i;
     541            break;
     542        }
    543543    }
    544544    SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
     
    564564    for (i = 0; i < 25; i++) {
    565565        if (pi->Status & (1<<i)) {
    566         LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i,
    567             ResourceString, 255);
    568         strcat(StatusMsg,ResourceString);
     566            LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i,
     567                        ResourceString, 255);
     568            strcat(StatusMsg,ResourceString);
    569569        }
    570570    }
    571571    /* append "ready" */
    572     /* FIXME: status==ready must only be appended if really so.
     572    /* FIXME: status==ready must only be appended if really so. 
    573573              but how to detect? */
    574     LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY,
    575         ResourceString, 255);
     574    LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 
     575                ResourceString, 255);
    576576    strcat(StatusMsg,ResourceString);
    577 
     577 
    578578    SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg);
    579579
     
    585585        SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName);
    586586    SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ?
    587             pi->pComment : ""));
     587                        pi->pComment : ""));
    588588    return;
    589589}
     
    596596 */
    597597static BOOL PRINTDLG_ChangePrinter(HWND hDlg, char *name,
    598                    PRINT_PTRA *PrintStructures)
     598                                   PRINT_PTRA *PrintStructures)
    599599{
    600600    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    610610    if(!OpenPrinterA(name, &hprn, NULL)) {
    611611        ERR("Can't open printer %s\n", name);
    612     return FALSE;
     612        return FALSE;
    613613    }
    614614    GetPrinterA(hprn, 2, NULL, 0, &needed);
    615615    PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
    616616    GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
    617         &needed);
     617                &needed);
    618618    GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    619619    PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
    620620    if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
    621         needed, &needed)) {
    622     ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
    623     return FALSE;
     621            needed, &needed)) {
     622        ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
     623        return FALSE;
    624624    }
    625625    ClosePrinter(hprn);
     
    629629    if(PrintStructures->lpDevMode) {
    630630        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    631     PrintStructures->lpDevMode = NULL;
     631        PrintStructures->lpDevMode = NULL;
    632632    }
    633633
     
    635635    if(dmSize == -1) {
    636636        ERR("DocumentProperties fails on %s\n", debugstr_a(name));
    637     return FALSE;
     637        return FALSE;
    638638    }
    639639    PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
    640640    dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
    641                 DM_OUT_BUFFER);
     641                                DM_OUT_BUFFER);
    642642    if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
    643               !strcmp(lpdm->dmDeviceName,
    644                   PrintStructures->lpDevMode->dmDeviceName)) {
     643                          !strcmp(lpdm->dmDeviceName,
     644                                  PrintStructures->lpDevMode->dmDeviceName)) {
    645645      /* Supplied devicemode matches current printer so try to use it */
    646646        DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
    647                 DM_OUT_BUFFER | DM_IN_BUFFER);
     647                            DM_OUT_BUFFER | DM_IN_BUFFER);
    648648    }
    649649    if(lpdm)
     
    655655      /* Print range (All/Range/Selection) */
    656656        SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
    657     SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
    658     CheckRadioButton(hDlg, rad1, rad3, rad1);       /* default */
    659     if (lppd->Flags & PD_NOSELECTION)
    660         EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
    661     else
    662         if (lppd->Flags & PD_SELECTION)
    663             CheckRadioButton(hDlg, rad1, rad3, rad2);
    664     if (lppd->Flags & PD_NOPAGENUMS) {
    665         EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
    666         EnableWindow(GetDlgItem(hDlg, stc2),FALSE);
    667         EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
    668         EnableWindow(GetDlgItem(hDlg, stc3),FALSE);
    669         EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
    670     } else {
    671         if (lppd->Flags & PD_PAGENUMS)
    672             CheckRadioButton(hDlg, rad1, rad3, rad3);
    673     }
    674     /* "All xxx pages"... */
    675     {
    676         char        resourcestr[64];
    677         char        result[64];
    678         LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES,
    679             resourcestr, 49);
    680         sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
    681         SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
    682     }
    683 
    684     /* Collate pages
    685     *
    686     * FIXME: The ico3 is not displayed for some reason. I don't know why.
    687     */
    688     if (lppd->Flags & PD_COLLATE) {
    689         SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    690                 (LPARAM)PrintStructures->hCollateIcon);
    691         CheckDlgButton(hDlg, chx2, 1);
    692     } else {
    693         SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    694                 (LPARAM)PrintStructures->hNoCollateIcon);
    695         CheckDlgButton(hDlg, chx2, 0);
    696     }
    697 
    698     if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
    699       /* if printer doesn't support it: no Collate */
    700         if (!(lpdm->dmFields & DM_COLLATE)) {
    701             EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
    702         EnableWindow(GetDlgItem(hDlg, ico3), FALSE);
    703         }
    704     }
    705 
    706     /* nCopies */
    707     {
    708       INT copies;
    709       if (lppd->hDevMode == 0)
    710           copies = lppd->nCopies;
    711       else
    712           copies = lpdm->dmCopies;
    713       if(copies == 0) copies = 1;
    714       else if(copies < 0) copies = MAX_COPIES;
    715       SetDlgItemInt(hDlg, edt3, copies, FALSE);
    716     }
    717 
    718     if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
    719       /* if printer doesn't support it: no nCopies */
    720         if (!(lpdm->dmFields & DM_COPIES)) {
    721             EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
    722         EnableWindow(GetDlgItem(hDlg, stc5), FALSE);
    723         }
    724     }
    725 
    726     /* print to file */
    727     CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
    728     if (lppd->Flags & PD_DISABLEPRINTTOFILE)
    729             EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
    730     if (lppd->Flags & PD_HIDEPRINTTOFILE)
     657        SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
     658        CheckRadioButton(hDlg, rad1, rad3, rad1);               /* default */
     659        if (lppd->Flags & PD_NOSELECTION)
     660            EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
     661        else
     662            if (lppd->Flags & PD_SELECTION)
     663                CheckRadioButton(hDlg, rad1, rad3, rad2);
     664        if (lppd->Flags & PD_NOPAGENUMS) {
     665            EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
     666            EnableWindow(GetDlgItem(hDlg, stc2),FALSE);
     667            EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
     668            EnableWindow(GetDlgItem(hDlg, stc3),FALSE);
     669            EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
     670        } else {
     671            if (lppd->Flags & PD_PAGENUMS)
     672                CheckRadioButton(hDlg, rad1, rad3, rad3);
     673        }
     674        /* "All xxx pages"... */
     675        {
     676            char        resourcestr[64];
     677            char        result[64];
     678            LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES,
     679                        resourcestr, 49);
     680            sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
     681            SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
     682        }
     683       
     684        /* Collate pages
     685        *
     686        * FIXME: The ico3 is not displayed for some reason. I don't know why.
     687        */
     688        if (lppd->Flags & PD_COLLATE) {
     689            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
     690                                (LPARAM)PrintStructures->hCollateIcon);
     691            CheckDlgButton(hDlg, chx2, 1);
     692        } else {
     693            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
     694                                (LPARAM)PrintStructures->hNoCollateIcon);
     695            CheckDlgButton(hDlg, chx2, 0);
     696        }
     697
     698        if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
     699          /* if printer doesn't support it: no Collate */
     700            if (!(lpdm->dmFields & DM_COLLATE)) {
     701                EnableWindow(GetDlgItem(hDlg, chx2), FALSE);   
     702                EnableWindow(GetDlgItem(hDlg, ico3), FALSE);   
     703            }
     704        }
     705
     706        /* nCopies */
     707        {
     708          INT copies;
     709          if (lppd->hDevMode == 0)
     710              copies = lppd->nCopies;
     711          else
     712              copies = lpdm->dmCopies;
     713          if(copies == 0) copies = 1;
     714          else if(copies < 0) copies = MAX_COPIES;
     715          SetDlgItemInt(hDlg, edt3, copies, FALSE);
     716        }
     717
     718        if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
     719          /* if printer doesn't support it: no nCopies */
     720            if (!(lpdm->dmFields & DM_COPIES)) {
     721                EnableWindow(GetDlgItem(hDlg, edt3), FALSE);   
     722                EnableWindow(GetDlgItem(hDlg, stc5), FALSE);   
     723            }
     724        }
     725
     726        /* print to file */
     727        CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
     728        if (lppd->Flags & PD_DISABLEPRINTTOFILE)
     729            EnableWindow(GetDlgItem(hDlg, chx1), FALSE);   
     730        if (lppd->Flags & PD_HIDEPRINTTOFILE)
    731731            ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
    732732
     
    739739
    740740      PRINTDLG_SetUpPaperComboBox(hDlg, cmb2,
    741                   PrintStructures->lpPrinterInfo->pPrinterName,
    742                   PrintStructures->lpPrinterInfo->pPortName,
    743                   lpdm);
     741                                  PrintStructures->lpPrinterInfo->pPrinterName,
     742                                  PrintStructures->lpPrinterInfo->pPortName,
     743                                  lpdm);
    744744      PRINTDLG_SetUpPaperComboBox(hDlg, cmb3,
    745                   PrintStructures->lpPrinterInfo->pPrinterName,
    746                   PrintStructures->lpPrinterInfo->pPortName,
    747                   lpdm);
     745                                  PrintStructures->lpPrinterInfo->pPrinterName,
     746                                  PrintStructures->lpPrinterInfo->pPortName,
     747                                  lpdm);
    748748      CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
    749749      SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    750750                          (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
    751751                                   PrintStructures->hLandscapeIcon));
    752 
     752     
    753753    }
    754754
     
    756756    if ((lppd->Flags & PD_SHOWHELP)==0) {
    757757        /* hide if PD_SHOWHELP not specified */
    758         ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
     758        ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);         
    759759    }
    760760    return TRUE;
     
    765765 */
    766766static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
    767                      PRINT_PTRA* PrintStructures)
     767                                     PRINT_PTRA* PrintStructures)
    768768{
    769769    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    778778    PrintStructures->hCollateIcon =
    779779      LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
    780     PrintStructures->hNoCollateIcon =
     780    PrintStructures->hNoCollateIcon = 
    781781      LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
    782782
     
    792792       PrintStructures->hLandscapeIcon == 0) {
    793793        ERR("no icon in resourcefile\n");
    794     COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    795     EndDialog(hDlg, FALSE);
     794        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     795        EndDialog(hDlg, FALSE);
    796796    }
    797797
     
    801801     */
    802802    if (lppd->Flags & PD_SHOWHELP) {
    803         if((PrintStructures->HelpMessageID =
    804         RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
    805         COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    806         return FALSE;
    807     }
     803        if((PrintStructures->HelpMessageID = 
     804            RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
     805            COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     806            return FALSE;
     807        }
    808808    } else
    809809        PrintStructures->HelpMessageID = 0;
     
    811811    if(!(lppd->Flags &PD_PRINTSETUP)) {
    812812        PrintStructures->hwndUpDown =
    813       CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
    814                   UDS_NOTHOUSANDS | UDS_ARROWKEYS |
    815                   UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
    816                   hDlg, UPDOWN_ID, COMDLG32_hInstance,
    817                   GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
     813          CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
     814                              UDS_NOTHOUSANDS | UDS_ARROWKEYS |
     815                              UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
     816                              hDlg, UPDOWN_ID, COMDLG32_hInstance,
     817                              GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
    818818    }
    819819
     
    823823     */
    824824    if (lppd->nMaxPage < lppd->nMinPage)
    825         lppd->nMaxPage = lppd->nMinPage;
    826     if (lppd->nMinPage == lppd->nMaxPage)
    827         lppd->Flags |= PD_NOPAGENUMS;
     825        lppd->nMaxPage = lppd->nMinPage;
     826    if (lppd->nMinPage == lppd->nMaxPage) 
     827        lppd->Flags |= PD_NOPAGENUMS;       
    828828    if (lppd->nToPage < lppd->nMinPage)
    829829        lppd->nToPage = lppd->nMinPage;
     
    837837    /* if we have the combo box, fill it */
    838838    if (GetDlgItem(hDlg,comboID)) {
    839     /* Fill Combobox
    840     */
    841     pdn = GlobalLock(lppd->hDevNames);
    842     pdm = GlobalLock(lppd->hDevMode);
    843     if(pdn)
    844         name = (char*)pdn + pdn->wDeviceOffset;
    845     else if(pdm)
    846         name = pdm->dmDeviceName;
    847     PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
    848     if(pdm) GlobalUnlock(lppd->hDevMode);
    849     if(pdn) GlobalUnlock(lppd->hDevNames);
    850 
    851     /* Now find selected printer and update rest of dlg */
    852     name = HeapAlloc(GetProcessHeap(),0,256);
    853     if (GetDlgItemTextA(hDlg, comboID, name, 255))
    854         PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    855     HeapFree(GetProcessHeap(),0,name);
     839        /* Fill Combobox
     840        */
     841        pdn = GlobalLock(lppd->hDevNames);
     842        pdm = GlobalLock(lppd->hDevMode);
     843        if(pdn)
     844            name = (char*)pdn + pdn->wDeviceOffset;
     845        else if(pdm)
     846            name = pdm->dmDeviceName;
     847        PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
     848        if(pdm) GlobalUnlock(lppd->hDevMode);
     849        if(pdn) GlobalUnlock(lppd->hDevNames);
     850
     851        /* Now find selected printer and update rest of dlg */
     852        name = HeapAlloc(GetProcessHeap(),0,256);
     853        if (GetDlgItemTextA(hDlg, comboID, name, 255))
     854            PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     855        HeapFree(GetProcessHeap(),0,name);
    856856    } else {
    857     /* else use default printer */
    858     char name[200];
    859     BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
    860 
    861     if (ret)
    862         PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    863     else
    864         FIXME("No default printer found, expect problems!\n");
     857        /* else use default printer */
     858        char name[200];
     859        BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
     860
     861        if (ret)
     862            PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     863        else
     864            FIXME("No default printer found, expect problems!\n");
    865865    }
    866866    return TRUE;
     
    872872 */
    873873static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam,
    874                      PRINT_PTRA* PrintStructures)
     874                                     PRINT_PTRA* PrintStructures)
    875875{
    876876    LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16;
     
    883883    PrintStructures->hCollateIcon =
    884884      LoadIconA(COMDLG32_hInstance, "PD32_COLLATE");
    885     PrintStructures->hNoCollateIcon =
     885    PrintStructures->hNoCollateIcon = 
    886886      LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE");
    887887    if(PrintStructures->hCollateIcon == 0 ||
    888888       PrintStructures->hNoCollateIcon == 0) {
    889889        ERR("no icon in resourcefile\n");
    890     COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    891     EndDialog(hDlg, FALSE);
     890        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     891        EndDialog(hDlg, FALSE);
    892892    }
    893893
     
    900900     */
    901901    if (lppd->Flags & PD_SHOWHELP) {
    902         if((PrintStructures->HelpMessageID =
    903         RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
    904         COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    905         return FALSE;
    906     }
     902        if((PrintStructures->HelpMessageID = 
     903            RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
     904            COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     905            return FALSE;
     906        }
    907907    } else
    908908        PrintStructures->HelpMessageID = 0;
    909909
    910910    if (!(lppd->Flags & PD_PRINTSETUP)) {
    911     /* We have a print quality combo box. What shall we do? */
    912     if (GetDlgItem(hDlg,cmb1)) {
    913         char buf [20];
    914 
    915         FIXME("Print quality only displaying currently.\n");
    916 
    917         pdm = GlobalLock16(lppd->hDevMode);
    918         if(pdm) {
    919         switch (pdm->dmPrintQuality) {
    920         case DMRES_HIGH     : strcpy(buf,"High");break;
    921         case DMRES_MEDIUM   : strcpy(buf,"Medium");break;
    922         case DMRES_LOW      : strcpy(buf,"Low");break;
    923         case DMRES_DRAFT    : strcpy(buf,"Draft");break;
    924         case 0          : strcpy(buf,"Default");break;
    925         default         : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break;
    926         }
    927             GlobalUnlock16(lppd->hDevMode);
    928         } else
    929         strcpy(buf,"Default");
    930         SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf);
    931         SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
    932         EnableWindow(GetDlgItem(hDlg,cmb1),FALSE);
    933     }
     911        /* We have a print quality combo box. What shall we do? */
     912        if (GetDlgItem(hDlg,cmb1)) {
     913            char buf [20];
     914
     915            FIXME("Print quality only displaying currently.\n");
     916
     917            pdm = GlobalLock16(lppd->hDevMode);
     918            if(pdm) {
     919                switch (pdm->dmPrintQuality) {
     920                case DMRES_HIGH         : strcpy(buf,"High");break;
     921                case DMRES_MEDIUM       : strcpy(buf,"Medium");break;
     922                case DMRES_LOW          : strcpy(buf,"Low");break;
     923                case DMRES_DRAFT        : strcpy(buf,"Draft");break;
     924                case 0                  : strcpy(buf,"Default");break;
     925                default                 : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break;
     926                }
     927                GlobalUnlock16(lppd->hDevMode);
     928            } else
     929                strcpy(buf,"Default");
     930            SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf);
     931            SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
     932            EnableWindow(GetDlgItem(hDlg,cmb1),FALSE);
     933        }
    934934    }
    935935
     
    939939     */
    940940    if (lppd->nMaxPage < lppd->nMinPage)
    941         lppd->nMaxPage = lppd->nMinPage;
    942     if (lppd->nMinPage == lppd->nMaxPage)
    943         lppd->Flags |= PD_NOPAGENUMS;
     941        lppd->nMaxPage = lppd->nMinPage;
     942    if (lppd->nMinPage == lppd->nMaxPage) 
     943        lppd->Flags |= PD_NOPAGENUMS;       
    944944    if (lppd->nToPage < lppd->nMinPage)
    945945        lppd->nToPage = lppd->nMinPage;
     
    953953    /* If the printer combo box is in the dialog, fill it */
    954954    if (GetDlgItem(hDlg,comboID)) {
    955     /* Fill Combobox
    956     */
    957     pdn = GlobalLock16(lppd->hDevNames);
    958     pdm = GlobalLock16(lppd->hDevMode);
    959     if(pdn)
    960         name = (char*)pdn + pdn->wDeviceOffset;
    961     else if(pdm)
    962         name = pdm->dmDeviceName;
    963     PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
    964     if(pdm) GlobalUnlock16(lppd->hDevMode);
    965     if(pdn) GlobalUnlock16(lppd->hDevNames);
    966 
    967     /* Now find selected printer and update rest of dlg */
    968     name = HeapAlloc(GetProcessHeap(),0,256);
    969     if (GetDlgItemTextA(hDlg, comboID, name, 255))
    970         PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     955        /* Fill Combobox
     956        */
     957        pdn = GlobalLock16(lppd->hDevNames);
     958        pdm = GlobalLock16(lppd->hDevMode);
     959        if(pdn)
     960            name = (char*)pdn + pdn->wDeviceOffset;
     961        else if(pdm)
     962            name = pdm->dmDeviceName;
     963        PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
     964        if(pdm) GlobalUnlock16(lppd->hDevMode);
     965        if(pdn) GlobalUnlock16(lppd->hDevNames);
     966
     967        /* Now find selected printer and update rest of dlg */
     968        name = HeapAlloc(GetProcessHeap(),0,256);
     969        if (GetDlgItemTextA(hDlg, comboID, name, 255))
     970            PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    971971    } else {
    972     /* else just use default printer */
    973     char name[200];
    974     BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
    975 
    976     if (ret)
    977         PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    978     else
    979         FIXME("No default printer found, expect problems!\n");
     972        /* else just use default printer */
     973        char name[200];
     974        BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
     975
     976        if (ret)
     977            PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     978        else
     979            FIXME("No default printer found, expect problems!\n");
    980980    }
    981981    HeapFree(GetProcessHeap(),0,name);
     
    988988 *                              PRINTDLG_WMCommand               [internal]
    989989 */
    990 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam,
    991             LPARAM lParam, PRINT_PTRA* PrintStructures)
     990static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 
     991                        LPARAM lParam, PRINT_PTRA* PrintStructures)
    992992{
    993993    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    999999        TRACE(" OK button was hit\n");
    10001000        if (PRINTDLG_UpdatePrintDlg(hDlg, PrintStructures)!=TRUE) {
    1001         FIXME("Update printdlg was not successful!\n");
    1002         return(FALSE);
    1003     }
    1004     EndDialog(hDlg, TRUE);
    1005     return(TRUE);
     1001            FIXME("Update printdlg was not successful!\n");
     1002            return(FALSE);
     1003        }
     1004        EndDialog(hDlg, TRUE);
     1005        return(TRUE);
    10061006
    10071007    case IDCANCEL:
    10081008        TRACE(" CANCEL button was hit\n");
    10091009        EndDialog(hDlg, FALSE);
    1010     return(FALSE);
     1010        return(FALSE);
    10111011
    10121012     case pshHelp:
    10131013        TRACE(" HELP button was hit\n");
    1014         SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID,
    1015                     (WPARAM) hDlg, (LPARAM) lppd);
     1014        SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 
     1015                                (WPARAM) hDlg, (LPARAM) lppd);
    10161016        break;
    10171017
    10181018     case chx2:                         /* collate pages checkbox */
    10191019        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
    1020             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
     1020            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
    10211021                                    (LPARAM)PrintStructures->hCollateIcon);
    10221022        else
    1023             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
     1023            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
    10241024                                    (LPARAM)PrintStructures->hNoCollateIcon);
    1025         break;
     1025        break;       
    10261026     case edt1:                         /* from page nr editbox */
    10271027     case edt2:                         /* to page nr editbox */
    10281028        if (HIWORD(wParam)==EN_CHANGE) {
    1029         WORD nToPage;
    1030         WORD nFromPage;
    1031         nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
    1032         nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
     1029            WORD nToPage;
     1030            WORD nFromPage;
     1031            nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
     1032            nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
    10331033            if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
    1034             CheckRadioButton(hDlg, rad1, rad3, rad3);
    1035     }
     1034                CheckRadioButton(hDlg, rad1, rad3, rad3);
     1035        }
    10361036        break;
    10371037
    10381038    case edt3:
    10391039        if(HIWORD(wParam) == EN_CHANGE) {
    1040         INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    1041         if(copies <= 1)
    1042             EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
    1043         else
    1044             EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
    1045     }
    1046     break;
     1040            INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
     1041            if(copies <= 1)
     1042                EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
     1043            else
     1044                EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
     1045        }
     1046        break;
    10471047
    10481048#ifndef __WIN32OS2__
    10491049     case psh1:                       /* Print Setup */
    1050     {
    1051         PRINTDLG16  pdlg;
    1052 
    1053         if (!PrintStructures->dlg.lpPrintDlg16) {
    1054         FIXME("The 32bit print dialog does not have this button!?\n");
    1055         break;
    1056         }
    1057 
    1058         memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg));
    1059         pdlg.Flags |= PD_PRINTSETUP;
    1060         pdlg.hwndOwner = hDlg;
    1061         if (!PrintDlg16(&pdlg))
    1062         break;
    1063     }
    1064     break;
     1050        {
     1051            PRINTDLG16  pdlg;
     1052           
     1053            if (!PrintStructures->dlg.lpPrintDlg16) {
     1054                FIXME("The 32bit print dialog does not have this button!?\n");
     1055                break;
     1056            }
     1057
     1058            memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg));
     1059            pdlg.Flags |= PD_PRINTSETUP;
     1060            pdlg.hwndOwner = hDlg;
     1061            if (!PrintDlg16(&pdlg))
     1062                break;
     1063        }
     1064        break;
    10651065#endif
    10661066
     
    10721072         GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
    10731073         if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) {
    1074          FIXME(" Call to OpenPrinter did not succeed!\n");
    1075          break;
    1076     }
    1077      DocumentPropertiesA(hDlg, hPrinter, PrinterName,
    1078                  PrintStructures->lpDevMode,
    1079                  PrintStructures->lpDevMode,
    1080                  DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
    1081     ClosePrinter(hPrinter);
     1074             FIXME(" Call to OpenPrinter did not succeed!\n");
     1075             break;
     1076        }
     1077         DocumentPropertiesA(hDlg, hPrinter, PrinterName,
     1078                             PrintStructures->lpDevMode,
     1079                             PrintStructures->lpDevMode,
     1080                             DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
     1081        ClosePrinter(hPrinter);
    10821082         break;
    10831083       }
     
    10951095        }
    10961096        break;
    1097 
     1097           
    10981098    case rad2: /* Paperorientation */
    10991099        if (lppd->Flags & PD_PRINTSETUP)
     
    11081108        }
    11091109        break;
    1110 
     1110           
    11111111    case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
    1112     if (PrinterComboID != wParam) {
    1113          FIXME("No handling for print quality combo box yet.\n");
    1114          break;
    1115     }
    1116     /* FALLTHROUGH */
     1112        if (PrinterComboID != wParam) {
     1113             FIXME("No handling for print quality combo box yet.\n");
     1114             break;
     1115        }
     1116        /* FALLTHROUGH */
    11171117    case cmb4:                         /* Printer combobox */
    11181118         if (HIWORD(wParam)==CBN_SELCHANGE) {
    1119          char   PrinterName[256];
    1120          GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
    1121          PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures);
    1122     }
    1123     break;
     1119             char   PrinterName[256];
     1120             GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
     1121             PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures);
     1122        }
     1123        break;
    11241124
    11251125    case cmb2: /* Papersize */
    11261126      {
    1127       DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
    1128       if(Sel != CB_ERR)
     1127          DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
     1128          if(Sel != CB_ERR)
    11291129#ifdef __WIN32OS2__
    1130           lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
     1130              lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
    11311131#else
    1132           lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
     1132              lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
    11331133#endif
    1134                                 CB_GETITEMDATA,
    1135                                 Sel, 0);
     1134                                                            CB_GETITEMDATA,
     1135                                                            Sel, 0);
    11361136      }
    11371137      break;
     
    11391139    case cmb3: /* Bin */
    11401140      {
    1141       DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
    1142       if(Sel != CB_ERR)
    1143           lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,
    1144                               CB_GETITEMDATA, Sel,
    1145                               0);
     1141          DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
     1142          if(Sel != CB_ERR)
     1143              lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,
     1144                                                          CB_GETITEMDATA, Sel,
     1145                                                          0);
    11461146      }
    1147       break;
     1147      break; 
    11481148    }
    11491149    if(lppd->Flags & PD_PRINTSETUP) {
    11501150        switch (LOWORD(wParam)) {
    1151     case rad1:                         /* orientation */
    1152     case rad2:
    1153         if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
     1151        case rad1:                         /* orientation */
     1152        case rad2:
     1153            if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
    11541154#ifdef __WIN32OS2__
    1155             if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
    1156             lpdm->dmOrientation = DMORIENT_PORTRAIT;
     1155                if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
     1156                    lpdm->dmOrientation = DMORIENT_PORTRAIT;
    11571157#else
    1158             if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
    1159             lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
     1158                if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
     1159                    lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
    11601160#endif
    1161             SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
    1162                     (WPARAM)IMAGE_ICON,
    1163                     (LPARAM)PrintStructures->hPortraitIcon);
    1164             SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
    1165                     (WPARAM)IMAGE_ICON,
    1166                     (LPARAM)PrintStructures->hPortraitIcon);
    1167         }
    1168         } else {
     1161                    SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
     1162                                        (WPARAM)IMAGE_ICON,
     1163                                        (LPARAM)PrintStructures->hPortraitIcon);
     1164                    SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
     1165                                        (WPARAM)IMAGE_ICON,
     1166                                        (LPARAM)PrintStructures->hPortraitIcon);
     1167                }
     1168            } else {
    11691169#ifdef __WIN32OS2__
    1170             if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
    1171             lpdm->dmOrientation = DMORIENT_LANDSCAPE;
     1170                if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
     1171                    lpdm->dmOrientation = DMORIENT_LANDSCAPE;
    11721172#else
    1173             if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
    1174                 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
     1173                if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
     1174                    lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
    11751175#endif
    1176             SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
    1177                     (WPARAM)IMAGE_ICON,
    1178                     (LPARAM)PrintStructures->hLandscapeIcon);
    1179             SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
    1180                     (WPARAM)IMAGE_ICON,
    1181                     (LPARAM)PrintStructures->hLandscapeIcon);
    1182         }
    1183         }
    1184         break;
    1185     }
     1176                    SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
     1177                                        (WPARAM)IMAGE_ICON,
     1178                                        (LPARAM)PrintStructures->hLandscapeIcon);
     1179                    SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
     1180                                        (WPARAM)IMAGE_ICON,
     1181                                        (LPARAM)PrintStructures->hLandscapeIcon);
     1182                }
     1183            }
     1184            break;
     1185        }
    11861186    }
    11871187    return FALSE;
    1188 }
     1188}   
    11891189
    11901190/***********************************************************************
    1191  *           PrintDlgProcA          [internal]
     1191 *           PrintDlgProcA                      [internal]
    11921192 */
    11931193#ifdef __WIN32OS2__
    11941194LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    1195                  LPARAM lParam)
     1195                             LPARAM lParam)
    11961196#else
    11971197BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    1198               LPARAM lParam)
     1198                          LPARAM lParam)
    11991199#endif
    12001200{
     
    12031203
    12041204    if (uMsg!=WM_INITDIALOG) {
    1205         PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);
    1206     if (!PrintStructures)
    1207         return FALSE;
     1205        PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
     1206        if (!PrintStructures)
     1207            return FALSE;
    12081208    } else {
    12091209        PrintStructures = (PRINT_PTRA*) lParam;
    1210     SetWindowLongA(hDlg, DWL_USER, lParam);
    1211     res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);
    1212 
    1213     if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
    1214         res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(
    1215         hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg
    1216         );
    1217     return res;
    1218     }
    1219 
     1210        SetWindowLongA(hDlg, DWL_USER, lParam);
     1211        res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);
     1212
     1213        if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
     1214            res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(
     1215                hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg
     1216            );
     1217        return res;
     1218    }
     1219 
    12201220    if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
    12211221        res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam,
    1222                             lParam);
    1223     if(res) return res;
     1222                                                        lParam);
     1223        if(res) return res;
    12241224    }
    12251225
     
    12291229
    12301230    case WM_DESTROY:
    1231     DestroyIcon(PrintStructures->hCollateIcon);
    1232     DestroyIcon(PrintStructures->hNoCollateIcon);
     1231        DestroyIcon(PrintStructures->hCollateIcon);
     1232        DestroyIcon(PrintStructures->hNoCollateIcon);
    12331233        DestroyIcon(PrintStructures->hPortraitIcon);
    12341234        DestroyIcon(PrintStructures->hLandscapeIcon);
    1235     if(PrintStructures->hwndUpDown)
    1236         DestroyWindow(PrintStructures->hwndUpDown);
     1235        if(PrintStructures->hwndUpDown)
     1236            DestroyWindow(PrintStructures->hwndUpDown);
    12371237        return FALSE;
    1238     }
     1238    }   
    12391239    return res;
    12401240}
     
    12551255        HGLOBAL16 hGlobal16;
    12561256        LPVOID template;
    1257 
     1257 
    12581258        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    12591259               PrintResourceName, RT_DIALOGA)))
     
    13001300
    13011301    if (lppd->Flags & PD_PRINTSETUP) {
    1302     if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
    1303         hDlgTmpl = lppd->hSetupTemplate;
    1304     } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
    1305         hResInfo = FindResourceA(lppd->hInstance,
    1306                      lppd->lpSetupTemplateName, RT_DIALOGA);
    1307         hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
     1302        if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
     1303            hDlgTmpl = lppd->hSetupTemplate;
     1304        } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {       
     1305            hResInfo = FindResourceA(lppd->hInstance,
     1306                                     lppd->lpSetupTemplateName, RT_DIALOGA);
     1307            hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
     1308        } else {
     1309            hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
     1310                                     RT_DIALOGA);
     1311            hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
     1312        }
    13081313    } else {
    1309         hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
    1310                      RT_DIALOGA);
    1311         hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
    1312     }
    1313     } else {
    1314     if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
    1315         hDlgTmpl = lppd->hPrintTemplate;
    1316     } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
    1317         hResInfo = FindResourceA(lppd->hInstance,
    1318                      lppd->lpPrintTemplateName,
    1319                      RT_DIALOGA);
    1320         hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
    1321     } else {
    1322         hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
    1323                      RT_DIALOGA);
    1324         hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
    1325     }
     1314        if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
     1315            hDlgTmpl = lppd->hPrintTemplate;
     1316        } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
     1317            hResInfo = FindResourceA(lppd->hInstance,
     1318                                     lppd->lpPrintTemplateName,
     1319                                     RT_DIALOGA);
     1320            hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
     1321        } else {
     1322            hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
     1323                                     RT_DIALOGA);
     1324            hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
     1325        }
    13261326    }
    13271327    return hDlgTmpl;
     
    13401340
    13411341    if (lppd->Flags & PD_PRINTSETUP) {
    1342     if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
    1343         hDlgTmpl = lppd->hSetupTemplate;
    1344     } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
    1345         hResInfo = FindResource16(lppd->hInstance,
    1346                      MapSL(lppd->lpSetupTemplateName), RT_DIALOGA);
    1347         hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
     1342        if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
     1343            hDlgTmpl = lppd->hSetupTemplate;
     1344        } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {       
     1345            hResInfo = FindResource16(lppd->hInstance,
     1346                                     MapSL(lppd->lpSetupTemplateName), RT_DIALOGA);
     1347            hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
     1348        } else {
     1349            hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP");
     1350        }
    13481351    } else {
    1349         hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP");
    1350     }
    1351     } else {
    1352     if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
    1353         hDlgTmpl = lppd->hPrintTemplate;
    1354     } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
    1355         hResInfo = FindResource16(lppd->hInstance,
    1356                      MapSL(lppd->lpPrintTemplateName),
    1357                      RT_DIALOGA);
    1358         hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
    1359     } else {
    1360         hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32");
    1361     }
     1352        if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
     1353            hDlgTmpl = lppd->hPrintTemplate;
     1354        } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
     1355            hResInfo = FindResource16(lppd->hInstance,
     1356                                     MapSL(lppd->lpPrintTemplateName),
     1357                                     RT_DIALOGA);
     1358            hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
     1359        } else {
     1360            hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32");
     1361        }
    13621362    }
    13631363    return hDlgTmpl;
     
    13771377    if(lppd->Flags & PD_RETURNDC) {
    13781378        lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
    1379                   (char*)pdn + pdn->wDeviceOffset,
    1380                   (char*)pdn + pdn->wOutputOffset,
    1381                   pdm );
     1379                              (char*)pdn + pdn->wDeviceOffset,
     1380                              (char*)pdn + pdn->wOutputOffset,
     1381                              pdm );
    13821382    } else if(lppd->Flags & PD_RETURNIC) {
    13831383        lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
    1384                   (char*)pdn + pdn->wDeviceOffset,
    1385                   (char*)pdn + pdn->wOutputOffset,
    1386                   pdm );
     1384                              (char*)pdn + pdn->wDeviceOffset,
     1385                              (char*)pdn + pdn->wOutputOffset,
     1386                              pdm );
    13871387    }
    13881388    GlobalUnlock(lppd->hDevNames);
     
    13991399    if(lppd->Flags & PD_RETURNDC) {
    14001400        lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
    1401                   (char*)pdn + pdn->wDeviceOffset,
    1402                   (char*)pdn + pdn->wOutputOffset,
    1403                   pdm );
     1401                              (char*)pdn + pdn->wDeviceOffset,
     1402                              (char*)pdn + pdn->wOutputOffset,
     1403                              pdm );
    14041404    } else if(lppd->Flags & PD_RETURNIC) {
    14051405        lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
    1406                   (char*)pdn + pdn->wDeviceOffset,
    1407                   (char*)pdn + pdn->wOutputOffset,
    1408                   pdm );
     1406                              (char*)pdn + pdn->wDeviceOffset,
     1407                              (char*)pdn + pdn->wOutputOffset,
     1408                              pdm );
    14091409    }
    14101410    GlobalUnlock16(lppd->hDevNames);
     
    14311431 *  * The Paper Orientation Icons are not implemented yet.
    14321432 *  * The Properties Button(s) should call DocumentPropertiesA().
    1433  *  * Settings are not yet taken from a provided DevMode or
     1433 *  * Settings are not yet taken from a provided DevMode or 
    14341434 *    default printer settings.
    14351435 */
    14361436BOOL WINAPI PrintDlgA(
    1437               LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */
    1438               )
     1437                      LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */
     1438                      )
    14391439{
    14401440    BOOL      bRet = FALSE;
     
    14481448    if(TRACE_ON(commdlg)) {
    14491449        char flagstr[1000] = "";
    1450     struct pd_flags *pflag = pd_flags;
    1451     for( ; pflag->name; pflag++) {
    1452         if(lppd->Flags & pflag->flag)
    1453             strcat(flagstr, pflag->name);
    1454     }
    1455     TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
    1456           "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
    1457           "flags %08lx (%s)\n",
    1458           lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
    1459           lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
    1460           lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
     1450        struct pd_flags *pflag = pd_flags;
     1451        for( ; pflag->name; pflag++) {
     1452            if(lppd->Flags & pflag->flag)
     1453                strcat(flagstr, pflag->name);
     1454        }
     1455        TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
     1456              "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
     1457              "flags %08lx (%s)\n",
     1458              lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
     1459              lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
     1460              lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
    14611461    }
    14621462
    14631463    if(lppd->lStructSize != sizeof(PRINTDLGA)) {
    14641464        WARN("structure size failure !!!\n");
    1465     COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    1466     return FALSE;
     1465        COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     1466        return FALSE;
    14671467    }
    14681468
    14691469    if(lppd->Flags & PD_RETURNDEFAULT) {
    14701470        PRINTER_INFO_2A *pbuf;
    1471     DRIVER_INFO_3A  *dbuf;
    1472     HANDLE hprn;
    1473     DWORD needed;
    1474 
    1475     if(lppd->hDevMode || lppd->hDevNames) {
    1476         WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
    1477         COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1478         return FALSE;
    1479     }
     1471        DRIVER_INFO_3A  *dbuf;
     1472        HANDLE hprn;
     1473        DWORD needed;
     1474
     1475        if(lppd->hDevMode || lppd->hDevNames) {
     1476            WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
     1477            COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1478            return FALSE;
     1479        }
    14801480        if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
    1481         WARN("Can't find default printer\n");
    1482         COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
    1483         return FALSE;
    1484     }
    1485 
    1486     GetPrinterA(hprn, 2, NULL, 0, &needed);
    1487     pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
    1488     GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
    1489 
    1490     GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    1491     dbuf = HeapAlloc(GetProcessHeap(),0,needed);
    1492     if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
    1493         ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName);
    1494         COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1495         return FALSE;
    1496     }
    1497     ClosePrinter(hprn);
    1498 
    1499     PRINTDLG_CreateDevNames(&(lppd->hDevNames),
    1500                   dbuf->pDriverPath,
    1501                   pbuf->pPrinterName,
    1502                   pbuf->pPortName);
    1503     lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
    1504                      pbuf->pDevMode->dmDriverExtra);
    1505     ptr = GlobalLock(lppd->hDevMode);
    1506     memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
    1507            pbuf->pDevMode->dmDriverExtra);
    1508     GlobalUnlock(lppd->hDevMode);
    1509     HeapFree(GetProcessHeap(), 0, pbuf);
    1510     HeapFree(GetProcessHeap(), 0, dbuf);
    1511     bRet = TRUE;
     1481            WARN("Can't find default printer\n");
     1482            COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
     1483            return FALSE;
     1484        }
     1485
     1486        GetPrinterA(hprn, 2, NULL, 0, &needed);
     1487        pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
     1488        GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
     1489
     1490        GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
     1491        dbuf = HeapAlloc(GetProcessHeap(),0,needed);
     1492        if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
     1493            ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName);
     1494            COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1495            return FALSE;
     1496        }
     1497        ClosePrinter(hprn);
     1498
     1499        PRINTDLG_CreateDevNames(&(lppd->hDevNames),
     1500                                  dbuf->pDriverPath,
     1501                                  pbuf->pPrinterName,
     1502                                  pbuf->pPortName);
     1503        lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
     1504                                     pbuf->pDevMode->dmDriverExtra);
     1505        ptr = GlobalLock(lppd->hDevMode);
     1506        memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
     1507               pbuf->pDevMode->dmDriverExtra);
     1508        GlobalUnlock(lppd->hDevMode);
     1509        HeapFree(GetProcessHeap(), 0, pbuf);
     1510        HeapFree(GetProcessHeap(), 0, dbuf);
     1511        bRet = TRUE;
    15121512    } else {
    1513     HGLOBAL hDlgTmpl;
    1514     PRINT_PTRA *PrintStructures;
    1515 
    1516     /* load Dialog resources,
    1517      * depending on Flags indicates Print32 or Print32_setup dialog
     1513        HGLOBAL hDlgTmpl;
     1514        PRINT_PTRA *PrintStructures;
     1515
     1516    /* load Dialog resources, 
     1517     * depending on Flags indicates Print32 or Print32_setup dialog 
    15181518     */
    1519     hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd);
    1520     if (!hDlgTmpl) {
    1521         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1522         return FALSE;
    1523     }
    1524     ptr = LockResource( hDlgTmpl );
    1525     if (!ptr) {
    1526         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1527         return FALSE;
    1528     }
     1519        hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd);
     1520        if (!hDlgTmpl) {
     1521            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1522            return FALSE;
     1523        }
     1524        ptr = LockResource( hDlgTmpl );
     1525        if (!ptr) {
     1526            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1527            return FALSE;
     1528        }
    15291529
    15301530        PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    1531                     sizeof(PRINT_PTRA));
    1532     PrintStructures->dlg.lpPrintDlg = lppd;
    1533 
    1534     /* and create & process the dialog .
    1535     * -1 is failure, 0 is broken hwnd, everything else is ok.
    1536     */
    1537     bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
    1538                        PrintDlgProcA,
    1539                        (LPARAM)PrintStructures));
    1540 
    1541     if(bRet) {
    1542         DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
    1543         PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
    1544         DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
    1545 
    1546         if (lppd->hDevMode == 0) {
    1547             TRACE(" No hDevMode yet... Need to create my own\n");
    1548         lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,
    1549                     lpdm->dmSize + lpdm->dmDriverExtra);
    1550         } else {
    1551             WORD locks;
    1552         if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
    1553             WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
    1554             while(locks--) {
    1555                 GlobalUnlock(lppd->hDevMode);
    1556             TRACE("Now got %d locks\n", locks);
    1557             }
    1558         }
    1559         lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
    1560                            lpdm->dmSize + lpdm->dmDriverExtra,
    1561                            GMEM_MOVEABLE);
    1562         }
    1563         lpdmReturn = GlobalLock(lppd->hDevMode);
    1564         memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
    1565 
    1566         if (lppd->hDevNames != 0) {
    1567             WORD locks;
    1568         if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {
    1569             WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
    1570             while(locks--)
    1571                 GlobalUnlock(lppd->hDevNames);
    1572         }
    1573         }
    1574         PRINTDLG_CreateDevNames(&(lppd->hDevNames),
    1575             di->pDriverPath,
    1576             pi->pPrinterName,
    1577             pi->pPortName
    1578         );
    1579         GlobalUnlock(lppd->hDevMode);
    1580     }
    1581     HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    1582     HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
    1583     HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
    1584     HeapFree(GetProcessHeap(), 0, PrintStructures);
     1531                                    sizeof(PRINT_PTRA));
     1532        PrintStructures->dlg.lpPrintDlg = lppd;
     1533
     1534        /* and create & process the dialog .
     1535        * -1 is failure, 0 is broken hwnd, everything else is ok.
     1536        */
     1537        bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
     1538                                           PrintDlgProcA,
     1539                                           (LPARAM)PrintStructures));
     1540
     1541        if(bRet) {
     1542            DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
     1543            PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
     1544            DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
     1545
     1546            if (lppd->hDevMode == 0) {
     1547                TRACE(" No hDevMode yet... Need to create my own\n");
     1548                lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,
     1549                                        lpdm->dmSize + lpdm->dmDriverExtra);
     1550            } else {
     1551                WORD locks;
     1552                if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
     1553                    WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
     1554                    while(locks--) {
     1555                        GlobalUnlock(lppd->hDevMode);
     1556                        TRACE("Now got %d locks\n", locks);
     1557                    }
     1558                }
     1559                lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
     1560                                               lpdm->dmSize + lpdm->dmDriverExtra,
     1561                                               GMEM_MOVEABLE);
     1562            }
     1563            lpdmReturn = GlobalLock(lppd->hDevMode);
     1564            memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
     1565
     1566            if (lppd->hDevNames != 0) {
     1567                WORD locks;
     1568                if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {
     1569                    WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
     1570                    while(locks--)
     1571                        GlobalUnlock(lppd->hDevNames);
     1572                }
     1573            }
     1574            PRINTDLG_CreateDevNames(&(lppd->hDevNames),
     1575                    di->pDriverPath,
     1576                    pi->pPrinterName,
     1577                    pi->pPortName
     1578            );
     1579            GlobalUnlock(lppd->hDevMode);
     1580        }
     1581        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
     1582        HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
     1583        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
     1584        HeapFree(GetProcessHeap(), 0, PrintStructures);
    15851585    }
    15861586    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
    15871587        bRet = PRINTDLG_CreateDC(lppd);
    15881588
    1589     TRACE("exit! (%d)\n", bRet);
    1590     return bRet;
     1589    TRACE("exit! (%d)\n", bRet);       
     1590    return bRet;   
    15911591}
    15921592
     
    15941594/***********************************************************************
    15951595 *           PrintDlg   (COMMDLG.20)
    1596  *
     1596 * 
    15971597 *  Displays the the PRINT dialog box, which enables the user to specify
    15981598 *  specific properties of the print job.
     
    16081608
    16091609BOOL16 WINAPI PrintDlg16(
    1610           LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */
     1610              LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */
    16111611) {
    16121612    BOOL      bRet = FALSE;
     
    16161616    if(TRACE_ON(commdlg)) {
    16171617        char flagstr[1000] = "";
    1618     struct pd_flags *pflag = pd_flags;
    1619     for( ; pflag->name; pflag++) {
    1620         if(lppd->Flags & pflag->flag)
    1621             strcat(flagstr, pflag->name);
    1622     }
    1623     TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
    1624           "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
    1625           "flags %08lx (%s)\n",
    1626           lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
    1627           lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
    1628           lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
     1618        struct pd_flags *pflag = pd_flags;
     1619        for( ; pflag->name; pflag++) {
     1620            if(lppd->Flags & pflag->flag)
     1621                strcat(flagstr, pflag->name);
     1622        }
     1623        TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
     1624              "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
     1625              "flags %08lx (%s)\n",
     1626              lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
     1627              lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
     1628              lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
    16291629    }
    16301630
    16311631    if(lppd->lStructSize != sizeof(PRINTDLG16)) {
    16321632        ERR("structure size (%ld/%d)\n",lppd->lStructSize,sizeof(PRINTDLG16));
    1633     COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    1634     return FALSE;
     1633        COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     1634        return FALSE;
    16351635    }
    16361636
    16371637    if(lppd->Flags & PD_RETURNDEFAULT) {
    16381638        PRINTER_INFO_2A *pbuf;
    1639     DRIVER_INFO_3A  *dbuf;
    1640     HANDLE hprn;
    1641     DWORD needed;
    1642 
    1643     if(lppd->hDevMode || lppd->hDevNames) {
    1644         WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
    1645         COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1646         return FALSE;
    1647     }
     1639        DRIVER_INFO_3A  *dbuf;
     1640        HANDLE hprn;
     1641        DWORD needed;
     1642
     1643        if(lppd->hDevMode || lppd->hDevNames) {
     1644            WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
     1645            COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1646            return FALSE;
     1647        }
    16481648        if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
    1649         WARN("Can't find default printer\n");
    1650         COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
    1651         return FALSE;
    1652     }
    1653 
    1654     GetPrinterA(hprn, 2, NULL, 0, &needed);
    1655     pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
    1656     GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
    1657     GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    1658     dbuf = HeapAlloc(GetProcessHeap(),0,needed);
    1659     if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
    1660         ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n",
    1661             pbuf->pPrinterName,GetLastError());
    1662         COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1663         return FALSE;
    1664     }
    1665     ClosePrinter(hprn);
    1666     PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
    1667                 dbuf->pDriverPath,
    1668                 pbuf->pPrinterName,
    1669                 pbuf->pPortName);
    1670     lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+
    1671                      pbuf->pDevMode->dmDriverExtra);
    1672     ptr = GlobalLock16(lppd->hDevMode);
    1673     memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
    1674            pbuf->pDevMode->dmDriverExtra);
    1675     GlobalUnlock16(lppd->hDevMode);
    1676     HeapFree(GetProcessHeap(), 0, pbuf);
    1677     HeapFree(GetProcessHeap(), 0, dbuf);
    1678     bRet = TRUE;
     1649            WARN("Can't find default printer\n");
     1650            COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
     1651            return FALSE;
     1652        }
     1653
     1654        GetPrinterA(hprn, 2, NULL, 0, &needed);
     1655        pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
     1656        GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
     1657        GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
     1658        dbuf = HeapAlloc(GetProcessHeap(),0,needed);
     1659        if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
     1660            ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n",
     1661                    pbuf->pPrinterName,GetLastError());
     1662            COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1663            return FALSE;
     1664        }
     1665        ClosePrinter(hprn);
     1666        PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
     1667                                dbuf->pDriverPath,
     1668                                pbuf->pPrinterName,
     1669                                pbuf->pPortName);
     1670        lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+
     1671                                     pbuf->pDevMode->dmDriverExtra);
     1672        ptr = GlobalLock16(lppd->hDevMode);
     1673        memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
     1674               pbuf->pDevMode->dmDriverExtra);
     1675        GlobalUnlock16(lppd->hDevMode);
     1676        HeapFree(GetProcessHeap(), 0, pbuf);
     1677        HeapFree(GetProcessHeap(), 0, dbuf);
     1678        bRet = TRUE;
    16791679    } else {
    1680     HGLOBAL hDlgTmpl;
    1681     PRINT_PTRA *PrintStructures;
    1682 
    1683     /* load Dialog resources,
    1684      * depending on Flags indicates Print32 or Print32_setup dialog
     1680        HGLOBAL hDlgTmpl;
     1681        PRINT_PTRA *PrintStructures;
     1682
     1683    /* load Dialog resources, 
     1684     * depending on Flags indicates Print32 or Print32_setup dialog 
    16851685     */
    1686     hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd);
    1687     if (!hDlgTmpl) {
    1688         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1689         return FALSE;
    1690     }
     1686        hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd);
     1687        if (!hDlgTmpl) {
     1688            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1689            return FALSE;
     1690        }
    16911691        PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    1692                     sizeof(PRINT_PTRA));
    1693     PrintStructures->dlg.lpPrintDlg16 = lppd;
    1694     PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));
    1695 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x;
    1696 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x);
    1697     CVAL(Flags);CVAL(hwndOwner);CVAL(hDC);
    1698     CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage);
    1699     CVAL(nCopies);CVAL(hInstance);CVAL(lCustData);
    1700     MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName);
    1701     /* Don't copy rest, it is 16 bit specific */
     1692                                    sizeof(PRINT_PTRA));
     1693        PrintStructures->dlg.lpPrintDlg16 = lppd;
     1694        PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));
     1695#define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x;
     1696#define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x);
     1697        CVAL(Flags);CVAL(hwndOwner);CVAL(hDC);
     1698        CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage);
     1699        CVAL(nCopies);CVAL(hInstance);CVAL(lCustData);
     1700        MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName);
     1701        /* Don't copy rest, it is 16 bit specific */
    17021702#undef MVAL
    17031703#undef CVAL
    17041704
    1705     PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA));
    1706 
    1707     /* and create & process the dialog .
    1708     * -1 is failure, 0 is broken hwnd, everything else is ok.
    1709     */
    1710     bRet =  (0<DialogBoxIndirectParam16(
    1711         hInst, hDlgTmpl, lppd->hwndOwner,
    1712         (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21),
    1713         (LPARAM)PrintStructures
    1714         )
    1715     );
    1716     if (!PrintStructures->lpPrinterInfo) bRet = FALSE;
    1717     if(bRet) {
    1718         DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
    1719         PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
    1720         DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
    1721 
    1722         if (lppd->hDevMode == 0) {
    1723             TRACE(" No hDevMode yet... Need to create my own\n");
    1724         lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,
    1725                     lpdm->dmSize + lpdm->dmDriverExtra);
    1726         } else {
    1727             WORD locks;
    1728         if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) {
    1729             WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
    1730             while(locks--) {
    1731                 GlobalUnlock16(lppd->hDevMode);
    1732             TRACE("Now got %d locks\n", locks);
    1733             }
    1734         }
    1735         lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode,
    1736                            lpdm->dmSize + lpdm->dmDriverExtra,
    1737                            GMEM_MOVEABLE);
    1738         }
    1739         lpdmReturn = GlobalLock16(lppd->hDevMode);
    1740         memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
    1741 
    1742         if (lppd->hDevNames != 0) {
    1743             WORD locks;
    1744         if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) {
    1745             WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
    1746             while(locks--)
    1747                 GlobalUnlock16(lppd->hDevNames);
    1748         }
    1749         }
    1750         PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
    1751             di->pDriverPath,
    1752             pi->pPrinterName,
    1753             pi->pPortName
    1754         );
    1755         GlobalUnlock16(lppd->hDevMode);
    1756     }
    1757     if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))
     1705        PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA));
     1706
     1707        /* and create & process the dialog .
     1708        * -1 is failure, 0 is broken hwnd, everything else is ok.
     1709        */
     1710        bRet =  (0<DialogBoxIndirectParam16(
     1711                hInst, hDlgTmpl, lppd->hwndOwner,
     1712                (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21),
     1713                (LPARAM)PrintStructures
     1714                )
     1715        );
     1716        if (!PrintStructures->lpPrinterInfo) bRet = FALSE;
     1717        if(bRet) {
     1718            DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
     1719            PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
     1720            DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
     1721
     1722            if (lppd->hDevMode == 0) {
     1723                TRACE(" No hDevMode yet... Need to create my own\n");
     1724                lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,
     1725                                        lpdm->dmSize + lpdm->dmDriverExtra);
     1726            } else {
     1727                WORD locks;
     1728                if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) {
     1729                    WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
     1730                    while(locks--) {
     1731                        GlobalUnlock16(lppd->hDevMode);
     1732                        TRACE("Now got %d locks\n", locks);
     1733                    }
     1734                }
     1735                lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode,
     1736                                               lpdm->dmSize + lpdm->dmDriverExtra,
     1737                                               GMEM_MOVEABLE);
     1738            }
     1739            lpdmReturn = GlobalLock16(lppd->hDevMode);
     1740            memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
     1741
     1742            if (lppd->hDevNames != 0) {
     1743                WORD locks;
     1744                if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) {
     1745                    WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
     1746                    while(locks--)
     1747                        GlobalUnlock16(lppd->hDevNames);
     1748                }
     1749            }
     1750            PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
     1751                    di->pDriverPath,
     1752                    pi->pPrinterName,
     1753                    pi->pPortName
     1754            );
     1755            GlobalUnlock16(lppd->hDevMode);
     1756        }
     1757        if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))
    17581758            GlobalFree16(hDlgTmpl); /* created from the 32 bits resource */
    1759     HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    1760     HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
    1761     HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
    1762     HeapFree(GetProcessHeap(), 0, PrintStructures);
     1759        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
     1760        HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
     1761        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
     1762        HeapFree(GetProcessHeap(), 0, PrintStructures);
    17631763    }
    17641764    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
    17651765        bRet = PRINTDLG_CreateDC16(lppd);
    17661766
    1767     TRACE("exit! (%d)\n", bRet);
    1768     return bRet;
     1767    TRACE("exit! (%d)\n", bRet);       
     1768    return bRet;   
    17691769}
    17701770#endif
     
    17981798
    17991799typedef struct {
    1800     LPPAGESETUPDLGA dlga;
    1801 
    1802     PRINTDLGA       pdlg;
     1800    LPPAGESETUPDLGA     dlga;
     1801
     1802    PRINTDLGA           pdlg;
    18031803} PageSetupData;
    18041804
     
    18081808
    18091809    if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATEHANDLE) {
    1810     hDlgTmpl = lppd->hPageSetupTemplate;
    1811     } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) {
    1812     hResInfo = FindResourceA(lppd->hInstance,
    1813                 lppd->lpPageSetupTemplateName, RT_DIALOGA);
    1814     hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
     1810        hDlgTmpl = lppd->hPageSetupTemplate;
     1811    } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) {     
     1812        hResInfo = FindResourceA(lppd->hInstance,
     1813                                lppd->lpPageSetupTemplateName, RT_DIALOGA);
     1814        hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
    18151815    } else {
    1816     hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA);
    1817     hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo);
     1816        hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA);
     1817        hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo);
    18181818    }
    18191819    return hDlgTmpl;
     
    18231823_c_10mm2size(PAGESETUPDLGA *dlga,DWORD size) {
    18241824    if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1825     return 10*size*10/25.4;
     1825        return 10*size*10/25.4;
    18261826    /* If we don't have a flag, we can choose one. Use millimeters
    18271827     * to avoid confusing me
     
    18361836_c_inch2size(PAGESETUPDLGA *dlga,DWORD size) {
    18371837    if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1838     return size;
     1838        return size;
    18391839    if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
    1840     return (size*254)/10;
     1840        return (size*254)/10;
    18411841    /* if we don't have a flag, we can choose one. Use millimeters
    18421842     * to avoid confusing me
     
    18501850    strcpy(strout,"<undef>");
    18511851    if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
    1852     sprintf(strout,"%.2fmm",(size*1.0)/100.0);
    1853     return;
     1852        sprintf(strout,"%.2fmm",(size*1.0)/100.0);
     1853        return;
    18541854    }
    18551855    if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
    1856     sprintf(strout,"%.2fin",(size*1.0)/1000.0);
    1857     return;
     1856        sprintf(strout,"%.2fin",(size*1.0)/1000.0);
     1857        return;
    18581858    }
    18591859    pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
     
    18641864static DWORD
    18651865_c_str2size(PageSetupData *pda,LPCSTR strin) {
    1866     float   val;
    1867     char    rest[200];
     1866    float       val;
     1867    char        rest[200];
    18681868
    18691869    rest[0]='\0';
    18701870    if (!sscanf(strin,"%f%s",&val,rest))
    1871     return 0;
     1871        return 0;
    18721872
    18731873    if (!strcmp(rest,"in") || !strcmp(rest,"inch")) {
    1874     if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1875         return 1000*val;
    1876     else
    1877         return val*25.4*100;
     1874        if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
     1875            return 1000*val;
     1876        else
     1877            return val*25.4*100;
    18781878    }
    18791879    if (!strcmp(rest,"cm")) { rest[0]='m'; val = val*10.0; }
     
    18811881
    18821882    if (!strcmp(rest,"mm")) {
    1883     if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
    1884         return 100*val;
    1885     else
    1886         return 1000.0*val/25.4;
     1883        if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
     1884            return 100*val;
     1885        else
     1886            return 1000.0*val/25.4;
    18871887    }
    18881888    if (rest[0]=='\0') {
    1889     /* use application supplied default */
    1890     if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
    1891         /* 100*mm */
    1892         return 100.0*val;
    1893     }
    1894     if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
    1895         /* 1000*inch */
    1896         return 1000.0*val;
    1897     }
     1889        /* use application supplied default */
     1890        if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
     1891            /* 100*mm */
     1892            return 100.0*val;
     1893        }
     1894        if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
     1895            /* 1000*inch */
     1896            return 1000.0*val;
     1897        }
    18981898    }
    18991899    ERR("Did not find a conversion for type '%s'!\n",rest);
     
    19081908static BOOL
    19091909PRINTDLG_PS_UpdateDlgStruct(HWND hDlg, PageSetupData *pda) {
    1910     DEVNAMES    *dn;
    1911     DEVMODEA    *dm;
    1912     LPSTR   devname,portname;
    1913     char    papername[64];
    1914     char    buf[200];
    1915 
     1910    DEVNAMES    *dn;
     1911    DEVMODEA    *dm;
     1912    LPSTR       devname,portname;
     1913    char        papername[64];
     1914    char        buf[200];
     1915   
    19161916    dn = GlobalLock(pda->pdlg.hDevNames);
    19171917    dm = GlobalLock(pda->pdlg.hDevMode);
    1918     devname = ((char*)dn)+dn->wDeviceOffset;
    1919     portname    = ((char*)dn)+dn->wOutputOffset;
     1918    devname     = ((char*)dn)+dn->wDeviceOffset;
     1919    portname    = ((char*)dn)+dn->wOutputOffset;
    19201920    PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm);
    19211921    PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm);
    19221922
    19231923    if (GetDlgItemTextA(hDlg,cmb2,papername,sizeof(papername))>0) {
    1924         PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize));
    1925     pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x);
    1926     pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y);
     1924        PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize));
     1925        pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x);
     1926        pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y);
    19271927    } else
    1928     FIXME("could not get dialog text for papersize cmbbox?\n");
     1928        FIXME("could not get dialog text for papersize cmbbox?\n");
    19291929#define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size(pda,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
    19301930    GETVAL(edt4,pda->dlga->rtMargin.left);
     
    19361936    /* If we are in landscape, swap x and y of page size */
    19371937    if (IsDlgButtonChecked(hDlg, rad2)) {
    1938     DWORD tmp;
    1939     tmp = pda->dlga->ptPaperSize.x;
    1940     pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y;
    1941     pda->dlga->ptPaperSize.y = tmp;
     1938        DWORD tmp;
     1939        tmp = pda->dlga->ptPaperSize.x;
     1940        pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y;
     1941        pda->dlga->ptPaperSize.y = tmp;
    19421942    }
    19431943    GlobalUnlock(pda->pdlg.hDevNames);
     
    19511951static BOOL
    19521952PRINTDLG_PS_ChangePrinter(HWND hDlg, PageSetupData *pda) {
    1953     DEVNAMES    *dn;
    1954     DEVMODEA    *dm;
    1955     LPSTR   devname,portname;
    1956 
     1953    DEVNAMES    *dn;
     1954    DEVMODEA    *dm;
     1955    LPSTR       devname,portname;
     1956   
    19571957    dn = GlobalLock(pda->pdlg.hDevNames);
    19581958    dm = GlobalLock(pda->pdlg.hDevMode);
    1959     devname = ((char*)dn)+dn->wDeviceOffset;
    1960     portname    = ((char*)dn)+dn->wOutputOffset;
     1959    devname     = ((char*)dn)+dn->wDeviceOffset;
     1960    portname    = ((char*)dn)+dn->wOutputOffset;
    19611961    PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm);
    19621962    PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm);
     
    19731973    case IDOK:
    19741974        if (!PRINTDLG_PS_UpdateDlgStruct(hDlg, pda))
    1975         return(FALSE);
    1976     EndDialog(hDlg, TRUE);
    1977     return TRUE ;
     1975            return(FALSE);
     1976        EndDialog(hDlg, TRUE);
     1977        return TRUE ;
    19781978
    19791979    case IDCANCEL:
    19801980        EndDialog(hDlg, FALSE);
    1981     return FALSE ;
     1981        return FALSE ;
    19821982
    19831983    case psh3: {
    1984     pda->pdlg.Flags     = 0;
    1985     pda->pdlg.hwndOwner = hDlg;
    1986     if (PrintDlgA(&(pda->pdlg)))
    1987         PRINTDLG_PS_ChangePrinter(hDlg,pda);
    1988     return TRUE;
     1984        pda->pdlg.Flags         = 0;
     1985        pda->pdlg.hwndOwner     = hDlg;
     1986        if (PrintDlgA(&(pda->pdlg)))
     1987            PRINTDLG_PS_ChangePrinter(hDlg,pda);
     1988        return TRUE;
    19891989    }
    19901990    }
    19911991    FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
    1992         LOWORD(lParam),wParam,lParam
     1992            LOWORD(lParam),wParam,lParam
    19931993    );
    19941994    return FALSE;
     
    19991999PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    20002000{
    2001     PageSetupData   *pda;
    2002     BOOL        res = FALSE;
     2001    PageSetupData       *pda;
     2002    BOOL                res = FALSE;
    20032003
    20042004    if (uMsg==WM_INITDIALOG) {
    2005     res = TRUE;
     2005        res = TRUE;
    20062006        pda = (PageSetupData*)lParam;
    2007     SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam);
    2008     if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
    2009         res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
    2010         if (!res) {
    2011         FIXME("Setup page hook failed?\n");
    2012         res = TRUE;
    2013         }
    2014     }
    2015     if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {
    2016         FIXME("PagePaintHook not yet implemented!\n");
    2017     }
    2018     if (pda->dlga->Flags & PSD_DISABLEPRINTER)
    2019             EnableWindow(GetDlgItem(hDlg, psh3), FALSE);
    2020     if (pda->dlga->Flags & PSD_DISABLEMARGINS) {
    2021             EnableWindow(GetDlgItem(hDlg, edt4), FALSE);
    2022             EnableWindow(GetDlgItem(hDlg, edt5), FALSE);
    2023             EnableWindow(GetDlgItem(hDlg, edt6), FALSE);
    2024             EnableWindow(GetDlgItem(hDlg, edt7), FALSE);
    2025     }
    2026     /* width larger as height -> landscape */
    2027     if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y)
     2007        SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam);
     2008        if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
     2009            res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
     2010            if (!res) {
     2011                FIXME("Setup page hook failed?\n");
     2012                res = TRUE;
     2013            }
     2014        }
     2015        if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {
     2016            FIXME("PagePaintHook not yet implemented!\n");
     2017        }
     2018        if (pda->dlga->Flags & PSD_DISABLEPRINTER)
     2019            EnableWindow(GetDlgItem(hDlg, psh3), FALSE);   
     2020        if (pda->dlga->Flags & PSD_DISABLEMARGINS) {
     2021            EnableWindow(GetDlgItem(hDlg, edt4), FALSE);   
     2022            EnableWindow(GetDlgItem(hDlg, edt5), FALSE);   
     2023            EnableWindow(GetDlgItem(hDlg, edt6), FALSE);   
     2024            EnableWindow(GetDlgItem(hDlg, edt7), FALSE);   
     2025        }
     2026        /* width larger as height -> landscape */
     2027        if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y)
    20282028            CheckRadioButton(hDlg, rad1, rad2, rad2);
    2029     else /* this is default if papersize is not set */
     2029        else /* this is default if papersize is not set */
    20302030            CheckRadioButton(hDlg, rad1, rad2, rad1);
    2031     if (pda->dlga->Flags & PSD_DISABLEORIENTATION) {
    2032         EnableWindow(GetDlgItem(hDlg,rad1),FALSE);
    2033         EnableWindow(GetDlgItem(hDlg,rad2),FALSE);
    2034     }
    2035     /* We fill them out enabled or not */
    2036     if (pda->dlga->Flags & PSD_MARGINS) {
    2037         char str[100];
    2038         _c_size2str(pda,pda->dlga->rtMargin.left,str);
    2039         SetDlgItemTextA(hDlg,edt4,str);
    2040         _c_size2str(pda,pda->dlga->rtMargin.top,str);
    2041         SetDlgItemTextA(hDlg,edt5,str);
    2042         _c_size2str(pda,pda->dlga->rtMargin.right,str);
    2043         SetDlgItemTextA(hDlg,edt6,str);
    2044         _c_size2str(pda,pda->dlga->rtMargin.bottom,str);
    2045         SetDlgItemTextA(hDlg,edt7,str);
     2031        if (pda->dlga->Flags & PSD_DISABLEORIENTATION) {
     2032            EnableWindow(GetDlgItem(hDlg,rad1),FALSE);
     2033            EnableWindow(GetDlgItem(hDlg,rad2),FALSE);
     2034        }
     2035        /* We fill them out enabled or not */
     2036        if (pda->dlga->Flags & PSD_MARGINS) {
     2037            char str[100];
     2038            _c_size2str(pda,pda->dlga->rtMargin.left,str);
     2039            SetDlgItemTextA(hDlg,edt4,str);
     2040            _c_size2str(pda,pda->dlga->rtMargin.top,str);
     2041            SetDlgItemTextA(hDlg,edt5,str);
     2042            _c_size2str(pda,pda->dlga->rtMargin.right,str);
     2043            SetDlgItemTextA(hDlg,edt6,str);
     2044            _c_size2str(pda,pda->dlga->rtMargin.bottom,str);
     2045            SetDlgItemTextA(hDlg,edt7,str);
     2046        } else {
     2047            /* default is 1 inch */
     2048            DWORD size = _c_inch2size(pda->dlga,1000);
     2049            char        str[20];
     2050            _c_size2str(pda,size,str);
     2051            SetDlgItemTextA(hDlg,edt4,str);
     2052            SetDlgItemTextA(hDlg,edt5,str);
     2053            SetDlgItemTextA(hDlg,edt6,str);
     2054            SetDlgItemTextA(hDlg,edt7,str);
     2055        }
     2056        PRINTDLG_PS_ChangePrinter(hDlg,pda);
     2057        if (pda->dlga->Flags & PSD_DISABLEPAPER) {
     2058            EnableWindow(GetDlgItem(hDlg,cmb2),FALSE);
     2059            EnableWindow(GetDlgItem(hDlg,cmb3),FALSE);
     2060        }
     2061        return TRUE;
    20462062    } else {
    2047         /* default is 1 inch */
    2048         DWORD size = _c_inch2size(pda->dlga,1000);
    2049         char    str[20];
    2050         _c_size2str(pda,size,str);
    2051         SetDlgItemTextA(hDlg,edt4,str);
    2052         SetDlgItemTextA(hDlg,edt5,str);
    2053         SetDlgItemTextA(hDlg,edt6,str);
    2054         SetDlgItemTextA(hDlg,edt7,str);
    2055     }
    2056     PRINTDLG_PS_ChangePrinter(hDlg,pda);
    2057     if (pda->dlga->Flags & PSD_DISABLEPAPER) {
    2058         EnableWindow(GetDlgItem(hDlg,cmb2),FALSE);
    2059         EnableWindow(GetDlgItem(hDlg,cmb3),FALSE);
    2060     }
    2061     return TRUE;
    2062     } else {
    2063     pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA");
    2064     if (!pda) {
    2065         WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
    2066         return FALSE;
    2067     }
    2068     if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
    2069         res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
    2070         if (res) return res;
    2071     }
     2063        pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA");
     2064        if (!pda) {
     2065            WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
     2066            return FALSE;
     2067        }
     2068        if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
     2069            res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
     2070            if (res) return res;
     2071        }
    20722072    }
    20732073    switch (uMsg) {
     
    20822082 */
    20832083BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
    2084     HGLOBAL     hDlgTmpl;
    2085     LPVOID      ptr;
    2086     BOOL        bRet;
    2087     PageSetupData   *pda;
    2088     PRINTDLGA       pdlg;
     2084    HGLOBAL             hDlgTmpl;
     2085    LPVOID              ptr;
     2086    BOOL                bRet;
     2087    PageSetupData       *pda;
     2088    PRINTDLGA           pdlg;
    20892089
    20902090#ifdef __WIN32OS2__
     
    20942094    if(TRACE_ON(commdlg)) {
    20952095        char flagstr[1000] = "";
    2096     struct pd_flags *pflag = psd_flags;
    2097     for( ; pflag->name; pflag++) {
    2098         if(setupdlg->Flags & pflag->flag) {
    2099             strcat(flagstr, pflag->name);
    2100             strcat(flagstr, "|");
    2101         }
    2102     }
    2103     TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
    2104           "hinst %08x, flags %08lx (%s)\n",
    2105           setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode,
    2106           setupdlg->hDevNames,
    2107           setupdlg->hInstance, setupdlg->Flags, flagstr);
     2096        struct pd_flags *pflag = psd_flags;
     2097        for( ; pflag->name; pflag++) {
     2098            if(setupdlg->Flags & pflag->flag) {
     2099                strcat(flagstr, pflag->name);
     2100                strcat(flagstr, "|");
     2101            }
     2102        }
     2103        TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
     2104              "hinst %08x, flags %08lx (%s)\n",
     2105              setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode,
     2106              setupdlg->hDevNames,
     2107              setupdlg->hInstance, setupdlg->Flags, flagstr);
    21082108    }
    21092109
    21102110    /* First get default printer data, we need it right after that. */
    21112111    memset(&pdlg,0,sizeof(pdlg));
    2112     pdlg.lStructSize    = sizeof(pdlg);
    2113     pdlg.Flags      = PD_RETURNDEFAULT;
     2112    pdlg.lStructSize    = sizeof(pdlg);
     2113    pdlg.Flags          = PD_RETURNDEFAULT;
    21142114    bRet = PrintDlgA(&pdlg);
    21152115    if (!bRet) return FALSE;
     
    21172117    /* short cut exit, just return default values */
    21182118    if (setupdlg->Flags & PSD_RETURNDEFAULT) {
    2119     setupdlg->hDevMode  = pdlg.hDevMode;
    2120     setupdlg->hDevNames = pdlg.hDevNames;
    2121     /* FIXME: Just return "A4" for now. */
    2122         PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize);
    2123     setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x);
    2124     setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y);
    2125     return TRUE;
     2119        setupdlg->hDevMode      = pdlg.hDevMode;
     2120        setupdlg->hDevNames     = pdlg.hDevNames;
     2121        /* FIXME: Just return "A4" for now. */
     2122        PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize);
     2123        setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x);
     2124        setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y);
     2125        return TRUE;
    21262126    }
    21272127    hDlgTmpl = PRINTDLG_GetPGSTemplate(setupdlg);
    21282128    if (!hDlgTmpl) {
    2129     COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    2130     return FALSE;
     2129        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     2130        return FALSE;
    21312131    }
    21322132    ptr = LockResource( hDlgTmpl );
    21332133    if (!ptr) {
    2134     COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    2135     return FALSE;
     2134        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     2135        return FALSE;
    21362136    }
    21372137    pda = HeapAlloc(GetProcessHeap(),0,sizeof(*pda));
     
    21402140
    21412141    bRet = (0<DialogBoxIndirectParamA(
    2142         setupdlg->hInstance,
    2143         ptr,
    2144         setupdlg->hwndOwner,
    2145         PageDlgProcA,
    2146         (LPARAM)pda)
     2142                setupdlg->hInstance,
     2143                ptr,
     2144                setupdlg->hwndOwner,
     2145                PageDlgProcA,
     2146                (LPARAM)pda)
    21472147    );
    21482148    return bRet;
     
    21552155    dprintf(("PageSetupDlgA %x NOT IMPLEMENTED", setupdlg));
    21562156#endif
    2157     FIXME("(%p), stub!\n",setupdlg);
    2158     return FALSE;
     2157        FIXME("(%p), stub!\n",setupdlg);
     2158        return FALSE;
    21592159}
    21602160
     
    21752175
    21762176    if (uMsg!=WM_INITDIALOG) {
    2177         PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);
    2178     if (!PrintStructures)
    2179         return FALSE;
     2177        PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
     2178        if (!PrintStructures)
     2179            return FALSE;
    21802180    } else {
    21812181        PrintStructures = (PRINT_PTRA*) lParam;
    2182     SetWindowLongA(hDlg, DWL_USER, lParam);
    2183     res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures);
    2184 
     2182        SetWindowLongA(hDlg, DWL_USER, lParam);
     2183        res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures);
     2184
     2185        if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
     2186            res = CallWindowProc16(
     2187                (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
     2188                hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16
     2189            );
     2190        }
     2191        return res;
     2192    }
     2193 
    21852194    if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
    21862195        res = CallWindowProc16(
    2187         (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
    2188         hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16
    2189         );
    2190     }
    2191     return res;
    2192     }
    2193 
    2194     if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
    2195         res = CallWindowProc16(
    2196         (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
    2197         hDlg,uMsg, wParam, lParam
    2198     );
    2199     if(LOWORD(res)) return res;
     2196                (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
     2197                hDlg,uMsg, wParam, lParam
     2198        );
     2199        if(LOWORD(res)) return res;
    22002200    }
    22012201
    22022202    switch (uMsg) {
    22032203    case WM_COMMAND: {
    2204     /* We need to map those for the 32bit window procedure, compare
    2205       * with 32Ato16 mapper in winproc.c
    2206       */
     2204        /* We need to map those for the 32bit window procedure, compare
     2205          * with 32Ato16 mapper in winproc.c
     2206          */
    22072207        return PRINTDLG_WMCommand(
    2208         hDlg,
    2209         MAKEWPARAM(wParam,HIWORD(lParam)),
    2210         LOWORD(lParam),
    2211         PrintStructures
    2212     );
     2208                hDlg,
     2209                MAKEWPARAM(wParam,HIWORD(lParam)),
     2210                LOWORD(lParam),
     2211                PrintStructures
     2212        );
    22132213    }
    22142214    case WM_DESTROY:
    2215     DestroyIcon(PrintStructures->hCollateIcon);
    2216     DestroyIcon(PrintStructures->hNoCollateIcon);
     2215        DestroyIcon(PrintStructures->hCollateIcon);
     2216        DestroyIcon(PrintStructures->hNoCollateIcon);
    22172217    /* FIXME: don't forget to delete the paper orientation icons here! */
    22182218
    22192219        return FALSE;
    2220     }
     2220    }   
    22212221    return res;
    22222222}
     
    22272227 */
    22282228LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    2229                    LPARAM lParam)
     2229                                   LPARAM lParam)
    22302230{
    22312231  switch (wMsg)
     
    22382238      switch (wParam) {
    22392239      case IDOK:
    2240     EndDialog(hWnd, TRUE);
    2241     return(TRUE);
     2240        EndDialog(hWnd, TRUE);
     2241        return(TRUE);
    22422242      case IDCANCEL:
    2243     EndDialog(hWnd, FALSE);
    2244     return(TRUE);
     2243        EndDialog(hWnd, FALSE);
     2244        return(TRUE);
    22452245      }
    22462246      return(FALSE);
     
    22512251
    22522252/***********************************************************************
    2253  *  PrintDlgExA (COMDLG32.@)
     2253 *      PrintDlgExA (COMDLG32.@)
    22542254 */
    22552255HRESULT WINAPI PrintDlgExA(LPVOID lpPrintDlgExA) /* [???] FIXME: LPPRINTDLGEXA */
    22562256{
    2257     FIXME("stub\n");
    2258     return E_NOTIMPL;
     2257        FIXME("stub\n");
     2258        return E_NOTIMPL;
    22592259}
    22602260/***********************************************************************
    2261  *  PrintDlgExW (COMDLG32.@)
     2261 *      PrintDlgExW (COMDLG32.@)
    22622262 */
    22632263HRESULT WINAPI PrintDlgExW(LPVOID lpPrintDlgExW) /* [???] FIXME: LPPRINTDLGEXW */
    22642264{
    2265     FIXME("stub\n");
    2266     return E_NOTIMPL;
    2267 }
     2265        FIXME("stub\n");
     2266        return E_NOTIMPL;
     2267}
Note: See TracChangeset for help on using the changeset viewer.