Changeset 7541 for trunk/src/comctl32/propsheet.cpp
- Timestamp:
- Dec 4, 2001, 12:26:26 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/propsheet.cpp
r7527 r7541 1 /* $Id: propsheet.cpp,v 1.1 1 2001-12-02 12:39:49sandervl Exp $ */1 /* $Id: propsheet.cpp,v 1.12 2001-12-04 11:26:26 sandervl Exp $ */ 2 2 /* 3 3 * Property Sheets … … 27 27 #include "comctl32.h" 28 28 #include "heapstring.h" 29 #include <debugtools.h> 29 30 30 31 /****************************************************************************** … … 168 169 if (dwFlags & PSH_USEPSTARTPAGE) 169 170 { 170 //TRACE(propsheet,"PSH_USEPSTARTPAGE is on");171 TRACE("PSH_USEPSTARTPAGE is on"); 171 172 psInfo->active_page = 0; 172 173 } … … 318 319 /* Extract the caption */ 319 320 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)); 321 322 p += lstrlenW((LPCWSTR)p) + 1; 322 323 … … 481 482 */ 482 483 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); 485 486 486 487 /* … … 493 494 494 495 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); 497 498 498 499 if (rcPage.right > rcOrigTab.right) … … 520 521 */ 521 522 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); 524 525 525 526 /* … … 532 533 533 534 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); 536 537 537 538 if ( (rcPage.right - rcPage.left) != (rcOrigTab.right - rcOrigTab.left) ) … … 574 575 575 576 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); 578 579 579 580 if (rcPage.right > rcSheetClient.right) … … 628 629 GetClientRect(hwndTabCtrl, &rc); 629 630 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); 632 633 633 634 rc.right += ((padding.x * 2) + tabOffsetX); … … 642 643 return TRUE; 643 644 } 644 645 645 /****************************************************************************** 646 646 * PROPSHEET_AdjustSizeWizard … … 656 656 PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg,psInfo); 657 657 658 dprintf(("PROPSHEET_AdjustSizeWizard %x", hwndDlg)); 659 658 660 /* Get the height of buttons */ 659 661 GetClientRect(hwndButton, &rc); … … 673 675 MapDialogRect(hwndDlg, &rc); 674 676 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); 676 678 677 679 /* Make room */ … … 685 687 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); 686 688 689 dprintf(("PROPSHEET_AdjustSizeWizard %x DONE", hwndDlg)); 687 690 return TRUE; 688 691 } 692 689 693 690 694 /****************************************************************************** … … 918 922 * 919 923 * Returns the layout information. 920 * Horizontal spacing is the distance between the Cancel and Help buttons.921 924 * 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 */ 932 static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, PropSheetInfo* psInfo) 924 933 { 925 934 PADDING_INFO padding; 926 935 RECT rc; 927 936 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); 932 959 GetWindowRect(hwndControl, &rc); 933 960 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); 947 965 948 966 /* Line */ … … 955 973 ScreenToClient(hwndDlg, &ptLine); 956 974 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; 966 982 967 983 return padding; … … 1030 1046 DLGTEMPLATE* pTemplate; 1031 1047 HWND hwndPage; 1032 1048 RECT rc; 1033 1049 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__ 1037 1058 //AH: Check if ppshpage is valid 1038 1059 if (ppshpage == NULL) … … 1041 1062 return FALSE; 1042 1063 } 1064 #endif 1043 1065 1044 1066 if (ppshpage->dwFlags & PSP_DLGINDIRECT) … … 1046 1068 else 1047 1069 { 1048 HRSRC hResource = FindResourceA(ppshpage->hInstance, 1070 HRSRC hResource; 1071 HANDLE hTemplate; 1072 1073 hResource = FindResourceA(ppshpage->hInstance, 1049 1074 ppshpage->pszTemplate, 1050 1075 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 1052 1085 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) 1063 1098 { 1064 1099 ((MyDLGTEMPLATEEX*)pTemplate)->style |= WS_CHILD | DS_CONTROL; … … 1069 1104 ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED; 1070 1105 ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_VISIBLE; 1106 #ifdef __WIN32OS2__ 1071 1107 ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_THICKFRAME; 1108 #endif 1072 1109 } 1073 1110 else 1074 1111 { 1075 pTemplate->style |= WS_CHILD WINDOW| DS_CONTROL;1112 pTemplate->style |= WS_CHILD | DS_CONTROL; 1076 1113 pTemplate->style &= ~DS_MODALFRAME; 1077 1114 pTemplate->style &= ~WS_CAPTION; … … 1080 1117 pTemplate->style &= ~WS_DISABLED; 1081 1118 pTemplate->style &= ~WS_VISIBLE; 1119 #ifdef __WIN32OS2__ 1082 1120 pTemplate->style &= ~WS_THICKFRAME; 1121 #endif 1083 1122 } 1084 1123 … … 1089 1128 1090 1129 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); 1095 1137 1096 1138 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 1097 1177 1098 1178 return TRUE; … … 1168 1248 } 1169 1249 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 1170 1262 /* HACK: Sometimes a property page doesn't get displayed at the right place inside the 1171 1263 * property sheet. This will force the window to be placed at the proper location … … 1208 1300 psInfo->active_page = index; 1209 1301 psInfo->activeValid = TRUE; 1210 1302 #endif 1211 1303 return 1; 1212 1304 } … … 1274 1366 msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); 1275 1367 1276 //TRACE("msg result %ld\n", msgResult);1368 TRACE("msg result %ld\n", msgResult); 1277 1369 1278 1370 if (msgResult == -1) … … 1313 1405 msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); 1314 1406 1315 //TRACE("msg result %ld\n", msgResult);1407 TRACE("msg result %ld\n", msgResult); 1316 1408 1317 1409 if (msgResult != 0) … … 1629 1721 if (index < 0 || index >= psInfo->nPages) 1630 1722 { 1631 //TRACE("Could not find page to select!\n");1723 TRACE("Could not find page to select!\n"); 1632 1724 return FALSE; 1633 1725 } 1634 1726 1727 if (!psInfo->proppage[index].hwndPage) { 1728 LPPROPSHEETPAGEA ppshpage = (LPPROPSHEETPAGEA)psInfo->proppage[index].hpage; 1729 PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage); 1730 } 1635 1731 hwndPage = psInfo->proppage[index].hwndPage; 1636 1732 … … 1639 1735 * If not it will get created and notified in PROPSHEET_ShowPage. 1640 1736 */ 1737 1641 1738 if (hwndPage) 1642 1739 { … … 1851 1948 if (index < 0 || index >= psInfo->nPages) 1852 1949 { 1853 //TRACE("Could not find page to remove!\n");1950 TRACE("Could not find page to remove!\n"); 1854 1951 return FALSE; 1855 1952 } 1856 1953 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); 1859 1956 /* 1860 1957 * Check if we're removing the active page. … … 1935 2032 HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); 1936 2033 1937 //TRACE("%ld\n", dwFlags);2034 TRACE("%ld\n", dwFlags); 1938 2035 1939 2036 EnableWindow(hwndBack, FALSE); … … 2007 2104 PropSheetInfoStr); 2008 2105 2009 //TRACE("\n");2106 TRACE("\n"); 2010 2107 if (HIWORD(psInfo->ppshheader->pszCaption)) 2011 2108 HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader->pszCaption);
Note:
See TracChangeset
for help on using the changeset viewer.