Ignore:
Timestamp:
Dec 4, 2001, 12:26:26 PM (24 years ago)
Author:
sandervl
Message:

Hack added for proper resizing of wizard property sheet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/propsheet.cpp

    r7527 r7541  
    1 /* $Id: propsheet.cpp,v 1.11 2001-12-02 12:39:49 sandervl Exp $ */
     1/* $Id: propsheet.cpp,v 1.12 2001-12-04 11:26:26 sandervl Exp $ */
    22/*
    33 * Property Sheets
     
    2727#include "comctl32.h"
    2828#include "heapstring.h"
     29#include <debugtools.h>
    2930
    3031/******************************************************************************
     
    168169  if (dwFlags & PSH_USEPSTARTPAGE)
    169170  {
    170     //TRACE(propsheet, "PSH_USEPSTARTPAGE is on");
     171    TRACE("PSH_USEPSTARTPAGE is on");
    171172    psInfo->active_page = 0;
    172173  }
     
    318319  /* Extract the caption */
    319320  psInfo->proppage[index].pszText = (LPCWSTR)p;
    320   //TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
     321  TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
    321322  p += lstrlenW((LPCWSTR)p) + 1;
    322323
     
    481482   */
    482483  GetClientRect(hwndTabCtrl, &rcOrigTab);
    483 //  TRACE(propsheet, "orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
    484 //        rcOrigTab.right, rcOrigTab.bottom);
     484  TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
     485        rcOrigTab.right, rcOrigTab.bottom);
    485486
    486487  /*
     
    493494
    494495  MapDialogRect(hwndDlg, &rcPage);
    495 //  TRACE(propsheet, "biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
    496 //        rcPage.right, rcPage.bottom);
     496  TRACE("biggest page %d %d %d %d (old %,%d)\n", rcPage.left, rcPage.top,
     497        rcPage.right, rcPage.bottom, rcOrigTab.right, rcOrigTab.bottom);
    497498
    498499  if (rcPage.right > rcOrigTab.right)
     
    520521   */
    521522  GetClientRect(hwndTabCtrl, &rcOrigTab);
    522   //TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
    523   //      rcOrigTab.right, rcOrigTab.bottom);
     523  TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
     524        rcOrigTab.right, rcOrigTab.bottom);
    524525
    525526  /*
     
    532533
    533534  MapDialogRect(hwndDlg, &rcPage);
    534   //TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
    535   //      rcPage.right, rcPage.bottom);
     535  TRACE("biggest page %d %d %d %d (old %d,%d %d,%d,)\n", rcPage.left, rcPage.top,
     536        rcPage.right, rcPage.bottom, rcOrigTab.left, rcOrigTab.top, rcOrigTab.right, rcOrigTab.bottom);
    536537
    537538  if ( (rcPage.right - rcPage.left) != (rcOrigTab.right - rcOrigTab.left) )
     
    574575
    575576  MapDialogRect(hwndDlg, &rcPage);
    576 //  TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
    577 //        rcPage.right, rcPage.bottom);
     577  TRACE("biggest page %d %d %d %d (old %d,%d)\n", rcPage.left, rcPage.top,
     578        rcPage.right, rcPage.bottom, rcSheetClient.right, rcSheetClient.bottom);
    578579
    579580  if (rcPage.right > rcSheetClient.right)
     
    628629  GetClientRect(hwndTabCtrl, &rc);
    629630
    630 //  TRACE(propsheet, "tab client rc %d %d %d %d\n",
    631 //        rc.left, rc.top, rc.right, rc.bottom);
     631  TRACE("tab client rc %d %d %d %d\n",
     632        rc.left, rc.top, rc.right, rc.bottom);
    632633
    633634  rc.right += ((padding.x * 2) + tabOffsetX);
     
    642643  return TRUE;
    643644}
    644 
    645645/******************************************************************************
    646646 *            PROPSHEET_AdjustSizeWizard
     
    656656  PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg,psInfo);
    657657
     658  dprintf(("PROPSHEET_AdjustSizeWizard %x", hwndDlg));
     659
    658660  /* Get the height of buttons */
    659661  GetClientRect(hwndButton, &rc);
     
    673675  MapDialogRect(hwndDlg, &rc);
    674676
    675 //  TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
     677  TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
    676678
    677679  /* Make room */
     
    685687               SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
    686688
     689  dprintf(("PROPSHEET_AdjustSizeWizard %x DONE", hwndDlg));
    687690  return TRUE;
    688691}
     692
    689693
    690694/******************************************************************************
     
    918922 *
    919923 * Returns the layout information.
    920  * Horizontal spacing is the distance between the Cancel and Help buttons.
    921924 * Vertical spacing is the distance between the line and the buttons.
    922  */
    923 static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg,PropSheetInfo* psInfo)
     925 * Do NOT use the Help button to gather padding information when it isn't mapped
     926 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
     927 * for it in this case !
     928 * FIXME: I'm not sure about any other coordinate problems with these evil
     929 * buttons. Fix it in case additional problems appear or maybe calculate
     930 * a padding in a completely different way, as this is somewhat messy.
     931 */
     932static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, PropSheetInfo* psInfo)
    924933{
    925934  PADDING_INFO padding;
    926935  RECT rc;
    927936  HWND hwndControl;
    928   POINT ptHelp, ptCancel, ptLine;
    929 
    930   /* Help button */
    931   hwndControl = GetDlgItem(hwndDlg, IDHELP);
     937  INT idButton;
     938  POINT ptButton, ptLine;
     939
     940  TRACE("\n");
     941  if (psInfo->hasHelp)
     942  {
     943        idButton = IDHELP;
     944  }
     945  else
     946  {
     947    if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
     948    {
     949        idButton = IDC_NEXT_BUTTON;
     950    }
     951    else
     952    {
     953        /* hopefully this is ok */
     954        idButton = IDCANCEL;
     955    }
     956  }
     957 
     958  hwndControl = GetDlgItem(hwndDlg, idButton);
    932959  GetWindowRect(hwndControl, &rc);
    933960
    934   ptHelp.x = rc.left;
    935   ptHelp.y = rc.top;
    936 
    937   ScreenToClient(hwndDlg, &ptHelp);
    938 
    939   /* Cancel button */
    940   hwndControl = GetDlgItem(hwndDlg, IDCANCEL);
    941   GetWindowRect(hwndControl, &rc);
    942 
    943   ptCancel.x = rc.right;
    944   ptCancel.y = rc.top;
    945 
    946   ScreenToClient(hwndDlg, &ptCancel);
     961  ptButton.x = rc.left;
     962  ptButton.y = rc.top;
     963
     964  ScreenToClient(hwndDlg, &ptButton);
    947965
    948966  /* Line */
     
    955973  ScreenToClient(hwndDlg, &ptLine);
    956974
    957   padding.x = ptHelp.x - ptCancel.x;
    958   padding.y = ptHelp.y - ptLine.y;
    959 
    960 //CB: BUG: psInfo->hasHelp not checked -> negative values
    961 //    add better wizard handling, fix button placement bugs FIXME
    962 //
    963 //    workaround for now:
    964 if (padding.x < 0) padding.x = 0;
    965 if (padding.y < 0) padding.y = 0;
     975  padding.y = ptButton.y - ptLine.y;
     976
     977  if (padding.y < 0)
     978          ERR("padding negative ! Please report this !\n");
     979
     980  /* this is most probably not correct, but the best we have now */
     981  padding.x = padding.y;
    966982
    967983  return padding;
     
    10301046  DLGTEMPLATE* pTemplate;
    10311047  HWND hwndPage;
    1032 
     1048  RECT rc;
    10331049  PropPageInfo* ppInfo = psInfo->proppage;
    1034 
    1035   //TRACE("index %d\n", index);
    1036 
     1050  PADDING_INFO padding;
     1051  UINT pageWidth,pageHeight;
     1052  DWORD resSize;
     1053  LPVOID temp = NULL;
     1054
     1055  TRACE("index %d\n", index);
     1056
     1057#ifdef __WIN32OS2__
    10371058  //AH: Check if ppshpage is valid
    10381059  if (ppshpage == NULL)
     
    10411062    return FALSE;
    10421063  }
     1064#endif
    10431065
    10441066  if (ppshpage->dwFlags & PSP_DLGINDIRECT)
     
    10461068  else
    10471069  {
    1048     HRSRC hResource = FindResourceA(ppshpage->hInstance,
     1070    HRSRC hResource;
     1071    HANDLE hTemplate;
     1072
     1073    hResource = FindResourceA(ppshpage->hInstance,
    10491074                                    ppshpage->pszTemplate,
    10501075                                    RT_DIALOGA);
    1051     HGLOBAL hTemplate = LoadResource(ppshpage->hInstance, hResource);
     1076    if(!hResource)
     1077        return FALSE;
     1078
     1079    resSize = SizeofResource(ppshpage->hInstance, hResource);
     1080
     1081    hTemplate = LoadResource(ppshpage->hInstance, hResource);
     1082    if(!hTemplate)
     1083        return FALSE;
     1084
    10521085    pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
    1053   }
    1054 
    1055   //AH: Check if pTemplate is valid
    1056   if (pTemplate == NULL)
    1057   {
    1058     dprintf(("COMCTL32:PROPSHEET_CreatePage: ERROR!!! Dialog Template == NULL!!!\n"));
    1059     return FALSE;
    1060   }
    1061 
    1062  if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
     1086    /*
     1087     * Make a copy of the dialog template to make it writable
     1088     */
     1089    temp = COMCTL32_Alloc(resSize);
     1090    if (!temp)
     1091      return FALSE;
     1092
     1093    memcpy(temp, pTemplate, resSize);
     1094    pTemplate = (DLGTEMPLATE*)temp;
     1095  }
     1096
     1097  if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
    10631098  {
    10641099    ((MyDLGTEMPLATEEX*)pTemplate)->style |= WS_CHILD | DS_CONTROL;
     
    10691104    ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED;
    10701105    ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_VISIBLE;
     1106#ifdef __WIN32OS2__
    10711107    ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_THICKFRAME;
     1108#endif
    10721109  }
    10731110  else
    10741111  {
    1075     pTemplate->style |= WS_CHILDWINDOW | DS_CONTROL;
     1112    pTemplate->style |= WS_CHILD | DS_CONTROL;
    10761113    pTemplate->style &= ~DS_MODALFRAME;
    10771114    pTemplate->style &= ~WS_CAPTION;
     
    10801117    pTemplate->style &= ~WS_DISABLED;
    10811118    pTemplate->style &= ~WS_VISIBLE;
     1119#ifdef __WIN32OS2__
    10821120    pTemplate->style &= ~WS_THICKFRAME;
     1121#endif
    10831122  }
    10841123
     
    10891128
    10901129  hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance,
    1091                                         pTemplate,
    1092                                         hwndParent,
    1093                                         ppshpage->pfnDlgProc,
    1094                                         (LPARAM)ppshpage);
     1130                                        pTemplate,
     1131                                        hwndParent,
     1132                                        ppshpage->pfnDlgProc,
     1133                                        (LPARAM)ppshpage);
     1134  /* Free a no more needed copy */
     1135  if(temp)
     1136      COMCTL32_Free(temp);
    10951137
    10961138  ppInfo[index].hwndPage = hwndPage;
     1139
     1140  rc.left = psInfo->x;
     1141  rc.top = psInfo->y;
     1142  rc.right = psInfo->width;
     1143  rc.bottom = psInfo->height;
     1144
     1145  MapDialogRect(hwndParent, &rc);
     1146
     1147  pageWidth = rc.right - rc.left;
     1148  pageHeight = rc.bottom - rc.top;
     1149
     1150  if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
     1151    padding = PROPSHEET_GetPaddingInfoWizard(hwndParent, (PropSheetInfo* )psInfo);
     1152  else
     1153  {
     1154    /*
     1155     * Ask the Tab control to fit this page in.
     1156     */
     1157
     1158    HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
     1159    SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
     1160    padding = PROPSHEET_GetPaddingInfo(hwndParent);
     1161  }
     1162
     1163#ifdef __WIN32OS2__
     1164  //HACK alert!
     1165  //SvL: CVP multiplies y padding by two to calculate the new height
     1166  //I have no idea if this is always correct
     1167  SetWindowPos(hwndPage, HWND_TOP,
     1168               rc.left + padding.x/2,
     1169               rc.top + padding.y/2,
     1170               pageWidth, pageHeight, 0);
     1171#else
     1172  SetWindowPos(hwndPage, HWND_TOP,
     1173               rc.left + padding.x,
     1174               rc.top + padding.y,
     1175               pageWidth, pageHeight, 0);
     1176#endif
    10971177
    10981178  return TRUE;
     
    11681248  }
    11691249
     1250#if 1
     1251  ShowWindow(psInfo->proppage[index].hwndPage, SW_SHOW);
     1252
     1253  /* Synchronize current selection with tab control
     1254   * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
     1255  HWND hwndTabCtrl;
     1256  hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
     1257  SendMessageA(hwndTabCtrl, TCM_SETCURSEL, index, 0);
     1258
     1259  psInfo->active_page = index;
     1260  psInfo->activeValid = TRUE;
     1261#else
    11701262  /* HACK: Sometimes a property page doesn't get displayed at the right place inside the
    11711263   *       property sheet. This will force the window to be placed at the proper location
     
    12081300  psInfo->active_page = index;
    12091301  psInfo->activeValid = TRUE;
    1210 
     1302#endif
    12111303  return 1;
    12121304}
     
    12741366  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
    12751367
    1276   //TRACE("msg result %ld\n", msgResult);
     1368  TRACE("msg result %ld\n", msgResult);
    12771369
    12781370  if (msgResult == -1)
     
    13131405  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
    13141406
    1315   //TRACE("msg result %ld\n", msgResult);
     1407  TRACE("msg result %ld\n", msgResult);
    13161408
    13171409  if (msgResult != 0)
     
    16291721  if (index < 0 || index >= psInfo->nPages)
    16301722  {
    1631     //TRACE("Could not find page to select!\n");
     1723    TRACE("Could not find page to select!\n");
    16321724    return FALSE;
    16331725  }
    16341726
     1727  if (!psInfo->proppage[index].hwndPage) {
     1728      LPPROPSHEETPAGEA ppshpage = (LPPROPSHEETPAGEA)psInfo->proppage[index].hpage;
     1729      PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
     1730  }
    16351731  hwndPage = psInfo->proppage[index].hwndPage;
    16361732
     
    16391735   * If not it will get created and notified in PROPSHEET_ShowPage.
    16401736   */
     1737
    16411738  if (hwndPage)
    16421739  {
     
    18511948  if (index < 0 || index >= psInfo->nPages)
    18521949  {
    1853       //TRACE("Could not find page to remove!\n");
     1950      TRACE("Could not find page to remove!\n");
    18541951      return FALSE;
    18551952  }
    18561953
    1857   //TRACE("total pages %d removing page %d active page %d\n",
    1858   //      psInfo->nPages, index, psInfo->active_page);
     1954  TRACE("total pages %d removing page %d active page %d\n",
     1955        psInfo->nPages, index, psInfo->active_page);
    18591956  /*
    18601957   * Check if we're removing the active page.
     
    19352032  HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
    19362033
    1937   //TRACE("%ld\n", dwFlags);
     2034  TRACE("%ld\n", dwFlags);
    19382035
    19392036  EnableWindow(hwndBack, FALSE);
     
    20072104                                                       PropSheetInfoStr);
    20082105
    2009   //TRACE("\n");
     2106  TRACE("\n");
    20102107  if (HIWORD(psInfo->ppshheader->pszCaption))
    20112108      HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader->pszCaption);
Note: See TracChangeset for help on using the changeset viewer.