More work on splitting the Win16/32 support. There are a few problems I have thought about that will need to be addressed after we are done. In some places we might still be including headers we dont need. I will fix this later as one of my goals once all of this code is split is to be able to build these dlls with either WINE, MS_VC or Mingw headers. Also if there is a comdlg32 guru still lurking on the list I am going to need your help soon with the printer dialog support.
Thanks Steven
Changelog: Split Win16/32 color dialog support Supporting compiling out 16 bit find dialog support
Index: Makefile.in =================================================================== RCS file: /home/wine/wine/dlls/commdlg/Makefile.in,v retrieving revision 1.29 diff -u -r1.29 Makefile.in --- Makefile.in 7 Jun 2003 00:33:32 -0000 1.29 +++ Makefile.in 11 Jun 2003 21:43:47 -0000 @@ -18,7 +18,6 @@ filedlg.c \ filedlg95.c \ filedlgbrowser.c \ - finddlg.c \ finddlg32.c \ filetitle.c \ fontdlg.c \ @@ -26,7 +25,9 @@ printdlg.c C_SRCS16 = \ + colordlg16.c \ fontdlg16.c \ + finddlg.c RC_SRCS= rsrc.rc Index: colordlg.c =================================================================== RCS file: /home/wine/wine/dlls/commdlg/colordlg.c,v retrieving revision 1.40 diff -u -r1.40 colordlg.c --- colordlg.c 29 Apr 2003 22:52:02 -0000 1.40 +++ colordlg.c 11 Jun 2003 21:44:16 -0000 @@ -40,6 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg); #include "cdlg.h" +#include "colordlg.h" static INT_PTR CALLBACK ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ); @@ -63,28 +64,6 @@ 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL }, }; -struct CCPRIVATE -{ - LPCHOOSECOLORW lpcc; /* points to public known data structure */ - LPCHOOSECOLOR16 lpcc16; /* save the 16 bits pointer */ - int nextuserdef; /* next free place in user defined color array */ - HDC hdcMem; /* color graph used for BitBlt() */ - HBITMAP hbmMem; /* color graph bitmap */ - RECT fullsize; /* original dialog window size */ - UINT msetrgb; /* # of SETRGBSTRING message (today not used) */ - RECT old3angle; /* last position of l-marker */ - RECT oldcross; /* last position of color/satuation marker */ - BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */ - int h; - int s; - int l; /* for temporary storing of hue,sat,lum */ - int capturedGraph; /* control mouse captured */ - RECT focusRect; /* rectangle last focused item */ - HWND hwndFocus; /* handle last focused item */ -}; - -#define LCCPRIV struct CCPRIVATE * - /*********************************************************************** * CC_HSLtoRGB [internal] */ @@ -355,7 +334,7 @@ * CC_MouseCheckResultWindow [internal] * test if double click one of the result colors */ -static int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam ) +int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam ) { HWND hwnd; POINT point; @@ -808,7 +787,7 @@ /*********************************************************************** * CC_HookCallChk [internal] */ -static BOOL CC_HookCallChk( LPCHOOSECOLORW lpcc ) +BOOL CC_HookCallChk( LPCHOOSECOLORW lpcc ) { if (lpcc) if(lpcc->Flags & CC_ENABLEHOOK) @@ -817,11 +796,10 @@ return FALSE; } - /*********************************************************************** * CC_WMInitDialog [internal] */ -static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ) +LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ) { int i, res; int r, g, b; @@ -952,7 +930,7 @@ /*********************************************************************** * CC_WMCommand [internal] */ -static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) +LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) { int r, g, b, i, xx; UINT cokmsg; @@ -1104,7 +1082,7 @@ /*********************************************************************** * CC_WMPaint [internal] */ -static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ) +LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ) { HDC hdc; PAINTSTRUCT ps; @@ -1124,11 +1102,10 @@ return TRUE; } - /*********************************************************************** * CC_WMLButtonUp [internal] */ -static LRESULT CC_WMLButtonUp( HWND hDlg, WPARAM wParam, LPARAM lParam ) +LRESULT CC_WMLButtonUp( HWND hDlg, WPARAM wParam, LPARAM lParam ) { LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); if (lpp->capturedGraph) @@ -1141,11 +1118,10 @@ return 0; } - /*********************************************************************** * CC_WMMouseMove [internal] */ -static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ) +LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ) { LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); int r, g, b; @@ -1179,10 +1155,11 @@ } return 0; } + /*********************************************************************** * CC_WMLButtonDown [internal] */ -static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ) +LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ) { LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); int r, g, b, i; @@ -1234,7 +1211,6 @@ return FALSE; } - /*********************************************************************** * ColorDlgProc32 [internal] * @@ -1297,158 +1273,6 @@ break; } return FALSE ; -} - -/*********************************************************************** - * ColorDlgProc (COMMDLG.8) - */ -BOOL16 CALLBACK ColorDlgProc16( HWND16 hDlg16, UINT16 message, - WPARAM16 wParam, LONG lParam ) -{ - BOOL16 res; - HWND hDlg = HWND_32(hDlg16); - - LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); - if (message != WM_INITDIALOG) - { - if (!lpp) - return FALSE; - res=0; - if (CC_HookCallChk(lpp->lpcc)) - res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg16, message, wParam, lParam); - if (res) - return res; - } - - /* FIXME: SetRGB message - if (message && message == msetrgb) - return HandleSetRGB(hDlg, lParam); - */ - - switch (message) - { - case WM_INITDIALOG: - return CC_WMInitDialog(hDlg, wParam, lParam, TRUE); - case WM_NCDESTROY: - DeleteDC(lpp->hdcMem); - DeleteObject(lpp->hbmMem); - HeapFree(GetProcessHeap(), 0, lpp->lpcc); - HeapFree(GetProcessHeap(), 0, lpp); - SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */ - break; - case WM_COMMAND: - if (CC_WMCommand(hDlg, wParam, lParam, - HIWORD(lParam), HWND_32(LOWORD(lParam)))) - return TRUE; - break; - case WM_PAINT: - if (CC_WMPaint(hDlg, wParam, lParam)) - return TRUE; - break; - case WM_LBUTTONDBLCLK: - if (CC_MouseCheckResultWindow(hDlg,lParam)) - return TRUE; - break; - case WM_MOUSEMOVE: - if (CC_WMMouseMove(hDlg, lParam)) - return TRUE; - break; - case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/ - if (CC_WMLButtonUp(hDlg, wParam, lParam)) - return TRUE; - break; - case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/ - if (CC_WMLButtonDown(hDlg, wParam, lParam)) - return TRUE; - break; - } - return FALSE ; -} - - - -/*********************************************************************** - * ChooseColor (COMMDLG.5) - */ -BOOL16 WINAPI ChooseColor16( LPCHOOSECOLOR16 lpChCol ) -{ - HINSTANCE16 hInst; - HANDLE16 hDlgTmpl16 = 0, hResource16 = 0; - HGLOBAL16 hGlobal16 = 0; - BOOL16 bRet = FALSE; - LPCVOID template; - FARPROC16 ptr; - - TRACE("ChooseColor\n"); - if (!lpChCol) return FALSE; - - if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) - hDlgTmpl16 = lpChCol->hInstance; - else if (lpChCol->Flags & CC_ENABLETEMPLATE) - { - HANDLE16 hResInfo; - if (!(hResInfo = FindResource16(lpChCol->hInstance, - MapSL(lpChCol->lpTemplateName), - RT_DIALOGA))) - { - COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); - return FALSE; - } - if (!(hDlgTmpl16 = LoadResource16(lpChCol->hInstance, hResInfo))) - { - COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); - return FALSE; - } - hResource16 = hDlgTmpl16; - } - else - { - HRSRC hResInfo; - HGLOBAL hDlgTmpl32; - LPCVOID template32; - DWORD size; - if (!(hResInfo = FindResourceA(COMDLG32_hInstance, "CHOOSE_COLOR", RT_DIALOGA))) - { - COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); - return FALSE; - } - if (!(hDlgTmpl32 = LoadResource(COMDLG32_hInstance, hResInfo)) || - !(template32 = LockResource(hDlgTmpl32))) - { - COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); - return FALSE; - } - size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo); - hGlobal16 = GlobalAlloc16(0, size); - if (!hGlobal16) - { - COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE); - ERR("alloc failure for %ld bytes\n", size); - return FALSE; - } - template = GlobalLock16(hGlobal16); - if (!template) - { - COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE); - ERR("global lock failure for %x handle\n", hDlgTmpl16); - GlobalFree16(hGlobal16); - return FALSE; - } - ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template); - hDlgTmpl16 = hGlobal16; - } - - ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 8); - hInst = GetWindowLongA(HWND_32(lpChCol->hwndOwner), GWL_HINSTANCE); - bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChCol->hwndOwner, - (DLGPROC16) ptr, (DWORD)lpChCol); - if (hResource16) FreeResource16(hDlgTmpl16); - if (hGlobal16) - { - GlobalUnlock16(hGlobal16); - GlobalFree16(hGlobal16); - } - return bRet; } /*********************************************************************** --- /dev/null Wed Jun 11 17:47:59 2003 +++ colordlg16.c Tue Jun 10 19:44:40 2003 @@ -0,0 +1,195 @@ +/* + * COMMDLG - Color Dialog + * + * Copyright 1994 Martin Ayotte + * Copyright 1996 Albrecht Kleine + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* BUGS : still seems to not refresh correctly + sometimes, especially when 2 instances of the + dialog are loaded at the same time */ + +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "wine/winbase16.h" +#include "wine/winuser16.h" +#include "commdlg.h" +#include "dlgs.h" +#include "wine/debug.h" +#include "cderr.h" + +WINE_DEFAULT_DEBUG_CHANNEL(commdlg); + +#include "cdlg.h" +#include "colordlg.h" + +/*********************************************************************** + * ColorDlgProc (COMMDLG.8) + */ +BOOL16 CALLBACK ColorDlgProc16( HWND16 hDlg16, UINT16 message, + WPARAM16 wParam, LONG lParam ) +{ + BOOL16 res; + HWND hDlg = HWND_32(hDlg16); + + LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); + if (message != WM_INITDIALOG) + { + if (!lpp) + return FALSE; + res=0; + if (CC_HookCallChk(lpp->lpcc)) + res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg16, message, wParam, lParam); + if (res) + return res; + } + + /* FIXME: SetRGB message + if (message && message == msetrgb) + return HandleSetRGB(hDlg, lParam); + */ + + switch (message) + { + case WM_INITDIALOG: + return CC_WMInitDialog(hDlg, wParam, lParam, TRUE); + case WM_NCDESTROY: + DeleteDC(lpp->hdcMem); + DeleteObject(lpp->hbmMem); + HeapFree(GetProcessHeap(), 0, lpp->lpcc); + HeapFree(GetProcessHeap(), 0, lpp); + SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */ + break; + case WM_COMMAND: + if (CC_WMCommand(hDlg, wParam, lParam, + HIWORD(lParam), HWND_32(LOWORD(lParam)))) + return TRUE; + break; + case WM_PAINT: + if (CC_WMPaint(hDlg, wParam, lParam)) + return TRUE; + break; + case WM_LBUTTONDBLCLK: + if (CC_MouseCheckResultWindow(hDlg,lParam)) + return TRUE; + break; + case WM_MOUSEMOVE: + if (CC_WMMouseMove(hDlg, lParam)) + return TRUE; + break; + case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/ + if (CC_WMLButtonUp(hDlg, wParam, lParam)) + return TRUE; + break; + case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/ + if (CC_WMLButtonDown(hDlg, wParam, lParam)) + return TRUE; + break; + } + return FALSE ; +} + + + +/*********************************************************************** + * ChooseColor (COMMDLG.5) + */ +BOOL16 WINAPI ChooseColor16( LPCHOOSECOLOR16 lpChCol ) +{ + HINSTANCE16 hInst; + HANDLE16 hDlgTmpl16 = 0, hResource16 = 0; + HGLOBAL16 hGlobal16 = 0; + BOOL16 bRet = FALSE; + LPCVOID template; + FARPROC16 ptr; + + TRACE("ChooseColor\n"); + if (!lpChCol) return FALSE; + + if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) + hDlgTmpl16 = lpChCol->hInstance; + else if (lpChCol->Flags & CC_ENABLETEMPLATE) + { + HANDLE16 hResInfo; + if (!(hResInfo = FindResource16(lpChCol->hInstance, + MapSL(lpChCol->lpTemplateName), + RT_DIALOGA))) + { + COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); + return FALSE; + } + if (!(hDlgTmpl16 = LoadResource16(lpChCol->hInstance, hResInfo))) + { + COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); + return FALSE; + } + hResource16 = hDlgTmpl16; + } + else + { + HRSRC hResInfo; + HGLOBAL hDlgTmpl32; + LPCVOID template32; + DWORD size; + if (!(hResInfo = FindResourceA(COMDLG32_hInstance, "CHOOSE_COLOR", RT_DIALOGA))) + { + COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); + return FALSE; + } + if (!(hDlgTmpl32 = LoadResource(COMDLG32_hInstance, hResInfo)) || + !(template32 = LockResource(hDlgTmpl32))) + { + COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); + return FALSE; + } + size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo); + hGlobal16 = GlobalAlloc16(0, size); + if (!hGlobal16) + { + COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE); + ERR("alloc failure for %ld bytes\n", size); + return FALSE; + } + template = GlobalLock16(hGlobal16); + if (!template) + { + COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE); + ERR("global lock failure for %x handle\n", hDlgTmpl16); + GlobalFree16(hGlobal16); + return FALSE; + } + ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template); + hDlgTmpl16 = hGlobal16; + } + + ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 8); + hInst = GetWindowLongA(HWND_32(lpChCol->hwndOwner), GWL_HINSTANCE); + bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChCol->hwndOwner, + (DLGPROC16) ptr, (DWORD)lpChCol); + if (hResource16) FreeResource16(hDlgTmpl16); + if (hGlobal16) + { + GlobalUnlock16(hGlobal16); + GlobalFree16(hGlobal16); + } + return bRet; +} --- /dev/null Wed Jun 11 17:49:48 2003 +++ colordlg.h Wed Jun 11 17:49:44 2003 @@ -0,0 +1,82 @@ +/* + * COMMDLG - Color Dialog + * + * Copyright 1994 Martin Ayotte + * Copyright 1996 Albrecht Kleine + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* BUGS : still seems to not refresh correctly + sometimes, especially when 2 instances of the + dialog are loaded at the same time */ + +#ifndef _WINE_COLORDLG_H +#define _WINE_COLORDLG_H + +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "wine/winbase16.h" +#include "wine/winuser16.h" +#include "commdlg.h" +#include "dlgs.h" +#include "wine/debug.h" +#include "cderr.h" + +#include "cdlg.h" + +struct CCPRIVATE +{ + LPCHOOSECOLORW lpcc; /* points to public known data structure */ + LPCHOOSECOLOR16 lpcc16; /* save the 16 bits pointer */ + int nextuserdef; /* next free place in user defined color array */ + HDC hdcMem; /* color graph used for BitBlt() */ + HBITMAP hbmMem; /* color graph bitmap */ + RECT fullsize; /* original dialog window size */ + UINT msetrgb; /* # of SETRGBSTRING message (today not used) */ + RECT old3angle; /* last position of l-marker */ + RECT oldcross; /* last position of color/satuation marker */ + BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */ + int h; + int s; + int l; /* for temporary storing of hue,sat,lum */ + int capturedGraph; /* control mouse captured */ + RECT focusRect; /* rectangle last focused item */ + HWND hwndFocus; /* handle last focused item */ +}; + +#define LCCPRIV struct CCPRIVATE * + +/* + * Internal Functions + * Do NOT Export to other programs and dlls + */ + +BOOL CC_HookCallChk( LPCHOOSECOLORW lpcc ); +int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam ); +LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ); +LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ); +LRESULT CC_WMLButtonUp( HWND hDlg, WPARAM wParam, LPARAM lParam ); +LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD + notifyCode, HWND hwndCtl ); +LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ); +LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ); + +#endif /* _WINE_COLORDLG_H */