- Timestamp:
- Sep 5, 2001, 2:14:25 PM (24 years ago)
- Location:
- trunk/src
- Files:
-
- 18 edited
-
comdlg32/colordlg.c (modified) (44 diffs)
-
comdlg32/filedlg.c (modified) (64 diffs)
-
comdlg32/filedlg95.c (modified) (97 diffs)
-
comdlg32/filedlgbrowser.c (modified) (41 diffs)
-
comdlg32/filetitle.c (modified) (4 diffs)
-
comdlg32/finddlg32.c (modified) (14 diffs)
-
comdlg32/fontdlg.c (modified) (39 diffs)
-
comdlg32/initcomdlg32.cpp (modified) (3 diffs)
-
comdlg32/initterm.cpp (modified) (2 diffs)
-
comdlg32/printdlg.c (modified) (82 diffs)
-
crtdll/crtdll.cpp (modified) (58 diffs)
-
crtdll/crtdll_main.c (modified) (35 diffs)
-
crtdll/dir.c (modified) (18 diffs)
-
crtdll/exit.c (modified) (13 diffs)
-
crtdll/file.c (modified) (51 diffs)
-
crtdll/initterm.cpp (modified) (3 diffs)
-
crtdll/memory.c (modified) (8 diffs)
-
crtdll/spawn.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/colordlg.c
r5583 r6645 1 /* $Id: colordlg.c,v 1.4 2001-09-05 12:11:59 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - Color Dialog … … 74 75 int nextuserdef; /* next free place in user defined color array */ 75 76 HDC hdcMem; /* color graph used for BitBlt() */ 76 HBITMAP hbmMem; /* color graph bitmap */ 77 HBITMAP hbmMem; /* color graph bitmap */ 77 78 RECT fullsize; /* original dialog window size */ 78 79 UINT msetrgb; /* # of SETRGBSTRING message (today not used) */ … … 155 156 /* lum */ 156 157 case 'L': mmsum *= 120; /* 0...61200=(255+255)*120 */ 157 result = mmsum / 255; /* 0...240 */158 break;158 result = mmsum / 255; /* 0...240 */ 159 break; 159 160 /* saturation */ 160 161 case 'S': if (!mmsum) 161 result = 0;162 else163 if (!mini || maxi == 255)164 result = 240;165 else166 {167 result = mmdif * 240; /* 0...61200=255*240 */168 result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */169 }170 break;162 result = 0; 163 else 164 if (!mini || maxi == 255) 165 result = 240; 166 else 167 { 168 result = mmdif * 240; /* 0...61200=255*240 */ 169 result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */ 170 } 171 break; 171 172 /* hue */ 172 173 case 'H': if (!mmdif) 173 result = 160;174 else175 {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 else184 if (maxi == g)185 {186 iresult = 40 * (b - r);187 iresult /= (int) mmdif;188 iresult += 80; /* 40 .. 120 */189 }190 else191 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;174 result = 160; 175 else 176 { 177 if (maxi == r) 178 { 179 iresult = 40 * (g - b); /* -10200 ... 10200 */ 180 iresult /= (int) mmdif; /* -40 .. 40 */ 181 if (iresult < 0) 182 iresult += 240; /* 0..40 and 200..240 */ 183 } 184 else 185 if (maxi == g) 186 { 187 iresult = 40 * (b - r); 188 iresult /= (int) mmdif; 189 iresult += 80; /* 40 .. 120 */ 190 } 191 else 192 if (maxi == b) 193 { 194 iresult = 40 * (r - g); 195 iresult /= (int) mmdif; 196 iresult += 160; /* 120 .. 200 */ 197 } 198 result = iresult; 199 } 200 break; 200 201 } 201 202 return result; /* is this integer arithmetic precise enough ? */ … … 249 250 */ 250 251 static int CC_MouseCheckPredefColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols, 251 LPARAM lParam )252 LPARAM lParam ) 252 253 { 253 254 HWND hwnd; … … 283 284 */ 284 285 static int CC_MouseCheckUserColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols, 285 LPARAM lParam )286 LPARAM lParam ) 286 287 { 287 288 HWND hwnd; … … 317 318 318 319 /* 240 ^...... ^^ 240 319 | . ||320 | . || 320 321 SAT | . || LUM 321 | . ||322 +-----> 239 ----323 HUE322 | . || 323 +-----> 239 ---- 324 HUE 324 325 */ 325 326 /*********************************************************************** … … 464 465 RECT rect; 465 466 HWND hwnd = GetDlgItem(hDlg, 0x2be); 466 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER); 467 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER); 467 468 468 469 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6))) /* if full size */ … … 476 477 ScreenToClient(hDlg, points); /* |< | */ 477 478 oben = points[0].y; /* | \ | */ 478 /* | \| */479 /* | \| */ 479 480 temp = (long)height * (long)y; 480 481 points[0].y = oben + height - temp / (long)MAXVERT; … … 502 503 int w = GetDialogBaseUnits(); 503 504 HWND hwnd = GetDlgItem(hDlg, 0x2c6); 504 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER ); 505 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER ); 505 506 RECT rect; 506 507 POINT point, p; … … 524 525 lpp->oldcross.right = point.x + w + 1; 525 526 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); 527 lpp->oldcross.bottom = point.y + w + 1; 528 529 MoveToEx(hDC, point.x - w, point.y, &p); 529 530 LineTo(hDC, point.x + w, point.y); 530 MoveToEx(hDC, point.x, point.y - w, &p); 531 MoveToEx(hDC, point.x, point.y - w, &p); 531 532 LineTo(hDC, point.x, point.y + w); 532 533 DeleteObject( SelectObject(hDC, hPen)) ; … … 543 544 * CC_PrepareColorGraph [internal] 544 545 */ 545 static void CC_PrepareColorGraph( HWND hDlg ) 546 static void CC_PrepareColorGraph( HWND hDlg ) 546 547 { 547 548 int sdif, hdif, xdif, ydif, r, g, b, hue, sat; 548 549 HWND hwnd = GetDlgItem(hDlg, 0x2c6); 549 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 550 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 550 551 HBRUSH hbrush; 551 552 HDC hdc ; … … 590 591 { 591 592 HWND hwnd = GetDlgItem( hDlg, 0x2c6 ); 592 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 593 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 593 594 HDC hDC; 594 595 RECT rect; … … 650 651 { 651 652 char buffer[10]; 652 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 653 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 653 654 int r = GetRValue(cr); 654 655 int g = GetGValue(cr); … … 695 696 { 696 697 int i; 697 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 698 698 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 699 699 700 EnableWindow( GetDlgItem(hDlg, 0x2cf), FALSE); 700 701 CC_PrepareColorGraph(hDlg); … … 743 744 for ( j = 0; j < rows; j++ ) 744 745 { 745 for ( i = 0; i < cols; i++ ) 746 for ( i = 0; i < cols; i++ ) 746 747 { 747 748 hBrush = CreateSolidBrush(predefcolors[j][i]); … … 764 765 /*********************************************************************** 765 766 * CC_PaintUserColorArray [internal] 766 * Paint the 16 user-selected colors 767 * Paint the 16 user-selected colors 767 768 */ 768 769 static void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, COLORREF* lpcr ) … … 782 783 783 784 hdc = GetDC(hwnd); 784 if (hdc) 785 if (hdc) 785 786 { 786 787 FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND) ); … … 791 792 hBrush = CreateSolidBrush(lpcr[i+j*cols]); 792 793 if (hBrush) 793 { 794 { 794 795 hBrush = SelectObject(hdc, hBrush) ; 795 796 Rectangle(hdc, rect.left, rect.top, … … 826 827 * CC_WMInitDialog [internal] 827 828 */ 828 static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ) 829 static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ) 829 830 { 830 831 int i, res; … … 833 834 RECT rect; 834 835 POINT point; 835 LCCPRIV lpp; 836 836 LCCPRIV lpp; 837 837 838 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam); 838 839 lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) ); … … 851 852 } 852 853 ch32->lStructSize = sizeof(CHOOSECOLORW); 853 ch32->hwndOwner = ch16->hwndOwner; 854 ch32->hwndOwner = ch16->hwndOwner; 854 855 ch32->hInstance = ch16->hInstance; 855 856 ch32->lpCustColors = PTR_SEG_TO_LIN(ch16->lpCustColors); … … 866 867 return FALSE; 867 868 } 868 SetWindowLongA(hDlg, DWL_USER, (LONG)lpp); 869 SetWindowLongA(hDlg, DWL_USER, (LONG)lpp); 869 870 870 871 if (!(lpp->lpcc->Flags & CC_SHOWHELP)) … … 876 877 if (lpp->lpcc->Flags & CC_RGBINIT) 877 878 { 878 for (i = 0; i < 6; i++) 879 for (i = 0; i < 6; i++) 879 880 for (j = 0; j < 8; j++) 880 881 if (predefcolors[i][j] == lpp->lpcc->rgbResult) … … 930 931 res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam); 931 932 } 932 933 933 934 /* Set the initial values of the color chooser dialog */ 934 935 r = GetRValue(lpp->lpcc->rgbResult); … … 959 960 * CC_WMCommand [internal] 960 961 */ 961 static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) 962 static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) 962 963 { 963 964 int r, g, b, i, xx; … … 965 966 HDC hdc; 966 967 COLORREF *cr; 967 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 968 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 968 969 TRACE("CC_WMCommand wParam=%x lParam=%lx\n", wParam, lParam); 969 970 switch (wParam) 970 971 { 971 972 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 973 case 0x2c3: 974 case 0x2c4: 975 if (notifyCode == EN_UPDATE && !lpp->updating) 976 { 977 i = CC_CheckDigitsInEdit(hwndCtl, 255); 978 r = GetRValue(lpp->lpcc->rgbResult); 979 g = GetGValue(lpp->lpcc->rgbResult); 980 b= GetBValue(lpp->lpcc->rgbResult); 981 xx = 0; 982 switch (wParam) 983 { 984 case 0x2c2: if ((xx = (i != r))) r = i; break; 985 case 0x2c3: if ((xx = (i != g))) g = i; break; 986 case 0x2c4: if ((xx = (i != b))) b = i; break; 987 } 988 if (xx) /* something has changed */ 989 { 990 lpp->lpcc->rgbResult = RGB(r, g, b); 991 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult); 992 lpp->h = CC_RGBtoHSL('H', r, g, b); 993 lpp->s = CC_RGBtoHSL('S', r, g, b); 994 lpp->l = CC_RGBtoHSL('L', r, g, b); 995 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l); 996 CC_PaintCross(hDlg, lpp->h, lpp->s); 997 CC_PaintTriangle(hDlg, lpp->l); 998 } 999 } 1000 break; 1001 1002 case 0x2bf: /* edit notify HSL */ 1003 case 0x2c0: 1004 case 0x2c1: 1005 if (notifyCode == EN_UPDATE && !lpp->updating) 1006 { 1007 i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240); 1008 xx = 0; 1009 switch (wParam) 1010 { 1011 case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break; 1012 case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break; 1013 case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break; 1014 } 1015 if (xx) /* something has changed */ 1016 { 1017 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l); 1018 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l); 1019 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l); 1020 lpp->lpcc->rgbResult = RGB(r, g, b); 1021 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult); 1022 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult); 1023 CC_PaintCross(hDlg, lpp->h, lpp->s); 1024 CC_PaintTriangle(hDlg, lpp->l); 1025 } 1026 } 1027 break; 1028 1028 1029 case 0x2cf: 1029 1030 CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, &lpp->fullsize); 1030 SetFocus( GetDlgItem(hDlg, 0x2bf));1031 break;1031 SetFocus( GetDlgItem(hDlg, 0x2bf)); 1032 break; 1032 1033 1033 1034 case 0x2c8: /* add colors ... column by column */ … … 1035 1036 cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult; 1036 1037 if (++lpp->nextuserdef == 16) 1037 lpp->nextuserdef = 0;1038 CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);1039 break;1038 lpp->nextuserdef = 0; 1039 CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors); 1040 break; 1040 1041 1041 1042 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);1043 hdc = GetDC(hDlg); 1044 lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult); 1045 ReleaseDC(hDlg, hdc); 1046 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult); 1047 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult); 1048 r = GetRValue(lpp->lpcc->rgbResult); 1049 g = GetGValue(lpp->lpcc->rgbResult); 1050 b = GetBValue(lpp->lpcc->rgbResult); 1051 lpp->h = CC_RGBtoHSL('H', r, g, b); 1052 lpp->s = CC_RGBtoHSL('S', r, g, b); 1053 lpp->l = CC_RGBtoHSL('L', r, g, b); 1054 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l); 1055 CC_PaintCross(hDlg, lpp->h, lpp->s); 1056 CC_PaintTriangle(hDlg, lpp->l); 1057 break; 1058 1059 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */ 1060 i = RegisterWindowMessageA(HELPMSGSTRINGA); 1060 1061 #ifndef __WIN32OS2__ 1061 1062 if (lpp->lpcc16) 1062 1063 { 1063 1064 if (lpp->lpcc->hwndOwner) 1064 SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);1065 SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16); 1065 1066 if ( CC_HookCallChk(lpp->lpcc)) 1066 CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,1067 WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);1067 CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg, 1068 WM_COMMAND, psh15, (LPARAM)lpp->lpcc16); 1068 1069 } 1069 1070 else … … 1071 1072 #endif //!__WIN32OS2__ 1072 1073 if (lpp->lpcc->hwndOwner) 1073 SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);1074 SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc); 1074 1075 if ( CC_HookCallChk(lpp->lpcc)) 1075 CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,1076 WM_COMMAND, psh15, (LPARAM)lpp->lpcc);1076 CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg, 1077 WM_COMMAND, psh15, (LPARAM)lpp->lpcc); 1077 1078 #ifndef __WIN32OS2__ 1078 1079 } 1079 1080 #endif //!__WIN32OS2__ 1080 break;1081 break; 1081 1082 1082 1083 case IDOK : 1083 cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);1084 cokmsg = RegisterWindowMessageA(COLOROKSTRINGA); 1084 1085 #ifndef __WIN32OS2__ 1085 1086 if (lpp->lpcc16) 1086 1087 { 1087 if (lpp->lpcc->hwndOwner)1088 if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))1089 break; /* do NOT close */1088 if (lpp->lpcc->hwndOwner) 1089 if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16)) 1090 break; /* do NOT close */ 1090 1091 } 1091 1092 else 1092 1093 { 1093 1094 #endif //!__WIN32OS2__ 1094 if (lpp->lpcc->hwndOwner)1095 if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))1096 break; /* do NOT close */1095 if (lpp->lpcc->hwndOwner) 1096 if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc)) 1097 break; /* do NOT close */ 1097 1098 #ifndef __WIN32OS2__ 1098 1099 } … … 1104 1105 } 1105 1106 #endif 1106 EndDialog(hDlg, 1) ;1107 return TRUE ;1108 1109 case IDCANCEL :1110 EndDialog(hDlg, 0) ;1111 return TRUE ;1107 EndDialog(hDlg, 1) ; 1108 return TRUE ; 1109 1110 case IDCANCEL : 1111 EndDialog(hDlg, 0) ; 1112 return TRUE ; 1112 1113 1113 1114 } … … 1118 1119 * CC_WMPaint [internal] 1119 1120 */ 1120 static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ) 1121 static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ) 1121 1122 { 1122 1123 HDC hdc; 1123 1124 PAINTSTRUCT ps; 1124 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1125 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1125 1126 1126 1127 hdc = BeginPaint(hDlg, &ps); … … 1151 1152 CC_PaintCross(hDlg, lpp->h, lpp->s); 1152 1153 return 1; 1153 } 1154 } 1154 1155 return 0; 1155 1156 } … … 1159 1160 * CC_WMMouseMove [internal] 1160 1161 */ 1161 static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ) 1162 { 1163 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1162 static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ) 1163 { 1164 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1164 1165 int r, g, b; 1165 1166 … … 1167 1168 { 1168 1169 int *ptrh = NULL, *ptrs = &lpp->l; 1169 if (lpp->capturedGraph == 0x2c6) 1170 if (lpp->capturedGraph == 0x2c6) 1170 1171 { 1171 1172 ptrh = &lpp->h; … … 1196 1197 * CC_WMLButtonDown [internal] 1197 1198 */ 1198 static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ) 1199 { 1200 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1199 static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ) 1200 { 1201 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1201 1202 int r, g, b, i; 1202 1203 i = 0; … … 1208 1209 i = 1; 1209 1210 else 1210 if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))1211 if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam)) 1211 1212 { 1212 i = 2;1213 i = 2; 1213 1214 lpp->capturedGraph = 0x2c6; 1214 1215 } 1215 else1216 if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))1216 else 1217 if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam)) 1217 1218 { 1218 i = 2;1219 i = 2; 1219 1220 lpp->capturedGraph = 0x2be; 1220 1221 } … … 1276 1277 1277 1278 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); 1279 { 1280 case WM_INITDIALOG: 1281 return CC_WMInitDialog(hDlg, wParam, lParam, FALSE); 1282 case WM_NCDESTROY: 1283 DeleteDC(lpp->hdcMem); 1284 DeleteObject(lpp->hbmMem); 1284 1285 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)*/1286 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */ 1287 break; 1288 case WM_COMMAND: 1289 if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam)) 1290 return TRUE; 1291 break; 1292 case WM_PAINT: 1293 if ( CC_WMPaint(hDlg, wParam, lParam)) 1294 return TRUE; 1295 break; 1296 case WM_LBUTTONDBLCLK: 1297 if (CC_MouseCheckResultWindow(hDlg, lParam)) 1298 return TRUE; 1299 break; 1300 case WM_MOUSEMOVE: 1301 if (CC_WMMouseMove(hDlg, lParam)) 1302 return TRUE; 1303 break; 1304 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/ 1304 1305 if (CC_WMLButtonUp(hDlg, wParam, lParam)) 1305 1306 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 }1307 break; 1308 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/ 1309 if (CC_WMLButtonDown(hDlg, wParam, lParam)) 1310 return TRUE; 1311 break; 1312 } 1312 1313 return FALSE ; 1313 1314 } … … 1321 1322 { 1322 1323 int res; 1323 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1324 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 1324 1325 if (message != WM_INITDIALOG) 1325 1326 { … … 1339 1340 1340 1341 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); 1342 { 1343 case WM_INITDIALOG: 1344 return CC_WMInitDialog(hDlg, wParam, lParam, TRUE); 1345 case WM_NCDESTROY: 1346 DeleteDC(lpp->hdcMem); 1347 DeleteObject(lpp->hbmMem); 1347 1348 HeapFree(GetProcessHeap(), 0, lpp->lpcc); 1348 1349 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)*/1350 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */ 1351 break; 1352 case WM_COMMAND: 1353 if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam))) 1354 return TRUE; 1355 break; 1356 case WM_PAINT: 1357 if (CC_WMPaint(hDlg, wParam, lParam)) 1358 return TRUE; 1359 break; 1360 case WM_LBUTTONDBLCLK: 1361 if (CC_MouseCheckResultWindow(hDlg,lParam)) 1362 return TRUE; 1363 break; 1364 case WM_MOUSEMOVE: 1365 if (CC_WMMouseMove(hDlg, lParam)) 1366 return TRUE; 1367 break; 1368 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/ 1368 1369 if (CC_WMLButtonUp(hDlg, wParam, lParam)) 1369 1370 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 }1371 break; 1372 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/ 1373 if (CC_WMLButtonDown(hDlg, wParam, lParam)) 1374 return TRUE; 1375 break; 1376 } 1376 1377 return FALSE ; 1377 1378 } … … 1390 1391 LPCVOID template; 1391 1392 FARPROC16 ptr; 1392 1393 1393 1394 TRACE("ChooseColor\n"); 1394 if (!lpChCol) return FALSE; 1395 if (!lpChCol) return FALSE; 1395 1396 1396 1397 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) … … 1415 1416 else 1416 1417 { 1417 HANDLE hResInfo, hDlgTmpl32;1418 HANDLE hResInfo, hDlgTmpl32; 1418 1419 LPCVOID template32; 1419 1420 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 }1421 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA))) 1422 { 1423 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 1424 return FALSE; 1425 } 1426 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) || 1427 !(template32 = LockResource(hDlgTmpl32))) 1428 { 1429 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1430 return FALSE; 1431 } 1431 1432 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo); 1432 1433 hGlobal16 = GlobalAlloc16(0, size); … … 1438 1439 } 1439 1440 template = GlobalLock16(hGlobal16); 1440 if (!template) 1441 if (!template) 1441 1442 { 1442 1443 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE); … … 1475 1476 1476 1477 TRACE("ChooseColor\n"); 1477 if (!lpChCol) return FALSE; 1478 if (!lpChCol) return FALSE; 1478 1479 1479 1480 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) … … 1504 1505 else 1505 1506 { 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 }1507 HANDLE hResInfo, hDlgTmpl; 1508 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA))) 1509 { 1510 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 1511 return FALSE; 1512 } 1513 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) || 1514 !(template = LockResource(hDlgTmpl))) 1515 { 1516 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1517 return FALSE; 1518 } 1518 1519 } 1519 1520 … … 1541 1542 if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) { 1542 1543 if (HIWORD(lpChCol->lpTemplateName)) 1543 lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);1544 lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName); 1544 1545 else 1545 lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;1546 lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName; 1546 1547 } 1547 1548 -
trunk/src/comdlg32/filedlg.c
r6315 r6645 1 /* $Id: filedlg.c,v 1.6 2001-09-05 12:12:00 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - File Dialogs … … 28 29 #define GlobalLock16 GlobalLock 29 30 #define GlobalUnlock16 GlobalUnlock 30 #define GlobalAlloc16 GlobalAlloc31 #define FreeResource16 FreeResource31 #define GlobalAlloc16 GlobalAlloc 32 #define FreeResource16 FreeResource 32 33 #define LoadResource16 LoadResourceA 33 34 #define FindResource16 FindResourceA 34 #define MapSL(a) a35 #define MapSL(a) a 35 36 #define CallWindowProc16 CallWindowProcA 36 37 … … 42 43 43 44 #define BUFFILE 512 44 #define BUFFILEALLOC 512 * sizeof(WCHAR) 45 46 struct FSPRIVATE 45 #define BUFFILEALLOC 512 * sizeof(WCHAR) 46 47 struct FSPRIVATE 47 48 { 48 49 HWND hwnd; /* file dialog window handle */ … … 75 76 #define LFS32A 2 76 77 #define LFS32W 3 77 78 78 79 static const WCHAR FILE_star[] = {'*','.','*', 0}; 79 80 static const WCHAR FILE_bslash[] = {'\\', 0}; … … 111 112 112 113 LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 113 LPARAM lParam);114 LPARAM lParam); 114 115 LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 115 LPARAM lParam);116 LPARAM lParam); 116 117 117 118 static LRESULT WINAPI FileOpenDlgProc(HWND hDlg, UINT msg, … … 119 120 120 121 /*********************************************************************** 121 * FileDlg_Init[internal]122 * FileDlg_Init [internal] 122 123 */ 123 124 static BOOL FileDlg_Init(void) … … 125 126 static BOOL initialized = 0; 126 127 CURSORICONINFO *fldrInfo; 127 128 128 129 if (!initialized) { 129 130 #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);131 if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED); 132 if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED); 133 if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED); 134 if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED); 135 if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED); 136 if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED); 136 137 #else 137 138 HINSTANCE inst = GetModuleHandleA( "comdlg32.dll" ); … … 148 149 hNet = LoadImageA( inst, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED ); 149 150 #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 }151 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 || 152 hHDisk == 0 || hCDRom == 0 || hNet == 0) 153 { 154 ERR("Error loading icons !\n"); 155 return FALSE; 156 } 156 157 #ifdef __WIN32OS2__ 157 fldrHeight = 16;158 fldrWidth = 16;158 fldrHeight = 16; 159 fldrWidth = 16; 159 160 #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;161 fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 ); 162 if (!fldrInfo) 163 { 164 ERR("Error measuring icons !\n"); 165 return FALSE; 166 } 167 fldrHeight = fldrInfo -> nHeight; 168 fldrWidth = fldrInfo -> nWidth; 169 GlobalUnlock16( hFolder2 ); 170 #endif 171 initialized = TRUE; 171 172 } 172 173 return TRUE; … … 188 189 if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE) 189 190 { 190 if (!(lfs->template = LockResource( ofnW->hInstance )))191 {192 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);193 return FALSE;194 }191 if (!(lfs->template = LockResource( ofnW->hInstance ))) 192 { 193 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 194 return FALSE; 195 } 195 196 } 196 197 else if (ofnW->Flags & OFN_ENABLETEMPLATE) 197 198 { 198 HANDLE hResInfo;199 HANDLE hResInfo; 199 200 if (lfs->ofnA) 200 hResInfo = FindResourceA(lfs->ofnA->hInstance,201 lfs->ofnA->lpTemplateName,201 hResInfo = FindResourceA(lfs->ofnA->hInstance, 202 lfs->ofnA->lpTemplateName, 202 203 RT_DIALOGA); 203 204 else 204 hResInfo = FindResourceW(ofnW->hInstance,205 ofnW->lpTemplateName,205 hResInfo = FindResourceW(ofnW->hInstance, 206 ofnW->lpTemplateName, 206 207 RT_DIALOGW); 207 208 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 }209 { 210 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 211 return FALSE; 212 } 213 if (!(hDlgTmpl = LoadResource(ofnW->hInstance, 214 hResInfo)) || 215 !(lfs->template = LockResource(hDlgTmpl))) 216 { 217 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 218 return FALSE; 219 } 219 220 } else { /* get it from internal Wine resource */ 220 HANDLE hResInfo;221 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 221 HANDLE hResInfo; 222 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 222 223 lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA))) 223 {224 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);225 return FALSE;224 { 225 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 226 return FALSE; 226 227 } 227 228 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) || … … 253 254 else if (ofn16->Flags & OFN_ENABLETEMPLATE) 254 255 { 255 HANDLE16 hResInfo;256 if (!(hResInfo = FindResource16(ofn16->hInstance,257 MapSL(ofn16->lpTemplateName),256 HANDLE16 hResInfo; 257 if (!(hResInfo = FindResource16(ofn16->hInstance, 258 MapSL(ofn16->lpTemplateName), 258 259 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 }260 { 261 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 262 return FALSE; 263 } 264 if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo ))) 265 { 266 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 267 return FALSE; 268 } 268 269 lfs->hResource16 = lfs->hDlgTmpl16; 269 270 } 270 271 else 271 272 { /* get resource from (32 bits) own Wine resource; convert it to 16 */ 272 HANDLE hResInfo, hDlgTmpl32;273 HANDLE hResInfo, hDlgTmpl32; 273 274 LPCVOID template32; 274 275 DWORD size; 275 276 276 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 277 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 277 278 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 }279 { 280 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 281 return FALSE; 282 } 283 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) || 284 !(template32 = LockResource( hDlgTmpl32 ))) 285 { 286 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 287 return FALSE; 288 } 288 289 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo); 289 290 hGlobal16 = GlobalAlloc16(0, size); … … 321 322 cp = strrchrW(temp, '\\'); 322 323 if (cp != NULL) { 323 strcpyW(temp, cp+1);324 strcpyW(temp, cp+1); 324 325 } 325 326 cp = strrchrW(temp, ':'); 326 327 if (cp != NULL) { 327 strcpyW(temp, cp+1);328 strcpyW(temp, cp+1); 328 329 } 329 330 /* FIXME: shouldn't we do something with the result here? ;-) */ … … 366 367 367 368 /*********************************************************************** 368 * FILEDLG_ScanDir [internal]369 * FILEDLG_ScanDir [internal] 369 370 */ 370 371 static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath) 371 372 { 372 WCHAR buffer[BUFFILE];373 HWND hdlg, hdlgDir;373 WCHAR buffer[BUFFILE]; 374 HWND hdlg, hdlgDir; 374 375 LRESULT lRet = TRUE; 375 376 HCURSOR hCursorWait, oldCursor; … … 387 388 /* list of files */ 388 389 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;390 WCHAR* scptr; /* ptr on semi-colon */ 391 WCHAR* filter = buffer; 392 393 TRACE("Using filter %s\n", debugstr_w(filter)); 394 SendMessageW(hdlg, LB_RESETCONTENT, 0, 0); 395 while (filter) { 396 scptr = strchrW(filter, ';'); 397 if (scptr) *scptr = 0; 397 398 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 }399 TRACE("Using file spec %s\n", debugstr_w(filter)); 400 if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR) 401 return FALSE; 402 if (scptr) *scptr = ';'; 403 filter = (scptr) ? (scptr + 1) : 0; 404 } 404 405 } 405 406 … … 416 417 417 418 /*********************************************************************** 418 * FILEDLG_GetFileType[internal]419 * FILEDLG_GetFileType [internal] 419 420 */ 420 421 … … 424 425 i = 0; 425 426 if (cfptr) 426 for ( ;(n = lstrlenW(cfptr)) != 0; i++) 427 for ( ;(n = lstrlenW(cfptr)) != 0; i++) 427 428 { 428 cfptr += n + 1;429 if (i == index)430 return cfptr;431 cfptr += lstrlenW(cfptr) + 1;429 cfptr += n + 1; 430 if (i == index) 431 return cfptr; 432 cfptr += lstrlenW(cfptr) + 1; 432 433 } 433 434 if (fptr) 434 for ( ;(n = lstrlenW(fptr)) != 0; i++) 435 for ( ;(n = lstrlenW(fptr)) != 0; i++) 435 436 { 436 fptr += n + 1;437 if (i == index)438 return fptr;439 fptr += lstrlenW(fptr) + 1;437 fptr += n + 1; 438 if (i == index) 439 return fptr; 440 fptr += lstrlenW(fptr) + 1; 440 441 } 441 442 return (LPWSTR) FILE_star; /* FIXME */ … … 455 456 { 456 457 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE; 457 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 458 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 458 459 (LPARAM)str); 459 460 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,461 if ((lpdis->itemState & ODS_SELECTED) && !savedlg) 462 { 463 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 464 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 465 } 466 if (savedlg) 467 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) ); 468 469 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1, 469 470 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED, 470 471 &(lpdis->rcItem), str, lstrlenW(str), NULL); 471 472 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 }473 if (lpdis->itemState & ODS_SELECTED) 474 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) ); 475 476 if ((lpdis->itemState & ODS_SELECTED) && !savedlg) 477 { 478 SetBkColor( lpdis->hDC, oldBk ); 479 SetTextColor( lpdis->hDC, oldText ); 480 } 480 481 HeapFree(GetProcessHeap(), 0, str); 481 return TRUE;482 return TRUE; 482 483 } 483 484 … … 486 487 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) 487 488 return FALSE; 488 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 489 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 489 490 (LPARAM)str); 490 491 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,492 if (lpdis->itemState & ODS_SELECTED) 493 { 494 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 495 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 496 } 497 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth, 497 498 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED, 498 499 &(lpdis->rcItem), str, lstrlenW(str), NULL); 499 500 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);501 if (lpdis->itemState & ODS_SELECTED) 502 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) ); 503 504 if (lpdis->itemState & ODS_SELECTED) 505 { 506 SetBkColor( lpdis->hDC, oldBk ); 507 SetTextColor( lpdis->hDC, oldText ); 508 } 509 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder); 509 510 HeapFree(GetProcessHeap(), 0, str); 510 return TRUE;511 return TRUE; 511 512 } 512 513 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2) … … 515 516 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) 516 517 return FALSE; 517 SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, 518 SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, 518 519 (LPARAM)str); 519 520 root[0] += str[2] - 'a'; … … 526 527 default: hIcon = hHDisk; break; 527 528 } 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,529 if (lpdis->itemState & ODS_SELECTED) 530 { 531 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 532 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 533 } 534 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth, 534 535 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED, 535 536 &(lpdis->rcItem), str, lstrlenW(str), NULL); 536 537 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);538 if (lpdis->itemState & ODS_SELECTED) 539 { 540 SetBkColor( lpdis->hDC, oldBk ); 541 SetTextColor( lpdis->hDC, oldText ); 542 } 543 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon); 543 544 HeapFree(GetProcessHeap(), 0, str); 544 return TRUE;545 return TRUE; 545 546 } 546 547 return FALSE; … … 550 551 * FILEDLG_WMMeasureItem [internal] 551 552 */ 552 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 553 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 553 554 { 554 555 LPMEASUREITEMSTRUCT lpmeasure; 555 556 556 557 lpmeasure = (LPMEASUREITEMSTRUCT)lParam; 557 558 lpmeasure->itemHeight = fldrHeight; … … 562 563 */ 563 564 #ifdef __WIN32OS2__ 564 static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam) 565 static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam) 565 566 { 566 567 LPMEASUREITEMSTRUCT lpmeasure; 567 568 568 569 lpmeasure = (LPMEASUREITEMSTRUCT)lParam; 569 570 lpmeasure->itemHeight = fldrHeight; … … 571 572 } 572 573 #else 573 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 574 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 574 575 { 575 576 LPMEASUREITEMSTRUCT16 lpmeasure; 576 577 577 578 lpmeasure = MapSL(lParam); 578 579 lpmeasure->itemHeight = fldrHeight; … … 608 609 TRACE("lpstrCustomFilter = %p\n", pstr); 609 610 while(*pstr) 610 {611 old_pstr = pstr;611 { 612 old_pstr = pstr; 612 613 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0, 613 614 (LPARAM)(ofn->lpstrCustomFilter) + n ); 614 615 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));616 pstr += lstrlenW(pstr) + 1; 617 TRACE("add str='%s' " 618 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr)); 618 619 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr); 619 620 n += lstrlenW(pstr) + 1; 620 pstr += lstrlenW(pstr) + 1;621 }621 pstr += lstrlenW(pstr) + 1; 622 } 622 623 } 623 624 /* read filter information */ 624 625 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 }626 pstr = (LPWSTR) ofn->lpstrFilter; 627 n = 0; 628 while(*pstr) { 629 old_pstr = pstr; 630 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0, 631 (LPARAM)(ofn->lpstrFilter + n) ); 632 n += lstrlenW(pstr) + 1; 633 pstr += lstrlenW(pstr) + 1; 634 TRACE("add str='%s' " 635 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr)); 636 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr); 637 n += lstrlenW(pstr) + 1; 638 pstr += lstrlenW(pstr) + 1; 639 } 639 640 } 640 641 /* set default filter */ 641 642 if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL) 642 ofn->nFilterIndex = 1;643 SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0); 643 ofn->nFilterIndex = 1; 644 SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0); 644 645 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));646 (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE); 647 TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n", 648 ofn->nFilterIndex, debugstr_w(tmpstr)); 648 649 SetDlgItemTextW( hWnd, edt1, tmpstr ); 649 650 /* get drive list */ … … 651 652 DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE); 652 653 /* read initial directory */ 653 if (ofn->lpstrInitialDir != NULL) 654 if (ofn->lpstrInitialDir != NULL) 654 655 { 655 656 int len; … … 690 691 { 691 692 str[0] = 'a' + i; 692 if(drives & (1 << i)) n++;693 if(drives & (1 << i)) n++; 693 694 694 695 if (toupper(str[0]) == toupper(dir[0])) break; … … 720 721 /*********************************************************************** 721 722 * FILEDLG_UpdateResult [internal] 722 * update the displayed file name (with path) 723 * update the displayed file name (with path) 723 724 */ 724 725 void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr) … … 747 748 if (lfs->ofn16) 748 749 { /* we have to convert to short (8.3) path */ 749 char tmp[1024]; /* MAX_PATHNAME_LEN */750 LPOPENFILENAME16 ofn16 = lfs->ofn16;750 char tmp[1024]; /* MAX_PATHNAME_LEN */ 751 LPOPENFILENAME16 ofn16 = lfs->ofn16; 751 752 char *dest = MapSL(ofn16->lpstrFile); 752 753 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1, 753 754 tmp, ofnW->nMaxFile, NULL, NULL )) 754 755 tmp[ofnW->nMaxFile-1] = 0; 755 GetShortPathNameA(tmp, dest, ofn16->nMaxFile);756 757 /* the same procedure as every year... */756 GetShortPathNameA(tmp, dest, ofn16->nMaxFile); 757 758 /* the same procedure as every year... */ 758 759 ofn16->nFileOffset = strrchr(dest,'\\') - dest +1; 759 760 ofn16->nFileExtension = 0; … … 779 780 /*********************************************************************** 780 781 * FILEDLG_UpdateFileTitle [internal] 781 * update the displayed file name (without path) 782 * update the displayed file name (without path) 782 783 */ 783 784 void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs) … … 785 786 LONG lRet; 786 787 LPOPENFILENAMEW ofnW = lfs->ofnW; 787 if (ofnW->lpstrFileTitle != NULL) 788 if (ofnW->lpstrFileTitle != NULL) 788 789 { 789 790 lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0); … … 825 826 pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC); 826 827 SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet, 827 (LPARAM)pstr);828 (LPARAM)pstr); 828 829 strcpyW( tmpstr, pstr ); 829 830 HeapFree(GetProcessHeap(), 0, pstr); … … 897 898 pBeginFileName = strrchrW(path, '\\'); 898 899 if (pBeginFileName == NULL) 899 pBeginFileName = strrchrW(path, ':');900 pBeginFileName = strrchrW(path, ':'); 900 901 901 902 if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL) … … 904 905 if (pBeginFileName != NULL) 905 906 { 906 lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);907 *(pBeginFileName + 1) = 0;908 }909 else910 {911 strcpyW(tmpstr2, path);912 *path = 0;907 lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE); 908 *(pBeginFileName + 1) = 0; 909 } 910 else 911 { 912 strcpyW(tmpstr2, path); 913 *path = 0; 913 914 } 914 915 … … 997 998 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring, 998 999 0, lfs->lParam ); 999 if (lRet) 1000 if (lRet) 1000 1001 { 1001 1002 *ofnW = ofnsav; /* restore old state */ … … 1009 1010 LPWSTR str = (LPWSTR)ofnW->lpstrFile; 1010 1011 LPWSTR ptr = strrchrW(str, '\\'); 1011 str[lstrlenW(str) + 1] = '\0';1012 *ptr = 0;1012 str[lstrlenW(str) + 1] = '\0'; 1013 *ptr = 0; 1013 1014 } 1014 1015 } … … 1035 1036 (LPARAM)pstr); 1036 1037 wsprintfW(diskname, FILE_specc, pstr[2]); 1037 HeapFree(GetProcessHeap(), 0, pstr); 1038 HeapFree(GetProcessHeap(), 0, pstr); 1038 1039 1039 1040 return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE ); … … 1067 1068 */ 1068 1069 static LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification, 1069 UINT control, LFSPRIVATE lfs ) 1070 UINT control, LFSPRIVATE lfs ) 1070 1071 { 1071 1072 switch (control) … … 1090 1091 1091 1092 case cmb1: /* file type drop list */ 1092 if (notification == CBN_SELCHANGE) 1093 if (notification == CBN_SELCHANGE) 1093 1094 return FILEDLG_FileTypeChange( lfs ); 1094 1095 break; … … 1215 1216 if (ofnA->lpstrTitle) 1216 1217 str = ofnA->lpstrTitle; 1217 else 1218 else 1218 1219 /* Allocates default title (FIXME : get it from resource) */ 1219 1220 str = open ? defaultopen:defaultsave; … … 1272 1273 /************************************************************************ 1273 1274 * FILEDLG_DestroyPrivate [internal] 1274 * destroys the private object 1275 * destroys the private object 1275 1276 */ 1276 1277 void FILEDLG_DestroyPrivate(LFSPRIVATE lfs) … … 1311 1312 /************************************************************************ 1312 1313 * FILEDLG_AllocPrivate [internal] 1313 * allocate a private object to hold 32 bits Unicode 1314 * allocate a private object to hold 32 bits Unicode 1314 1315 * structure that will be used throughtout the calls, while 1315 1316 * keeping available the original structures and a few variables … … 1369 1370 FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open); 1370 1371 } 1371 else 1372 else 1372 1373 ret = NULL; 1373 1374 } … … 1390 1391 * Creates a win31 style dialog box for the user to select a file to open/save. 1391 1392 */ 1392 BOOL WINAPI GetFileName31A( 1393 BOOL WINAPI GetFileName31A( 1393 1394 LPOPENFILENAMEA lpofn, /* addess of structure with data*/ 1394 1395 UINT dlgType /* type dialogue : open/save */ … … 1405 1406 { 1406 1407 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1407 bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner, 1408 bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner, 1408 1409 (DLGPROC) FileOpenDlgProc, (DWORD) lfs); 1409 1410 FILEDLG_DestroyPrivate(lfs); … … 1420 1421 * Creates a win31 style dialog box for the user to select a file to open/save 1421 1422 */ 1422 BOOL WINAPI GetFileName31W( 1423 BOOL WINAPI GetFileName31W( 1423 1424 LPOPENFILENAMEW lpofn, /* addess of structure with data*/ 1424 1425 UINT dlgType /* type dialogue : open/save */ … … 1435 1436 { 1436 1437 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1437 bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner, 1438 bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner, 1438 1439 (DLGPROC) FileOpenDlgProc, (DWORD) lfs); 1439 1440 FILEDLG_DestroyPrivate(lfs); … … 1453 1454 LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 1454 1455 LPARAM lParam) 1455 { 1456 { 1456 1457 LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP); 1457 1458 DRAWITEMSTRUCT dis; 1458 1459 1459 1460 TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam); 1460 1461 if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook) 1461 1462 { 1462 1463 LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam); 1463 if (lRet) 1464 if (lRet) 1464 1465 return lRet; /* else continue message processing */ 1465 1466 } … … 1483 1484 switch (HIWORD(lParam)) 1484 1485 { 1485 case CTLCOLOR_BTN:1486 SetTextColor((HDC16)wParam, 0x00000000);1486 case CTLCOLOR_BTN: 1487 SetTextColor((HDC16)wParam, 0x00000000); 1487 1488 return hGRAYBrush; 1488 case CTLCOLOR_STATIC:1489 case CTLCOLOR_STATIC: 1489 1490 SetTextColor((HDC16)wParam, 0x00000000); 1490 1491 return hGRAYBrush; 1491 }1492 } 1492 1493 break; 1493 1494 #endif … … 1510 1511 LRESULT lRet; 1511 1512 lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam); 1512 if (lRet) 1513 if (lRet) 1513 1514 return lRet; /* else continue message processing */ 1514 } 1515 } 1515 1516 switch (wMsg) { 1516 1517 case WM_INITDIALOG: 1517 1518 return FILEDLG_WMInitDialog(hWnd, wParam, lParam); 1518 1519 1519 1520 case WM_MEASUREITEM: 1520 1521 return FILEDLG_WMMeasureItem16(hWnd, wParam, lParam); 1521 1522 1522 1523 case WM_DRAWITEM: 1523 1524 FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis); … … 1527 1528 return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam), wParam, lfs); 1528 1529 } 1529 1530 1530 1531 /* 1531 1532 case WM_CTLCOLOR: … … 1541 1542 } 1542 1543 return FALSE; 1543 1544 1544 1545 */ 1545 1546 return FALSE; … … 1549 1550 /*********************************************************************** 1550 1551 * FileOpenDlgProc [internal] 1551 * Used for open and save, in fact. 1552 * Used for open and save, in fact. 1552 1553 */ 1553 1554 static LRESULT WINAPI FileOpenDlgProc(HWND hWnd, UINT wMsg, … … 1561 1562 LRESULT lRet; 1562 1563 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam); 1563 if (lRet) 1564 if (lRet) 1564 1565 return lRet; /* else continue message processing */ 1565 1566 } … … 1582 1583 switch (HIWORD(lParam)) 1583 1584 { 1584 case CTLCOLOR_BTN:1585 SetTextColor((HDC16)wParam, 0x00000000);1585 case CTLCOLOR_BTN: 1586 SetTextColor((HDC16)wParam, 0x00000000); 1586 1587 return hGRAYBrush; 1587 case CTLCOLOR_STATIC:1588 case CTLCOLOR_STATIC: 1588 1589 SetTextColor((HDC16)wParam, 0x00000000); 1589 1590 return hGRAYBrush; 1590 }1591 } 1591 1592 break; 1592 1593 #endif … … 1595 1596 } 1596 1597 1597 /* ------------------ APIs ---------------------- */ 1598 /* ------------------ APIs ---------------------- */ 1598 1599 #ifndef __WIN32OS2__ 1599 1600 /*********************************************************************** … … 1609 1610 * unknown, there are some FIXME's left. 1610 1611 */ 1611 BOOL16 WINAPI GetOpenFileName16( 1612 SEGPTR ofn /* [in/out] address of structure with data*/1613 )1612 BOOL16 WINAPI GetOpenFileName16( 1613 SEGPTR ofn /* [in/out] address of structure with data*/ 1614 ) 1614 1615 { 1615 1616 HINSTANCE hInst; … … 1626 1627 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1627 1628 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6); 1628 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1629 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1629 1630 (DLGPROC16) ptr, (DWORD) lfs); 1630 1631 FILEDLG_DestroyPrivate(lfs); … … 1647 1648 * unknown. There are some FIXME's left. 1648 1649 */ 1649 BOOL16 WINAPI GetSaveFileName16( 1650 SEGPTR ofn /* [in/out] addess of structure with data*/1651 )1650 BOOL16 WINAPI GetSaveFileName16( 1651 SEGPTR ofn /* [in/out] addess of structure with data*/ 1652 ) 1652 1653 { 1653 1654 HINSTANCE hInst; … … 1664 1665 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1665 1666 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7); 1666 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1667 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1667 1668 (DLGPROC16) ptr, (DWORD) lfs); 1668 1669 FILEDLG_DestroyPrivate(lfs); 1669 } 1670 } 1670 1671 1671 1672 TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile)); … … 1685 1686 */ 1686 1687 BOOL WINAPI GetOpenFileNameA( 1687 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */1688 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */ 1688 1689 { 1689 1690 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1721 1722 */ 1722 1723 BOOL WINAPI GetOpenFileNameW( 1723 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */1724 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */ 1724 1725 { 1725 1726 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1757 1758 */ 1758 1759 BOOL WINAPI GetSaveFileNameA( 1759 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */1760 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */ 1760 1761 { 1761 1762 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1775 1776 { 1776 1777 return GetFileDialog95A(ofn, SAVE_DIALOG); 1777 } 1778 } 1778 1779 else 1779 1780 { … … 1793 1794 */ 1794 1795 BOOL WINAPI GetSaveFileNameW( 1795 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */1796 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */ 1796 1797 { 1797 1798 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1811 1812 { 1812 1813 return GetFileDialog95W(ofn, SAVE_DIALOG); 1813 } 1814 } 1814 1815 else 1815 1816 { -
trunk/src/comdlg32/filedlg95.c
r6300 r6645 1 /* $Id: filedlg95.c,v 1.24 2001-09-05 12:12:00 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - File Open Dialogs Win95 look and feel 3 4 * 4 5 * FIXME: The whole concept of handling unicode is badly broken. 5 * many hook-messages expecting a pointer to a6 * OPENFILENAMEA or W structure. With the current architecture7 * we would have to convert the beast at every call to a hook.8 * we have to find a better solution but if would likely cause9 * a complete rewrite with after we shouldhandle the10 * OPENFILENAME structure without any converting (jsch).6 * many hook-messages expecting a pointer to a 7 * OPENFILENAMEA or W structure. With the current architecture 8 * we would have to convert the beast at every call to a hook. 9 * we have to find a better solution but if would likely cause 10 * a complete rewrite with after we shouldhandle the 11 * OPENFILENAME structure without any converting (jsch). 11 12 * 12 13 * FIXME: any hook gets a OPENFILENAMEA structure … … 77 78 78 79 #define IsHooked(fodInfos) \ 79 ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)80 ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook) 80 81 /*********************************************************************** 81 82 * Data structure and global variables … … 86 87 HIMAGELIST hImgList; 87 88 int m_iIndent; /* Indentation index */ 88 LPITEMIDLIST pidlItem; /* absolute pidl of the item */ 89 LPITEMIDLIST pidlItem; /* absolute pidl of the item */ 89 90 90 91 } SFOLDER,*LPSFOLDER; … … 216 217 * GetFileName95 217 218 * 218 * Creates an Open common dialog box that lets the user select 219 * Creates an Open common dialog box that lets the user select 219 220 * the drive, directory, and the name of a file or set of files to open. 220 221 * … … 251 252 return FALSE; 252 253 } 253 254 254 255 /* old style hook messages */ 255 256 if (IsHooked(fodInfos)) … … 260 261 fodInfos->HookMsg.sharevistring = RegisterWindowMessageA(SHAREVISTRINGA); 261 262 } 262 263 263 264 lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32, 264 265 (LPDLGTEMPLATEA) template, … … 270 271 if( lRes == -1) 271 272 return FALSE; 272 273 273 274 return lRes; 274 275 } … … 291 292 LPSTR lpstrSavDir = NULL; 292 293 DWORD dwFlags = 0; 293 294 /* Initialise FileOpenDlgInfos structure*/ 294 295 /* Initialise FileOpenDlgInfos structure*/ 295 296 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos)); 296 297 ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos)); 297 298 298 299 /* Pass in the original ofn */ 299 300 fodInfos->ofnInfos = ofn; 300 301 301 302 /* Save original hInstance value */ 302 303 hInstance = ofn->hInstance; … … 316 317 fodInfos->DlgInfos.dwDlgProp = 0; 317 318 fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL; 318 319 319 320 switch(iDlgType) 320 321 { … … 400 401 FileOpenDlgInfos *fodInfos; 401 402 HINSTANCE hInstance; 402 403 403 404 /* out arguments */ 404 405 LPWSTR lpstrFile = NULL; … … 437 438 /* filter is a list... title\0ext\0......\0\0 */ 438 439 s = ofn->lpstrFilter; 439 440 440 441 while (*s) s = s+strlenW(s)+1; 441 442 s++; … … 520 521 } 521 522 #endif 522 523 523 524 /* restore saved IN arguments and convert OUT arguments back */ 524 525 ofn->Flags = dwFlags; … … 598 599 SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left), 599 600 (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER); 600 601 601 602 hwndChild = GetWindow(hwndChildDlg,GW_CHILD); 602 603 if(hwndStc32) … … 615 616 { 616 617 if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE) 617 continue;618 continue; 618 619 GetWindowRect(hwndChild,&rectCtrl); 619 620 MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2); 620 621 621 622 /* 622 623 Check the initial position of the controls relative to the initial … … 629 630 } 630 631 else if (rectCtrl.left >= rectTemp.right) 631 {632 { 632 633 rectCtrl.left += ptMoveCtl.x; 633 }634 } 634 635 else if (rectCtrl.top >= rectTemp.bottom) 635 636 { 636 rectCtrl.top += ptMoveCtl.y;637 }638 639 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 640 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,641 SWP_NOSIZE | SWP_NOZORDER );637 rectCtrl.top += ptMoveCtl.y; 638 } 639 640 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 641 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top, 642 SWP_NOSIZE | SWP_NOZORDER ); 642 643 } 643 644 } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL); 644 645 } 645 646 hwndChild = GetWindow(hwndParentDlg,GW_CHILD); 646 647 647 648 if(hwndStc32) 648 649 { … … 665 666 rectCtrl.top += ptMoveCtl.y; 666 667 667 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 668 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 668 669 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top, 669 670 SWP_NOSIZE |SWP_NOZORDER ); 670 671 } 671 672 } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL); 672 } 673 } 673 674 } 674 675 } … … 686 687 { 687 688 case WM_INITDIALOG: 688 { 689 { 689 690 fodInfos = (FileOpenDlgInfos *)lParam; 690 691 lParam = (LPARAM) fodInfos->ofnInfos; … … 693 694 if(fodInfos && IsHooked(fodInfos)) 694 695 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam); 695 return 0; 696 } 696 return 0; 697 } 697 698 } 698 699 699 700 if(fodInfos && IsHooked(fodInfos)) 700 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam); 701 702 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 701 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam); 702 703 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 703 704 } 704 705 … … 736 737 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 737 738 return (HWND)NULL; 738 }739 } 739 740 } 740 741 … … 742 743 if(hChildDlg) 743 744 { 744 ShowWindow(hChildDlg,SW_SHOW); 745 ShowWindow(hChildDlg,SW_SHOW); 745 746 return hChildDlg; 746 747 } … … 758 759 tmplate.cx = rectHwnd.right-rectHwnd.left; 759 760 tmplate.cy = rectHwnd.bottom-rectHwnd.top; 760 761 761 762 return CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos); 762 763 } 763 764 return (HWND)NULL; 764 765 } 765 766 766 767 /*********************************************************************** 767 768 * SendCustomDlgNotificationMessage … … 784 785 { 785 786 OFNOTIFYA ofnNotify; 786 HRESULT ret;787 HRESULT ret; 787 788 ofnNotify.hdr.hwndFrom=hwndParentDlg; 788 789 ofnNotify.hdr.idFrom=0; 789 790 ofnNotify.hdr.code = uCode; 790 791 ofnNotify.lpOFN = fodInfos->ofnInfos; 791 TRACE("CALL NOTIFY for %x\n", uCode);792 ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);793 TRACE("RET NOTIFY\n");794 return ret;792 TRACE("CALL NOTIFY for %x\n", uCode); 793 ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); 794 TRACE("RET NOTIFY\n"); 795 return ret; 795 796 } 796 797 return TRUE; … … 815 816 GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath)); 816 817 lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath); 817 if (lpstrFileSpec==lpstrPath) 818 {818 if (lpstrFileSpec==lpstrPath) 819 { 819 820 char lpstrCurrentDir[MAX_PATH]; 820 821 /* Prepend the current path */ … … 823 824 snprintf((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath); 824 825 reqSize=strlen(lpstrCurrentDir)+1+strlen(lpstrPath)+1; 825 } 826 else 827 {826 } 827 else 828 { 828 829 lstrcpynA((LPSTR)lParam,(LPSTR)lpstrPath,(int)wParam); 829 830 reqSize=strlen(lpstrPath); … … 833 834 834 835 case CDM_GETFOLDERPATH: 835 SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);836 SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath); 836 837 if ((LPSTR)lParam!=NULL) 837 838 lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam); … … 839 840 840 841 case CDM_GETSPEC: 841 reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));842 reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath)); 842 843 lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath); 843 844 if ((LPSTR)lParam!=NULL) … … 846 847 847 848 case CDM_SETCONTROLTEXT: 848 if ( 0 != lParam )849 SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );850 return TRUE;849 if ( 0 != lParam ) 850 SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam ); 851 return TRUE; 851 852 852 853 case CDM_HIDECONTROL: … … 857 858 return TRUE; 858 859 } 859 860 860 861 /*********************************************************************** 861 862 * FileOpenDlgProc95 … … 868 869 TRACE("0x%04x 0x%04x\n", hwnd, uMsg); 869 870 #endif 870 871 871 872 switch(uMsg) 872 873 { … … 875 876 FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam; 876 877 877 /* Adds the FileOpenDlgInfos in the property list of the dialog 878 /* Adds the FileOpenDlgInfos in the property list of the dialog 878 879 so it will be easily accessible through a GetPropA(...) */ 879 SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);880 881 fodInfos->DlgInfos.hwndCustomDlg =882 CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);880 SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos); 881 882 fodInfos->DlgInfos.hwndCustomDlg = 883 CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd); 883 884 884 885 FILEDLG95_InitControls(hwnd); 885 886 SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE); 886 FILEDLG95_FillControls(hwnd, wParam, lParam);887 FILEDLG95_FillControls(hwnd, wParam, lParam); 887 888 SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE); 888 889 SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM, … … 902 903 } 903 904 return FALSE; 904 905 905 906 case WM_GETISHELLBROWSER: 906 907 return FILEDLG95_OnWMGetIShellBrowser(hwnd); … … 912 913 case WM_NOTIFY: 913 914 { 914 LPNMHDR lpnmh = (LPNMHDR)lParam;915 UINT stringId = -1;916 917 /* set up the button tooltips strings */918 if(TTN_GETDISPINFOA == lpnmh->code )919 {920 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 921 switch(lpnmh->idFrom )922 {923 /* Up folder button */924 case FCIDM_TB_UPFOLDER:925 stringId = IDS_UPFOLDER;926 break;927 /* New folder button */928 case FCIDM_TB_NEWFOLDER:929 stringId = IDS_NEWFOLDER;930 break;931 /* List option button */932 case FCIDM_TB_SMALLICON:933 stringId = IDS_LISTVIEW;934 break;935 /* Details option button */936 case FCIDM_TB_REPORTVIEW:937 stringId = IDS_REPORTVIEW;938 break;939 /* Desktop button */940 case FCIDM_TB_DESKTOP:941 stringId = IDS_TODESKTOP;942 break;943 default:944 stringId = 0;945 }946 lpdi->hinst = COMMDLG_hInstance32; 947 lpdi->lpszText = (LPSTR) stringId;948 }915 LPNMHDR lpnmh = (LPNMHDR)lParam; 916 UINT stringId = -1; 917 918 /* set up the button tooltips strings */ 919 if(TTN_GETDISPINFOA == lpnmh->code ) 920 { 921 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 922 switch(lpnmh->idFrom ) 923 { 924 /* Up folder button */ 925 case FCIDM_TB_UPFOLDER: 926 stringId = IDS_UPFOLDER; 927 break; 928 /* New folder button */ 929 case FCIDM_TB_NEWFOLDER: 930 stringId = IDS_NEWFOLDER; 931 break; 932 /* List option button */ 933 case FCIDM_TB_SMALLICON: 934 stringId = IDS_LISTVIEW; 935 break; 936 /* Details option button */ 937 case FCIDM_TB_REPORTVIEW: 938 stringId = IDS_REPORTVIEW; 939 break; 940 /* Desktop button */ 941 case FCIDM_TB_DESKTOP: 942 stringId = IDS_TODESKTOP; 943 break; 944 default: 945 stringId = 0; 946 } 947 lpdi->hinst = COMMDLG_hInstance32; 948 lpdi->lpszText = (LPSTR) stringId; 949 } 949 950 return FALSE; 950 951 } … … 978 979 { 979 980 { HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR }, 980 { COMDLG32_hInstance, 800 } // desktop icon981 { COMDLG32_hInstance, 800 } // desktop icon 981 982 }; 982 983 983 984 RECT rectTB; 984 985 985 986 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 986 987 … … 996 997 MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2); 997 998 998 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL, 999 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL, 999 1000 WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE, 1000 0, 0, 150, 26, hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL); 1001 1002 SetWindowPos(fodInfos->DlgInfos.hwndTB, 0, 1003 rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,1004 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );1001 0, 0, 150, 26, hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL); 1002 1003 SetWindowPos(fodInfos->DlgInfos.hwndTB, 0, 1004 rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top, 1005 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER ); 1005 1006 1006 1007 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); … … 1012 1013 1013 1014 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 9,(LPARAM) &tbb); 1014 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0); 1015 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0); 1015 1016 1016 1017 /* Set the window text with the text specified in the OPENFILENAME structure */ … … 1052 1053 are hidden and we are not using a custom template */ 1053 1054 if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) && 1054 (!(fodInfos->ofnInfos->Flags & 1055 (!(fodInfos->ofnInfos->Flags & 1055 1056 (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE)))) 1056 1057 { … … 1061 1062 /* subtract the height of the help button plus the space between 1062 1063 the help button and the cancel button to the height of the dialog */ 1063 SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left, 1064 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom), 1064 SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left, 1065 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom), 1065 1066 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); 1066 1067 } … … 1083 1084 { 1084 1085 LPITEMIDLIST pidlItemId = NULL; 1085 1086 1086 1087 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam; 1087 1088 1088 TRACE("dir=%s file=%s\n", 1089 TRACE("dir=%s file=%s\n", 1089 1090 fodInfos->ofnInfos->lpstrInitialDir, fodInfos->ofnInfos->lpstrFile); 1090 1091 … … 1187 1188 /* Do not use the listview selection anymore */ 1188 1189 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW; 1189 return 0; 1190 return 0; 1190 1191 } 1191 1192 … … 1204 1205 SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser); 1205 1206 1206 return TRUE; 1207 return TRUE; 1207 1208 } 1208 1209 … … 1210 1211 /*********************************************************************** 1211 1212 * FILEDLG95_OnOpenMultipleFiles 1212 * 1213 * 1213 1214 * Handles the opening of multiple files. 1214 1215 * … … 1227 1228 lpstrFile = fodInfos->ofnInfos->lpstrFile; 1228 1229 lpstrFile[0] = '\0'; 1229 1230 1230 1231 SHGetPathFromIDListA( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec ); 1231 1232 … … 1233 1234 ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST)) 1234 1235 { 1235 LPSTR lpstrTemp = lpstrFileList; 1236 LPSTR lpstrTemp = lpstrFileList; 1236 1237 1237 1238 for ( nCount = 0; nCount < nFileCount; nCount++ ) … … 1258 1259 return FALSE; 1259 1260 } 1260 1261 1261 1262 /* move to the next file in the list of files */ 1262 1263 lpstrTemp += strlen(lpstrTemp) + 1; … … 1281 1282 * 1282 1283 * Ok button WM_COMMAND message handler 1283 * 1284 * 1284 1285 * If the function succeeds, the return value is nonzero. 1285 1286 */ … … 1322 1323 return FALSE; 1323 1324 } 1324 1325 1325 1326 if(nFileCount > 1) 1326 1327 { … … 1381 1382 to a folder if the path points to a directory or the last 1382 1383 valid element is a directory. 1383 1384 1384 1385 valid variables: 1385 1386 lpstrPathAndFile: cleaned up path … … 1431 1432 lpwstrTemp, sizeof(lpwstrTemp)/sizeof(WCHAR) ); 1432 1433 1433 /* if the last element is a wildcard do a search */1434 /* if the last element is a wildcard do a search */ 1434 1435 if(strpbrk(lpszTemp1, "*?") != NULL) 1435 1436 { 1436 nOpenAction = ONOPEN_SEARCH;1437 break;1438 }1437 nOpenAction = ONOPEN_SEARCH; 1438 break; 1439 } 1439 1440 } 1440 1441 lpszTemp1 = lpszTemp; … … 1464 1465 TRACE("value\n"); 1465 1466 1466 /* end dialog, return value */1467 /* end dialog, return value */ 1467 1468 nOpenAction = ONOPEN_OPEN; 1468 break;1469 break; 1469 1470 } 1470 COMDLG32_SHFree(pidl);1471 pidl = NULL;1471 COMDLG32_SHFree(pidl); 1472 pidl = NULL; 1472 1473 } 1473 1474 else 1474 1475 { 1475 if(*lpszTemp)/* points to trailing null for last path element */1476 if(*lpszTemp) /* points to trailing null for last path element */ 1476 1477 { 1477 if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)1478 {1478 if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST) 1479 { 1479 1480 FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING); 1480 break;1481 }1482 }1481 break; 1482 } 1483 } 1483 1484 else 1484 {1485 { 1485 1486 if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) 1486 {1487 { 1487 1488 FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING); 1488 break;1489 }1490 }1491 /* change to the current folder */1489 break; 1490 } 1491 } 1492 /* change to the current folder */ 1492 1493 nOpenAction = ONOPEN_OPEN; 1493 break;1494 break; 1494 1495 } 1495 1496 } … … 1527 1528 /* replace the current filter */ 1528 1529 if(fodInfos->ShellInfos.lpstrCurrentFilter) 1529 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);1530 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter); 1530 1531 len = MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1, NULL, 0 ); 1531 1532 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR)); … … 1541 1542 TRACE("ONOPEN_BROWSE\n"); 1542 1543 { 1543 IPersistFolder2 * ppf2;1544 IPersistFolder2 * ppf2; 1544 1545 if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2))) 1545 1546 { … … 1547 1548 IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent); 1548 1549 IPersistFolder2_Release(ppf2); 1549 if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))1550 {1551 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);1552 }1553 else if( nOpenAction == ONOPEN_SEARCH )1554 {1550 if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent)) 1551 { 1552 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE); 1553 } 1554 else if( nOpenAction == ONOPEN_SEARCH ) 1555 { 1555 1556 IShellView_Refresh(fodInfos->Shell.FOIShellView); 1556 }1557 } 1557 1558 COMDLG32_SHFree(pidlCurrent); 1558 1559 } … … 1563 1564 TRACE("ONOPEN_OPEN %s\n", lpstrPathAndFile); 1564 1565 { 1565 /* add default extension */1566 if (fodInfos->ofnInfos->lpstrDefExt)1567 {1568 if (! *PathFindExtensionA(lpstrPathAndFile))1569 {1570 strcat(lpstrPathAndFile, ".");1571 strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt);1572 }1573 }1566 /* add default extension */ 1567 if (fodInfos->ofnInfos->lpstrDefExt) 1568 { 1569 if (! *PathFindExtensionA(lpstrPathAndFile)) 1570 { 1571 strcat(lpstrPathAndFile, "."); 1572 strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt); 1573 } 1574 } 1574 1575 1575 1576 /* Check that the size of the file does not exceed buffer size. … … 1579 1580 { 1580 1581 LPSTR lpszTemp; 1581 1582 1582 1583 /* fill destination buffer */ 1583 1584 strcpy(fodInfos->ofnInfos->lpstrFile, lpstrPathAndFile); … … 1589 1590 lpszTemp = PathFindFileNameA(lpstrPathAndFile); 1590 1591 fodInfos->ofnInfos->nFileOffset = lpszTemp - lpstrPathAndFile; 1591 1592 1592 1593 /* set extension offset */ 1593 1594 lpszTemp = PathFindExtensionA(lpstrPathAndFile); 1594 1595 fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? lpszTemp - lpstrPathAndFile + 1 : 0; 1595 1596 1596 1597 /* set the lpstrFileTitle */ 1597 1598 if(fodInfos->ofnInfos->lpstrFileTitle) 1598 {1599 { 1599 1600 LPSTR lpstrFileTitle = PathFindFileNameA(lpstrPathAndFile); 1600 strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle);1601 }1601 strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle); 1602 } 1602 1603 1603 1604 /* ask the hook if we can close */ 1604 1605 if(IsHooked(fodInfos)) 1605 {1606 /* FIXME we are sending ASCII-structures. Does not work with NT */1607 /* first old style */1608 TRACE("---\n");1606 { 1607 /* FIXME we are sending ASCII-structures. Does not work with NT */ 1608 /* first old style */ 1609 TRACE("---\n"); 1609 1610 CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook, 1610 1611 fodInfos->DlgInfos.hwndCustomDlg, 1611 1612 fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos); 1612 if (GetWindowLongA(hwnd, DWL_MSGRESULT))1613 {1614 TRACE("cancled\n");1615 ret = FALSE;1616 goto ret;1617 }1618 }1613 if (GetWindowLongA(hwnd, DWL_MSGRESULT)) 1614 { 1615 TRACE("cancled\n"); 1616 ret = FALSE; 1617 goto ret; 1618 } 1619 } 1619 1620 1620 1621 TRACE("close\n"); 1621 FILEDLG95_Clean(hwnd);1622 FILEDLG95_Clean(hwnd); 1622 1623 ret = EndDialog(hwnd, TRUE); 1623 }1624 else1624 } 1625 else 1625 1626 { 1626 1627 /* FIXME set error FNERR_BUFFERTOSMALL */ … … 1650 1651 1651 1652 /* 1652 * Initialisation of the FileOpenDialogInfos structure 1653 * Initialisation of the FileOpenDialogInfos structure 1653 1654 */ 1654 1655 … … 1661 1662 if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)) 1662 1663 { 1663 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL; 1664 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL; 1664 1665 } 1665 1666 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT; … … 1671 1672 1672 1673 /* Construct the IShellBrowser interface */ 1673 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 1674 1674 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 1675 1675 1676 return NOERROR; 1676 1677 } … … 1690 1691 1691 1692 if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, 1692 SVGIO_BACKGROUND,1693 &IID_IContextMenu,1694 (LPVOID*)&pcm)))1693 SVGIO_BACKGROUND, 1694 &IID_IContextMenu, 1695 (LPVOID*)&pcm))) 1695 1696 { 1696 1697 CMINVOKECOMMANDINFO ci; … … 1739 1740 LPITEMIDLIST pidl; 1740 1741 HRESULT hres; 1741 1742 1742 1743 TRACE("\n"); 1743 1744 … … 1772 1773 * FILEDLG95_FILETYPE_Init 1773 1774 * 1774 * Initialisation of the file type combo box 1775 * Initialisation of the file type combo box 1775 1776 */ 1776 1777 static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) … … 1782 1783 if(fodInfos->ofnInfos->lpstrFilter) 1783 1784 { 1784 int nFilters = 0; /* number of filters */1785 int nFilters = 0; /* number of filters */ 1785 1786 LPSTR lpstrFilter; 1786 1787 LPCSTR lpstrPos = fodInfos->ofnInfos->lpstrFilter; … … 1788 1789 for(;;) 1789 1790 { 1790 /* filter is a list... title\0ext\0......\0\0 1791 /* filter is a list... title\0ext\0......\0\0 1791 1792 * Set the combo item text to the title and the item data 1792 1793 * to the ext … … 1796 1797 1797 1798 /* Get the title */ 1798 if(! *lpstrPos) break; /* end */1799 if(! *lpstrPos) break; /* end */ 1799 1800 lpstrDisplay = lpstrPos; 1800 1801 lpstrPos += strlen(lpstrPos) + 1; 1801 1802 1802 1803 /* Copy the extensions */ 1803 if (! *lpstrPos) return E_FAIL; /* malformed filter */1804 if (! *lpstrPos) return E_FAIL; /* malformed filter */ 1804 1805 if (!(lpstrExt = (LPSTR) MemAlloc(strlen(lpstrPos)+1))) return E_FAIL; 1805 1806 strcpy(lpstrExt,lpstrPos); 1806 1807 lpstrPos += strlen(lpstrPos) + 1; 1807 1808 1808 1809 /* Add the item at the end of the combo */ 1809 1810 CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay); … … 1816 1817 * FIXME: lpstrCustomFilter not handled at all 1817 1818 */ 1818 1819 1819 1820 /* set default filter index */ 1820 1821 if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->ofnInfos->lpstrCustomFilter == NULL) … … 1824 1825 if ( fodInfos->ofnInfos->nFilterIndex > nFilters ) 1825 1826 fodInfos->ofnInfos->nFilterIndex = nFilters; 1826 1827 1827 1828 /* Set the current index selection. */ 1828 1829 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->ofnInfos->nFilterIndex-1); 1829 1830 1830 1831 /* Get the corresponding text string from the combo box. */ 1831 1832 lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, … … 1833 1834 1834 1835 if ((INT)lpstrFilter == CB_ERR) /* control is empty */ 1835 lpstrFilter = NULL; 1836 lpstrFilter = NULL; 1836 1837 1837 1838 if(lpstrFilter) 1838 1839 { 1839 1840 DWORD len; 1840 _strlwr(lpstrFilter); /* lowercase */1841 _strlwr(lpstrFilter); /* lowercase */ 1841 1842 len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 ); 1842 1843 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) ); … … 1942 1943 1943 1944 } 1944 1945 1945 1946 /*********************************************************************** 1946 1947 * FILEDLG95_LOOKIN_Init 1947 1948 * 1948 * Initialisation of the look in combo box 1949 * Initialisation of the look in combo box 1949 1950 */ 1950 1951 static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo) 1951 1952 { 1952 IShellFolder *psfRoot, *psfDrives;1953 IEnumIDList *lpeRoot, *lpeDrives;1954 LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;1953 IShellFolder *psfRoot, *psfDrives; 1954 IEnumIDList *lpeRoot, *lpeDrives; 1955 LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp; 1955 1956 1956 1957 LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos)); … … 1982 1983 while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL)) 1983 1984 { 1984 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);1985 1986 /* special handling for CSIDL_DRIVES */1987 if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))1988 {1989 if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))1990 {1991 /* enumerate the drives */1992 if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))1993 {1994 while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))1995 {1996 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);1997 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);1998 COMDLG32_SHFree(pidlAbsTmp);1999 COMDLG32_SHFree(pidlTmp1);2000 }2001 IEnumIDList_Release(lpeDrives);2002 }2003 IShellFolder_Release(psfDrives);2004 }2005 }1985 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND); 1986 1987 /* special handling for CSIDL_DRIVES */ 1988 if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives)) 1989 { 1990 if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives))) 1991 { 1992 /* enumerate the drives */ 1993 if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives))) 1994 { 1995 while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL)) 1996 { 1997 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1); 1998 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND); 1999 COMDLG32_SHFree(pidlAbsTmp); 2000 COMDLG32_SHFree(pidlTmp1); 2001 } 2002 IEnumIDList_Release(lpeDrives); 2003 } 2004 IShellFolder_Release(psfDrives); 2005 } 2006 } 2006 2007 COMDLG32_SHFree(pidlTmp); 2007 2008 } … … 2049 2050 { 2050 2051 ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 2051 0, 2052 &sfi, 2053 sizeof (SHFILEINFOA), 2054 SHGFI_PIDL | SHGFI_SMALLICON | 2055 SHGFI_OPENICON | SHGFI_SYSICONINDEX | 2056 SHGFI_DISPLAYNAME ); 2052 0, 2053 &sfi, 2054 sizeof (SHFILEINFOA), 2055 SHGFI_PIDL | SHGFI_SMALLICON | 2056 SHGFI_OPENICON | SHGFI_SYSICONINDEX | 2057 SHGFI_DISPLAYNAME ); 2057 2058 } 2058 2059 else 2059 2060 { 2060 2061 ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 2061 0, 2062 &sfi, 2062 0, 2063 &sfi, 2063 2064 sizeof (SHFILEINFOA), 2064 SHGFI_PIDL | SHGFI_SMALLICON | 2065 SHGFI_SYSICONINDEX | 2065 SHGFI_PIDL | SHGFI_SMALLICON | 2066 SHGFI_SYSICONINDEX | 2066 2067 SHGFI_DISPLAYNAME); 2067 2068 } … … 2086 2087 iIndentation = 0; 2087 2088 ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 2088 0, 2089 &sfi, 2090 sizeof (SHFILEINFOA), 2091 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON 2089 0, 2090 &sfi, 2091 sizeof (SHFILEINFOA), 2092 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON 2092 2093 | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME ); 2093 2094 … … 2109 2110 rectText.left = rectIcon.right; 2110 2111 rectText.top = 2111 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;2112 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2; 2112 2113 rectText.right = pDIStruct->rcItem.right + XTEXTOFFSET; 2113 2114 rectText.bottom = 2114 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;2115 2115 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2; 2116 2116 2117 /* Draw the icon from the image list */ 2117 2118 ImageList_Draw(ilItemImage, 2118 2119 sfi.iIcon, 2119 pDIStruct->hDC, 2120 rectIcon.left, 2121 rectIcon.top, 2122 ILD_TRANSPARENT ); 2120 pDIStruct->hDC, 2121 rectIcon.left, 2122 rectIcon.top, 2123 ILD_TRANSPARENT ); 2123 2124 2124 2125 /* Draw the associated text */ … … 2147 2148 { 2148 2149 LPSFOLDER tmpFolder; 2149 int iItem; 2150 int iItem; 2150 2151 2151 2152 iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB); … … 2153 2154 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB, 2154 2155 iItem))) 2155 return FALSE;2156 return FALSE; 2156 2157 2157 2158 … … 2164 2165 break; 2165 2166 } 2166 2167 2167 2168 } 2168 2169 return FALSE; … … 2189 2190 if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr))) 2190 2191 return -1; 2191 2192 2192 2193 tmpFolder = MemAlloc(sizeof(SFOLDER)); 2193 2194 tmpFolder->m_iIndent = 0; … … 2204 2205 if(tmpFolder->m_iIndent > liInfos->iMaxIndentation) 2205 2206 liInfos->iMaxIndentation = tmpFolder->m_iIndent; 2206 2207 2207 2208 sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM; 2208 2209 SHGetFileInfoA((LPSTR)pidl, … … 2210 2211 &sfi, 2211 2212 sizeof(sfi), 2212 SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 2213 SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 2213 2214 | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED); 2214 2215 … … 2218 2219 { 2219 2220 int iItemID; 2220 2221 2221 2222 TRACE("-- Add %s at %u\n", sfi.szDisplayName, tmpFolder->m_iIndent); 2222 2223 … … 2244 2245 * FILEDLG95_LOOKIN_InsertItemAfterParent 2245 2246 * 2246 * Insert an item below its parent 2247 * Insert an item below its parent 2247 2248 */ 2248 2249 static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl) 2249 2250 { 2250 2251 2251 2252 LPITEMIDLIST pidlParent = GetParentPidl(pidl); 2252 2253 int iParentPos; … … 2303 2304 } 2304 2305 } 2305 2306 2306 2307 CBSetCurSel(hwnd,iItemPos); 2307 2308 liInfos->uSelectedItem = iItemPos; … … 2421 2422 if (nFileSelected >= 1) 2422 2423 { 2423 nLength += 3; /* first and last quotes, trailing \0 */2424 nLength += 3; /* first and last quotes, trailing \0 */ 2424 2425 for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ ) 2425 2426 { 2426 2427 pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 ); 2427 2428 2428 2429 if (pidl) 2429 {2430 { 2430 2431 /* get the total length of the selected file names*/ 2431 2432 lpstrTemp[0] = '\0'; … … 2433 2434 2434 2435 if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */ 2435 {2436 { 2436 2437 nLength += strlen( lpstrTemp ) + 3; 2437 2438 nFiles++; 2438 }2439 } 2439 2440 COMDLG32_SHFree( pidl ); 2440 }2441 } 2441 2442 } 2442 2443 } … … 2456 2457 2457 2458 if (pidl) 2458 {2459 /* get the file name */2459 { 2460 /* get the file name */ 2460 2461 lpstrTemp[0] = '\0'; 2461 2462 GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp ); 2462 2463 2463 2464 if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */ 2464 {2465 { 2465 2466 if ( nFiles > 1) 2466 {2467 { 2467 2468 *lpstrCurrFile++ = '\"'; 2468 2469 strcpy( lpstrCurrFile, lpstrTemp ); … … 2470 2471 strcpy( lpstrCurrFile, "\" " ); 2471 2472 lpstrCurrFile += 2; 2472 }2473 else2474 {2473 } 2474 else 2475 { 2475 2476 strcpy( lpstrAllFile, lpstrTemp ); 2476 }2477 }2477 } 2478 } 2478 2479 COMDLG32_SHFree( (LPVOID) pidl ); 2479 }2480 } 2480 2481 } 2481 2482 } … … 2495 2496 static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) 2496 2497 { 2497 switch (src->uType)2498 {2499 case STRRET_WSTR:2500 WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);2501 COMDLG32_SHFree(src->u.pOleStr);2502 break;2503 2504 case STRRET_CSTRA:2505 lstrcpynA((LPSTR)dest, src->u.cStr, len);2506 break;2507 2508 case STRRET_OFFSETA:2509 lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);2510 break;2511 2512 default:2513 FIXME("unknown type!\n");2514 if (len)2515 {2516 *(LPSTR)dest = '\0';2517 }2518 return(FALSE);2519 }2520 return S_OK;2498 switch (src->uType) 2499 { 2500 case STRRET_WSTR: 2501 WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL); 2502 COMDLG32_SHFree(src->u.pOleStr); 2503 break; 2504 2505 case STRRET_CSTRA: 2506 lstrcpynA((LPSTR)dest, src->u.cStr, len); 2507 break; 2508 2509 case STRRET_OFFSETA: 2510 lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len); 2511 break; 2512 2513 default: 2514 FIXME("unknown type!\n"); 2515 if (len) 2516 { 2517 *(LPSTR)dest = '\0'; 2518 } 2519 return(FALSE); 2520 } 2521 return S_OK; 2521 2522 } 2522 2523 … … 2528 2529 int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPSTR * lpstrFileList, UINT * sizeUsed) 2529 2530 { 2530 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);2531 UINT nStrCharCount = 0;/* index in src buffer */2532 UINT nFileIndex = 0;/* index in dest buffer */2533 UINT nFileCount = 0;/* number of files */2534 UINT nStrLen = 0;/* length of string in edit control */2535 LPSTR lpstrEdit;/* buffer for string from edit control */2536 2537 TRACE("\n");2538 2539 /* get the filenames from the edit control */2540 nStrLen = SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0);2541 lpstrEdit = MemAlloc(nStrLen+1);2542 GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1);2543 2544 TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit);2545 2546 /* we might get single filename without any '"',2547 * so we need nStrLen + terminating \0 + end-of-list \0 */2548 *lpstrFileList = MemAlloc(nStrLen+2);2549 *sizeUsed = 0;2550 2551 /* build 0-delimited file list from filenames */2552 while ( nStrCharCount <= nStrLen )2553 {2554 if ( lpstrEdit[nStrCharCount]=='"' )2555 {2556 nStrCharCount++;2557 while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))2558 {2559 (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];2560 (*sizeUsed)++;2561 nStrCharCount++;2562 }2563 (*lpstrFileList)[nFileIndex++] = '\0';2564 (*sizeUsed)++;2565 nFileCount++;2566 } 2567 nStrCharCount++;2568 }2569 2570 /* single, unquoted string */2571 if ((nStrLen > 0) && (*sizeUsed == 0) )2572 {2573 strcpy(*lpstrFileList, lpstrEdit);2574 nFileIndex = strlen(lpstrEdit) + 1;2575 (*sizeUsed) = nFileIndex;2576 nFileCount = 1;2577 }2578 2579 /* trailing \0 */2580 (*lpstrFileList)[nFileIndex] = '\0';2581 (*sizeUsed)++;2582 2583 MemFree(lpstrEdit);2584 return nFileCount;2531 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 2532 UINT nStrCharCount = 0; /* index in src buffer */ 2533 UINT nFileIndex = 0; /* index in dest buffer */ 2534 UINT nFileCount = 0; /* number of files */ 2535 UINT nStrLen = 0; /* length of string in edit control */ 2536 LPSTR lpstrEdit; /* buffer for string from edit control */ 2537 2538 TRACE("\n"); 2539 2540 /* get the filenames from the edit control */ 2541 nStrLen = SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0); 2542 lpstrEdit = MemAlloc(nStrLen+1); 2543 GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1); 2544 2545 TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit); 2546 2547 /* we might get single filename without any '"', 2548 * so we need nStrLen + terminating \0 + end-of-list \0 */ 2549 *lpstrFileList = MemAlloc(nStrLen+2); 2550 *sizeUsed = 0; 2551 2552 /* build 0-delimited file list from filenames */ 2553 while ( nStrCharCount <= nStrLen ) 2554 { 2555 if ( lpstrEdit[nStrCharCount]=='"' ) 2556 { 2557 nStrCharCount++; 2558 while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen)) 2559 { 2560 (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount]; 2561 (*sizeUsed)++; 2562 nStrCharCount++; 2563 } 2564 (*lpstrFileList)[nFileIndex++] = '\0'; 2565 (*sizeUsed)++; 2566 nFileCount++; 2567 } 2568 nStrCharCount++; 2569 } 2570 2571 /* single, unquoted string */ 2572 if ((nStrLen > 0) && (*sizeUsed == 0) ) 2573 { 2574 strcpy(*lpstrFileList, lpstrEdit); 2575 nFileIndex = strlen(lpstrEdit) + 1; 2576 (*sizeUsed) = nFileIndex; 2577 nFileCount = 1; 2578 } 2579 2580 /* trailing \0 */ 2581 (*lpstrFileList)[nFileIndex] = '\0'; 2582 (*sizeUsed)++; 2583 2584 MemFree(lpstrEdit); 2585 return nFileCount; 2585 2586 } 2586 2587 … … 2625 2626 LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex) 2626 2627 { 2627 2628 2628 2629 STGMEDIUM medium; 2629 2630 FORMATETC formatetc; 2630 2631 LPITEMIDLIST pidl = NULL; 2631 2632 2632 2633 TRACE("sv=%p index=%u\n", doSelected, nPidlIndex); 2633 2634 2634 2635 /* Set the FORMATETC structure*/ 2635 2636 SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); … … 2685 2686 * GetName 2686 2687 * 2687 * Get the pidl's display name (relative to folder) and 2688 * Get the pidl's display name (relative to folder) and 2688 2689 * put it in lpstrFileName. 2689 * 2690 * 2690 2691 * Return NOERROR on success, 2691 2692 * E_FAIL otherwise … … 2719 2720 * GetShellFolderFromPidl 2720 2721 * 2721 * pidlRel is the item pidl relative 2722 * pidlRel is the item pidl relative 2722 2723 * Return the IShellFolder of the absolute pidl 2723 2724 */ … … 2735 2736 if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf))) 2736 2737 { 2737 IShellFolder_Release(psfParent);2738 IShellFolder_Release(psfParent); 2738 2739 return psf; 2739 2740 } … … 2755 2756 2756 2757 TRACE("%p\n", pidl); 2757 2758 2758 2759 pidlParent = COMDLG32_PIDL_ILClone(pidl); 2759 2760 COMDLG32_PIDL_ILRemoveLastID(pidlParent); 2760 2761 2761 2762 return pidlParent; 2762 2763 } … … 2765 2766 * GetPidlFromName 2766 2767 * 2767 * returns the pidl of the file name relative to folder 2768 * returns the pidl of the file name relative to folder 2768 2769 * NULL if an error occurred 2769 2770 */ … … 2779 2780 if(!*lpcstrFileName) return NULL; 2780 2781 2781 MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH); 2782 MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH); 2782 2783 2783 2784 if(!lpsf) … … 2789 2790 else 2790 2791 { 2791 IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL); 2792 IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL); 2792 2793 } 2793 2794 return pidl; … … 2798 2799 BOOL IsPidlFolder (LPSHELLFOLDER psf, LPITEMIDLIST pidl) 2799 2800 { 2800 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;2801 HRESULT ret;2802 2803 TRACE("%p, %p\n", psf, pidl);2804 2805 ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );2806 2807 TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);2808 /* see documentation shell 4.1*/2801 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 2802 HRESULT ret; 2803 2804 TRACE("%p, %p\n", psf, pidl); 2805 2806 ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr ); 2807 2808 TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret); 2809 /* see documentation shell 4.1*/ 2809 2810 return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER); 2810 2811 } … … 2841 2842 2842 2843 return bBrowseSelFolder; 2843 } 2844 } 2844 2845 2845 2846 /* -
trunk/src/comdlg32/filedlgbrowser.c
r5583 r6645 1 /* $Id: filedlgbrowser.c,v 1.9 2001-09-05 12:12:01 bird Exp $ */ 1 2 /* 2 3 * Implementation of IShellBrowser for the File Open common dialog 3 * 4 * 4 5 * 5 6 */ … … 59 60 * External Prototypes 60 61 */ 61 extern const char *FileOpenDlgInfosStr; 62 extern const char *FileOpenDlgInfosStr; 62 63 63 64 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName); … … 91 92 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) 92 93 { 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:94 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl); 95 96 switch (src->uType) 97 { 98 case STRRET_WSTR: 99 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len); 100 COMDLG32_SHFree(src->u.pOleStr); 101 break; 102 103 case STRRET_CSTRA: 103 104 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len )) 104 105 ((LPWSTR)dest)[len-1] = 0; 105 break;106 107 case STRRET_OFFSETA:108 if (pidl)109 {106 break; 107 108 case STRRET_OFFSETA: 109 if (pidl) 110 { 110 111 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, 111 112 -1, (LPWSTR)dest, len )) 112 113 ((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;114 } 115 break; 116 117 default: 118 FIXME("unknown type!\n"); 119 if (len) 120 { *(LPWSTR)dest = '\0'; 121 } 122 return(FALSE); 123 } 124 return S_OK; 124 125 } 125 126 126 127 /* 127 * IShellBrowser128 * IShellBrowser 128 129 */ 129 130 130 131 /************************************************************************** 131 132 * IShellBrowserImpl_Construct … … 158 159 */ 159 160 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface, 160 REFIID riid, 161 REFIID riid, 161 162 LPVOID *ppvObj) 162 163 { … … 168 169 169 170 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/ 170 { *ppvObj = This; 171 { *ppvObj = This; 171 172 } 172 173 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/ … … 215 216 TRACE("(%p)\n", This); 216 217 217 if (!--(This->ref)) 218 { 218 if (!--(This->ref)) 219 { 219 220 HeapFree(GetProcessHeap(),0, This); 220 221 return 0; … … 235 236 * 236 237 * Note : We will never be window less in the File Open dialog 237 * 238 */ 239 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 238 * 239 */ 240 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 240 241 HWND * phwnd) 241 242 { … … 249 250 *phwnd = This->hwndOwner; 250 251 251 return (*phwnd) ? S_OK : E_UNEXPECTED; 252 return (*phwnd) ? S_OK : E_UNEXPECTED; 252 253 253 254 } … … 276 277 * See Windows documentation on IShellBrowser::BrowseObject for more details 277 278 * 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, 279 * This function will override user specified flags and will always 280 * use SBSP_DEFBROWSER and SBSP_DEFMODE. 281 */ 282 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, 283 LPCITEMIDLIST pidl, 283 284 UINT wFlags) 284 285 { … … 301 302 if(wFlags & SBSP_RELATIVE) 302 303 { 303 304 304 305 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */ 305 306 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder, … … 307 308 { 308 309 ERR("bind to object failed\n"); 309 return hRes;310 return hRes; 310 311 } 311 312 /* create an absolute pidl */ … … 326 327 psfTmp = GetShellFolderFromPidl(pidlTmp); 327 328 } 328 329 329 330 if(!psfTmp) 330 331 { … … 333 334 } 334 335 335 /* If the pidl to browse to is equal to the actual pidl ... 336 /* If the pidl to browse to is equal to the actual pidl ... 336 337 do nothing and pretend you did it*/ 337 338 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent)) 338 339 { 339 340 IShellFolder_Release(psfTmp); 340 COMDLG32_SHFree(pidlTmp);341 COMDLG32_SHFree(pidlTmp); 341 342 TRACE("keep current folder\n"); 342 343 return NOERROR; … … 395 396 396 397 /* changes the tab order of the ListView to reflect the window's File Dialog */ 397 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 398 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 398 399 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); 399 400 … … 402 403 SetFocus(fodInfos->ShellInfos.hwndView); 403 404 404 return hRes; 405 return hRes; 405 406 error: 406 407 ERR("Failed with error 0x%08lx\n", hRes); … … 411 412 * IShellBrowserImpl_EnableModelessSB 412 413 */ 413 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface, 414 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface, 414 415 BOOL fEnable) 415 416 416 417 { 417 418 ICOM_THIS(IShellBrowserImpl, iface); … … 426 427 * IShellBrowserImpl_GetControlWindow 427 428 */ 428 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface, 429 UINT id, 429 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface, 430 UINT id, 430 431 HWND *lphwnd) 431 432 432 433 { 433 434 ICOM_THIS(IShellBrowserImpl, iface); … … 442 443 */ 443 444 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface, 444 DWORD grfMode, 445 DWORD grfMode, 445 446 LPSTREAM *ppStrm) 446 447 447 448 { 448 449 ICOM_THIS(IShellBrowserImpl, iface); … … 452 453 /* Feature not implemented */ 453 454 return E_NOTIMPL; 454 } 455 } 455 456 /************************************************************************** 456 457 * IShellBrowserImpl_InsertMenusSB … … 459 460 HMENU hmenuShared, 460 461 LPOLEMENUGROUPWIDTHS lpMenuWidths) 461 462 462 463 { 463 464 ICOM_THIS(IShellBrowserImpl, iface); … … 473 474 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface, 474 475 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 } 476 477 { 478 ICOM_THIS(IShellBrowserImpl, iface); 479 480 TRACE("(%p)\n", This); 481 482 /* Feature not implemented */ 483 return E_NOTIMPL; 484 } 484 485 /************************************************************************** 485 486 * IShellBrowserImpl_QueryActiveShellView … … 487 488 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface, 488 489 IShellView **ppshv) 489 490 490 491 { 491 492 ICOM_THIS(IShellBrowserImpl, iface); … … 503 504 IShellView_AddRef(fodInfos->Shell.FOIShellView); 504 505 return NOERROR; 505 } 506 } 506 507 /************************************************************************** 507 508 * IShellBrowserImpl_RemoveMenusSB … … 509 510 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface, 510 511 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 } 512 513 { 514 ICOM_THIS(IShellBrowserImpl, iface); 515 516 TRACE("(%p)\n", This); 517 518 /* Feature not implemented */ 519 return E_NOTIMPL; 520 } 520 521 /************************************************************************** 521 522 * IShellBrowserImpl_SendControlMsg 522 523 */ 523 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface, 524 UINT id, 525 UINT uMsg, 526 WPARAM wParam, 524 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface, 525 UINT id, 526 UINT uMsg, 527 WPARAM wParam, 527 528 LPARAM lParam, 528 529 LRESULT *pret) 529 530 530 531 { 531 532 ICOM_THIS(IShellBrowserImpl, iface); 532 533 LRESULT lres; 533 534 534 535 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret); 535 536 … … 538 539 case FCW_TOOLBAR: 539 540 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam); 540 break;541 break; 541 542 default: 542 543 FIXME("ctrl id: %x\n", id); … … 550 551 */ 551 552 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface, 552 HMENU hmenuShared, 553 HMENU hmenuShared, 553 554 HOLEMENU holemenuReserved, 554 555 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 } 556 557 { 558 ICOM_THIS(IShellBrowserImpl, iface); 559 560 TRACE("(%p)\n", This); 561 562 /* Feature not implemented */ 563 return E_NOTIMPL; 564 } 564 565 /************************************************************************** 565 566 * IShellBrowserImpl_SetStatusTextSB … … 567 568 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface, 568 569 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 } 570 571 { 572 ICOM_THIS(IShellBrowserImpl, iface); 573 574 TRACE("(%p)\n", This); 575 576 /* Feature not implemented */ 577 return E_NOTIMPL; 578 } 578 579 /************************************************************************** 579 580 * IShellBrowserImpl_SetToolbarItems 580 581 */ 581 582 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface, 582 LPTBBUTTON lpButtons, 583 UINT nButtons, 583 LPTBBUTTON lpButtons, 584 UINT nButtons, 584 585 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 } 586 587 { 588 ICOM_THIS(IShellBrowserImpl, iface); 589 590 TRACE("(%p)\n", This); 591 592 /* Feature not implemented */ 593 return E_NOTIMPL; 594 } 594 595 /************************************************************************** 595 596 * IShellBrowserImpl_TranslateAcceleratorSB 596 597 */ 597 598 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface, 598 LPMSG lpmsg, 599 LPMSG lpmsg, 599 600 WORD wID) 600 601 601 602 { 602 603 ICOM_THIS(IShellBrowserImpl, iface); … … 644 645 */ 645 646 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface( 646 ICommDlgBrowser *iface,647 REFIID riid, 648 LPVOID *ppvObj)647 ICommDlgBrowser *iface, 648 REFIID riid, 649 LPVOID *ppvObj) 649 650 { 650 651 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface); … … 693 694 TRACE("(%p)\n", This); 694 695 695 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 696 696 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 697 697 698 /* If the selected object is not a folder, send a IDOK command to parent window */ 698 699 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1))) … … 702 703 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 703 704 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); 704 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )705 {705 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) ) 706 { 706 707 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE); 707 }708 } 708 709 else 709 {710 { 710 711 /* Tell the dialog that the user selected a file */ 711 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);712 }712 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L); 713 } 713 714 714 715 /* Free memory used by pidl */ … … 737 738 case CDBOSC_SETFOCUS: 738 739 /* FIXME: Reset the default button. 739 This should be taken care of by defdlg. If control740 other than button receives focus the default button741 should be restored. */740 This should be taken care of by defdlg. If control 741 other than button receives focus the default button 742 should be restored. */ 742 743 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0); 743 744 744 745 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");746 case CDBOSC_KILLFOCUS: 747 { 748 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 749 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) 750 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save"); 750 751 } 751 752 break; … … 753 754 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv); 754 755 case CDBOSC_RENAME: 755 /* nothing to do */756 /* nothing to do */ 756 757 break; 757 758 } 758 759 759 return NOERROR; 760 return NOERROR; 760 761 } 761 762 … … 763 764 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject 764 765 */ 765 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 766 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 766 767 IShellView * ppshv, 767 768 LPCITEMIDLIST pidl) … … 780 781 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK; 781 782 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); 782 783 783 784 if( (ulAttr & SFGAO_HIDDEN) /* hidden */ 784 785 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */ … … 786 787 787 788 /* always include directorys and links */ 788 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 789 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 789 790 return S_OK; 790 791 … … 797 798 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl))) 798 799 { 799 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))800 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter)) 800 801 return S_OK; 801 802 } … … 807 808 /************************************************************************** 808 809 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange 809 */ 810 */ 810 811 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv) 811 812 { … … 816 817 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 817 818 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView); 818 819 819 820 /* release old selections */ 820 821 if (fodInfos->Shell.FOIDataObject) 821 822 IDataObject_Release(fodInfos->Shell.FOIDataObject); 822 823 823 824 /* get a new DataObject from the ShellView */ 824 825 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION, 825 826 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject))) 826 827 return E_FAIL; 827 828 828 829 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner); 829 830 … … 856 857 */ 857 858 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface( 858 IServiceProvider *iface,859 REFIID riid, 860 LPVOID *ppvObj)859 IServiceProvider *iface, 860 REFIID riid, 861 LPVOID *ppvObj) 861 862 { 862 863 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface); … … 895 896 * 896 897 * NOTES 897 * the w2k shellview asks for 898 * the w2k shellview asks for 898 899 * guidService = SID_STopLevelBrowser 899 900 * riid = IShellBrowser … … 904 905 905 906 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService( 906 IServiceProvider * iface,907 REFGUID guidService,908 REFIID riid,909 void** ppv)907 IServiceProvider * iface, 908 REFGUID guidService, 909 REFIID riid, 910 void** ppv) 910 911 { 911 912 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface); -
trunk/src/comdlg32/filetitle.c
r4511 r6645 1 /* $Id: filetitle.c,v 1.5 2001-09-05 12:12:01 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - File Dialogs … … 13 14 #include "debugtools.h" 14 15 15 #include "heap.h" /* Has to go */16 #include "heap.h" /* Has to go */ 16 17 17 18 DEFAULT_DEBUG_CHANNEL(commdlg) … … 20 21 21 22 /*********************************************************************** 22 * GetFileTitleA(COMDLG32.8)23 * GetFileTitleA (COMDLG32.8) 23 24 * 24 25 */ 25 26 short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf) 26 27 { 27 int i, len;28 int i, len; 28 29 29 TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);30 TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf); 30 31 31 if(lpFile == NULL || lpTitle == NULL)32 return -1;32 if(lpFile == NULL || lpTitle == NULL) 33 return -1; 33 34 34 len = strlen(lpFile);35 len = strlen(lpFile); 35 36 36 if (len == 0)37 return -1;37 if (len == 0) 38 return -1; 38 39 39 if(strpbrk(lpFile, "*[]"))40 return -1;40 if(strpbrk(lpFile, "*[]")) 41 return -1; 41 42 42 len--;43 len--; 43 44 44 if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')45 return -1;45 if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':') 46 return -1; 46 47 47 for(i = len; i >= 0; i--)48 {49 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')50 {51 i++;52 break;53 }54 }48 for(i = len; i >= 0; i--) 49 { 50 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':') 51 { 52 i++; 53 break; 54 } 55 } 55 56 56 if(i == -1)57 i++;57 if(i == -1) 58 i++; 58 59 59 TRACE("---> '%s' \n", &lpFile[i]); 60 61 len = strlen(lpFile+i)+1; 62 if(cbBuf < len) 63 return len; 60 TRACE("---> '%s' \n", &lpFile[i]); 64 61 65 strncpy(lpTitle, &lpFile[i], len); 66 return 0; 62 len = strlen(lpFile+i)+1; 63 if(cbBuf < len) 64 return len; 65 66 strncpy(lpTitle, &lpFile[i], len); 67 return 0; 67 68 } 68 69 69 70 70 71 /*********************************************************************** 71 * GetFileTitleW(COMDLG32.9)72 * GetFileTitleW (COMDLG32.9) 72 73 * 73 74 */ 74 75 short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf) 75 76 { 76 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile);/* Has to go */77 LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);78 shortret;77 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile); /* Has to go */ 78 LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf); 79 short ret; 79 80 80 ret = GetFileTitleA(file, title, cbBuf);81 ret = GetFileTitleA(file, title, cbBuf); 81 82 82 lstrcpynAtoW(lpTitle, title, cbBuf);83 HeapFree(GetProcessHeap(), 0, file);84 HeapFree(GetProcessHeap(), 0, title);85 return ret;83 lstrcpynAtoW(lpTitle, title, cbBuf); 84 HeapFree(GetProcessHeap(), 0, file); 85 HeapFree(GetProcessHeap(), 0, title); 86 return ret; 86 87 } 87 88 … … 89 90 #ifndef __WIN32OS2__ 90 91 /*********************************************************************** 91 * GetFileTitle16(COMMDLG.27)92 * GetFileTitle16 (COMMDLG.27) 92 93 */ 93 94 short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf) 94 95 { 95 return GetFileTitleA(lpFile, lpTitle, cbBuf);96 return GetFileTitleA(lpFile, lpTitle, cbBuf); 96 97 } 97 98 #endif -
trunk/src/comdlg32/finddlg32.c
r5588 r6645 1 /* $Id: finddlg32.c,v 1.4 2001-09-05 12:12:01 bird Exp $ */ 1 2 /* 2 3 * Common Dialog Boxes interface (32 bit) … … 24 25 /*-----------------------------------------------------------------------*/ 25 26 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)27 static UINT FindReplaceMessage; 28 static UINT HelpMessage; 29 30 #define FR_MASK (FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_REPLACEALL | FR_REPLACE | FR_FINDNEXT | FR_DIALOGTERM) 30 31 /* CRITICAL_SECTION COMDLG32_CritSect; */ 31 32 … … 49 50 50 51 /*********************************************************************** 51 * COMDLG32_FR_GetFlags[internal]52 * COMDLG32_FR_GetFlags [internal] 52 53 * Returns the button state that needs to be reported to the caller. 53 * RETURNS54 * Current state of check and radio buttons54 * RETURNS 55 * Current state of check and radio buttons 55 56 */ 56 57 static DWORD COMDLG32_FR_GetFlags(HWND hDlgWnd) 57 58 { 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;59 DWORD flags = 0; 60 if(IsDlgButtonChecked(hDlgWnd, rad2) == BST_CHECKED) 61 flags |= FR_DOWN; 62 if(IsDlgButtonChecked(hDlgWnd, chx1) == BST_CHECKED) 63 flags |= FR_WHOLEWORD; 64 if(IsDlgButtonChecked(hDlgWnd, chx2) == BST_CHECKED) 65 flags |= FR_MATCHCASE; 65 66 return flags; 66 67 } 67 68 68 69 /*********************************************************************** 69 * COMDLG32_FR_HandleWMCommand[internal]70 * COMDLG32_FR_HandleWMCommand [internal] 70 71 * Handle WM_COMMAND messages... 71 72 */ 72 73 static void COMDLG32_FR_HandleWMCommand(HWND hDlgWnd, COMDLG32_FR_Data *pData, int Id, int NotifyCode) 73 74 { 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)75 DWORD flag; 76 77 pData->user_fr.fra->Flags &= ~FR_MASK; /* Clear return flags */ 78 if(pData->fr.Flags & FR_WINE_REPLACE) /* Replace always goes down... */ 79 pData->user_fr.fra->Flags |= FR_DOWN; 80 81 if(NotifyCode == BN_CLICKED) 82 { 83 switch(Id) 84 { 85 case IDOK: /* Find Next */ 86 if(GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0) 86 87 { 87 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT;88 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT; 88 89 if(pData->fr.Flags & FR_WINE_UNICODE) 89 90 { … … 94 95 else 95 96 { 96 strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);97 strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat); 97 98 } 98 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);99 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra); 99 100 } 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;101 break; 102 103 case IDCANCEL: 104 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_DIALOGTERM; 105 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra); 106 DestroyWindow(hDlgWnd); 107 break; 107 108 108 109 case psh2: /* Replace All */ 109 flag = FR_REPLACEALL;110 flag = FR_REPLACEALL; 110 111 goto Replace; 111 112 112 113 case psh1: /* Replace */ 113 flag = FR_REPLACE;114 flag = FR_REPLACE; 114 115 Replace: 115 if((pData->fr.Flags & FR_WINE_REPLACE)116 if((pData->fr.Flags & FR_WINE_REPLACE) 116 117 && GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0) 117 118 { 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;119 pData->fr.lpstrReplaceWith[0] = 0; /* In case the next GetDlgItemText Fails */ 120 GetDlgItemTextA(hDlgWnd, edt2, pData->fr.lpstrReplaceWith, pData->fr.wReplaceWithLen); 121 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag; 121 122 if(pData->fr.Flags & FR_WINE_UNICODE) 122 123 { … … 130 131 else 131 132 { 132 strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);133 strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith);133 strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat); 134 strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith); 134 135 } 135 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);136 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra); 136 137 } 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;138 break; 139 140 case pshHelp: 141 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd); 142 SendMessageA(pData->fr.hwndOwner, HelpMessage, (WPARAM)hDlgWnd, (LPARAM)pData->user_fr.fra); 143 break; 143 144 } 144 145 } 145 146 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);147 { 148 BOOL enable = SendDlgItemMessageA(hDlgWnd, edt1, WM_GETTEXTLENGTH, 0, 0) > 0; 149 EnableWindow(GetDlgItem(hDlgWnd, IDOK), enable); 149 150 if(pData->fr.Flags & FR_WINE_REPLACE) 150 151 { 151 EnableWindow(GetDlgItem(hDlgWnd, psh1), enable);152 EnableWindow(GetDlgItem(hDlgWnd, psh2), enable);152 EnableWindow(GetDlgItem(hDlgWnd, psh1), enable); 153 EnableWindow(GetDlgItem(hDlgWnd, psh2), enable); 153 154 } 154 }155 } 156 157 /*********************************************************************** 158 * COMDLG32_FindReplaceDlgProc[internal]155 } 156 } 157 158 /*********************************************************************** 159 * COMDLG32_FindReplaceDlgProc [internal] 159 160 * [Find/Replace]Text32[A/W] window procedure. 160 161 */ 161 162 static BOOL CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) 162 163 { 163 COMDLG32_FR_Data *pdata = (COMDLG32_FR_Data *)GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom);164 BOOL retval = TRUE;;165 166 if(iMsg == WM_INITDIALOG)164 COMDLG32_FR_Data *pdata = (COMDLG32_FR_Data *)GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom); 165 BOOL retval = TRUE;; 166 167 if(iMsg == WM_INITDIALOG) 167 168 { 168 169 pdata = (COMDLG32_FR_Data *)lParam; 169 if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata))170 if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata)) 170 171 { 171 ERR("Could not Set prop; invent a gracefull exit?...\n");172 DestroyWindow(hDlgWnd);172 ERR("Could not Set prop; invent a gracefull exit?...\n"); 173 DestroyWindow(hDlgWnd); 173 174 return FALSE; 174 175 } 175 SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wFindWhatLen, 0);176 SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat);176 SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wFindWhatLen, 0); 177 SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat); 177 178 if(pdata->fr.Flags & FR_WINE_REPLACE) 178 179 { 179 SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wReplaceWithLen, 0);180 SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith);180 SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wReplaceWithLen, 0); 181 SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith); 181 182 } 182 183 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 }184 if(!(pdata->fr.Flags & FR_SHOWHELP)) 185 ShowWindow(GetDlgItem(hDlgWnd, pshHelp), SW_HIDE); 186 if(pdata->fr.Flags & FR_HIDEUPDOWN) 187 { 188 ShowWindow(GetDlgItem(hDlgWnd, rad1), SW_HIDE); 189 ShowWindow(GetDlgItem(hDlgWnd, rad2), SW_HIDE); 190 ShowWindow(GetDlgItem(hDlgWnd, grp1), SW_HIDE); 191 } 192 else if(pdata->fr.Flags & FR_NOUPDOWN) 193 { 194 EnableWindow(GetDlgItem(hDlgWnd, rad1), FALSE); 195 EnableWindow(GetDlgItem(hDlgWnd, rad2), FALSE); 196 EnableWindow(GetDlgItem(hDlgWnd, grp1), FALSE); 197 } 197 198 else 198 199 { 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);200 SendDlgItemMessageA(hDlgWnd, rad1, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? 0 : BST_CHECKED, 0); 201 SendDlgItemMessageA(hDlgWnd, rad2, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? BST_CHECKED : 0, 0); 201 202 } 202 203 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);204 if(pdata->fr.Flags & FR_HIDEMATCHCASE) 205 ShowWindow(GetDlgItem(hDlgWnd, chx2), SW_HIDE); 206 else if(pdata->fr.Flags & FR_NOMATCHCASE) 207 EnableWindow(GetDlgItem(hDlgWnd, chx2), FALSE); 207 208 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);209 SendDlgItemMessageA(hDlgWnd, chx2, BM_SETCHECK, pdata->fr.Flags & FR_MATCHCASE ? BST_CHECKED : 0, 0); 210 211 if(pdata->fr.Flags & FR_HIDEWHOLEWORD) 212 ShowWindow(GetDlgItem(hDlgWnd, chx1), SW_HIDE); 213 else if(pdata->fr.Flags & FR_NOWHOLEWORD) 214 EnableWindow(GetDlgItem(hDlgWnd, chx1), FALSE); 214 215 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)) 223 return TRUE; 224 ShowWindow(hDlgWnd, SW_SHOWNORMAL); 225 UpdateWindow(hDlgWnd); 216 SendDlgItemMessageA(hDlgWnd, chx1, BM_SETCHECK, pdata->fr.Flags & FR_WHOLEWORD ? BST_CHECKED : 0, 0); 217 218 /* We did the init here, now call the hook if requested */ 219 220 /* We do not do ShowWindow if hook exists and is FALSE */ 221 /* per MSDN Article Q96135 */ 222 if((pdata->fr.Flags & FR_ENABLEHOOK) 223 && ! pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, (LPARAM) &pdata->fr)) 226 224 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 } 225 ShowWindow(hDlgWnd, SW_SHOWNORMAL); 226 UpdateWindow(hDlgWnd); 227 return TRUE; 228 } 229 230 if(pdata && (pdata->fr.Flags & FR_ENABLEHOOK)) 231 { 232 retval = pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, lParam); 233 } 234 else 235 retval = FALSE; 236 237 if(pdata && !retval) 238 { 239 retval = TRUE; 240 switch(iMsg) 241 { 242 case WM_COMMAND: 243 COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, LOWORD(wParam), HIWORD(wParam)); 244 break; 245 246 case WM_CLOSE: 247 COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, IDCANCEL, BN_CLICKED); 248 break; 249 250 case WM_HELP: 251 /* Heeeeelp! */ 252 FIXME("Got WM_HELP. Who is gonna supply it?\n"); 253 break; 254 255 case WM_CONTEXTMENU: 256 /* Heeeeelp! */ 257 FIXME("Got WM_CONTEXTMENU. Who is gonna supply it?\n"); 258 break; 259 /* FIXME: Handle F1 help */ 260 261 default: 262 retval = FALSE; /* We did not handle the message */ 263 } 263 264 } 264 265 … … 269 270 if(iMsg == WM_DESTROY) 270 271 { 271 RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);272 HeapFree(GetProcessHeap(), 0, pdata);272 RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom); 273 HeapFree(GetProcessHeap(), 0, pdata); 273 274 } 274 275 … … 277 278 278 279 /*********************************************************************** 279 * COMDLG32_FR_CheckPartial[internal]280 * COMDLG32_FR_CheckPartial [internal] 280 281 * Check various fault conditions in the supplied parameters that 281 282 * cause an extended error to be reported. 282 * RETURNS283 * TRUE: Success284 * FALSE: Failure283 * RETURNS 284 * TRUE: Success 285 * FALSE: Failure 285 286 */ 286 287 static BOOL COMDLG32_FR_CheckPartial( 287 LPFINDREPLACEA pfr,/* [in] Find structure */288 BOOL Replace /* [in] True if called as replace */288 LPFINDREPLACEA pfr, /* [in] Find structure */ 289 BOOL Replace /* [in] True if called as replace */ 289 290 ) { 290 if(!pfr)291 { 292 COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES);293 return FALSE; 294 }291 if(!pfr) 292 { 293 COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES); 294 return FALSE; 295 } 295 296 296 297 if(pfr->lStructSize != sizeof(FINDREPLACEA)) 297 298 { 298 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);299 return FALSE;299 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 300 return FALSE; 300 301 } 301 302 302 303 if(!IsWindow(pfr->hwndOwner)) 303 304 { 304 COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE);305 return FALSE;306 } 307 308 if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat)305 COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE); 306 return FALSE; 307 } 308 309 if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat) 309 310 ||(Replace && (pfr->wReplaceWithLen < 1 || !pfr->lpstrReplaceWith))) 310 311 { 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);312 COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO); 313 return FALSE; 314 } 315 316 if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0) 317 { 318 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 319 return FALSE; 320 } 321 if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) 322 { 323 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 323 324 return FALSE; 324 325 } … … 326 327 if((pfr->Flags & FR_ENABLEHOOK) && !pfr->lpfnHook) 327 328 { 328 COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);329 COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK); 329 330 return FALSE; 330 331 } … … 332 333 if((pfr->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE)) && !pfr->hInstance) 333 334 { 334 COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE);335 COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE); 335 336 return FALSE; 336 337 } … … 338 339 if((pfr->Flags & FR_ENABLETEMPLATE) && !pfr->lpTemplateName) 339 340 { 340 COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE);341 return FALSE; 342 } 343 344 return TRUE;345 } 346 347 /*********************************************************************** 348 * COMDLG32_FR_DoFindReplace[internal]341 COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE); 342 return FALSE; 343 } 344 345 return TRUE; 346 } 347 348 /*********************************************************************** 349 * COMDLG32_FR_DoFindReplace [internal] 349 350 * Actual load and creation of the Find/Replace dialog. 350 * RETURNS351 * Window handle to created dialog:Success352 * NULL:Failure351 * RETURNS 352 * Window handle to created dialog:Success 353 * NULL:Failure 353 354 */ 354 355 static HWND COMDLG32_FR_DoFindReplace( 355 COMDLG32_FR_Data *pdata/* [in] Internal data structure */356 COMDLG32_FR_Data *pdata /* [in] Internal data structure */ 356 357 ) { 357 HWND hdlgwnd = 0;358 HWND hdlgwnd = 0; 358 359 HGLOBAL loadrc; 359 360 DWORD error; 360 361 LPDLGTEMPLATEW rcs; 361 362 362 TRACE("hInst=%08x, Flags=%08lx\n", pdata->fr.hInstance, pdata->fr.Flags);363 TRACE("hInst=%08x, Flags=%08lx\n", pdata->fr.hInstance, pdata->fr.Flags); 363 364 364 365 if(!(pdata->fr.Flags & FR_ENABLETEMPLATEHANDLE)) 365 366 { 366 HMODULE hmod = COMDLG32_hInstance;367 HRSRC htemplate;368 if(pdata->fr.Flags & FR_ENABLETEMPLATE)369 {370 hmod = (HMODULE)pdata->fr.hInstance;367 HMODULE hmod = COMDLG32_hInstance; 368 HRSRC htemplate; 369 if(pdata->fr.Flags & FR_ENABLETEMPLATE) 370 { 371 hmod = (HMODULE)pdata->fr.hInstance; 371 372 if(pdata->fr.Flags & FR_WINE_UNICODE) 372 373 { 373 htemplate = FindResourceW(hmod, (LPWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOGA);374 htemplate = FindResourceW(hmod, (LPWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOGA); 374 375 } 375 376 else 376 377 { 377 htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOGA);378 htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOGA); 378 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 } 380 } 394 381 else 395 { 396 loadrc = (HGLOBAL)pdata->fr.hInstance; 382 { 383 int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD 384 : FINDDLGORD; 385 htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOGA); 386 } 387 if(!htemplate) 388 { 389 error = CDERR_FINDRESFAILURE; 390 goto cleanup; 391 } 392 393 loadrc = LoadResource(hmod, htemplate); 394 } 395 else 396 { 397 loadrc = (HGLOBAL)pdata->fr.hInstance; 397 398 } 398 399 399 400 if(!loadrc) 400 401 { 401 error = CDERR_LOADRESFAILURE;402 goto cleanup;403 }402 error = CDERR_LOADRESFAILURE; 403 goto cleanup; 404 } 404 405 405 406 if((rcs = (LPDLGTEMPLATEW)LockResource(loadrc)) == NULL) 406 407 { 407 error = CDERR_LOCKRESFAILURE;408 goto cleanup;408 error = CDERR_LOCKRESFAILURE; 409 goto cleanup; 409 410 } 410 411 411 412 hdlgwnd = CreateDialogIndirectParamA(COMDLG32_hInstance, 412 rcs,413 rcs, 413 414 pdata->fr.hwndOwner, 414 415 (DLGPROC)COMDLG32_FindReplaceDlgProc, 415 416 (LPARAM)pdata); 416 if(!hdlgwnd)417 { 418 error = CDERR_DIALOGFAILURE;417 if(!hdlgwnd) 418 { 419 error = CDERR_DIALOGFAILURE; 419 420 cleanup: 420 COMDLG32_SetCommDlgExtendedError(error);421 COMDLG32_SetCommDlgExtendedError(error); 421 422 HeapFree(GetProcessHeap(), 0, pdata); 422 423 } … … 425 426 426 427 /*********************************************************************** 427 * FindTextA[COMDLG32.6]428 * RETURNS429 * Window handle to created dialog: Success430 * NULL: Failure428 * FindTextA [COMDLG32.6] 429 * RETURNS 430 * Window handle to created dialog: Success 431 * NULL: Failure 431 432 */ 432 433 HWND WINAPI FindTextA( 433 LPFINDREPLACEA pfr/* [in] Find/replace structure*/434 LPFINDREPLACEA pfr /* [in] Find/replace structure*/ 434 435 ) { 435 COMDLG32_FR_Data *pdata;436 COMDLG32_FR_Data *pdata; 436 437 437 438 TRACE("LPFINDREPLACE=%p\n", pfr); 438 439 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 */440 if(!COMDLG32_FR_CheckPartial(pfr, FALSE)) 441 return 0; 442 443 if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL) 444 return 0; /* Error has been set */ 444 445 445 446 pdata->user_fr.fra = pfr; 446 447 pdata->fr = *pfr; 447 return COMDLG32_FR_DoFindReplace(pdata);448 } 449 450 /*********************************************************************** 451 * ReplaceTextA[COMDLG32.19]452 * RETURNS453 * Window handle to created dialog: Success454 * NULL: Failure448 return COMDLG32_FR_DoFindReplace(pdata); 449 } 450 451 /*********************************************************************** 452 * ReplaceTextA [COMDLG32.19] 453 * RETURNS 454 * Window handle to created dialog: Success 455 * NULL: Failure 455 456 */ 456 457 HWND WINAPI ReplaceTextA( 457 LPFINDREPLACEA pfr/* [in] Find/replace structure*/458 LPFINDREPLACEA pfr /* [in] Find/replace structure*/ 458 459 ) { 459 COMDLG32_FR_Data *pdata;460 COMDLG32_FR_Data *pdata; 460 461 461 462 TRACE("LPFINDREPLACE=%p\n", pfr); 462 463 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 */464 if(!COMDLG32_FR_CheckPartial(pfr, TRUE)) 465 return 0; 466 467 if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL) 468 return 0; /* Error has been set */ 468 469 469 470 pdata->user_fr.fra = pfr; 470 471 pdata->fr = *pfr; 471 pdata->fr.Flags |= FR_WINE_REPLACE;472 return COMDLG32_FR_DoFindReplace(pdata);473 } 474 475 /*********************************************************************** 476 * FindTextW[COMDLG32.7]477 * RETURNS478 * Window handle to created dialog: Success479 * NULL: Failure472 pdata->fr.Flags |= FR_WINE_REPLACE; 473 return COMDLG32_FR_DoFindReplace(pdata); 474 } 475 476 /*********************************************************************** 477 * FindTextW [COMDLG32.7] 478 * RETURNS 479 * Window handle to created dialog: Success 480 * NULL: Failure 480 481 */ 481 482 HWND WINAPI FindTextW( 482 LPFINDREPLACEW pfr/* [in] Find/replace structure*/483 LPFINDREPLACEW pfr /* [in] Find/replace structure*/ 483 484 ) { 484 COMDLG32_FR_Data *pdata;485 COMDLG32_FR_Data *pdata; 485 486 DWORD len; 486 487 487 488 TRACE("LPFINDREPLACE=%p\n", pfr); 488 489 489 if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))490 return 0;490 if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE)) 491 return 0; 491 492 492 493 len = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, … … 496 497 497 498 pdata->user_fr.frw = pfr; 498 pdata->fr = *(LPFINDREPLACEA)pfr; /* FINDREPLACEx have same size */499 pdata->fr.Flags |= FR_WINE_UNICODE;499 pdata->fr = *(LPFINDREPLACEA)pfr; /* FINDREPLACEx have same size */ 500 pdata->fr.Flags |= FR_WINE_UNICODE; 500 501 pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1); /* Set string pointer */ 501 502 WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, … … 505 506 506 507 /*********************************************************************** 507 * ReplaceTextW[COMDLG32.20]508 * RETURNS509 * Window handle to created dialog: Success510 * NULL: Failure508 * ReplaceTextW [COMDLG32.20] 509 * RETURNS 510 * Window handle to created dialog: Success 511 * NULL: Failure 511 512 */ 512 513 HWND WINAPI ReplaceTextW( 513 LPFINDREPLACEW pfr/* [in] Find/replace structure*/514 LPFINDREPLACEW pfr /* [in] Find/replace structure*/ 514 515 ) { 515 COMDLG32_FR_Data *pdata;516 COMDLG32_FR_Data *pdata; 516 517 DWORD len1, len2; 517 518 518 519 TRACE("LPFINDREPLACE=%p\n", pfr); 519 520 520 if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))521 return 0;521 if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE)) 522 return 0; 522 523 523 524 len1 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, … … 525 526 len2 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen, 526 527 NULL, 0, NULL, NULL ); 527 if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data)528 if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data) 528 529 + len1 + len2)) == NULL) 529 530 return 0; /* Error has been set */ 530 531 531 532 pdata->user_fr.frw = pfr; 532 pdata->fr = *(LPFINDREPLACEA)pfr; /* FINDREPLACEx have same size */533 pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE;533 pdata->fr = *(LPFINDREPLACEA)pfr; /* FINDREPLACEx have same size */ 534 pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE; 534 535 pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1); /* Set string pointer */ 535 536 pdata->fr.lpstrReplaceWith = pdata->fr.lpstrFindWhat + len1; -
trunk/src/comdlg32/fontdlg.c
r5583 r6645 1 /* $Id: fontdlg.c,v 1.4 2001-09-05 12:12:02 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - Font Dialog … … 45 46 46 47 #ifdef __WIN32OS2__ 47 static HBITMAP hBitmapTT = 0; 48 static HBITMAP hBitmapTT = 0; 48 49 #else 49 static HBITMAP16 hBitmapTT = 0; 50 static HBITMAP16 hBitmapTT = 0; 50 51 #endif 51 52 52 53 LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, 53 LPARAM lParam);54 LPARAM lParam); 54 55 LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, 55 LPARAM lParam);56 LPARAM lParam); 56 57 57 58 #ifndef __WIN32OS2__ … … 79 80 80 81 /*********************************************************************** 81 * ChooseFont16 (COMMDLG.15) 82 * ChooseFont16 (COMMDLG.15) 82 83 */ 83 84 BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont) … … 92 93 LOGFONTA lf32a; 93 94 SEGPTR lpTemplateName; 94 95 95 96 cf32a.lpLogFont=&lf32a; 96 97 CFn_CHOOSEFONT16to32A(lpChFont, &cf32a); 97 98 98 99 TRACE("ChooseFont\n"); 99 if (!lpChFont) return FALSE; 100 if (!lpChFont) return FALSE; 100 101 101 102 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE) … … 157 158 } 158 159 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template); 159 hDlgTmpl16 = hGlobal16; 160 hDlgTmpl16 = hGlobal16; 160 161 161 162 } … … 204 205 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE | 205 206 CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n"); 206 return DialogBoxIndirectParamA(COMMDLG_hInstance32, template, 207 return DialogBoxIndirectParamA(COMMDLG_hInstance32, template, 207 208 lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcA, (LPARAM)lpChFont ); 208 209 } … … 239 240 cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle); 240 241 lpChFont->lpTemplateName=(LPWSTR)&cf32a; 241 bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, 242 bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, 242 243 lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcW, (LPARAM)lpChFont ); 243 244 HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle); … … 288 289 * AddFontFamily [internal] 289 290 */ 290 static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType, 291 static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType, 291 292 LPCHOOSEFONTA lpcf, HWND hwnd) 292 293 { … … 304 305 if (lpcf->Flags & CF_TTONLY) 305 306 if (!(nFontType & TRUETYPE_FONTTYPE)) 306 return 1; 307 return 1; 307 308 308 309 i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName); … … 327 328 * FontFamilyEnumProc32 [internal] 328 329 */ 329 static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont, 330 LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)330 static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont, 331 LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam) 331 332 { 332 333 LPCFn_ENUMSTRUCT e; … … 344 345 HWND16 hwnd=LOWORD(lParam); 345 346 HWND hDlg=GetParent(hwnd); 346 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 347 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 347 348 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont ); 348 349 LOGFONTA lf32a; … … 362 363 #define FSTYLES 4 363 364 struct FONTSTYLE 364 { int italic; 365 { int italic; 365 366 int weight; 366 367 char stname[20]; }; 367 static struct FONTSTYLE fontstyles[FSTYLES]={ 368 static struct FONTSTYLE fontstyles[FSTYLES]={ 368 369 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"}, 369 370 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}}; … … 389 390 j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str ); 390 391 if (j==CB_ERR) return 1; 391 j=SendMessageA(hwnd, CB_SETITEMDATA, j, 392 j=SendMessageA(hwnd, CB_SETITEMDATA, j, 392 393 MAKELONG(fontstyles[i].weight,fontstyles[i].italic)); 393 394 #else … … 396 397 SEGPTR_FREE(str); 397 398 if (j==CB_ERR) return 1; 398 j=SendMessage16(hwnd, CB_SETITEMDATA16, j, 399 j=SendMessage16(hwnd, CB_SETITEMDATA16, j, 399 400 MAKELONG(fontstyles[i].weight,fontstyles[i].italic)); 400 401 #endif 401 if (j==CB_ERR) return 1; 402 if (j==CB_ERR) return 1; 402 403 } 403 } 404 } 404 405 return 0; 405 406 } … … 417 418 { 418 419 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 }420 j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer); 421 if (j==CB_ERR) 422 { 423 j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer); 424 if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h); 425 if (j==CB_ERR) return 1; 426 } 426 427 } 427 428 return 0; 428 } 429 429 } 430 430 431 /************************************************************************* 431 432 * SetFontSizesToCombo3 [internal] … … 444 445 * AddFontStyle [internal] 445 446 */ 446 static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType, 447 static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType, 447 448 LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg) 448 449 { 449 450 int i; 450 451 451 452 TRACE("(nFontType=%d)\n",nFontType); 452 453 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);454 " ch=%d op=%d cp=%d q=%d pf=%xh\n", 455 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth, 456 lplf->lfEscapement,lplf->lfOrientation, 457 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline, 458 lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision, 459 lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily); 459 460 if (nFontType & RASTER_FONTTYPE) 460 461 { … … 473 474 return 1 ; 474 475 475 } 476 } 476 477 477 478 #ifndef __WIN32OS2__ … … 485 486 HWND16 hcmb3=HIWORD(lParam); 486 487 HWND hDlg=GetParent(hcmb3); 487 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 488 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 488 489 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont); 489 490 LOGFONTA lf32a; … … 497 498 * FontStyleEnumProc32 [internal] 498 499 */ 499 static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont, 500 static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont, 500 501 LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam ) 501 502 { … … 520 521 HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA)); 521 522 522 SetWindowLongA(hDlg, DWL_USER, lParam); 523 SetWindowLongA(hDlg, DWL_USER, lParam); 523 524 lpxx=lpcf->lpLogFont; 524 525 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam); … … 527 528 { 528 529 ERR("structure size failure !!!\n"); 529 EndDialog (hDlg, 0); 530 EndDialog (hDlg, 0); 530 531 return FALSE; 531 532 } … … 536 537 SendDlgItemMessageA(hDlg,stc6,WM_SETFONT, 537 538 CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE); 538 539 539 540 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner)) 540 541 ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE); … … 582 583 { 583 584 SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0); 584 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),585 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE), 585 586 GetDlgItem(hDlg,cmb1)); 586 587 init=1; … … 592 593 SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0); 593 594 } 594 595 595 596 /* look for fitting font size in combobox3 */ 596 597 j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0); … … 607 608 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE), 608 609 GetDlgItem(hDlg,cmb1)); 609 } 610 } 610 611 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle) 611 612 { … … 622 623 { 623 624 WARN("HDC failure !!!\n"); 624 EndDialog (hDlg, 0); 625 EndDialog (hDlg, 0); 625 626 return FALSE; 626 627 } … … 628 629 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC)) 629 630 ReleaseDC(hDlg,hdc); 630 SetCursor(hcursor); 631 SetCursor(hcursor); 631 632 return TRUE; 632 633 } … … 659 660 COLORREF cr, oldText=0, oldBk=0; 660 661 RECT rect; 661 #if 0 662 #if 0 662 663 HDC hMemDC; 663 664 int nFontType; 664 665 HBITMAP hBitmap; /* for later TT usage */ 665 #endif 666 #endif 666 667 LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam; 667 668 668 if (lpdi->itemID == 0xFFFF) /* got no items */669 if (lpdi->itemID == 0xFFFF) /* got no items */ 669 670 DrawFocusRect(lpdi->hDC, &lpdi->rcItem); 670 671 else … … 685 686 } 686 687 else 687 return TRUE; /* this should never happen */688 return TRUE; /* this should never happen */ 688 689 689 690 rect=lpdi->rcItem; 690 691 switch (lpdi->CtlID) 691 692 { 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,693 case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */ 694 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID, 695 (LPARAM)buffer); 696 GetObjectA( hBitmapTT, sizeof(bm), &bm ); 697 TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10, 697 698 lpdi->rcItem.top, buffer, strlen(buffer)); 698 699 #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,700 nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L); 701 /* FIXME: draw bitmap if truetype usage */ 702 if (nFontType&TRUETYPE_FONTTYPE) 703 { 704 hMemDC = CreateCompatibleDC(lpdi->hDC); 705 hBitmap = SelectObject(hMemDC, hBitmapTT); 706 BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top, 706 707 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); 707 SelectObject(hMemDC, hBitmap);708 DeleteDC(hMemDC);709 }708 SelectObject(hMemDC, hBitmap); 709 DeleteDC(hMemDC); 710 } 710 711 #endif 711 break;712 break; 712 713 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,714 case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */ 715 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID, 716 (LPARAM)buffer); 717 TextOutA(lpdi->hDC, lpdi->rcItem.left, 717 718 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,719 break; 720 721 case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */ 722 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID, 723 (LPARAM)buffer); 724 TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5, 724 725 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,726 cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L); 727 hBrush = CreateSolidBrush(cr); 728 if (hBrush) 729 { 730 hBrush = SelectObject (lpdi->hDC, hBrush) ; 731 rect.right=rect.left+25; 732 rect.top++; 733 rect.left+=5; 734 rect.bottom--; 735 Rectangle( lpdi->hDC, rect.left, rect.top, 735 736 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 */737 DeleteObject( SelectObject (lpdi->hDC, hBrush)) ; 738 } 739 rect=lpdi->rcItem; 740 rect.left+=25+5; 741 break; 742 743 default: return TRUE; /* this should never happen */ 743 744 } 744 745 if (lpdi->itemState == ODS_SELECTED) … … 777 778 HDC hdc; 778 779 LPLOGFONTA lpxx=lpcf->lpLogFont; 779 780 780 781 TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam); 781 782 switch (LOWORD(wParam)) 782 783 { 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 {784 case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE) 785 { 786 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg); 787 if (hdc) 788 { 788 789 #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);790 SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0); 791 SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0); 792 i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0); 792 793 #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);794 SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0); 795 SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0); 796 i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0); 796 797 #endif 797 if (i!=CB_ERR)798 {799 HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));800 CFn_ENUMSTRUCT s;798 if (i!=CB_ERR) 799 { 800 HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA)); 801 CFn_ENUMSTRUCT s; 801 802 char str[256]; 802 803 SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i, 803 804 (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 else805 TRACE("WM_COMMAND/cmb1 =>%s\n",str); 806 s.hWnd1=GetDlgItem(hDlg, cmb2); 807 s.hWnd2=GetDlgItem(hDlg, cmb3); 808 s.lpcf32a=lpcf; 809 EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s); 810 SetCursor(hcursor); 811 } 812 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC)) 813 ReleaseDC(hDlg,hdc); 814 } 815 else 815 816 { 816 817 WARN("HDC failure !!!\n"); 817 EndDialog (hDlg, 0); 818 EndDialog (hDlg, 0); 818 819 return TRUE; 819 820 } 820 }821 case chx1:822 case chx2:823 case cmb2:824 case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )825 {821 } 822 case chx1: 823 case chx2: 824 case cmb2: 825 case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED ) 826 { 826 827 char str[256]; 827 828 TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam); 828 i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);829 if (i==CB_ERR)829 i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0); 830 if (i==CB_ERR) 830 831 i=GetDlgItemTextA( hDlg, cmb1, str, 256 ); 831 832 else 832 833 { 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 EnumFonts840 call back with the extra FONTTYPE_... bits added */841 lpxx->lfPitchAndFamily=j&0xff;842 lpxx->lfCharSet=j>>8;834 SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i, 835 (LPARAM)str); 836 l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0); 837 j=HIWORD(l); 838 lpcf->nFontType = LOWORD(l); 839 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */ 840 /* same value reported to the EnumFonts 841 call back with the extra FONTTYPE_... bits added */ 842 lpxx->lfPitchAndFamily=j&0xff; 843 lpxx->lfCharSet=j>>8; 843 844 } 844 845 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 else858 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;846 i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0); 847 if (i!=CB_ERR) 848 { 849 l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0); 850 if (0!=(lpxx->lfItalic=HIWORD(l))) 851 lpcf->nFontType |= ITALIC_FONTTYPE; 852 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM) 853 lpcf->nFontType |= BOLD_FONTTYPE; 854 } 855 i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0); 856 if (i!=CB_ERR) 857 lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0)); 858 else 859 lpxx->lfHeight=0; 860 lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1); 861 lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2); 862 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0; 863 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS; 864 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS; 865 lpxx->lfQuality=DEFAULT_QUALITY; 865 866 lpcf->iPointSize= -10*lpxx->lfHeight; 866 867 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 }868 hFont=CreateFontIndirectA(lpxx); 869 if (hFont) 870 { 871 HFONT oldFont=SendDlgItemMessageA(hDlg, stc6, 872 WM_GETFONT, 0, 0); 873 SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE); 874 DeleteObject(oldFont); 875 } 875 876 } 876 877 break; 877 878 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) && 879 case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0); 880 if (i!=CB_ERR) 881 { 882 lpcf->rgbColors=textcolors[i]; 883 InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 ); 884 } 885 break; 886 887 case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA ); 888 if (lpcf->hwndOwner) 889 SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER)); 890 /* if (CFn_HookCallChk(lpcf)) 891 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/ 892 break; 893 894 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) || 895 ( (lpcf->Flags & CF_LIMITSIZE) && 896 (-lpxx->lfHeight >= lpcf->nSizeMin) && 896 897 (-lpxx->lfHeight <= lpcf->nSizeMax))) 897 EndDialog(hDlg, TRUE);898 else899 {898 EndDialog(hDlg, TRUE); 899 else 900 { 900 901 char buffer[80]; 901 sprintf(buffer,"Select a font size between %d and %d points.",902 sprintf(buffer,"Select a font size between %d and %d points.", 902 903 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 }904 MessageBoxA(hDlg, buffer, NULL, MB_OK); 905 } 906 return(TRUE); 907 case IDCANCEL:EndDialog(hDlg, FALSE); 908 return(TRUE); 909 } 909 910 return(FALSE); 910 911 } … … 930 931 UINT uMsg32; 931 932 WPARAM wParam32; 932 LRESULT res=0; 933 LRESULT res=0; 933 934 if (message!=WM_INITDIALOG) 934 935 { 935 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 936 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 936 937 if (!lpcf) 937 938 return FALSE; … … 945 946 lpcf=(LPCHOOSEFONT16)lParam; 946 947 lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName; 947 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 948 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 948 949 { 949 950 TRACE("CFn_WMInitDialog returned FALSE\n"); 950 951 return FALSE; 951 } 952 } 952 953 if (CFn_HookCallChk(lpcf)) 953 954 return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam); … … 959 960 case WM_MEASUREITEM: 960 961 res=CFn_WMMeasureItem(hDlg, wParam32, lParam); 961 break;962 break; 962 963 case WM_DRAWITEM: 963 964 res=CFn_WMDrawItem(hDlg, wParam32, lParam); 964 break;965 break; 965 966 case WM_CTLCOLORSTATIC: 966 967 res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a); 967 break;968 break; 968 969 case WM_COMMAND: 969 970 res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a); 970 break;971 break; 971 972 case WM_DESTROY: 972 973 res=CFn_WMDestroy(hDlg, wParam32, lParam); 973 break;974 case WM_CHOOSEFONT_GETLOGFONT: 974 break; 975 case WM_CHOOSEFONT_GETLOGFONT: 975 976 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", 976 lParam);977 FIXME("current logfont back to caller\n");977 lParam); 978 FIXME("current logfont back to caller\n"); 978 979 break; 979 980 } 980 WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res); 981 WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res); 981 982 return res; 982 983 } … … 993 994 if (uMsg!=WM_INITDIALOG) 994 995 { 995 lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER); 996 lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER); 996 997 if (!lpcf) 997 998 return FALSE; … … 1004 1005 { 1005 1006 lpcf=(LPCHOOSEFONTA)lParam; 1006 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf)) 1007 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf)) 1007 1008 { 1008 1009 TRACE("CFn_WMInitDialog returned FALSE\n"); 1009 1010 return FALSE; 1010 } 1011 } 1011 1012 if (CFn_HookCallChk32(lpcf)) 1012 1013 return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam); … … 1026 1027 case WM_CHOOSEFONT_GETLOGFONT: 1027 1028 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", 1028 lParam);1029 FIXME("current logfont back to caller\n");1029 lParam); 1030 FIXME("current logfont back to caller\n"); 1030 1031 break; 1031 1032 } … … 1044 1045 if (uMsg!=WM_INITDIALOG) 1045 1046 { 1046 lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER); 1047 lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER); 1047 1048 if (!lpcf32w) 1048 1049 return FALSE; … … 1056 1057 lpcf32w=(LPCHOOSEFONTW)lParam; 1057 1058 lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName; 1058 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 1059 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 1059 1060 { 1060 1061 TRACE("CFn_WMInitDialog returned FALSE\n"); 1061 1062 return FALSE; 1062 } 1063 } 1063 1064 if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w)) 1064 1065 return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam); … … 1077 1078 case WM_DESTROY: 1078 1079 return CFn_WMDestroy(hDlg, wParam, lParam); 1079 case WM_CHOOSEFONT_GETLOGFONT: 1080 case WM_CHOOSEFONT_GETLOGFONT: 1080 1081 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", 1081 lParam);1082 FIXME("current logfont back to caller\n");1082 lParam); 1083 FIXME("current logfont back to caller\n"); 1083 1084 break; 1084 1085 } -
trunk/src/comdlg32/initcomdlg32.cpp
r6401 r6645 1 /* $Id: initcomdlg32.cpp,v 1.3 2001-09-05 12:12:02 bird Exp $ */ 1 2 /* 2 3 * DLL entry point … … 54 55 case DLL_THREAD_ATTACH: 55 56 case DLL_THREAD_DETACH: 56 return COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);57 return COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad); 57 58 58 59 case DLL_PROCESS_DETACH: 59 COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);60 return TRUE;60 COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad); 61 return TRUE; 61 62 } 62 63 return FALSE; … … 83 84 switch (ulFlag) { 84 85 case 0 : 85 dllHandle = RegisterLxDll(hModule, LibMainComdlg32, (PVOID)&comdlg32_PEResTab,86 dllHandle = RegisterLxDll(hModule, LibMainComdlg32, (PVOID)&comdlg32_PEResTab, 86 87 COMDLG32_MAJORIMAGE_VERSION, COMDLG32_MINORIMAGE_VERSION, 87 88 IMAGE_SUBSYSTEM_WINDOWS_GUI); 88 if(dllHandle == 0) 89 return 0UL;89 if(dllHandle == 0) 90 return 0UL; 90 91 91 92 break; 92 93 case 1 : 93 94 if(dllHandle) { 94 UnregisterLxDll(dllHandle);95 UnregisterLxDll(dllHandle); 95 96 } 96 97 break; -
trunk/src/comdlg32/initterm.cpp
r6375 r6645 1 /* $Id: initterm.cpp,v 1.14 2001-09-05 12:12:02 bird Exp $ */ 1 2 /* 2 3 * DLL entry point … … 66 67 case 1 : 67 68 inittermComdlg32(hModule, ulFlag); 68 ctordtorTerm();69 ctordtorTerm(); 69 70 break; 70 71 -
trunk/src/comdlg32/printdlg.c
r6335 r6645 1 /* $Id: printdlg.c,v 1.2 2001-09-05 12:12:02 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - Print Dialog … … 30 31 /* This PRINTDLGA internal structure stores 31 32 * pointers to several throughout useful structures. 32 * 33 */ 34 typedef struct 33 * 34 */ 35 typedef struct 35 36 { 36 37 LPDEVMODEA lpDevMode; 37 38 struct { 38 39 LPPRINTDLGA lpPrintDlg; 39 LPPRINTDLG16 lpPrintDlg16;40 LPPRINTDLG16 lpPrintDlg16; 40 41 } dlg; 41 42 LPPRINTER_INFO_2A lpPrinterInfo; … … 108 109 * 109 110 * Returns the default printer name in buf. 110 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 111 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 111 112 * these entries are mapped somewhere in the registry rather than win.ini. 112 113 * … … 118 119 119 120 if(!GetProfileStringA("windows", "device", "", buf, len)) { 120 TRACE("No profile entry for default printer found.\n");121 return FALSE;121 TRACE("No profile entry for default printer found.\n"); 122 return FALSE; 122 123 } 123 124 if((ptr = strchr(buf, ',')) == NULL) { 124 FIXME("bad format for default printer (%s)!\n",buf);125 return FALSE;125 FIXME("bad format for default printer (%s)!\n",buf); 126 return FALSE; 126 127 } 127 128 *ptr = '\0'; … … 145 146 res = OpenPrinterA(buf, hprn, NULL); 146 147 if (!res) 147 FIXME("Could not open printer %s?!\n",buf);148 FIXME("Could not open printer %s?!\n",buf); 148 149 return res; 149 150 } … … 169 170 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num); 170 171 pi = HeapAlloc(GetProcessHeap(), 0, needed); 171 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 172 &num);172 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 173 &num); 173 174 174 175 for(i = 0; i < num; i++) { 175 176 SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0, 176 (LPARAM)pi[i].pPrinterName );177 (LPARAM)pi[i].pPrinterName ); 177 178 } 178 179 HeapFree(GetProcessHeap(), 0, pi); 179 180 if(!name || 180 181 (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, 181 (LPARAM)name)) == CB_ERR) {182 (LPARAM)name)) == CB_ERR) { 182 183 183 184 char buf[260]; 184 185 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");186 name); 187 if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf))) 188 return num; 189 i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf); 190 if(i == CB_ERR) 191 FIXME("Can't find default printer in printer list\n"); 191 192 } 192 193 SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0); … … 202 203 * (NB. when we handle unicode the offsets will be in wchars). 203 204 */ 204 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 205 char* DeviceName, char* OutputPort)205 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 206 char* DeviceName, char* OutputPort) 206 207 { 207 208 long size; … … 215 216 + strlen(OutputPort) + 1 216 217 + sizeof(DEVNAMES); 217 218 218 219 if(*hmem) 219 220 *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE); … … 233 234 strcpy(pTempPtr, DeviceName); 234 235 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 235 236 236 237 pTempPtr += strlen(DeviceName) + 1; 237 238 strcpy(pTempPtr, OutputPort); … … 244 245 } 245 246 #ifndef __WIN32OS2__ 246 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 247 char* DeviceName, char* OutputPort)247 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 248 char* DeviceName, char* OutputPort) 248 249 { 249 250 long size; … … 257 258 + strlen(OutputPort) + 1 258 259 + sizeof(DEVNAMES); 259 260 260 261 if(*hmem) 261 262 *hmem = GlobalReAlloc16(*hmem, size, GMEM_MOVEABLE); … … 275 276 strcpy(pTempPtr, DeviceName); 276 277 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 277 278 278 279 pTempPtr += strlen(DeviceName) + 1; 279 280 strcpy(pTempPtr, OutputPort); … … 292 293 * 293 294 * updates the PrintDlg structure for returnvalues. 294 * 295 * 295 296 * RETURNS 296 297 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values) 297 298 * TRUE if succesful. 298 299 */ 299 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 300 PRINT_PTRA* PrintStructures)300 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 301 PRINT_PTRA* PrintStructures) 301 302 { 302 303 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 306 307 307 308 if(!lpdm) { 308 FIXME("No lpdm ptr?\n");309 return FALSE;309 FIXME("No lpdm ptr?\n"); 310 return FALSE; 310 311 } 311 312 … … 313 314 if(!(lppd->Flags & PD_PRINTSETUP)) { 314 315 /* check whether nFromPage and nToPage are within range defined by 315 * nMinPage and nMaxPage316 */316 * nMinPage and nMaxPage 317 */ 317 318 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 there355 * 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;319 WORD nToPage; 320 WORD nFromPage; 321 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE); 322 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); 323 if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage || 324 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) { 325 char resourcestr[256]; 326 char resultstr[256]; 327 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 328 resourcestr, 255); 329 sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage); 330 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 331 resourcestr, 255); 332 MessageBoxA(hDlg, resultstr, resourcestr, 333 MB_OK | MB_ICONWARNING); 334 return FALSE; 335 } 336 lppd->nFromPage = nFromPage; 337 lppd->nToPage = nToPage; 338 } 339 340 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */ 341 lppd->Flags |= PD_PRINTTOFILE; 342 pi->pPortName = "FILE:"; 343 } 344 345 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */ 346 FIXME("Collate lppd not yet implemented as output\n"); 347 } 348 349 /* set PD_Collate and nCopies */ 350 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 351 /* The application doesn't support multiple copies or collate... 352 */ 353 lppd->Flags &= ~PD_COLLATE; 354 lppd->nCopies = 1; 355 /* if the printer driver supports it... store info there 356 * otherwise no collate & multiple copies ! 357 */ 358 if (lpdm->dmFields & DM_COLLATE) 359 lpdm->dmCollate = 360 (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED); 361 if (lpdm->dmFields & DM_COPIES) 362 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 363 } else { 364 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 365 lppd->Flags |= PD_COLLATE; 365 366 else 366 367 lppd->Flags &= ~PD_COLLATE; 367 368 lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 368 }369 } 369 370 } 370 371 return TRUE; … … 372 373 373 374 static BOOL PRINTDLG_PaperSize( 374 PRINTDLGA*pdlga,const char *PaperSize,LPPOINT size375 PRINTDLGA *pdlga,const char *PaperSize,LPPOINT size 375 376 ) { 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 377 DEVNAMES *dn; 378 DEVMODEA *dm; 379 LPSTR devname,portname; 380 int i; 381 DWORD NrOfEntries,ret; 382 char *Names = NULL; 383 POINT *points = NULL; 384 BOOL retval = FALSE; 385 385 386 dn = GlobalLock(pdlga->hDevNames); 386 387 dm = GlobalLock(pdlga->hDevMode); 387 devname = ((char*)dn)+dn->wDeviceOffset;388 portname = ((char*)dn)+dn->wOutputOffset;388 devname = ((char*)dn)+dn->wDeviceOffset; 389 portname = ((char*)dn)+dn->wOutputOffset; 389 390 390 391 391 392 NrOfEntries = DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,NULL,dm); 392 393 if (!NrOfEntries) { 393 FIXME("No papernames found for %s/%s\n",devname,portname);394 goto out;394 FIXME("No papernames found for %s/%s\n",devname,portname); 395 goto out; 395 396 } 396 397 Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64); 397 398 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;399 FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret); 400 goto out; 400 401 } 401 402 for (i=0;i<NrOfEntries;i++) 402 if (!strcmp(PaperSize,Names+(64*i)))403 break;403 if (!strcmp(PaperSize,Names+(64*i))) 404 break; 404 405 HeapFree(GetProcessHeap(),0,Names); 405 406 if (i==NrOfEntries) { 406 FIXME("Papersize %s not found in list?\n",PaperSize);407 goto out;407 FIXME("Papersize %s not found in list?\n",PaperSize); 408 goto out; 408 409 } 409 410 points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries); 410 411 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;412 FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret); 413 goto out; 413 414 } 414 415 /* this is _10ths_ of a millimeter */ … … 434 435 */ 435 436 static BOOL PRINTDLG_SetUpPaperComboBox(HWND hDlg, 436 int nIDComboBox,437 char* PrinterName, 438 char* PortName,439 LPDEVMODEA dm)437 int nIDComboBox, 438 char* PrinterName, 439 char* PortName, 440 LPDEVMODEA dm) 440 441 { 441 442 int i; … … 448 449 int fwCapability_Names; 449 450 int fwCapability_Words; 450 451 451 452 TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox); 452 453 453 454 /* query the dialog box for the current selected value */ 454 455 Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0); … … 498 499 fwCapability_Words = DC_BINS; 499 500 } 500 501 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 501 502 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 502 503 * paper settings. As Wine doesn't allow VXDs, this results in a crash. 503 504 */ … … 511 512 != NrOfEntries) { 512 513 ERR("Number of caps is different\n"); 513 NrOfEntries = 0;514 NrOfEntries = 0; 514 515 } 515 516 … … 519 520 fwCapability_Names, Names, dm); 520 521 NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName, 521 fwCapability_Words, (LPSTR)Words, dm);522 fwCapability_Words, (LPSTR)Words, dm); 522 523 523 524 /* reset any current content in the combobox */ 524 525 SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0); 525 526 526 527 /* store new content */ 527 528 for (i = 0; i < NrOfEntries; i++) { 528 529 DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0, 529 (LPARAM)(&Names[i*NamesSize]) );530 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 531 Words[i]);530 (LPARAM)(&Names[i*NamesSize]) ); 531 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 532 Words[i]); 532 533 } 533 534 … … 537 538 for (i = 0; i < NrOfEntries; i++) { 538 539 if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == 539 oldWord) {540 Sel = i;541 break;542 }540 oldWord) { 541 Sel = i; 542 break; 543 } 543 544 } 544 545 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0); … … 564 565 for (i = 0; i < 25; i++) { 565 566 if (pi->Status & (1<<i)) { 566 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 567 ResourceString, 255);568 strcat(StatusMsg,ResourceString);567 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 568 ResourceString, 255); 569 strcat(StatusMsg,ResourceString); 569 570 } 570 571 } 571 572 /* append "ready" */ 572 /* FIXME: status==ready must only be appended if really so. 573 /* FIXME: status==ready must only be appended if really so. 573 574 but how to detect? */ 574 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 575 ResourceString, 255);575 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 576 ResourceString, 255); 576 577 strcat(StatusMsg,ResourceString); 577 578 578 579 SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg); 579 580 … … 585 586 SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName); 586 587 SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ? 587 pi->pComment : ""));588 pi->pComment : "")); 588 589 return; 589 590 } … … 596 597 */ 597 598 static BOOL PRINTDLG_ChangePrinter(HWND hDlg, char *name, 598 PRINT_PTRA *PrintStructures)599 PRINT_PTRA *PrintStructures) 599 600 { 600 601 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 610 611 if(!OpenPrinterA(name, &hprn, NULL)) { 611 612 ERR("Can't open printer %s\n", name); 612 return FALSE;613 return FALSE; 613 614 } 614 615 GetPrinterA(hprn, 2, NULL, 0, &needed); 615 616 PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed); 616 617 GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed, 617 &needed);618 &needed); 618 619 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); 619 620 PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed); 620 621 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;622 needed, &needed)) { 623 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName); 624 return FALSE; 624 625 } 625 626 ClosePrinter(hprn); … … 629 630 if(PrintStructures->lpDevMode) { 630 631 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 631 PrintStructures->lpDevMode = NULL;632 PrintStructures->lpDevMode = NULL; 632 633 } 633 634 … … 635 636 if(dmSize == -1) { 636 637 ERR("DocumentProperties fails on %s\n", debugstr_a(name)); 637 return FALSE;638 return FALSE; 638 639 } 639 640 PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize); 640 641 dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL, 641 DM_OUT_BUFFER);642 DM_OUT_BUFFER); 642 643 if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) && 643 !strcmp(lpdm->dmDeviceName,644 PrintStructures->lpDevMode->dmDeviceName)) {644 !strcmp(lpdm->dmDeviceName, 645 PrintStructures->lpDevMode->dmDeviceName)) { 645 646 /* Supplied devicemode matches current printer so try to use it */ 646 647 DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm, 647 DM_OUT_BUFFER | DM_IN_BUFFER);648 DM_OUT_BUFFER | DM_IN_BUFFER); 648 649 } 649 650 if(lpdm) … … 655 656 /* Print range (All/Range/Selection) */ 656 657 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 else662 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 else712 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)658 SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE); 659 CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */ 660 if (lppd->Flags & PD_NOSELECTION) 661 EnableWindow(GetDlgItem(hDlg, rad2), FALSE); 662 else 663 if (lppd->Flags & PD_SELECTION) 664 CheckRadioButton(hDlg, rad1, rad3, rad2); 665 if (lppd->Flags & PD_NOPAGENUMS) { 666 EnableWindow(GetDlgItem(hDlg, rad3), FALSE); 667 EnableWindow(GetDlgItem(hDlg, stc2),FALSE); 668 EnableWindow(GetDlgItem(hDlg, edt1), FALSE); 669 EnableWindow(GetDlgItem(hDlg, stc3),FALSE); 670 EnableWindow(GetDlgItem(hDlg, edt2), FALSE); 671 } else { 672 if (lppd->Flags & PD_PAGENUMS) 673 CheckRadioButton(hDlg, rad1, rad3, rad3); 674 } 675 /* "All xxx pages"... */ 676 { 677 char resourcestr[64]; 678 char result[64]; 679 LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 680 resourcestr, 49); 681 sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1); 682 SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result); 683 } 684 685 /* Collate pages 686 * 687 * FIXME: The ico3 is not displayed for some reason. I don't know why. 688 */ 689 if (lppd->Flags & PD_COLLATE) { 690 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 691 (LPARAM)PrintStructures->hCollateIcon); 692 CheckDlgButton(hDlg, chx2, 1); 693 } else { 694 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 695 (LPARAM)PrintStructures->hNoCollateIcon); 696 CheckDlgButton(hDlg, chx2, 0); 697 } 698 699 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 700 /* if printer doesn't support it: no Collate */ 701 if (!(lpdm->dmFields & DM_COLLATE)) { 702 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 703 EnableWindow(GetDlgItem(hDlg, ico3), FALSE); 704 } 705 } 706 707 /* nCopies */ 708 { 709 INT copies; 710 if (lppd->hDevMode == 0) 711 copies = lppd->nCopies; 712 else 713 copies = lpdm->dmCopies; 714 if(copies == 0) copies = 1; 715 else if(copies < 0) copies = MAX_COPIES; 716 SetDlgItemInt(hDlg, edt3, copies, FALSE); 717 } 718 719 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 720 /* if printer doesn't support it: no nCopies */ 721 if (!(lpdm->dmFields & DM_COPIES)) { 722 EnableWindow(GetDlgItem(hDlg, edt3), FALSE); 723 EnableWindow(GetDlgItem(hDlg, stc5), FALSE); 724 } 725 } 726 727 /* print to file */ 728 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0); 729 if (lppd->Flags & PD_DISABLEPRINTTOFILE) 730 EnableWindow(GetDlgItem(hDlg, chx1), FALSE); 731 if (lppd->Flags & PD_HIDEPRINTTOFILE) 731 732 ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE); 732 733 … … 739 740 740 741 PRINTDLG_SetUpPaperComboBox(hDlg, cmb2, 741 PrintStructures->lpPrinterInfo->pPrinterName,742 PrintStructures->lpPrinterInfo->pPortName,743 lpdm);742 PrintStructures->lpPrinterInfo->pPrinterName, 743 PrintStructures->lpPrinterInfo->pPortName, 744 lpdm); 744 745 PRINTDLG_SetUpPaperComboBox(hDlg, cmb3, 745 PrintStructures->lpPrinterInfo->pPrinterName,746 PrintStructures->lpPrinterInfo->pPortName,747 lpdm);746 PrintStructures->lpPrinterInfo->pPrinterName, 747 PrintStructures->lpPrinterInfo->pPortName, 748 lpdm); 748 749 CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2); 749 750 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 750 751 (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon : 751 752 PrintStructures->hLandscapeIcon)); 752 753 753 754 } 754 755 … … 756 757 if ((lppd->Flags & PD_SHOWHELP)==0) { 757 758 /* hide if PD_SHOWHELP not specified */ 758 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 759 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 759 760 } 760 761 return TRUE; … … 765 766 */ 766 767 static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam, 767 PRINT_PTRA* PrintStructures)768 PRINT_PTRA* PrintStructures) 768 769 { 769 770 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 778 779 PrintStructures->hCollateIcon = 779 780 LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0); 780 PrintStructures->hNoCollateIcon = 781 PrintStructures->hNoCollateIcon = 781 782 LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0); 782 783 … … 792 793 PrintStructures->hLandscapeIcon == 0) { 793 794 ERR("no icon in resourcefile\n"); 794 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);795 EndDialog(hDlg, FALSE);795 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 796 EndDialog(hDlg, FALSE); 796 797 } 797 798 … … 801 802 */ 802 803 if (lppd->Flags & PD_SHOWHELP) { 803 if((PrintStructures->HelpMessageID = 804 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {805 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);806 return FALSE;807 }804 if((PrintStructures->HelpMessageID = 805 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 806 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 807 return FALSE; 808 } 808 809 } else 809 810 PrintStructures->HelpMessageID = 0; … … 811 812 if(!(lppd->Flags &PD_PRINTSETUP)) { 812 813 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);814 CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER | 815 UDS_NOTHOUSANDS | UDS_ARROWKEYS | 816 UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0, 817 hDlg, UPDOWN_ID, COMDLG32_hInstance, 818 GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1); 818 819 } 819 820 … … 823 824 */ 824 825 if (lppd->nMaxPage < lppd->nMinPage) 825 lppd->nMaxPage = lppd->nMinPage;826 if (lppd->nMinPage == lppd->nMaxPage) 827 lppd->Flags |= PD_NOPAGENUMS;826 lppd->nMaxPage = lppd->nMinPage; 827 if (lppd->nMinPage == lppd->nMaxPage) 828 lppd->Flags |= PD_NOPAGENUMS; 828 829 if (lppd->nToPage < lppd->nMinPage) 829 830 lppd->nToPage = lppd->nMinPage; … … 837 838 /* if we have the combo box, fill it */ 838 839 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);840 /* Fill Combobox 841 */ 842 pdn = GlobalLock(lppd->hDevNames); 843 pdm = GlobalLock(lppd->hDevMode); 844 if(pdn) 845 name = (char*)pdn + pdn->wDeviceOffset; 846 else if(pdm) 847 name = pdm->dmDeviceName; 848 PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name); 849 if(pdm) GlobalUnlock(lppd->hDevMode); 850 if(pdn) GlobalUnlock(lppd->hDevNames); 851 852 /* Now find selected printer and update rest of dlg */ 853 name = HeapAlloc(GetProcessHeap(),0,256); 854 if (GetDlgItemTextA(hDlg, comboID, name, 255)) 855 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 856 HeapFree(GetProcessHeap(),0,name); 856 857 } 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 else864 FIXME("No default printer found, expect problems!\n");858 /* else use default printer */ 859 char name[200]; 860 BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name)); 861 862 if (ret) 863 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 864 else 865 FIXME("No default printer found, expect problems!\n"); 865 866 } 866 867 return TRUE; … … 872 873 */ 873 874 static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, 874 PRINT_PTRA* PrintStructures)875 PRINT_PTRA* PrintStructures) 875 876 { 876 877 LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16; … … 883 884 PrintStructures->hCollateIcon = 884 885 LoadIconA(COMDLG32_hInstance, "PD32_COLLATE"); 885 PrintStructures->hNoCollateIcon = 886 PrintStructures->hNoCollateIcon = 886 887 LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE"); 887 888 if(PrintStructures->hCollateIcon == 0 || 888 889 PrintStructures->hNoCollateIcon == 0) { 889 890 ERR("no icon in resourcefile\n"); 890 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);891 EndDialog(hDlg, FALSE);891 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 892 EndDialog(hDlg, FALSE); 892 893 } 893 894 … … 900 901 */ 901 902 if (lppd->Flags & PD_SHOWHELP) { 902 if((PrintStructures->HelpMessageID = 903 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {904 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);905 return FALSE;906 }903 if((PrintStructures->HelpMessageID = 904 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 905 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 906 return FALSE; 907 } 907 908 } else 908 909 PrintStructures->HelpMessageID = 0; 909 910 910 911 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 }912 /* We have a print quality combo box. What shall we do? */ 913 if (GetDlgItem(hDlg,cmb1)) { 914 char buf [20]; 915 916 FIXME("Print quality only displaying currently.\n"); 917 918 pdm = GlobalLock16(lppd->hDevMode); 919 if(pdm) { 920 switch (pdm->dmPrintQuality) { 921 case DMRES_HIGH : strcpy(buf,"High");break; 922 case DMRES_MEDIUM : strcpy(buf,"Medium");break; 923 case DMRES_LOW : strcpy(buf,"Low");break; 924 case DMRES_DRAFT : strcpy(buf,"Draft");break; 925 case 0 : strcpy(buf,"Default");break; 926 default : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break; 927 } 928 GlobalUnlock16(lppd->hDevMode); 929 } else 930 strcpy(buf,"Default"); 931 SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf); 932 SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0); 933 EnableWindow(GetDlgItem(hDlg,cmb1),FALSE); 934 } 934 935 } 935 936 … … 939 940 */ 940 941 if (lppd->nMaxPage < lppd->nMinPage) 941 lppd->nMaxPage = lppd->nMinPage;942 if (lppd->nMinPage == lppd->nMaxPage) 943 lppd->Flags |= PD_NOPAGENUMS;942 lppd->nMaxPage = lppd->nMinPage; 943 if (lppd->nMinPage == lppd->nMaxPage) 944 lppd->Flags |= PD_NOPAGENUMS; 944 945 if (lppd->nToPage < lppd->nMinPage) 945 946 lppd->nToPage = lppd->nMinPage; … … 953 954 /* If the printer combo box is in the dialog, fill it */ 954 955 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);956 /* Fill Combobox 957 */ 958 pdn = GlobalLock16(lppd->hDevNames); 959 pdm = GlobalLock16(lppd->hDevMode); 960 if(pdn) 961 name = (char*)pdn + pdn->wDeviceOffset; 962 else if(pdm) 963 name = pdm->dmDeviceName; 964 PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name); 965 if(pdm) GlobalUnlock16(lppd->hDevMode); 966 if(pdn) GlobalUnlock16(lppd->hDevNames); 967 968 /* Now find selected printer and update rest of dlg */ 969 name = HeapAlloc(GetProcessHeap(),0,256); 970 if (GetDlgItemTextA(hDlg, comboID, name, 255)) 971 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 971 972 } 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 else979 FIXME("No default printer found, expect problems!\n");973 /* else just use default printer */ 974 char name[200]; 975 BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name)); 976 977 if (ret) 978 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 979 else 980 FIXME("No default printer found, expect problems!\n"); 980 981 } 981 982 HeapFree(GetProcessHeap(),0,name); … … 988 989 * PRINTDLG_WMCommand [internal] 989 990 */ 990 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 991 LPARAM lParam, PRINT_PTRA* PrintStructures)991 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 992 LPARAM lParam, PRINT_PTRA* PrintStructures) 992 993 { 993 994 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 999 1000 TRACE(" OK button was hit\n"); 1000 1001 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);1002 FIXME("Update printdlg was not successful!\n"); 1003 return(FALSE); 1004 } 1005 EndDialog(hDlg, TRUE); 1006 return(TRUE); 1006 1007 1007 1008 case IDCANCEL: 1008 1009 TRACE(" CANCEL button was hit\n"); 1009 1010 EndDialog(hDlg, FALSE); 1010 return(FALSE);1011 return(FALSE); 1011 1012 1012 1013 case pshHelp: 1013 1014 TRACE(" HELP button was hit\n"); 1014 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 1015 (WPARAM) hDlg, (LPARAM) lppd);1015 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 1016 (WPARAM) hDlg, (LPARAM) lppd); 1016 1017 break; 1017 1018 1018 1019 case chx2: /* collate pages checkbox */ 1019 1020 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 1020 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1021 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1021 1022 (LPARAM)PrintStructures->hCollateIcon); 1022 1023 else 1023 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1024 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1024 1025 (LPARAM)PrintStructures->hNoCollateIcon); 1025 break; 1026 break; 1026 1027 case edt1: /* from page nr editbox */ 1027 1028 case edt2: /* to page nr editbox */ 1028 1029 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);1030 WORD nToPage; 1031 WORD nFromPage; 1032 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE); 1033 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); 1033 1034 if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage) 1034 CheckRadioButton(hDlg, rad1, rad3, rad3);1035 }1035 CheckRadioButton(hDlg, rad1, rad3, rad3); 1036 } 1036 1037 break; 1037 1038 1038 1039 case edt3: 1039 1040 if(HIWORD(wParam) == EN_CHANGE) { 1040 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);1041 if(copies <= 1)1042 EnableWindow(GetDlgItem(hDlg, chx2), FALSE);1043 else1044 EnableWindow(GetDlgItem(hDlg, chx2), TRUE);1045 }1046 break;1041 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 1042 if(copies <= 1) 1043 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 1044 else 1045 EnableWindow(GetDlgItem(hDlg, chx2), TRUE); 1046 } 1047 break; 1047 1048 1048 1049 #ifndef __WIN32OS2__ 1049 1050 case psh1: /* Print Setup */ 1050 {1051 PRINTDLG16pdlg;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;1051 { 1052 PRINTDLG16 pdlg; 1053 1054 if (!PrintStructures->dlg.lpPrintDlg16) { 1055 FIXME("The 32bit print dialog does not have this button!?\n"); 1056 break; 1057 } 1058 1059 memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg)); 1060 pdlg.Flags |= PD_PRINTSETUP; 1061 pdlg.hwndOwner = hDlg; 1062 if (!PrintDlg16(&pdlg)) 1063 break; 1064 } 1065 break; 1065 1066 #endif 1066 1067 … … 1072 1073 GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255); 1073 1074 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);1075 FIXME(" Call to OpenPrinter did not succeed!\n"); 1076 break; 1077 } 1078 DocumentPropertiesA(hDlg, hPrinter, PrinterName, 1079 PrintStructures->lpDevMode, 1080 PrintStructures->lpDevMode, 1081 DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT); 1082 ClosePrinter(hPrinter); 1082 1083 break; 1083 1084 } … … 1095 1096 } 1096 1097 break; 1097 1098 1098 1099 case rad2: /* Paperorientation */ 1099 1100 if (lppd->Flags & PD_PRINTSETUP) … … 1108 1109 } 1109 1110 break; 1110 1111 1111 1112 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 */1113 if (PrinterComboID != wParam) { 1114 FIXME("No handling for print quality combo box yet.\n"); 1115 break; 1116 } 1117 /* FALLTHROUGH */ 1117 1118 case cmb4: /* Printer combobox */ 1118 1119 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;1120 char PrinterName[256]; 1121 GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255); 1122 PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures); 1123 } 1124 break; 1124 1125 1125 1126 case cmb2: /* Papersize */ 1126 1127 { 1127 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);1128 if(Sel != CB_ERR)1128 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0); 1129 if(Sel != CB_ERR) 1129 1130 #ifdef __WIN32OS2__ 1130 lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,1131 lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, 1131 1132 #else 1132 lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,1133 lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, 1133 1134 #endif 1134 CB_GETITEMDATA,1135 Sel, 0);1135 CB_GETITEMDATA, 1136 Sel, 0); 1136 1137 } 1137 1138 break; … … 1139 1140 case cmb3: /* Bin */ 1140 1141 { 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);1142 DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0); 1143 if(Sel != CB_ERR) 1144 lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3, 1145 CB_GETITEMDATA, Sel, 1146 0); 1146 1147 } 1147 break; 1148 break; 1148 1149 } 1149 1150 if(lppd->Flags & PD_PRINTSETUP) { 1150 1151 switch (LOWORD(wParam)) { 1151 case rad1: /* orientation */1152 case rad2:1153 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {1152 case rad1: /* orientation */ 1153 case rad2: 1154 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) { 1154 1155 #ifdef __WIN32OS2__ 1155 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {1156 lpdm->dmOrientation = DMORIENT_PORTRAIT;1156 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) { 1157 lpdm->dmOrientation = DMORIENT_PORTRAIT; 1157 1158 #else 1158 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {1159 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;1159 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) { 1160 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; 1160 1161 #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 {1162 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1163 (WPARAM)IMAGE_ICON, 1164 (LPARAM)PrintStructures->hPortraitIcon); 1165 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, 1166 (WPARAM)IMAGE_ICON, 1167 (LPARAM)PrintStructures->hPortraitIcon); 1168 } 1169 } else { 1169 1170 #ifdef __WIN32OS2__ 1170 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {1171 lpdm->dmOrientation = DMORIENT_LANDSCAPE;1171 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) { 1172 lpdm->dmOrientation = DMORIENT_LANDSCAPE; 1172 1173 #else 1173 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {1174 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;1174 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) { 1175 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; 1175 1176 #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 }1177 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1178 (WPARAM)IMAGE_ICON, 1179 (LPARAM)PrintStructures->hLandscapeIcon); 1180 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, 1181 (WPARAM)IMAGE_ICON, 1182 (LPARAM)PrintStructures->hLandscapeIcon); 1183 } 1184 } 1185 break; 1186 } 1186 1187 } 1187 1188 return FALSE; 1188 } 1189 } 1189 1190 1190 1191 /*********************************************************************** 1191 * PrintDlgProcA [internal]1192 * PrintDlgProcA [internal] 1192 1193 */ 1193 1194 #ifdef __WIN32OS2__ 1194 1195 LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, 1195 LPARAM lParam)1196 LPARAM lParam) 1196 1197 #else 1197 1198 BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, 1198 LPARAM lParam)1199 LPARAM lParam) 1199 1200 #endif 1200 1201 { … … 1203 1204 1204 1205 if (uMsg!=WM_INITDIALOG) { 1205 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 1206 if (!PrintStructures)1207 return FALSE;1206 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 1207 if (!PrintStructures) 1208 return FALSE; 1208 1209 } else { 1209 1210 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.lpPrintDlg1216 ); 1217 return res;1218 } 1219 1211 SetWindowLongA(hDlg, DWL_USER, lParam); 1212 res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures); 1213 1214 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) 1215 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook( 1216 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg 1217 ); 1218 return res; 1219 } 1220 1220 1221 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) { 1221 1222 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, 1222 lParam);1223 if(res) return res;1223 lParam); 1224 if(res) return res; 1224 1225 } 1225 1226 … … 1229 1230 1230 1231 case WM_DESTROY: 1231 DestroyIcon(PrintStructures->hCollateIcon);1232 DestroyIcon(PrintStructures->hNoCollateIcon);1232 DestroyIcon(PrintStructures->hCollateIcon); 1233 DestroyIcon(PrintStructures->hNoCollateIcon); 1233 1234 DestroyIcon(PrintStructures->hPortraitIcon); 1234 1235 DestroyIcon(PrintStructures->hLandscapeIcon); 1235 if(PrintStructures->hwndUpDown)1236 DestroyWindow(PrintStructures->hwndUpDown);1236 if(PrintStructures->hwndUpDown) 1237 DestroyWindow(PrintStructures->hwndUpDown); 1237 1238 return FALSE; 1238 } 1239 } 1239 1240 return res; 1240 1241 } … … 1255 1256 HGLOBAL16 hGlobal16; 1256 1257 LPVOID template; 1257 1258 1258 1259 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 1259 1260 PrintResourceName, RT_DIALOGA))) … … 1300 1301 1301 1302 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); 1308 } else { 1309 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP", 1310 RT_DIALOGA); 1311 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1312 } 1303 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1304 hDlgTmpl = lppd->hSetupTemplate; 1305 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1306 hResInfo = FindResourceA(lppd->hInstance, 1307 lppd->lpSetupTemplateName, RT_DIALOGA); 1308 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1313 1309 } 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 } 1310 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP", 1311 RT_DIALOGA); 1312 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1313 } 1314 } else { 1315 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 1316 hDlgTmpl = lppd->hPrintTemplate; 1317 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 1318 hResInfo = FindResourceA(lppd->hInstance, 1319 lppd->lpPrintTemplateName, 1320 RT_DIALOGA); 1321 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1322 } else { 1323 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32", 1324 RT_DIALOGA); 1325 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1326 } 1326 1327 } 1327 1328 return hDlgTmpl; … … 1340 1341 1341 1342 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); 1348 } else { 1349 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP"); 1350 } 1343 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1344 hDlgTmpl = lppd->hSetupTemplate; 1345 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1346 hResInfo = FindResource16(lppd->hInstance, 1347 MapSL(lppd->lpSetupTemplateName), RT_DIALOGA); 1348 hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo); 1351 1349 } 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 } 1350 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP"); 1351 } 1352 } else { 1353 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 1354 hDlgTmpl = lppd->hPrintTemplate; 1355 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 1356 hResInfo = FindResource16(lppd->hInstance, 1357 MapSL(lppd->lpPrintTemplateName), 1358 RT_DIALOGA); 1359 hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo); 1360 } else { 1361 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32"); 1362 } 1362 1363 } 1363 1364 return hDlgTmpl; … … 1377 1378 if(lppd->Flags & PD_RETURNDC) { 1378 1379 lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset, 1379 (char*)pdn + pdn->wDeviceOffset,1380 (char*)pdn + pdn->wOutputOffset,1381 pdm );1380 (char*)pdn + pdn->wDeviceOffset, 1381 (char*)pdn + pdn->wOutputOffset, 1382 pdm ); 1382 1383 } else if(lppd->Flags & PD_RETURNIC) { 1383 1384 lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset, 1384 (char*)pdn + pdn->wDeviceOffset,1385 (char*)pdn + pdn->wOutputOffset,1386 pdm );1385 (char*)pdn + pdn->wDeviceOffset, 1386 (char*)pdn + pdn->wOutputOffset, 1387 pdm ); 1387 1388 } 1388 1389 GlobalUnlock(lppd->hDevNames); … … 1399 1400 if(lppd->Flags & PD_RETURNDC) { 1400 1401 lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset, 1401 (char*)pdn + pdn->wDeviceOffset,1402 (char*)pdn + pdn->wOutputOffset,1403 pdm );1402 (char*)pdn + pdn->wDeviceOffset, 1403 (char*)pdn + pdn->wOutputOffset, 1404 pdm ); 1404 1405 } else if(lppd->Flags & PD_RETURNIC) { 1405 1406 lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset, 1406 (char*)pdn + pdn->wDeviceOffset,1407 (char*)pdn + pdn->wOutputOffset,1408 pdm );1407 (char*)pdn + pdn->wDeviceOffset, 1408 (char*)pdn + pdn->wOutputOffset, 1409 pdm ); 1409 1410 } 1410 1411 GlobalUnlock16(lppd->hDevNames); … … 1431 1432 * * The Paper Orientation Icons are not implemented yet. 1432 1433 * * The Properties Button(s) should call DocumentPropertiesA(). 1433 * * Settings are not yet taken from a provided DevMode or 1434 * * Settings are not yet taken from a provided DevMode or 1434 1435 * default printer settings. 1435 1436 */ 1436 1437 BOOL WINAPI PrintDlgA( 1437 LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */1438 )1438 LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */ 1439 ) 1439 1440 { 1440 1441 BOOL bRet = FALSE; … … 1448 1449 if(TRACE_ON(commdlg)) { 1449 1450 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);1451 struct pd_flags *pflag = pd_flags; 1452 for( ; pflag->name; pflag++) { 1453 if(lppd->Flags & pflag->flag) 1454 strcat(flagstr, pflag->name); 1455 } 1456 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 1457 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n" 1458 "flags %08lx (%s)\n", 1459 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames, 1460 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage, 1461 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr); 1461 1462 } 1462 1463 1463 1464 if(lppd->lStructSize != sizeof(PRINTDLGA)) { 1464 1465 WARN("structure size failure !!!\n"); 1465 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);1466 return FALSE; 1466 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 1467 return FALSE; 1467 1468 } 1468 1469 1469 1470 if(lppd->Flags & PD_RETURNDEFAULT) { 1470 1471 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 }1472 DRIVER_INFO_3A *dbuf; 1473 HANDLE hprn; 1474 DWORD needed; 1475 1476 if(lppd->hDevMode || lppd->hDevNames) { 1477 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 1478 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1479 return FALSE; 1480 } 1480 1481 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;1482 WARN("Can't find default printer\n"); 1483 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1484 return FALSE; 1485 } 1486 1487 GetPrinterA(hprn, 2, NULL, 0, &needed); 1488 pbuf = HeapAlloc(GetProcessHeap(), 0, needed); 1489 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed); 1490 1491 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); 1492 dbuf = HeapAlloc(GetProcessHeap(),0,needed); 1493 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) { 1494 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName); 1495 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1496 return FALSE; 1497 } 1498 ClosePrinter(hprn); 1499 1500 PRINTDLG_CreateDevNames(&(lppd->hDevNames), 1501 dbuf->pDriverPath, 1502 pbuf->pPrinterName, 1503 pbuf->pPortName); 1504 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize + 1505 pbuf->pDevMode->dmDriverExtra); 1506 ptr = GlobalLock(lppd->hDevMode); 1507 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize + 1508 pbuf->pDevMode->dmDriverExtra); 1509 GlobalUnlock(lppd->hDevMode); 1510 HeapFree(GetProcessHeap(), 0, pbuf); 1511 HeapFree(GetProcessHeap(), 0, dbuf); 1512 bRet = TRUE; 1512 1513 } else { 1513 HGLOBAL hDlgTmpl;1514 PRINT_PTRA *PrintStructures;1515 1516 /* load Dialog resources, 1517 * depending on Flags indicates Print32 or Print32_setup dialog 1514 HGLOBAL hDlgTmpl; 1515 PRINT_PTRA *PrintStructures; 1516 1517 /* load Dialog resources, 1518 * depending on Flags indicates Print32 or Print32_setup dialog 1518 1519 */ 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 }1520 hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd); 1521 if (!hDlgTmpl) { 1522 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1523 return FALSE; 1524 } 1525 ptr = LockResource( hDlgTmpl ); 1526 if (!ptr) { 1527 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1528 return FALSE; 1529 } 1529 1530 1530 1531 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->pPortName1578 );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);1532 sizeof(PRINT_PTRA)); 1533 PrintStructures->dlg.lpPrintDlg = lppd; 1534 1535 /* and create & process the dialog . 1536 * -1 is failure, 0 is broken hwnd, everything else is ok. 1537 */ 1538 bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner, 1539 PrintDlgProcA, 1540 (LPARAM)PrintStructures)); 1541 1542 if(bRet) { 1543 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn; 1544 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo; 1545 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo; 1546 1547 if (lppd->hDevMode == 0) { 1548 TRACE(" No hDevMode yet... Need to create my own\n"); 1549 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, 1550 lpdm->dmSize + lpdm->dmDriverExtra); 1551 } else { 1552 WORD locks; 1553 if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) { 1554 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks); 1555 while(locks--) { 1556 GlobalUnlock(lppd->hDevMode); 1557 TRACE("Now got %d locks\n", locks); 1558 } 1559 } 1560 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode, 1561 lpdm->dmSize + lpdm->dmDriverExtra, 1562 GMEM_MOVEABLE); 1563 } 1564 lpdmReturn = GlobalLock(lppd->hDevMode); 1565 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra); 1566 1567 if (lppd->hDevNames != 0) { 1568 WORD locks; 1569 if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) { 1570 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks); 1571 while(locks--) 1572 GlobalUnlock(lppd->hDevNames); 1573 } 1574 } 1575 PRINTDLG_CreateDevNames(&(lppd->hDevNames), 1576 di->pDriverPath, 1577 pi->pPrinterName, 1578 pi->pPortName 1579 ); 1580 GlobalUnlock(lppd->hDevMode); 1581 } 1582 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 1583 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo); 1584 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo); 1585 HeapFree(GetProcessHeap(), 0, PrintStructures); 1585 1586 } 1586 1587 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC)) 1587 1588 bRet = PRINTDLG_CreateDC(lppd); 1588 1589 1589 TRACE("exit! (%d)\n", bRet); 1590 return bRet; 1590 TRACE("exit! (%d)\n", bRet); 1591 return bRet; 1591 1592 } 1592 1593 … … 1594 1595 /*********************************************************************** 1595 1596 * PrintDlg (COMMDLG.20) 1596 * 1597 * 1597 1598 * Displays the the PRINT dialog box, which enables the user to specify 1598 1599 * specific properties of the print job. … … 1608 1609 1609 1610 BOOL16 WINAPI PrintDlg16( 1610 LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */1611 LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */ 1611 1612 ) { 1612 1613 BOOL bRet = FALSE; … … 1616 1617 if(TRACE_ON(commdlg)) { 1617 1618 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);1619 struct pd_flags *pflag = pd_flags; 1620 for( ; pflag->name; pflag++) { 1621 if(lppd->Flags & pflag->flag) 1622 strcat(flagstr, pflag->name); 1623 } 1624 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 1625 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n" 1626 "flags %08lx (%s)\n", 1627 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames, 1628 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage, 1629 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr); 1629 1630 } 1630 1631 1631 1632 if(lppd->lStructSize != sizeof(PRINTDLG16)) { 1632 1633 ERR("structure size (%ld/%d)\n",lppd->lStructSize,sizeof(PRINTDLG16)); 1633 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);1634 return FALSE;1634 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 1635 return FALSE; 1635 1636 } 1636 1637 1637 1638 if(lppd->Flags & PD_RETURNDEFAULT) { 1638 1639 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 }1640 DRIVER_INFO_3A *dbuf; 1641 HANDLE hprn; 1642 DWORD needed; 1643 1644 if(lppd->hDevMode || lppd->hDevNames) { 1645 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 1646 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1647 return FALSE; 1648 } 1648 1649 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;1650 WARN("Can't find default printer\n"); 1651 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1652 return FALSE; 1653 } 1654 1655 GetPrinterA(hprn, 2, NULL, 0, &needed); 1656 pbuf = HeapAlloc(GetProcessHeap(), 0, needed); 1657 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed); 1658 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); 1659 dbuf = HeapAlloc(GetProcessHeap(),0,needed); 1660 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) { 1661 ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n", 1662 pbuf->pPrinterName,GetLastError()); 1663 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1664 return FALSE; 1665 } 1666 ClosePrinter(hprn); 1667 PRINTDLG_CreateDevNames16(&(lppd->hDevNames), 1668 dbuf->pDriverPath, 1669 pbuf->pPrinterName, 1670 pbuf->pPortName); 1671 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+ 1672 pbuf->pDevMode->dmDriverExtra); 1673 ptr = GlobalLock16(lppd->hDevMode); 1674 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize + 1675 pbuf->pDevMode->dmDriverExtra); 1676 GlobalUnlock16(lppd->hDevMode); 1677 HeapFree(GetProcessHeap(), 0, pbuf); 1678 HeapFree(GetProcessHeap(), 0, dbuf); 1679 bRet = TRUE; 1679 1680 } else { 1680 HGLOBAL hDlgTmpl;1681 PRINT_PTRA *PrintStructures;1682 1683 /* load Dialog resources, 1684 * depending on Flags indicates Print32 or Print32_setup dialog 1681 HGLOBAL hDlgTmpl; 1682 PRINT_PTRA *PrintStructures; 1683 1684 /* load Dialog resources, 1685 * depending on Flags indicates Print32 or Print32_setup dialog 1685 1686 */ 1686 hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd);1687 if (!hDlgTmpl) {1688 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);1689 return FALSE;1690 }1687 hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd); 1688 if (!hDlgTmpl) { 1689 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1690 return FALSE; 1691 } 1691 1692 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 */1693 sizeof(PRINT_PTRA)); 1694 PrintStructures->dlg.lpPrintDlg16 = lppd; 1695 PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA)); 1696 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x; 1697 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x); 1698 CVAL(Flags);CVAL(hwndOwner);CVAL(hDC); 1699 CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage); 1700 CVAL(nCopies);CVAL(hInstance);CVAL(lCustData); 1701 MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName); 1702 /* Don't copy rest, it is 16 bit specific */ 1702 1703 #undef MVAL 1703 1704 #undef CVAL 1704 1705 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)PrintStructures1714 )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->pPortName1754 );1755 GlobalUnlock16(lppd->hDevMode);1756 }1757 if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))1706 PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA)); 1707 1708 /* and create & process the dialog . 1709 * -1 is failure, 0 is broken hwnd, everything else is ok. 1710 */ 1711 bRet = (0<DialogBoxIndirectParam16( 1712 hInst, hDlgTmpl, lppd->hwndOwner, 1713 (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21), 1714 (LPARAM)PrintStructures 1715 ) 1716 ); 1717 if (!PrintStructures->lpPrinterInfo) bRet = FALSE; 1718 if(bRet) { 1719 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn; 1720 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo; 1721 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo; 1722 1723 if (lppd->hDevMode == 0) { 1724 TRACE(" No hDevMode yet... Need to create my own\n"); 1725 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE, 1726 lpdm->dmSize + lpdm->dmDriverExtra); 1727 } else { 1728 WORD locks; 1729 if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) { 1730 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks); 1731 while(locks--) { 1732 GlobalUnlock16(lppd->hDevMode); 1733 TRACE("Now got %d locks\n", locks); 1734 } 1735 } 1736 lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode, 1737 lpdm->dmSize + lpdm->dmDriverExtra, 1738 GMEM_MOVEABLE); 1739 } 1740 lpdmReturn = GlobalLock16(lppd->hDevMode); 1741 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra); 1742 1743 if (lppd->hDevNames != 0) { 1744 WORD locks; 1745 if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) { 1746 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks); 1747 while(locks--) 1748 GlobalUnlock16(lppd->hDevNames); 1749 } 1750 } 1751 PRINTDLG_CreateDevNames16(&(lppd->hDevNames), 1752 di->pDriverPath, 1753 pi->pPrinterName, 1754 pi->pPortName 1755 ); 1756 GlobalUnlock16(lppd->hDevMode); 1757 } 1758 if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE))) 1758 1759 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);1760 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 1761 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo); 1762 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo); 1763 HeapFree(GetProcessHeap(), 0, PrintStructures); 1763 1764 } 1764 1765 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC)) 1765 1766 bRet = PRINTDLG_CreateDC16(lppd); 1766 1767 1767 TRACE("exit! (%d)\n", bRet); 1768 return bRet; 1768 TRACE("exit! (%d)\n", bRet); 1769 return bRet; 1769 1770 } 1770 1771 #endif … … 1798 1799 1799 1800 typedef struct { 1800 LPPAGESETUPDLGA dlga;1801 1802 PRINTDLGA pdlg;1801 LPPAGESETUPDLGA dlga; 1802 1803 PRINTDLGA pdlg; 1803 1804 } PageSetupData; 1804 1805 … … 1808 1809 1809 1810 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);1811 hDlgTmpl = lppd->hPageSetupTemplate; 1812 } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { 1813 hResInfo = FindResourceA(lppd->hInstance, 1814 lppd->lpPageSetupTemplateName, RT_DIALOGA); 1815 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1815 1816 } else { 1816 hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA);1817 hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo);1817 hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA); 1818 hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo); 1818 1819 } 1819 1820 return hDlgTmpl; … … 1823 1824 _c_10mm2size(PAGESETUPDLGA *dlga,DWORD size) { 1824 1825 if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1825 return 10*size*10/25.4;1826 return 10*size*10/25.4; 1826 1827 /* If we don't have a flag, we can choose one. Use millimeters 1827 1828 * to avoid confusing me … … 1836 1837 _c_inch2size(PAGESETUPDLGA *dlga,DWORD size) { 1837 1838 if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1838 return size;1839 return size; 1839 1840 if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) 1840 return (size*254)/10;1841 return (size*254)/10; 1841 1842 /* if we don't have a flag, we can choose one. Use millimeters 1842 1843 * to avoid confusing me … … 1850 1851 strcpy(strout,"<undef>"); 1851 1852 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { 1852 sprintf(strout,"%.2fmm",(size*1.0)/100.0);1853 return;1853 sprintf(strout,"%.2fmm",(size*1.0)/100.0); 1854 return; 1854 1855 } 1855 1856 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { 1856 sprintf(strout,"%.2fin",(size*1.0)/1000.0);1857 return;1857 sprintf(strout,"%.2fin",(size*1.0)/1000.0); 1858 return; 1858 1859 } 1859 1860 pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; … … 1864 1865 static DWORD 1865 1866 _c_str2size(PageSetupData *pda,LPCSTR strin) { 1866 float val;1867 char rest[200];1867 float val; 1868 char rest[200]; 1868 1869 1869 1870 rest[0]='\0'; 1870 1871 if (!sscanf(strin,"%f%s",&val,rest)) 1871 return 0;1872 return 0; 1872 1873 1873 1874 if (!strcmp(rest,"in") || !strcmp(rest,"inch")) { 1874 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)1875 return 1000*val;1876 else1877 return val*25.4*100;1875 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1876 return 1000*val; 1877 else 1878 return val*25.4*100; 1878 1879 } 1879 1880 if (!strcmp(rest,"cm")) { rest[0]='m'; val = val*10.0; } … … 1881 1882 1882 1883 if (!strcmp(rest,"mm")) { 1883 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)1884 return 100*val;1885 else1886 return 1000.0*val/25.4;1884 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) 1885 return 100*val; 1886 else 1887 return 1000.0*val/25.4; 1887 1888 } 1888 1889 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 }1890 /* use application supplied default */ 1891 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { 1892 /* 100*mm */ 1893 return 100.0*val; 1894 } 1895 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { 1896 /* 1000*inch */ 1897 return 1000.0*val; 1898 } 1898 1899 } 1899 1900 ERR("Did not find a conversion for type '%s'!\n",rest); … … 1908 1909 static BOOL 1909 1910 PRINTDLG_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 1911 DEVNAMES *dn; 1912 DEVMODEA *dm; 1913 LPSTR devname,portname; 1914 char papername[64]; 1915 char buf[200]; 1916 1916 1917 dn = GlobalLock(pda->pdlg.hDevNames); 1917 1918 dm = GlobalLock(pda->pdlg.hDevMode); 1918 devname = ((char*)dn)+dn->wDeviceOffset;1919 portname = ((char*)dn)+dn->wOutputOffset;1919 devname = ((char*)dn)+dn->wDeviceOffset; 1920 portname = ((char*)dn)+dn->wOutputOffset; 1920 1921 PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm); 1921 1922 PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm); 1922 1923 1923 1924 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);1925 PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize)); 1926 pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x); 1927 pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y); 1927 1928 } else 1928 FIXME("could not get dialog text for papersize cmbbox?\n");1929 FIXME("could not get dialog text for papersize cmbbox?\n"); 1929 1930 #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); } 1930 1931 GETVAL(edt4,pda->dlga->rtMargin.left); … … 1936 1937 /* If we are in landscape, swap x and y of page size */ 1937 1938 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;1939 DWORD tmp; 1940 tmp = pda->dlga->ptPaperSize.x; 1941 pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y; 1942 pda->dlga->ptPaperSize.y = tmp; 1942 1943 } 1943 1944 GlobalUnlock(pda->pdlg.hDevNames); … … 1951 1952 static BOOL 1952 1953 PRINTDLG_PS_ChangePrinter(HWND hDlg, PageSetupData *pda) { 1953 DEVNAMES *dn;1954 DEVMODEA *dm;1955 LPSTR devname,portname;1956 1954 DEVNAMES *dn; 1955 DEVMODEA *dm; 1956 LPSTR devname,portname; 1957 1957 1958 dn = GlobalLock(pda->pdlg.hDevNames); 1958 1959 dm = GlobalLock(pda->pdlg.hDevMode); 1959 devname = ((char*)dn)+dn->wDeviceOffset;1960 portname = ((char*)dn)+dn->wOutputOffset;1960 devname = ((char*)dn)+dn->wDeviceOffset; 1961 portname = ((char*)dn)+dn->wOutputOffset; 1961 1962 PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm); 1962 1963 PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm); … … 1973 1974 case IDOK: 1974 1975 if (!PRINTDLG_PS_UpdateDlgStruct(hDlg, pda)) 1975 return(FALSE);1976 EndDialog(hDlg, TRUE);1977 return TRUE ;1976 return(FALSE); 1977 EndDialog(hDlg, TRUE); 1978 return TRUE ; 1978 1979 1979 1980 case IDCANCEL: 1980 1981 EndDialog(hDlg, FALSE); 1981 return FALSE ;1982 return FALSE ; 1982 1983 1983 1984 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;1985 pda->pdlg.Flags = 0; 1986 pda->pdlg.hwndOwner = hDlg; 1987 if (PrintDlgA(&(pda->pdlg))) 1988 PRINTDLG_PS_ChangePrinter(hDlg,pda); 1989 return TRUE; 1989 1990 } 1990 1991 } 1991 1992 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n", 1992 LOWORD(lParam),wParam,lParam1993 LOWORD(lParam),wParam,lParam 1993 1994 ); 1994 1995 return FALSE; … … 1999 2000 PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 2000 2001 { 2001 PageSetupData *pda;2002 BOOL res = FALSE;2002 PageSetupData *pda; 2003 BOOL res = FALSE; 2003 2004 2004 2005 if (uMsg==WM_INITDIALOG) { 2005 res = TRUE;2006 res = TRUE; 2006 2007 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)2008 SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam); 2009 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 2010 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 2011 if (!res) { 2012 FIXME("Setup page hook failed?\n"); 2013 res = TRUE; 2014 } 2015 } 2016 if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) { 2017 FIXME("PagePaintHook not yet implemented!\n"); 2018 } 2019 if (pda->dlga->Flags & PSD_DISABLEPRINTER) 2020 EnableWindow(GetDlgItem(hDlg, psh3), FALSE); 2021 if (pda->dlga->Flags & PSD_DISABLEMARGINS) { 2022 EnableWindow(GetDlgItem(hDlg, edt4), FALSE); 2023 EnableWindow(GetDlgItem(hDlg, edt5), FALSE); 2024 EnableWindow(GetDlgItem(hDlg, edt6), FALSE); 2025 EnableWindow(GetDlgItem(hDlg, edt7), FALSE); 2026 } 2027 /* width larger as height -> landscape */ 2028 if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y) 2028 2029 CheckRadioButton(hDlg, rad1, rad2, rad2); 2029 else /* this is default if papersize is not set */2030 else /* this is default if papersize is not set */ 2030 2031 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); 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; 2032 if (pda->dlga->Flags & PSD_DISABLEORIENTATION) { 2033 EnableWindow(GetDlgItem(hDlg,rad1),FALSE); 2034 EnableWindow(GetDlgItem(hDlg,rad2),FALSE); 2035 } 2036 /* We fill them out enabled or not */ 2037 if (pda->dlga->Flags & PSD_MARGINS) { 2038 char str[100]; 2039 _c_size2str(pda,pda->dlga->rtMargin.left,str); 2040 SetDlgItemTextA(hDlg,edt4,str); 2041 _c_size2str(pda,pda->dlga->rtMargin.top,str); 2042 SetDlgItemTextA(hDlg,edt5,str); 2043 _c_size2str(pda,pda->dlga->rtMargin.right,str); 2044 SetDlgItemTextA(hDlg,edt6,str); 2045 _c_size2str(pda,pda->dlga->rtMargin.bottom,str); 2046 SetDlgItemTextA(hDlg,edt7,str); 2062 2047 } 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 } 2048 /* default is 1 inch */ 2049 DWORD size = _c_inch2size(pda->dlga,1000); 2050 char str[20]; 2051 _c_size2str(pda,size,str); 2052 SetDlgItemTextA(hDlg,edt4,str); 2053 SetDlgItemTextA(hDlg,edt5,str); 2054 SetDlgItemTextA(hDlg,edt6,str); 2055 SetDlgItemTextA(hDlg,edt7,str); 2056 } 2057 PRINTDLG_PS_ChangePrinter(hDlg,pda); 2058 if (pda->dlga->Flags & PSD_DISABLEPAPER) { 2059 EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); 2060 EnableWindow(GetDlgItem(hDlg,cmb3),FALSE); 2061 } 2062 return TRUE; 2063 } else { 2064 pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA"); 2065 if (!pda) { 2066 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n"); 2067 return FALSE; 2068 } 2069 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 2070 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 2071 if (res) return res; 2072 } 2072 2073 } 2073 2074 switch (uMsg) { … … 2082 2083 */ 2083 2084 BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) { 2084 HGLOBAL hDlgTmpl;2085 LPVOID ptr;2086 BOOL bRet;2087 PageSetupData *pda;2088 PRINTDLGA pdlg;2085 HGLOBAL hDlgTmpl; 2086 LPVOID ptr; 2087 BOOL bRet; 2088 PageSetupData *pda; 2089 PRINTDLGA pdlg; 2089 2090 2090 2091 #ifdef __WIN32OS2__ … … 2094 2095 if(TRACE_ON(commdlg)) { 2095 2096 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);2097 struct pd_flags *pflag = psd_flags; 2098 for( ; pflag->name; pflag++) { 2099 if(setupdlg->Flags & pflag->flag) { 2100 strcat(flagstr, pflag->name); 2101 strcat(flagstr, "|"); 2102 } 2103 } 2104 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 2105 "hinst %08x, flags %08lx (%s)\n", 2106 setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode, 2107 setupdlg->hDevNames, 2108 setupdlg->hInstance, setupdlg->Flags, flagstr); 2108 2109 } 2109 2110 2110 2111 /* First get default printer data, we need it right after that. */ 2111 2112 memset(&pdlg,0,sizeof(pdlg)); 2112 pdlg.lStructSize = sizeof(pdlg);2113 pdlg.Flags = PD_RETURNDEFAULT;2113 pdlg.lStructSize = sizeof(pdlg); 2114 pdlg.Flags = PD_RETURNDEFAULT; 2114 2115 bRet = PrintDlgA(&pdlg); 2115 2116 if (!bRet) return FALSE; … … 2117 2118 /* short cut exit, just return default values */ 2118 2119 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;2120 setupdlg->hDevMode = pdlg.hDevMode; 2121 setupdlg->hDevNames = pdlg.hDevNames; 2122 /* FIXME: Just return "A4" for now. */ 2123 PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize); 2124 setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x); 2125 setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y); 2126 return TRUE; 2126 2127 } 2127 2128 hDlgTmpl = PRINTDLG_GetPGSTemplate(setupdlg); 2128 2129 if (!hDlgTmpl) { 2129 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);2130 return FALSE;2130 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2131 return FALSE; 2131 2132 } 2132 2133 ptr = LockResource( hDlgTmpl ); 2133 2134 if (!ptr) { 2134 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);2135 return FALSE;2135 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2136 return FALSE; 2136 2137 } 2137 2138 pda = HeapAlloc(GetProcessHeap(),0,sizeof(*pda)); … … 2140 2141 2141 2142 bRet = (0<DialogBoxIndirectParamA( 2142 setupdlg->hInstance,2143 ptr,2144 setupdlg->hwndOwner,2145 PageDlgProcA,2146 (LPARAM)pda)2143 setupdlg->hInstance, 2144 ptr, 2145 setupdlg->hwndOwner, 2146 PageDlgProcA, 2147 (LPARAM)pda) 2147 2148 ); 2148 2149 return bRet; … … 2155 2156 dprintf(("PageSetupDlgA %x NOT IMPLEMENTED", setupdlg)); 2156 2157 #endif 2157 FIXME("(%p), stub!\n",setupdlg);2158 return FALSE;2158 FIXME("(%p), stub!\n",setupdlg); 2159 return FALSE; 2159 2160 } 2160 2161 … … 2175 2176 2176 2177 if (uMsg!=WM_INITDIALOG) { 2177 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 2178 if (!PrintStructures)2179 return FALSE;2178 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 2179 if (!PrintStructures) 2180 return FALSE; 2180 2181 } else { 2181 2182 PrintStructures = (PRINT_PTRA*) lParam; 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 2183 SetWindowLongA(hDlg, DWL_USER, lParam); 2184 res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures); 2185 2194 2186 if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { 2195 2187 res = CallWindowProc16( 2196 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2197 hDlg,uMsg, wParam, lParam 2198 ); 2199 if(LOWORD(res)) return res; 2188 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2189 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16 2190 ); 2191 } 2192 return res; 2193 } 2194 2195 if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { 2196 res = CallWindowProc16( 2197 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2198 hDlg,uMsg, wParam, lParam 2199 ); 2200 if(LOWORD(res)) return res; 2200 2201 } 2201 2202 2202 2203 switch (uMsg) { 2203 2204 case WM_COMMAND: { 2204 /* We need to map those for the 32bit window procedure, compare2205 * with 32Ato16 mapper in winproc.c2206 */2205 /* We need to map those for the 32bit window procedure, compare 2206 * with 32Ato16 mapper in winproc.c 2207 */ 2207 2208 return PRINTDLG_WMCommand( 2208 hDlg,2209 MAKEWPARAM(wParam,HIWORD(lParam)),2210 LOWORD(lParam),2211 PrintStructures2212 );2209 hDlg, 2210 MAKEWPARAM(wParam,HIWORD(lParam)), 2211 LOWORD(lParam), 2212 PrintStructures 2213 ); 2213 2214 } 2214 2215 case WM_DESTROY: 2215 DestroyIcon(PrintStructures->hCollateIcon);2216 DestroyIcon(PrintStructures->hNoCollateIcon);2216 DestroyIcon(PrintStructures->hCollateIcon); 2217 DestroyIcon(PrintStructures->hNoCollateIcon); 2217 2218 /* FIXME: don't forget to delete the paper orientation icons here! */ 2218 2219 2219 2220 return FALSE; 2220 } 2221 } 2221 2222 return res; 2222 2223 } … … 2227 2228 */ 2228 2229 LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 2229 LPARAM lParam)2230 LPARAM lParam) 2230 2231 { 2231 2232 switch (wMsg) … … 2238 2239 switch (wParam) { 2239 2240 case IDOK: 2240 EndDialog(hWnd, TRUE);2241 return(TRUE);2241 EndDialog(hWnd, TRUE); 2242 return(TRUE); 2242 2243 case IDCANCEL: 2243 EndDialog(hWnd, FALSE);2244 return(TRUE);2244 EndDialog(hWnd, FALSE); 2245 return(TRUE); 2245 2246 } 2246 2247 return(FALSE); … … 2251 2252 2252 2253 /*********************************************************************** 2253 * PrintDlgExA (COMDLG32.@)2254 * PrintDlgExA (COMDLG32.@) 2254 2255 */ 2255 2256 HRESULT WINAPI PrintDlgExA(LPVOID lpPrintDlgExA) /* [???] FIXME: LPPRINTDLGEXA */ 2256 2257 { 2257 FIXME("stub\n");2258 return E_NOTIMPL;2258 FIXME("stub\n"); 2259 return E_NOTIMPL; 2259 2260 } 2260 2261 /*********************************************************************** 2261 * PrintDlgExW (COMDLG32.@)2262 * PrintDlgExW (COMDLG32.@) 2262 2263 */ 2263 2264 HRESULT WINAPI PrintDlgExW(LPVOID lpPrintDlgExW) /* [???] FIXME: LPPRINTDLGEXW */ 2264 2265 { 2265 FIXME("stub\n");2266 return E_NOTIMPL;2267 } 2266 FIXME("stub\n"); 2267 return E_NOTIMPL; 2268 } -
trunk/src/crtdll/crtdll.cpp
r5472 r6645 1 /* $Id: crtdll.cpp,v 1.30 2001-09-05 12:14:23 bird Exp $ */ 1 2 /* 2 3 * The C RunTime DLL 3 * 4 * 4 5 * Implements C run-time functionality as known from UNIX. 5 6 * 6 * TODO: 7 * TODO: 7 8 * - Check setjmp(3) 8 9 * - fix *ALL* functions for the FS: wrapper problem … … 72 73 // Definitions for internal functions 73 74 // 74 void qsort1 (char*, char*, size_t,75 void qsort1 (char*, char*, size_t, 75 76 int (* CDECL)(const void*, const void*)); 76 77 … … 444 445 445 446 /********************************************************************* 446 * _cscanf(CRTDLL.67)447 * _cscanf (CRTDLL.67) 447 448 */ 448 449 INT CDECL CRTDLL__cscanf( char *s, va_list arg ) … … 604 605 605 606 /********************************************************************* 606 * _ftime(CRTDLL.112)607 * _ftime (CRTDLL.112) 607 608 */ 608 609 void CDECL CRTDLL__ftime( struct timeb *timebuf ) … … 618 619 LONG CDECL CRTDLL__ftol(void) 619 620 { 620 /* don't just do DO_FPU("fistp",retval), because the rounding621 * mode must also be set to "round towards zero"... */622 double fl;623 POP_FPU(fl);624 return (LONG)fl;621 /* don't just do DO_FPU("fistp",retval), because the rounding 622 * mode must also be set to "round towards zero"... */ 623 double fl; 624 POP_FPU(fl); 625 return (LONG)fl; 625 626 } 626 627 … … 775 776 776 777 /********************************************************************* 777 * _ltoa (CRTDLL.179)778 * _ltoa (CRTDLL.179) 778 779 */ 779 780 LPSTR CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix) … … 784 785 785 786 /********************************************************************* 786 * _matherr (CRTDLL.181)787 * _matherr (CRTDLL.181) 787 788 */ 788 789 double CDECL CRTDLL__matherr( struct exception * excep ) … … 881 882 882 883 /********************************************************************* 883 * CRTDLL__searchenv (CRTDLL.260)884 * CRTDLL__searchenv (CRTDLL.260) 884 885 */ 885 886 void CDECL CRTDLL__searchenv(char *file, char *var,char *path ) … … 891 892 892 893 /********************************************************************* 893 * CRTDLL__seterrormode (CRTDLL.261)894 * CRTDLL__seterrormode (CRTDLL.261) 894 895 */ 895 896 void CDECL CRTDLL__seterrormode(int uMode) … … 902 903 903 904 /********************************************************************* 904 * CRTDLL__setjmp (CRTDLL.262)905 * CRTDLL__setjmp (CRTDLL.262) 905 906 */ 906 907 int CDECL CRTDLL__setjmp( jmp_buf env ) … … 937 938 938 939 /********************************************************************* 939 * _sopen(CRTDLL.268)940 * _sopen (CRTDLL.268) 940 941 */ 941 942 int CDECL CRTDLL__sopen( const char *s, int i1, int i2, va_list arg ) … … 947 948 948 949 /********************************************************************* 949 * CRTDLL__spawnl (CRTDLL.269)950 * CRTDLL__spawnl (CRTDLL.269) 950 951 */ 951 952 int CDECL CRTDLL__spawnl(int nMode, char* szPath, char* szArgv0, va_list arg) … … 957 958 958 959 /********************************************************************* 959 * CRTDLL__spawnle (CRTDLL.270)960 * CRTDLL__spawnle (CRTDLL.270) 960 961 */ 961 962 int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, va_list arg ) … … 967 968 968 969 /********************************************************************* 969 * CRTDLL__spawnlp (CRTDLL.271)970 * CRTDLL__spawnlp (CRTDLL.271) 970 971 */ 971 972 int CDECL CRTDLL__spawnlp(int nMode, char* szPath, char* szArgv0, va_list arg) … … 977 978 978 979 /********************************************************************* 979 * CRTDLL__spawnlpe (CRTDLL.272)980 * CRTDLL__spawnlpe (CRTDLL.272) 980 981 */ 981 982 int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, va_list arg ) … … 987 988 988 989 /********************************************************************* 989 * CRTDLL__spawnv (CRTDLL.273)990 * CRTDLL__spawnv (CRTDLL.273) 990 991 */ 991 992 int CDECL CRTDLL__spawnv( int i, char *s1, char ** s2 ) … … 997 998 998 999 /********************************************************************* 999 * CRTDLL__spawnvp (CRTDLL.275)1000 * CRTDLL__spawnvp (CRTDLL.275) 1000 1001 */ 1001 1002 int CDECL CRTDLL__spawnvp( int i, char *s1, char ** s2 ) … … 1006 1007 1007 1008 /********************************************************************* 1008 * CRTDLL__spawnv (CRTDLL.276)1009 * CRTDLL__spawnv (CRTDLL.276) 1009 1010 */ 1010 1011 int CDECL CRTDLL__spawnvpe( int i, char *s1, char ** s2, char ** s3 ) … … 1016 1017 1017 1018 /********************************************************************* 1018 * CRTDLL__statusfp (CRTDLL.279)1019 * CRTDLL__statusfp (CRTDLL.279) 1019 1020 */ 1020 1021 unsigned int CDECL CRTDLL__statusfp( void ) … … 1023 1024 return (_status87()); 1024 1025 } 1025 1026 1027 /********************************************************************* 1028 * _ultoa (CRTDLL.309)1026 1027 1028 /********************************************************************* 1029 * _ultoa (CRTDLL.309) 1029 1030 */ 1030 1031 LPSTR CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix) … … 1036 1037 1037 1038 /********************************************************************* 1038 * CRTDLL__ungetch (CRTDLL.311)1039 * CRTDLL__ungetch (CRTDLL.311) 1039 1040 */ 1040 1041 int CDECL CRTDLL__ungetch( int i ) … … 1046 1047 1047 1048 /********************************************************************* 1048 * _utime (CRTDLL.314)1049 * _utime (CRTDLL.314) 1049 1050 */ 1050 1051 int CDECL CRTDLL__utime( char *path, struct utimbuf * times ) … … 1056 1057 1057 1058 /********************************************************************* 1058 * _vsnprintf(CRTDLL.315)1059 * _vsnprintf (CRTDLL.315) 1059 1060 */ 1060 1061 int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg ) … … 1100 1101 1101 1102 /********************************************************************* 1102 * abs (CRTDLL.336)1103 * abs (CRTDLL.336) 1103 1104 */ 1104 1105 double CDECL CRTDLL_abs(double d) … … 1112 1113 1113 1114 /********************************************************************* 1114 * acos (CRTDLL.337)1115 * acos (CRTDLL.337) 1115 1116 */ 1116 1117 double CDECL CRTDLL_acos( double x ) … … 1122 1123 1123 1124 /********************************************************************* 1124 * asctime (CRTDLL.338)1125 * asctime (CRTDLL.338) 1125 1126 */ 1126 1127 char * CDECL CRTDLL_asctime( const struct tm *timeptr ) … … 1132 1133 1133 1134 /********************************************************************* 1134 * asin (CRTDLL.339)1135 * asin (CRTDLL.339) 1135 1136 */ 1136 1137 double CDECL CRTDLL_asin( double x ) … … 1142 1143 1143 1144 /********************************************************************* 1144 * atan (CRTDLL.340)1145 * atan (CRTDLL.340) 1145 1146 */ 1146 1147 double CDECL CRTDLL_atan(double d) … … 1154 1155 1155 1156 /********************************************************************* 1156 * atan2 (CRTDLL.341)1157 * atan2 (CRTDLL.341) 1157 1158 */ 1158 1159 double CDECL CRTDLL_atan2( double y, double x ) … … 1164 1165 1165 1166 /********************************************************************* 1166 * atof (CRTDLL.343)1167 * atof (CRTDLL.343) 1167 1168 */ 1168 1169 double CDECL CRTDLL_atof( const char *nptr ) … … 1174 1175 1175 1176 /********************************************************************* 1176 * atoi (CRTDLL.344)1177 * atoi (CRTDLL.344) 1177 1178 */ 1178 1179 int CDECL CRTDLL_atoi(LPSTR str) … … 1186 1187 1187 1188 /********************************************************************* 1188 * atol (CRTDLL.345)1189 * atol (CRTDLL.345) 1189 1190 */ 1190 1191 long CDECL CRTDLL_atol(LPSTR str) … … 1198 1199 1199 1200 /********************************************************************* 1200 * bsearch (CRTDLL.346)1201 * bsearch (CRTDLL.346) 1201 1202 */ 1202 1203 void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width, … … 1205 1206 int left, right, median, sign; 1206 1207 const void *element; 1207 1208 1208 1209 if (width == 0) 1209 1210 return 0; … … 1226 1227 1227 1228 /********************************************************************* 1228 * ceil (CRTDLL.348)1229 * ceil (CRTDLL.348) 1229 1230 */ 1230 1231 double CDECL CRTDLL_ceil(double d) … … 1237 1238 1238 1239 /********************************************************************* 1239 * clock (CRTDLL.350)1240 * clock (CRTDLL.350) 1240 1241 */ 1241 1242 clock_t CDECL CRTDLL_clock( void ) … … 1247 1248 1248 1249 /********************************************************************* 1249 * cos (CRTDLL.351)1250 * cos (CRTDLL.351) 1250 1251 */ 1251 1252 double CDECL CRTDLL_cos(double d) … … 1259 1260 1260 1261 /********************************************************************* 1261 * cosh (CRTDLL.352)1262 * cosh (CRTDLL.352) 1262 1263 */ 1263 1264 double CDECL CRTDLL_cosh( double x ) … … 1269 1270 1270 1271 /********************************************************************* 1271 * ctime (CRTDLL.353)1272 * ctime (CRTDLL.353) 1272 1273 */ 1273 1274 char * CDECL CRTDLL_ctime( const time_t *timer ) … … 1279 1280 1280 1281 /********************************************************************* 1281 * difftime (CRTDLL.354)1282 * difftime (CRTDLL.354) 1282 1283 */ 1283 1284 double CDECL CRTDLL_difftime( time_t t1, time_t t0 ) … … 1289 1290 1290 1291 /********************************************************************* 1291 * div (CRTDLL.355)1292 * div (CRTDLL.355) 1292 1293 */ 1293 1294 ULONG CDECL CRTDLL_div( int number, int denom ) … … 1303 1304 1304 1305 /********************************************************************* 1305 * exp (CRTDLL.357)1306 * exp (CRTDLL.357) 1306 1307 */ 1307 1308 double CDECL CRTDLL_exp( double x ) … … 1313 1314 1314 1315 /********************************************************************* 1315 * fabs (CRTDLL.358)1316 * fabs (CRTDLL.358) 1316 1317 */ 1317 1318 double CDECL CRTDLL_fabs(double d) … … 1325 1326 1326 1327 /********************************************************************* 1327 * floor (CRTDLL.367)1328 * floor (CRTDLL.367) 1328 1329 */ 1329 1330 double CDECL CRTDLL_floor(double d) … … 1337 1338 1338 1339 /********************************************************************* 1339 * fmod (CRTDLL.368)1340 * fmod (CRTDLL.368) 1340 1341 */ 1341 1342 double CDECL CRTDLL_fmod(double x, double y ) … … 1347 1348 1348 1349 /********************************************************************* 1349 * frexp (CRTDLL.377)1350 * frexp (CRTDLL.377) 1350 1351 */ 1351 1352 double CDECL CRTDLL_frexp( double value, int *exp ) … … 1489 1490 1490 1491 /********************************************************************* 1491 * labs (CRTDLL.416)1492 * labs (CRTDLL.416) 1492 1493 */ 1493 1494 long int CDECL CRTDLL_labs( long int j ) … … 1499 1500 1500 1501 /********************************************************************* 1501 * ldexp (CRTDLL.417)1502 */ 1503 double CDECL CRTDLL_ldexp( double x, int exp ) 1502 * ldexp (CRTDLL.417) 1503 */ 1504 double CDECL CRTDLL_ldexp( double x, int exp ) 1504 1505 { 1505 1506 dprintf2(("CRTDLL: ldexp\n")); … … 1509 1510 1510 1511 /********************************************************************* 1511 * ldiv (CRTDLL.418)1512 */ 1513 ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom ) 1512 * ldiv (CRTDLL.418) 1513 */ 1514 ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom ) 1514 1515 { 1515 1516 dprintf2(("CRTDLL: ldiv\n")); … … 1519 1520 1520 1521 /********************************************************************* 1521 * localeconv (CRTDLL.419)1522 * localeconv (CRTDLL.419) 1522 1523 */ 1523 1524 struct lconv * CDECL CRTDLL_localeconv(void) … … 1529 1530 1530 1531 /********************************************************************* 1531 * localtime (CRTDLL.420)1532 * localtime (CRTDLL.420) 1532 1533 */ 1533 1534 struct tm * CDECL CRTDLL_localtime( const time_t *timer ) … … 1539 1540 1540 1541 /********************************************************************* 1541 * log (CRTDLL.421)1542 * log (CRTDLL.421) 1542 1543 */ 1543 1544 double CDECL CRTDLL_log( double x ) … … 1549 1550 1550 1551 /********************************************************************* 1551 * log10 (CRTDLL.422)1552 * log10 (CRTDLL.422) 1552 1553 */ 1553 1554 double CDECL CRTDLL_log10( double x ) … … 1581 1582 * pow (CRTDLL.436) 1582 1583 */ 1583 double CDECL CRTDLL_pow( double x, double y ) 1584 double CDECL CRTDLL_pow( double x, double y ) 1584 1585 { 1585 1586 dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y)); … … 1621 1622 1622 1623 /********************************************************************* 1623 * scanf(CRTDLL.448)1624 * scanf (CRTDLL.448) 1624 1625 */ 1625 1626 int CDECL CRTDLL_scanf( const char *format, va_list arg ) … … 1705 1706 1706 1707 /********************************************************************* 1707 * sscanf(CRTDLL.458)1708 * sscanf (CRTDLL.458) 1708 1709 */ 1709 1710 int CDECL CRTDLL_sscanf( const char *s, const char *format, va_list arg ) … … 1782 1783 1783 1784 /********************************************************************* 1784 * ungetc(CRTDLL.492)1785 * ungetc (CRTDLL.492) 1785 1786 */ 1786 1787 INT CDECL CRTDLL_ungetc(int c, FILE *f) … … 1812 1813 1813 1814 /********************************************************************* 1814 * CRTDLL__setjmp3 (CRTDLL.600)1815 * CRTDLL__setjmp3 (CRTDLL.600) 1815 1816 */ 1816 1817 int CDECL CRTDLL__setjmp3( jmp_buf env ) -
trunk/src/crtdll/crtdll_main.c
r4667 r6645 1 /* $Id: crtdll_main.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */ 1 2 /* 2 3 * The C RunTime DLL 3 * 4 * 4 5 * Implements C run-time functionality as known from UNIX. 5 6 * … … 13 14 Unresolved issues Uwe Bonnes 970904: 14 15 - tested with ftp://ftp.remcomp.com/pub/remcomp/lcc-win32.zip, a C-Compiler 15 for Win32, based on lcc, from Jacob Navia16 for Win32, based on lcc, from Jacob Navia 16 17 UB 000416: 17 18 - probably not thread safe 18 19 */ 19 20 20 /* NOTE: This file also implements the wcs* functions. They _ARE_ in 21 /* NOTE: This file also implements the wcs* functions. They _ARE_ in 21 22 * the newer Linux libcs, but use 4 byte wide characters, so are unusable, 22 23 * since we need 2 byte wide characters. - Marcus Meissner, 981031 … … 63 64 UINT CRTDLL_winminor_dll; /* CRTDLL.330 */ 64 65 UINT CRTDLL_winver_dll; /* CRTDLL.331 */ 65 INT CRTDLL_doserrno = 0; 66 INT CRTDLL_doserrno = 0; 66 67 INT CRTDLL_errno = 0; 67 68 const INT CRTDLL__sys_nerr = 43; … … 77 78 * CRTDLL_MainInit (CRTDLL.init) 78 79 */ 79 80 80 81 BOOL WINAPI CRTDLL_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 81 82 { 82 83 FS_OS2 83 84 84 85 // call i/o initializer in file.c 85 if (fdwReason == DLL_PROCESS_ATTACH) 86 if (fdwReason == DLL_PROCESS_ATTACH) 86 87 { 87 88 __CRTDLL__init_io(); 88 89 } 89 90 90 91 /* 91 92 PH 2000/11/21 this code doesn't look very useful 92 93 93 94 if (fdwReason == DLL_PROCESS_ATTACH) { 94 95 _fdopen(0,"r"); … … 103 104 } 104 105 */ 105 106 106 107 FS_WIN32 107 108 return TRUE; … … 176 177 char *cmdline; 177 178 char **xargv; 178 intxargc,end,last_arg,afterlastspace;179 DWORDversion;180 181 TRACE("(%p,%p,%p,%ld).\n",182 argc,argv,environ,flag183 );184 185 if (CRTDLL_acmdln_dll != NULL)186 HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);187 188 CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );189 TRACE("got '%s'\n", cmdline);190 191 version= GetVersion();192 CRTDLL_osver_dll = version >> 16;193 CRTDLL_winminor_dll = version & 0xFF;194 CRTDLL_winmajor_dll = (version>>8) & 0xFF;195 CRTDLL_baseversion_dll = version >> 16;196 CRTDLL_winver_dll = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);197 CRTDLL_baseminor_dll = (version >> 16) & 0xFF;198 CRTDLL_basemajor_dll = (version >> 24) & 0xFF;199 CRTDLL_osversion_dll = version & 0xFFFF;200 CRTDLL_osminor_dll = version & 0xFF;201 CRTDLL_osmajor_dll = (version>>8) & 0xFF;202 203 /* missing threading init */204 205 end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;206 while (1)207 {208 if ((cmdline[end]==' ') || (cmdline[end]=='\0'))209 {210 if (cmdline[end]=='\0')211 last_arg=1;212 else213 cmdline[end]='\0';214 /* alloc xargc + NULL entry */215 xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,216 sizeof(char*)*(xargc+1));217 if (strlen(cmdline+afterlastspace))218 {219 xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);220 xargc++;179 int xargc,end,last_arg,afterlastspace; 180 DWORD version; 181 182 TRACE("(%p,%p,%p,%ld).\n", 183 argc,argv,environ,flag 184 ); 185 186 if (CRTDLL_acmdln_dll != NULL) 187 HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll); 188 189 CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() ); 190 TRACE("got '%s'\n", cmdline); 191 192 version = GetVersion(); 193 CRTDLL_osver_dll = version >> 16; 194 CRTDLL_winminor_dll = version & 0xFF; 195 CRTDLL_winmajor_dll = (version>>8) & 0xFF; 196 CRTDLL_baseversion_dll = version >> 16; 197 CRTDLL_winver_dll = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8); 198 CRTDLL_baseminor_dll = (version >> 16) & 0xFF; 199 CRTDLL_basemajor_dll = (version >> 24) & 0xFF; 200 CRTDLL_osversion_dll = version & 0xFFFF; 201 CRTDLL_osminor_dll = version & 0xFF; 202 CRTDLL_osmajor_dll = (version>>8) & 0xFF; 203 204 /* missing threading init */ 205 206 end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0; 207 while (1) 208 { 209 if ((cmdline[end]==' ') || (cmdline[end]=='\0')) 210 { 211 if (cmdline[end]=='\0') 212 last_arg=1; 213 else 214 cmdline[end]='\0'; 215 /* alloc xargc + NULL entry */ 216 xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv, 217 sizeof(char*)*(xargc+1)); 218 if (strlen(cmdline+afterlastspace)) 219 { 220 xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace); 221 xargc++; 221 222 if (!last_arg) /* need to seek to the next arg ? */ 222 {223 end++;224 while (cmdline[end]==' ')225 end++;226 }227 afterlastspace=end;228 }229 else230 {231 xargv[xargc] = NULL; /* the last entry is NULL */232 break;233 }234 }235 else236 end++;237 }238 CRTDLL_argc_dll= xargc;239 *argc= xargc;240 CRTDLL_argv_dll= xargv;241 *argv= xargv;242 243 TRACE("found %d arguments\n",244 CRTDLL_argc_dll);245 CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();246 return environ;223 { 224 end++; 225 while (cmdline[end]==' ') 226 end++; 227 } 228 afterlastspace=end; 229 } 230 else 231 { 232 xargv[xargc] = NULL; /* the last entry is NULL */ 233 break; 234 } 235 } 236 else 237 end++; 238 } 239 CRTDLL_argc_dll = xargc; 240 *argc = xargc; 241 CRTDLL_argv_dll = xargv; 242 *argv = xargv; 243 244 TRACE("found %d arguments\n", 245 CRTDLL_argc_dll); 246 CRTDLL_environ_dll = *environ = GetEnvironmentStringsA(); 247 return environ; 247 248 } 248 249 … … 253 254 DWORD CDECL CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end) 254 255 { 255 _INITTERMFUN*current;256 257 TRACE("(%p,%p)\n",start,end);258 current=start;259 while (current<end) {260 if (*current) (*current)();261 current++;262 }263 return 0;256 _INITTERMFUN *current; 257 258 TRACE("(%p,%p)\n",start,end); 259 current=start; 260 while (current<end) { 261 if (*current) (*current)(); 262 current++; 263 } 264 return 0; 264 265 } 265 266 … … 309 310 INT CDECL CRTDLL_rand() 310 311 { 311 return (rand() & CRTDLL_RAND_MAX); 312 return (rand() & CRTDLL_RAND_MAX); 312 313 } 313 314 … … 319 320 { 320 321 // return (_rotl(value, shift)); 321 322 322 323 shift &= 31; 323 324 return (x << shift) | (x >> (32-shift)); … … 331 332 { 332 333 // return (_lrotl(value, shift)); 333 334 334 335 shift &= 31; 335 336 return (x << shift) | (x >> (32-shift)); … … 343 344 { 344 345 // return (_lrotr(value, shift)); 345 346 346 347 shift &= 0x1f; 347 348 return (x >> shift) | (x << (32-shift)); … … 355 356 { 356 357 // return (_rotr(value, shift)); 357 358 358 359 shift &= 0x1f; 359 360 return (x >> shift) | (x << (32-shift)); … … 367 368 { 368 369 // return (vswprintf(s, t, format, arg)); 369 370 370 371 return wvsprintfW( buffer, spec, args ); 371 372 } … … 388 389 { 389 390 return (setlocale(category, locale)); 390 391 391 392 /* 392 393 LPSTR categorystr; … … 437 438 { 438 439 // return (_fullpath(buf, path, size)); 439 440 440 441 if (!buf) 441 442 { … … 455 456 { 456 457 // _splitpath( path, drive, dir, fname, ext); 457 458 458 459 /* drive includes : 459 460 directory includes leading and trailing (forward and backward slashes) … … 519 520 { 520 521 // _makepath(path, drive, dir, fname, ext); 521 522 522 523 char ch; 523 524 TRACE("CRTDLL__makepath got %s %s %s %s\n", drive, directory, … … 567 568 { 568 569 // return (_errno()); 569 570 570 571 return &CRTDLL_errno; 571 572 } … … 574 575 /********************************************************************* 575 576 * __doserrno (CRTDLL.26) 576 * 577 * 577 578 * Return the address of the DOS errno (holding the last OS error). 578 579 * @@@PH Note: veeeery strange ... … … 583 584 { 584 585 // return (__doserrno()); 585 586 586 587 return &CRTDLL_doserrno; 587 588 } … … 601 602 { 602 603 // return (_strerror((char*)s)); 603 604 604 605 static char strerrbuff[256]; 605 606 sprintf(strerrbuff,"%s: %s\n",err,CRTDLL_strerror(CRTDLL_errno)); … … 616 617 { 617 618 // perror( s ); 618 619 619 620 char *err_str = CRTDLL_strerror(CRTDLL_errno); 620 621 CRTDLL_fprintf(CRTDLL_stderr,"%s: %s\n",err,err_str); 621 622 CRTDLL_free(err_str); 622 623 } 623 624 624 625 625 626 /********************************************************************* … … 631 632 * The caller does not own the string returned. 632 633 */ 633 extern char *strerror(int errnum); 634 extern char *strerror(int errnum); 634 635 635 636 LPSTR CDECL CRTDLL_strerror (INT err) … … 645 646 { 646 647 //return (signal(sig, ptr)); 647 648 648 649 FIXME("(%d %p):stub.\n", sig, ptr); 649 650 return (void*)-1; … … 667 668 { 668 669 // return (getenv(name)); 669 670 670 671 LPSTR environ = GetEnvironmentStringsA(); 671 672 LPSTR pp,pos = NULL; … … 674 675 for (pp = environ; (*pp); pp = pp + strlen(pp) +1) 675 676 { 676 pos =strchr(pp,'=');677 if (pos)678 length = pos -pp;679 else680 length = strlen(pp);681 if (!strncmp(pp,name,length)) break;677 pos =strchr(pp,'='); 678 if (pos) 679 length = pos -pp; 680 else 681 length = strlen(pp); 682 if (!strncmp(pp,name,length)) break; 682 683 } 683 if ((pp)&& (pos)) 684 if ((pp)&& (pos)) 684 685 { 685 pp = pos+1;686 TRACE("got %s\n",pp);686 pp = pos+1; 687 TRACE("got %s\n",pp); 687 688 } 688 689 FreeEnvironmentStringsA( environ ); … … 695 696 */ 696 697 INT CDECL CRTDLL__except_handler2 ( 697 PEXCEPTION_RECORD rec,698 PEXCEPTION_FRAME frame,699 PCONTEXT context,700 PEXCEPTION_FRAME *dispatcher)701 { 702 FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",703 rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,704 frame->Handler, context, dispatcher);705 return ExceptionContinueSearch;698 PEXCEPTION_RECORD rec, 699 PEXCEPTION_FRAME frame, 700 PCONTEXT context, 701 PEXCEPTION_FRAME *dispatcher) 702 { 703 FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n", 704 rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress, 705 frame->Handler, context, dispatcher); 706 return ExceptionContinueSearch; 706 707 } 707 708 … … 724 725 { 725 726 // return (_toascii(c)); 726 727 727 728 return c & 0x7f; 728 729 } … … 754 755 { 755 756 // return (_iscsym(c)); 756 757 757 758 return (isalnum(c) || c == '_'); 758 759 } … … 773 774 { 774 775 // return (_iscsymf(c)); 775 776 776 777 return (isalpha(c) || c == '_'); 777 778 } … … 846 847 { 847 848 if (cf((LPVOID*)match, (LPVOID*)pStart) == 0) 848 return pStart; /* found */849 return pStart; /* found */ 849 850 pStart += elem_size; 850 851 } while (--size); … … 914 915 { 915 916 // return (_toupper(n)); 916 917 917 918 return toupper(c); 918 919 } … … 925 926 { 926 927 // return (_tolower(n)); 927 928 928 929 return tolower(c); 929 930 } … … 946 947 { 947 948 // return (_cabs(c)); 948 949 949 950 return sqrt(c.real * c.real + c.imaginary * c.imaginary); 950 951 } … … 1006 1007 * 1007 1008 * Reset the state of the floating point processor. 1008 * 1009 * 1009 1010 * PARAMS 1010 1011 * None. -
trunk/src/crtdll/dir.c
r4675 r6645 1 /* $Id: dir.c,v 1.5 2001-09-05 12:14:24 bird Exp $ */ 1 2 /* 2 3 * CRTDLL drive/directory functions 3 * 4 * 4 5 * Copyright 1996,1998 Marcus Meissner 5 6 * Copyright 1996 Jukka Iivonen … … 57 58 * RETURNS 58 59 * Sucess: 0 59 * 60 * 60 61 * Failure: -1 61 62 */ … … 64 65 dprintf(("CRTDLL: _chdir(%s)\n", 65 66 newdir)); 66 67 67 68 if (!SetCurrentDirectoryA(newdir)) 68 69 { … … 84 85 * RETURNS 85 86 * Sucess: 0 86 * 87 * Failure: 1 87 * 88 * Failure: 1 88 89 */ 89 90 BOOL CDECL CRTDLL__chdrive(INT newdrive) … … 91 92 char buffer[3] = "A:"; 92 93 buffer[0] += newdrive - 1; 93 94 94 95 dprintf(("CRTDLL: _chdrive(%s)\n", 95 96 buffer)); 96 97 97 98 if (!SetCurrentDirectoryA( buffer )) 98 99 { … … 108 109 /********************************************************************* 109 110 * _findclose (CRTDLL.098) 110 * 111 * 111 112 * Free the resources from a search handle created from _findfirst. 112 113 * … … 123 124 dprintf(("CRTDLL: _findclose(%08xh)\n", 124 125 hand)); 125 126 126 127 if (!FindClose((HANDLE)hand)) 127 128 { … … 141 142 * PARAMS 142 143 * fspec [in] File specification string for search, e.g "C:\*.BAT" 143 * 144 * 144 145 * ft [out] A pointer to a find_t structure to populate. 145 146 * … … 155 156 WIN32_FIND_DATAA find_data; 156 157 HANDLE hfind; 157 158 158 159 dprintf(("CRTDLL: _findfirst(%s)\n", 159 160 fspec)); … … 173 174 /********************************************************************* 174 175 * _findnext (CRTDLL.100) 175 * 176 * 176 177 * Return the next matching file/directory from a search hadle. 177 178 * 178 179 * PARAMS 179 180 * hand [in] Search handle from a pervious call to _findfirst 180 * 181 * 181 182 * ft [out] A pointer to a find_t structure to populate. 182 183 * … … 190 191 { 191 192 WIN32_FIND_DATAA find_data; 192 193 193 194 dprintf(("CRTDLL: _findnext(%08xh)\n", 194 195 hand)); 195 196 196 197 if (!FindNextFileA(hand, &find_data)) 197 198 { … … 224 225 { 225 226 // return (_getcwd(buf, size)); 226 227 227 228 char dir[_MAX_PATH]; 228 229 int dir_len = GetCurrentDirectoryA(_MAX_PATH,dir); 229 230 230 231 dprintf(("CRTDLL: _getcwd()\n")); 231 232 232 233 if (dir_len < 1) 233 234 return NULL; /* FIXME: Real return value untested */ … … 258 259 { 259 260 // return (_getdcwd(drive, buffer, maxlen)); 260 261 261 262 static CHAR* dummy; 262 263 263 264 dprintf(("CRTDLL: _getdcwd()\n")); 264 265 265 266 if (!drive || drive == CRTDLL__getdrive()) 266 267 return CRTDLL__getcwd(buf,size); /* current */ … … 305 306 DWORD ret[4]; 306 307 UINT err; 307 308 308 309 dprintf(("CRTDLL: _getdiskfree(%08xh)\n", disk)); 309 310 310 311 if (disk > 26) 311 312 return ERROR_INVALID_PARAMETER; /* CRTDLL doesn't set errno here */ … … 335 336 { 336 337 // return DRIVE_GetCurrentDrive() + 1; 337 338 338 339 char buffer[MAX_PATH]; 339 340 340 341 dprintf(("CRTDLL: _getdrive()\n")); 341 342 342 if (!GetCurrentDirectoryA( sizeof(buffer), buffer )) 343 return 0; 344 if (buffer[1] != ':') 343 if (!GetCurrentDirectoryA( sizeof(buffer), buffer )) 344 return 0; 345 if (buffer[1] != ':') 345 346 return 0; 346 347 return toupper(buffer[0]) - 'A' + 1; … … 357 358 dprintf(("CRTDLL: _mkdir(%s)\n", 358 359 newdir)); 359 360 360 361 if (CreateDirectoryA(newdir,NULL)) 361 362 return 0; … … 368 369 * _rmdir (CRTDLL.255) 369 370 * 370 * Delete a directory 371 * Delete a directory 371 372 * 372 373 */ … … 375 376 dprintf(("CRTDLL: _rmdir(%s)\n", 376 377 dir)); 377 378 378 379 if (RemoveDirectoryA(dir)) 379 380 return 0; -
trunk/src/crtdll/exit.c
r4667 r6645 1 /* $Id: exit.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */ 1 2 /* 2 3 * CRTDLL exit/abort/atexit functions 3 * 4 * 4 5 * Copyright 1996,1998 Marcus Meissner 5 6 * Copyright 1996 Jukka Iivonen … … 10 11 * and whether they return to the caller (really!). 11 12 * return do 12 * Name to caller? cleanup? 13 * Name to caller? cleanup? 13 14 * _c_exit Y N 14 15 * _cexit Y Y … … 54 55 55 56 /********************************************************************* 56 * __dllonexit(CRTDLL.25)57 * __dllonexit (CRTDLL.25) 57 58 */ 58 59 VOID CDECL CRTDLL___dllonexit () 59 { 60 { 60 61 dprintf(("__dllonexit not implemented.\n")); 61 62 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); … … 64 65 65 66 /********************************************************************* 66 * _abnormal_termination(CRTDLL.36)67 * _abnormal_termination (CRTDLL.36) 67 68 */ 68 69 int CDECL CRTDLL__abnormal_termination(void) … … 83 84 { 84 85 dprintf2(("CRTDLL: _amsg_exit\n")); 85 86 86 87 // fprintf(stderr,strerror(errnum)); 87 88 // ExitProcess(-1); 88 89 89 90 CRTDLL_fprintf(CRTDLL_stderr,"\nrun-time error:\nError Code %d\n",errnum); 90 91 CRTDLL__exit(255); … … 95 96 * _assert (CRTDLL.041) 96 97 * 97 * Print an assertion message and call abort(). Really only present 98 * Print an assertion message and call abort(). Really only present 98 99 * for win binaries. Winelib programs would typically use libc's 99 100 * version. … … 102 103 { 103 104 dprintf2(("CRTDLL: _assert\n")); 104 105 105 106 CRTDLL_fprintf(CRTDLL_stderr,"Assertion failed: %s, file %s, line %d\n\n", 106 107 (char*)str,(char*)file, line); 107 108 CRTDLL_abort(); 108 109 109 110 // _assert(str, file, line); 110 111 } … … 119 120 dprintf2(("_c_exit(%d)\n",ret)); 120 121 FIXME("not calling CRTDLL cleanup\n"); 121 122 122 123 /* dont exit, return to caller */ 123 124 124 125 ExitProcess(ret); 125 126 } … … 135 136 FIXME("not calling CRTDLL cleanup\n"); 136 137 /* dont exit, return to caller */ 137 138 138 139 ExitProcess(ret); 139 140 } … … 145 146 VOID CDECL CRTDLL__exit(LONG ret) 146 147 { 147 dprintf2(("CRTDLL: _exit (%08xh)\n", 148 dprintf2(("CRTDLL: _exit (%08xh)\n", 148 149 ret)); 149 150 TRACE(":exit code %ld\n",ret); … … 199 200 { 200 201 dprintf2(("CRTDLL: abort\n")); 201 202 202 203 CRTDLL_fprintf(CRTDLL_stderr,"\nabnormal program termination\n"); 203 204 CRTDLL__exit(3); … … 207 208 208 209 /********************************************************************* 209 * atexit (CRTDLL.342)210 * atexit (CRTDLL.342) 210 211 * 211 212 * Register a function to be called when the process terminates. … … 214 215 { 215 216 dprintf(("CRTDLL: atexit\n")); 216 217 217 218 return CRTDLL__onexit(func) == func ? 0 : -1; 218 219 219 220 // if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0])) 220 221 // return -1; -
trunk/src/crtdll/file.c
r4671 r6645 1 /* $Id: file.c,v 1.3 2001-09-05 12:14:24 bird Exp $ */ 1 2 /* 2 3 * CRTDLL file functions 3 * 4 * 4 5 * Copyright 1996,1998 Marcus Meissner 5 6 * Copyright 1996 Jukka Iivonen … … 8 9 * 9 10 * Implementation Notes: 10 * Mapping is performed between FILE*, fd and HANDLE's. This allows us to 11 * implement all calls using the Win32 API, support remapping fd's to 11 * Mapping is performed between FILE*, fd and HANDLE's. This allows us to 12 * implement all calls using the Win32 API, support remapping fd's to 12 13 * FILES and do some other tricks as well (like closeall, _get_osfhandle). 13 14 * For mix and matching with the host libc, processes can use the Win32 HANDLE … … 128 129 else 129 130 while(__CRTDLL_fdstart < __CRTDLL_fdend && 130 __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)131 __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE) 131 132 __CRTDLL_fdstart++; 132 133 … … 143 144 { 144 145 TRACE(":fd (%d) allocating FILE*\n",fd); 145 if (fd < 0 || fd >= __CRTDLL_fdend || 146 if (fd < 0 || fd >= __CRTDLL_fdend || 146 147 __CRTDLL_handles[fd] == INVALID_HANDLE_VALUE) 147 148 { … … 178 179 179 180 TRACE(":handles (%d)(%d)(%d)\n",__CRTDLL_handles[0], 180 __CRTDLL_handles[1],__CRTDLL_handles[2]);181 __CRTDLL_handles[1],__CRTDLL_handles[2]); 181 182 182 183 for (i = 0; i < 3; i++) … … 195 196 { 196 197 // return (_access(path, mode)); 197 198 198 199 DWORD attr = GetFileAttributesA(filename); 199 200 … … 202 203 if (!filename) 203 204 { 204 /* FIXME: Should GetFileAttributesA() return this? */205 /* FIXME: Should GetFileAttributesA() return this? */ 205 206 __CRTDLL__set_errno(ERROR_INVALID_DATA); 206 207 return -1; … … 303 304 { 304 305 // return (__eof(_fd)); 305 306 306 307 DWORD curpos,endpos; 307 308 HANDLE hand = __CRTDLL__fdtoh(fd); … … 338 339 { 339 340 // return (_fcloseall()); 340 341 341 342 int num_closed = 0, i = 3; 342 343 … … 361 362 { 362 363 // return (_fdopen(handle, mode)); 363 364 364 365 CRTDLL_FILE* file = __CRTDLL__alloc_fp(fd); 365 366 … … 378 379 { 379 380 // return (_fgetchar()); 380 381 381 382 return CRTDLL_fgetc(CRTDLL_stdin); 382 383 } … … 390 391 * becomes negative. We ensure that _cnt is always 0 after any read 391 392 * so this function is always called. Our implementation simply calls 392 * fgetc as all the underlying buffering is handled by Wines 393 * fgetc as all the underlying buffering is handled by Wines 393 394 * implementation of the Win32 file I/O calls. 394 395 */ … … 410 411 { 411 412 // return (_fileno(f)); 412 413 413 414 TRACE(":FILE* (%p) fd (%d)\n",file,file->_file); 414 415 return file->_file; … … 440 441 { 441 442 // return (_flushall()); 442 443 443 444 int num_flushed = 0, i = 3; 444 445 … … 447 448 { 448 449 if (CRTDLL__commit(i) == -1) 449 if (__CRTDLL_files[i])450 __CRTDLL_files[i]->_flag |= _IOERR;450 if (__CRTDLL_files[i]) 451 __CRTDLL_files[i]->_flag |= _IOERR; 451 452 num_flushed++; 452 453 } … … 465 466 { 466 467 // return(_fputchar(c)); 467 468 468 469 return CRTDLL_fputc(c, CRTDLL_stdout); 469 470 } … … 484 485 /********************************************************************* 485 486 * _fstat (CRTDLL.111) 486 * 487 * 487 488 * Get information about an open file. 488 489 */ … … 490 491 { 491 492 // return (_fstat(file, buf)); 492 493 493 494 DWORD dw; 494 495 BY_HANDLE_FILE_INFORMATION hfi; … … 548 549 { 549 550 /* FIXME: I'm not convinced that I should be copying the 550 * handle here - it may be leaked if the app doesn't 551 * handle here - it may be leaked if the app doesn't 551 552 * close it (and the API docs dont say that it should) 552 553 * Not duplicating it means that it can't be inherited … … 557 558 */ 558 559 DuplicateHandle(GetCurrentProcess(),hand,GetCurrentProcess(), 559 &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );560 &newhand,0,TRUE,DUPLICATE_SAME_ACCESS ); 560 561 } 561 562 return newhand; … … 588 589 { 589 590 // return (_lseek(handle, offset, origin)); 590 591 591 592 LONG ret; 592 593 HANDLE hand = __CRTDLL__fdtoh(fd); … … 777 778 { 778 779 // return (_setmode(fh, mode)); 779 780 780 781 if (mode & _O_TEXT) 781 782 FIXME("fd (%d) mode (%d) TEXT not implemented\n",fd,mode); … … 790 791 { 791 792 // return(_stat(s1, n)); 792 793 793 794 DWORD dw; 794 795 WIN32_FILE_ATTRIBUTE_DATA hfi; … … 826 827 { 827 828 unsigned int ext = tolower(path[plen-1]) | (tolower(path[plen-2]) << 8) 828 | (tolower(path[plen-3]) << 16);829 | (tolower(path[plen-3]) << 16); 829 830 if (ext == EXE || ext == BAT || ext == CMD || ext == COM) 830 mode |= CRTDLL_S_IEXEC;831 mode |= CRTDLL_S_IEXEC; 831 832 } 832 833 } … … 843 844 buf->st_mtime = buf->st_ctime = dw; 844 845 TRACE("\n%d %d %d %d %d %d\n", buf->st_mode,buf->st_nlink,buf->st_size, 845 buf->st_atime,buf->st_mtime, buf->st_ctime);846 buf->st_atime,buf->st_mtime, buf->st_ctime); 846 847 return 0; 847 848 } … … 856 857 { 857 858 // return (_tell(i)); 858 859 859 860 return CRTDLL__lseek(fd, 0, SEEK_CUR); 860 861 } … … 863 864 /********************************************************************* 864 865 * _tempnam (CRTDLL.305) 865 * 866 * 866 867 */ 867 868 LPSTR CDECL CRTDLL__tempnam(LPCSTR dir, LPCSTR prefix) 868 869 { 869 870 // return (_tempnam(dir, prefix)); 870 871 871 872 char tmpbuf[MAX_PATH]; 872 873 … … 890 891 { 891 892 // return (_umask(i)); 892 893 893 894 INT old_umask = __CRTDLL_umask; 894 895 TRACE("umask (%d)\n",umask); … … 976 977 { 977 978 // return (fclose(fp)); 978 979 979 980 return CRTDLL__close(file->_file); 980 981 } … … 989 990 { 990 991 // return (feof(fp)); 991 992 992 993 return file->_flag & _IOEOF; 993 994 } … … 1002 1003 { 1003 1004 // return (ferror(fp)); 1004 1005 1005 1006 return file->_flag & _IOERR; 1006 1007 } … … 1024 1025 { 1025 1026 // return (fgetc(fp)); 1026 1027 1027 1028 char c; 1028 1029 if (CRTDLL__read(file->_file,&c,1) != 1) … … 1050 1051 { 1051 1052 // return (fgets(s, n, fp)); 1052 1053 1053 1054 int cc; 1054 1055 LPSTR buf_start = s; 1055 1056 1056 1057 TRACE(":file(%p) fd (%d) str (%p) len (%d)\n", 1057 file,file->_file,s,size);1058 file,file->_file,s,size); 1058 1059 1059 1060 /* BAD, for the whole WINE process blocks... just done this way to test … … 1088 1089 { 1089 1090 // return (fputs(s, fp)); 1090 1091 1091 1092 return CRTDLL_fwrite(s,strlen(s),1,file); 1092 1093 } … … 1099 1100 { 1100 1101 // return (fprintf(file, format, arg)); 1101 1102 1102 1103 va_list valist; 1103 1104 INT res; … … 1118 1119 { 1119 1120 // return (fopen( filename, mode)); 1120 1121 1121 1122 CRTDLL_FILE* file; 1122 1123 INT flags = 0, plus = 0, fd; … … 1182 1183 { 1183 1184 // return (fputc(c, fp)); 1184 1185 1185 1186 return CRTDLL__write(file->_file, &c, 1) == 1? c : EOF; 1186 1187 } … … 1193 1194 { 1194 1195 // return (fread(ptr, size, n, fp)); 1195 1196 1196 1197 DWORD read = CRTDLL__read(file->_file,ptr, size * nmemb); 1197 1198 if (read <= 0) … … 1203 1204 /********************************************************************* 1204 1205 * freopen (CRTDLL.379) 1205 * 1206 * 1206 1207 */ 1207 1208 CRTDLL_FILE* CDECL CRTDLL_freopen(LPCSTR path, LPCSTR mode,CRTDLL_FILE* file) 1208 1209 { 1209 1210 // return (freopen(filename, mode, fp)); 1210 1211 1211 1212 CRTDLL_FILE* newfile; 1212 1213 INT fd; … … 1256 1257 { 1257 1258 // return (fsetpos(fp, pos)); 1258 1259 1259 1260 return CRTDLL__lseek(file->_file,*pos,SEEK_SET); 1260 1261 } … … 1392 1393 { 1393 1394 // return (fseek(file, offset, whence)); 1394 1395 1395 1396 return CRTDLL__lseek(file->_file,offset,whence); 1396 1397 } … … 1403 1404 { 1404 1405 // return (ftell(fp)); 1405 1406 1406 1407 return CRTDLL__tell(file->_file); 1407 1408 } … … 1428 1429 { 1429 1430 // return (getchar()); 1430 1431 1431 1432 return CRTDLL_fgetc(CRTDLL_stdin); 1432 1433 } … … 1459 1460 */ 1460 1461 for(cc = CRTDLL_fgetc(CRTDLL_stdin); cc != EOF && cc != '\n'; 1461 cc = CRTDLL_fgetc(CRTDLL_stdin))1462 if(cc != '\r') *buf++ = (char)cc;1462 cc = CRTDLL_fgetc(CRTDLL_stdin)) 1463 if(cc != '\r') *buf++ = (char)cc; 1463 1464 1464 1465 *buf = '\0'; … … 1497 1498 { 1498 1499 // return puts( s ); 1499 1500 1500 1501 return CRTDLL_fputs(s, CRTDLL_stdout); 1501 1502 } … … 1511 1512 { 1512 1513 // rewind(fp); 1513 1514 1514 1515 TRACE(":file (%p) fd (%d)\n",file,file->_file); 1515 1516 CRTDLL__lseek(file->_file,0,SEEK_SET); … … 1524 1525 { 1525 1526 // return (remove(file)); 1526 1527 1527 1528 TRACE(":path (%s)\n",path); 1528 1529 if (DeleteFileA(path)) … … 1540 1541 { 1541 1542 // return (rename(old, new2)); 1542 1543 1543 1544 TRACE(":from %s to %s\n",oldpath,newpath); 1544 1545 if (MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING)) … … 1556 1557 { 1557 1558 // setbuf(fp, buf); 1558 1559 1559 1560 TRACE(":file (%p) fd (%d) buf (%p)\n", file, file->_file,buf); 1560 1561 if (buf) … … 1569 1570 * 1570 1571 * lcclnk from lcc-win32 relies on a terminating dot in the name returned 1571 * 1572 * 1572 1573 */ 1573 1574 LPSTR CDECL CRTDLL_tmpnam(LPSTR s) 1574 1575 { 1575 1576 // return (tmpnam(s)); 1576 1577 1577 1578 char tmpbuf[MAX_PATH]; 1578 1579 char* prefix = "TMP"; … … 1599 1600 { 1600 1601 // return (vfprintf(file, format, args)); 1601 1602 1602 1603 /* FIXME: We should parse the format string, calculate the maximum, 1603 1604 * length of each arg, malloc a buffer, print to it, and fwrite that. -
trunk/src/crtdll/initterm.cpp
r5135 r6645 1 /* $Id: initterm.cpp,v 1.7 2001-09-05 12:14:25 bird Exp $ */ 1 2 /* 2 3 * DLL entry point … … 55 56 case DLL_THREAD_ATTACH: 56 57 case DLL_THREAD_DETACH: 57 return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);58 return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad); 58 59 59 60 case DLL_PROCESS_DETACH: 60 CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);61 ctordtorTerm();62 return TRUE;61 CRTDLL_Init(hinstDLL, fdwReason, fImpLoad); 62 ctordtorTerm(); 63 return TRUE; 63 64 } 64 65 return FALSE; … … 90 91 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 91 92 92 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);93 if(dllHandle == 0) 94 return 0UL;93 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab); 94 if(dllHandle == 0) 95 return 0UL; 95 96 96 97 break; 97 98 case 1 : 98 99 if(dllHandle) { 99 UnregisterLxDll(dllHandle);100 UnregisterLxDll(dllHandle); 100 101 } 101 102 break; -
trunk/src/crtdll/memory.c
r4671 r6645 1 /* $Id: memory.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */ 1 2 /* 2 3 * CRTDLL memory functions 3 * 4 * 4 5 * Copyright 1996,1998 Marcus Meissner 5 6 * Copyright 1996 Jukka Iivonen … … 32 33 VOID* result; 33 34 if(!(result = HeapAlloc(GetProcessHeap(),0,size)) && new_handler) 34 (*new_handler)();35 (*new_handler)(); 35 36 return result; 36 37 } … … 79 80 { 80 81 // return (_heapchk()); 81 82 82 83 if (!HeapValidate( GetProcessHeap(), 0, NULL)) 83 84 { … … 97 98 { 98 99 // return (_heapmin()); 99 100 100 101 if (!HeapCompact( GetProcessHeap(), 0 )) 101 102 { … … 116 117 { 117 118 // return (_heapset(fill)); 118 119 119 120 INT retVal; 120 121 struct _heapinfo heap; … … 144 145 phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0; 145 146 146 if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && 147 if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && 147 148 !HeapValidate( GetProcessHeap(), 0, phe.lpData )) 148 149 { … … 180 181 { 181 182 // return (_msize(ptr)); 182 183 183 184 LONG size = HeapSize(GetProcessHeap(),0,mem); 184 185 if (size == -1) … … 215 216 /********************************************************************* 216 217 * malloc (CRTDLL.424) 217 * 218 * 218 219 * Alocate memory from the heap. 219 220 */ -
trunk/src/crtdll/spawn.c
r4672 r6645 1 /* $Id: spawn.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */ 1 2 /* 2 3 * CRTDLL spawn functions 3 * 4 * 4 5 * Copyright 1996,1998 Marcus Meissner 5 6 * Copyright 1996 Jukka Iivonen … … 24 25 * Implementation Notes: 25 26 * MT Safe - But only because of missing functionality. 26 * 27 * 27 28 * After translating input arguments into the required format for 28 29 * CreateProcess(), the internal function __CRTDLL__spawn() is … … 82 83 83 84 if (!CreateProcessA(exe, args, NULL, NULL, TRUE, 84 flags == _P_DETACH ? DETACHED_PROCESS : 0,85 env, NULL, &si, &pi))85 flags == _P_DETACH ? DETACHED_PROCESS : 0, 86 env, NULL, &si, &pi)) 86 87 { 87 88 __CRTDLL__set_errno(GetLastError()); … … 157 158 { 158 159 // return (_spawnve(i, s1, s2, s3)); 159 160 160 161 LPSTR args = __CRTDLL__argvtos(argv,' '); 161 162 LPSTR envs = __CRTDLL__argvtos(envv,0); … … 186 187 { 187 188 // return system(string); 188 189 189 190 /* FIXME: should probably launch cmd interpreter in COMSPEC */ 190 191 return __CRTDLL__spawn(_P_WAIT, NULL, x, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
