From: <mie...@us...> - 2007-07-02 05:37:07
|
Revision: 543 http://svn.sourceforge.net/oorexx/?rev=543&view=rev Author: miesfeld Date: 2007-07-01 22:37:09 -0700 (Sun, 01 Jul 2007) Log Message: ----------- [ 1738452 ] ooDialog - update ListControl. The first step towards updating ooDialog, determine which version of the Common Control Library is in use. Modified Paths: -------------- interpreter-3.x/trunk/platform/windows/oodialog/oovother.c interpreter-3.x/trunk/platform/windows/oodialog/oovuser.c interpreter-3.x/trunk/platform/windows/oodialog/oovutil.c interpreter-3.x/trunk/platform/windows/oodialog/oovutil.h Modified: interpreter-3.x/trunk/platform/windows/oodialog/oovother.c =================================================================== --- interpreter-3.x/trunk/platform/windows/oodialog/oovother.c 2007-07-01 23:35:21 UTC (rev 542) +++ interpreter-3.x/trunk/platform/windows/oodialog/oovother.c 2007-07-02 05:37:09 UTC (rev 543) @@ -35,6 +35,10 @@ /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*----------------------------------------------------------------------------*/ +#define NTDDI_VERSION NTDDI_WINXPSP2 +#define _WIN32_WINNT 0x0501 +#define WINVER 0x0501 + #include <windows.h> #include <mmsystem.h> #define INCL_REXXSAA Modified: interpreter-3.x/trunk/platform/windows/oodialog/oovuser.c =================================================================== --- interpreter-3.x/trunk/platform/windows/oodialog/oovuser.c 2007-07-01 23:35:21 UTC (rev 542) +++ interpreter-3.x/trunk/platform/windows/oodialog/oovuser.c 2007-07-02 05:37:09 UTC (rev 543) @@ -55,9 +55,8 @@ extern CRITICAL_SECTION crit_sec; extern BOOL DialogInAdminTable(DIALOGADMIN * Dlg); extern BOOL GetDialogIcons(DIALOGADMIN *, INT, BOOL, PHANDLE, PHANDLE); +extern BOOL InitForCommonControls(void); - -static BOOL CommCtrlLoaded = FALSE; //#define USE_DS_CONTROL @@ -408,6 +407,10 @@ else { CHECKARGL(8); + + if ( ! ComCtl32Version && ! InitForCommonControls() ) + RETC(0) + /* set number of items to dialogtemplate */ p = (DLGTEMPLATE *) atol(argv[4].strptr); if (!p) @@ -951,10 +954,6 @@ if (!strstr(argv[7].strptr,"HIDDEN")) lStyle |= WS_VISIBLE; if (strstr(argv[7].strptr,"GROUP")) lStyle |= WS_GROUP; if (strstr(argv[7].strptr,"DISABLED")) lStyle |= WS_DISABLED; - if (!CommCtrlLoaded) { - InitCommonControls(); - CommCtrlLoaded = TRUE; - } if (!strcmp(argv[0].strptr,"TREE")) { Modified: interpreter-3.x/trunk/platform/windows/oodialog/oovutil.c =================================================================== --- interpreter-3.x/trunk/platform/windows/oodialog/oovutil.c 2007-07-01 23:35:21 UTC (rev 542) +++ interpreter-3.x/trunk/platform/windows/oodialog/oovutil.c 2007-07-02 05:37:09 UTC (rev 543) @@ -37,6 +37,8 @@ /*----------------------------------------------------------------------------*/ #include <windows.h> #include <mmsystem.h> +#include <shlwapi.h> +#include <commctrl.h> #define INCL_REXXSAA #define INCL_RXMACRO #include <rexx.h> @@ -59,6 +61,7 @@ extern INT StoredDialogs = 0; extern CRITICAL_SECTION crit_sec = {0}; extern WPARAM InterruptScroll; +extern DWORD ComCtl32Version = 0; extern BOOL SearchMessageTable(ULONG message, WPARAM param, LPARAM lparam, DIALOGADMIN * addressedTo); extern BOOL DrawBitmapButton(DIALOGADMIN * addr, HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL MsgEnabled); @@ -71,9 +74,13 @@ extern LONG SetRexxStem(CHAR * name, INT id, char * secname, CHAR * data); extern BOOL GetDialogIcons(DIALOGADMIN *, INT, BOOL, PHANDLE, PHANDLE); extern HICON GetIconForID(DIALOGADMIN *, UINT, BOOL, int, int); +extern BOOL InitForCommonControls(void); INT DelDialog(DIALOGADMIN * aDlg); +#define COMCTL_ERR_TITLE "ooDialog - Windows Common Controls Error" +#define GENERIC_ERR_TITLE "ooDialog - Error" + LONG HandleError(PRXSTRING r, CHAR * text) { HWND hW = NULL; @@ -578,6 +585,9 @@ GET_ADM; if (!dlgAdm) RETERR; + if ( ! ComCtl32Version && ! InitForCommonControls() ) + RETC(0) + EnterCriticalSection(&crit_sec); if (!InstallNecessaryStuff(dlgAdm, &argv[1], argc-1)) { @@ -1283,6 +1293,86 @@ } +/** + * Convenience function to put up an error message box. + * + * @param pszMsg The message. + * @param pszTitle The title of for the message box. + */ +static void internalErrorMsg(PSZ pszMsg, PSZ pszTitle) +{ + MessageBox(0, pszMsg, pszTitle, MB_OK | MB_ICONHAND | MB_SYSTEMMODAL); +} + +/** + * Determines the version of comctl32.dll and initializes the common controls. + * + * The minimum version of 4.71 is supported on Windows 95 with Internet Explorer + * 4.0, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, and Windows 2000. + * + * @return TRUE if comctl32.dll is at least version 4.71, otherwise FALSE. + */ +BOOL InitForCommonControls(void) +{ + HINSTANCE hinst; + BOOL success = FALSE; + + hinst = LoadLibrary(TEXT("comctl32.dll")); + if ( hinst ) + { + DLLGETVERSIONPROC pDllGetVersion; + + pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinst, "DllGetVersion"); + if ( pDllGetVersion ) + { + DLLVERSIONINFO info; + + ZeroMemory(&info, sizeof(info)); + info.cbSize = sizeof(info); + if ( SUCCEEDED((*pDllGetVersion)(&info)) ) + ComCtl32Version = MAKEVERSION(info.dwMajorVersion, info.dwMinorVersion); + } + FreeLibrary(hinst); + } + + if ( ComCtl32Version == 0 ) + { + internalErrorMsg("The version of the Windows Common Controls library (comctl32.dll)\n" + "could not be determined. ooDialog will not run", COMCTL_ERR_TITLE); + } + else if ( ComCtl32Version < COMCTL32_4_71 ) + { + CHAR msg[256]; + sprintf(msg, "ooDialog can not run with this version of the Windows Common Controls library\n" + "(comctl32.dll.) The minimum version required is 4.71.\n\nThis system has version: %s\n", + ComCtl32Version == COMCTL32_4_0 ? "4.0" : "4.7" ); + + internalErrorMsg(msg, COMCTL_ERR_TITLE); + ComCtl32Version = 0; + } + else + { + INITCOMMONCONTROLSEX ctrlex; + + ctrlex.dwSize = sizeof(ctrlex); + ctrlex.dwICC = ICC_WIN95_CLASSES; + if ( ! InitCommonControlsEx(&ctrlex) ) + { + CHAR msg[128]; + sprintf(msg, "Initializing the Windows Common Controls library (InitCommonControlsEx)\n" + "failed. Windows System Error Code: %d\n", GetLastError()); + internalErrorMsg(msg, COMCTL_ERR_TITLE); + ComCtl32Version = 0; + } + else + { + success = TRUE; + } + } + return success; +} + + ULONG APIENTRY InstMMFuncs( PUCHAR funcname, ULONG argc, @@ -1295,6 +1385,10 @@ BOOL err = FALSE; retstr->strlength = 1; + /* If the common controls are not initialized, don't load. */ + if ( ! ComCtl32Version && ! InitForCommonControls() ) + RETC(1) + rc = RexxRegisterFunctionDll( "RemoveMMFuncs", VISDLL, @@ -1308,9 +1402,9 @@ } if (err) - RETC(1) /* not ok then return 1 so that old CLS files won't run */ - else - RETVAL(DLLVER) /* ok, so we return the DLL version */ + RETC(1) /* not ok then return 1 so that old CLS files won't run */ + + RETVAL(DLLVER) /* ok, so we return the DLL version */ } @@ -1359,6 +1453,10 @@ BOOL err = FALSE; retstr->strlength = 1; + /* If the common controls are not initialized, don't load. */ + if ( ! ComCtl32Version && ! InitForCommonControls() ) + RETC(1) + rc = RexxRegisterFunctionDll( "RemoveExtendedMMFuncs", VISDLL, @@ -1425,6 +1523,10 @@ BOOL err = FALSE; retstr->strlength = 1; + /* If the common controls are not initialized, don't load. */ + if ( ! ComCtl32Version && ! InitForCommonControls() ) + RETC(1) + rc = RexxRegisterFunctionDll( "RemoveUserMMFuncs", VISDLL, Modified: interpreter-3.x/trunk/platform/windows/oodialog/oovutil.h =================================================================== --- interpreter-3.x/trunk/platform/windows/oodialog/oovutil.h 2007-07-01 23:35:21 UTC (rev 542) +++ interpreter-3.x/trunk/platform/windows/oodialog/oovutil.h 2007-07-02 05:37:09 UTC (rev 543) @@ -69,6 +69,24 @@ extern LONG HandleError(PRXSTRING r, CHAR * text); +/* Defines for the different possible versions of comctl32.dll up to Windows + * XP SP2. These DWORD "packed version" numbers are calculated using the + * following macro: + */ +#define MAKEVERSION(major,minor) MAKELONG(minor,major) + +#define COMCTL32_4_0 262144 +#define COMCTL32_4_7 262151 +#define COMCTL32_4_71 262215 +#define COMCTL32_4_72 262216 +#define COMCTL32_5_8 327688 +#define COMCTL32_5_81 327761 +#define COMCTL32_5_82 327762 +#define COMCTL32_6_0 393216 + +/* The version of comctl32.dll in use when oodialog.dll is loaded. */ +extern DWORD ComCtl32Version; + /* macros to check the number of arguments */ #define CHECKARG(argexpct) { \ if (argc != argexpct) \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |