Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Joao Paulo Negri
|
Mar 23, 2004 - 12:23 PM
|
When I compile my project using the library’s debug version provided by you freely in the site (compiled with or without SP5) it works fine, the menubar appears OK in Windows NT 4.0 and in Windows XP. When I compile the Prof-UIS library in my machine (With Windows XP, Visual Studio 6.0 with SP5 and Microsoft Platform SDK Frebruary 2003) the menubar appears with no itens in Windows NT 4.0, either in debug or release version. It works fine on Windows XP. I did not change anything in source code or in library project. I ’ve already tried to define in my project: _WIN32_IE=0x0400 _WIN32_WINNT=0x0400 These definitions were in the library project when I install the Prof-UIS library. Thanks
|
|
Joao Paulo Negri
|
Mar 24, 2004 - 7:37 AM
|
The problem occurs when I call g_CmdManager->UpdateFromMenu(pApp->m_pszProfileName,IDR_MAINFRAME); in ::GetMenuItemInfo(hMenu,nMenuItemIdx,TRUE, &mii ) Like Gary Hughes problem (posted in Jul 4,2002), but even if I define: _WIN32_IE=0x0400 _WIN32_WINNT=0x0400 it doesn’t work. If I call ::GetLastError it returns 87 (The parameter is incorrect. ERROR_INVALID_PARAMETER) The strange fact is that it works if I use the same Prof-UIS library provided by you on this site, and it doesn’t work on Win NT4 if I compile the library on my machine.
Any suggestions?
|
|
Technical Support
|
Mar 24, 2004 - 8:41 AM
|
Dear Joao,
Yes, you need to add these macro definions to your C++ project settings and to the Prof-UIS library project settings:
_WIN32_IE=0x0400
_WIN32_WINNT=0x0400
Then, rebuild both the library and your project. That should make your program WinNT4 compatible. Of course, the library’s samples should also be recompiled.
Here is a short description of this snag.
Many structures in Win32 automatically include additional members if any of the above preprocessor macro symbols are set to values equal to or greater than 0x0500 . For example, MENUITEMINFO in WINUSER.H is defined as:
#if(WINVER >= 0x0400)
typedef struct tagMENUITEMINFOA
{
UINT cbSize;
UINT fMask;
UINT fType; // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)
UINT fState; // used if MIIM_STATE
UINT wID; // used if MIIM_ID
HMENU hSubMenu; // used if MIIM_SUBMENU
HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS
HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS
DWORD dwItemData; // used if MIIM_DATA
LPSTR dwTypeData; // used if MIIM_TYPE (4.0) or
MIIM_STRING (>4.0)
UINT cch; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
#if (_WIN32_WINNT >= 0x0500)
HBITMAP hbmpItem; // used if MIIM_BITMAP
#endif
} MENUITEMINFOA, FAR *LPMENUITEMINFOA;
If you compile your program with _WIN32_WINNT equal to 0x0500 or greater, then that structure is larger than the structure which several WinNT4 API functions wait for. In this case WinNT4 API frequently causes failures.
So compile your program with the above macro definions and it will be compatible with Win9x, WinME, WinNT4, Win2K, WinXP, and, probably, with future Windows OSes.
|
|
Joao Paulo Negri
|
Mar 24, 2004 - 12:15 PM
|
OK, I found a solution. Before compile the Library, I removed the Platform SDK directories from Visual Studio Options/Directory Menu (include,source,library and executables). Then my project worked fine on WinNT 4. Thanks
|
|
Joao Paulo Negri
|
Mar 24, 2004 - 10:53 AM
|
If I compile any project and put: sTemp.Format("_WIN32_IE = 0x%X",_WIN32_IE); AfxMessageBox(sTemp); sTemp.Format("_WIN32_WINNT = 0x%X",_WIN32_WINNT); AfxMessageBox(sTemp); sTemp.Format("WINVER = 0x%X",WINVER); AfxMessageBox(sTemp); It returns: _WIN32_IE = 0x400 _WIN32_WINNT = 0x400 WINVER = 0x501 _WIN32_IE = 0x400 and MENUITEMINFO is defined as: #if(WINVER >= 0x0400) typedef struct tagMENUITEMINFOA { UINT cbSize; UINT fMask; UINT fType; // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0) UINT fState; // used if MIIM_STATE UINT wID; // used if MIIM_ID HMENU hSubMenu; // used if MIIM_SUBMENU HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS ULONG_PTR dwItemData; // used if MIIM_DATA LPSTR dwTypeData; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0) UINT cch; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0) #if(WINVER >= 0x0500) HBITMAP hbmpItem; // used if MIIM_BITMAP #endif /* WINVER >= 0x0500 */ } MENUITEMINFOA, FAR *LPMENUITEMINFOA; If I define in my project WINVER=0x0400 thrers is a exception in my program
|
|
Joao Paulo Negri
|
Mar 24, 2004 - 10:27 AM
|
It doesn’t work. The function ::GetMenuItemInfo fails on WinNT4 even if i define WIN32_IE=0x0400 _WIN32_WINNT=0x0400
I create a new project and put on CMainFrame::OnCreate: CMenu menu; if(!menu.LoadMenu(IDR_MAINFRAME) ) { ASSERT(FALSE); return false; } CString sTemp = ""; sTemp.Format("_WIN32_IE = 0x%X",_WIN32_IE); AfxMessageBox(sTemp); sTemp.Format("_WIN32_WINNT = 0x%X",_WIN32_WINNT); AfxMessageBox(sTemp); HMENU hMenu = menu.GetSafeHmenu(); int nMenuItemCount = ::GetMenuItemCount(hMenu); for(int nMenuItemIdx=0; nMenuItemIdx < nMenuItemCount;nMenuItemIdx++) { MENUITEMINFO mii; ::memset( &mii, 0, sizeof(MENUITEMINFO) ); mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_CHECKMARKS |MIIM_DATA |MIIM_ID |MIIM_STATE |MIIM_SUBMENU |MIIM_TYPE ; mii.cch = 1024; CString sMenuText; mii.dwTypeData = sMenuText.GetBuffer(1024); ASSERT( mii.dwTypeData != NULL ); if( mii.dwTypeData == NULL ) { ASSERT(FALSE); } mii.dwTypeData = NULL; if( !::GetMenuItemInfo(menu.GetSafeHmenu(),nMenuItemIdx,TRUE,&mii)) { sMenuText.ReleaseBuffer(); AfxMessageBox("FAIL!!!"); } else { AfxMessageBox("OK!!!"); } } /////////////////////////////////////// The AfxMessageBox shows the version of WIN32_IE and _WIN32_WINNT as 0x0400, but the command fails only in WinNT4
|
|