// ======================================================================== // THIS TECHNICAL INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright 1997-1998 Giuseppe "Jo" Parrello. All Rights Reserved. // // Site : http://space.tin.it/computer/giparrel // E-Mail : joparrel@tin.it, giusparr@tin.it, giparre@tin.it // // Bugs, Tips, and Deepenings. Only for 5.02 users (unless specified). // // March 16, 1998. // // ======================================================================== ----------------------------------------------------------------- ----- TI000001: -------------------------------------------- ----------------------------------------------------------------- Q.: I've built a MDI application using AppExpert. When I open the document's system menu, I don't see any message on message bar. How can I do? A.: Go to ClassExpert and select the class derived from "TMDIChild" (in the following list is named "TAppMDIChild"). In the "Events" pane of ClassExpert open the "Windows Message" tree. Open the "Other Messages" tree and select "WM_MENUSELECT" message. Right click and select "Add handler" menu. ClassExpert has added a function for WM_MENUSELECT message in your TMDIChild derived class, called "EvMenuSelect". Add this code and be sure that the function seems as follows: void TAppMDIChild::EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu) { TMDIChild::EvMenuSelect(menuItemId, flags, hMenu); if ((flags & MF_SYSMENU)>0) { TMessageBar* messageBar = TYPESAFE_DOWNCAST (GetApplication()->GetMainWindow()->ChildWithId (IDW_STATUSBAR), TMessageBar); if (messageBar) { switch (menuItemId) { case SC_RESTORE : messageBar->SetHintText("Restore the active document to its previous size"); break; case SC_MOVE : messageBar->SetHintText("Moves the active document to another position"); break; case SC_SIZE : messageBar->SetHintText("Changes the size of the active document"); break; case SC_MINIMIZE : messageBar->SetHintText("Reduces the active document to an icon"); break; case SC_MAXIMIZE : messageBar->SetHintText("Enlarges the active document to its maximum size"); break; case SC_CLOSE : messageBar->SetHintText("Closes the active document"); break; case SC_NEXTWINDOW: messageBar->SetHintText("Switches to next document"); break; case SC_PREVWINDOW: messageBar->SetHintText("Switches to previous document"); break; default : { if ((flags==65535) && (hMenu==NULL)) messageBar->SetHintText(NULL); else messageBar->SetHintText("Active document operations"); } } } } } Add "owl/messageb.h" in your source file as this function uses TMessageBar class. ----------------------------------------------------------------- ----- TI000002: -------------------------------------------- ----------------------------------------------------------------- Q.: I've a MRU list in my application and I'd like to see a message for each MRU item on the message bar. How can I do? A.: Declare a constant named, for example, IDW_FIRSTMRU as 31990 (as defined in source "RCNTFILE.CPP" file): #define IDW_FIRSTMRU 31990 and make sure this define be visible by your .rc file. Then modify your .rc file adding a string declaration for each menu item starting from IDW_FIRSTMRU: STRINGTABLE { IDW_FIRSTMRU, "MRU File number 1" IDW_FIRSTMRU+1, "MRU File number 2" ...... } ----------------------------------------------------------------- ----- TI000003: -------------------------------------------- ----------------------------------------------------------------- Q.: I've built a MDI application using AppExpert. When I open the "Window" menu and go to the windows list, I don't see any message on message bar. How can I do? A.: You must modify the function "EvMenuSelect" in "DECFRAME.CPP" file (TDecoratedFrame class) in the following way: 1) Copy "DECFRAME.CPP" file from "/source" directory to your project directory. 2) Add "DECFRAME.CPP" in your project. 3) Open "DECFRAME.CPP" in your IDE. 4) Go to "EvMenuSelect" function and place a double comment parenthesis ("/* ..... */") in the line containing the "IDW_FIRSTMDICHILD" constant (the second line of "if" statement). 5) Modify your .rc file adding a string declaration for each menu item starting from IDW_FIRSTMDICHILD: STRINGTABLE { IDW_FIRSTMDICHILD, "Windows number 1" IDW_FIRSTMDICHILD+1, "Windows number 2" ...... } ----------------------------------------------------------------- ----- TI000004: -------------------------------------------- ----------------------------------------------------------------- Q.: Why in Win16 Targets I don't see the name of each menu item of a menu bar on message bar? A.: You must modify the function "GetMenuItemID" in "MENU.CPP" file (TMenu class) in the following way: 1) Copy "MENU.CPP" file from "/source" directory to your project directory. 2) Add "MENU.CPP" in your project. 3) Open "MENU.CPP" in your IDE. 4) Go to "GetMenuItemID" function and after the first "if" conditional block you must add the following lines: #if defined(BI_PLAT_WIN16) uint state = GetMenuState(pos, MF_BYPOSITION); if (state == uint(-1)) { uint id16 = ::GetMenuItemID((HMENU) pos,0); if ((id16 != uint(-1)) && ( id16 > 0)) return (id16 - 1); } #endif 5) Save the file. Modify your .RC file in the following way: If you used AppExpert you will find the first line in STRINGTABLE section of your .rc file like this: STRINGTABLE { -1, "File/Document operations" ..... } That is wrong. Change that in the following way: STRINGTABLE { CM_FILENEW - 1, "File/Document operations" // for SDI application or CM_MDIFILENEW - 1, "File/Document operations" // for MDI application ..... } ----------------------------------------------------------------- ----- TI000005: (BUG only for 5.01 and 5.02 release) ------- ----------------------------------------------------------------- Q.: I tried to enable CTL3D library using EnableCtl3d() function. But it doesn't work in Windows 3.1. Why? A.: There is a bug on Borland C++ 5.02. If you want to enable 3D Controls, try to search CTL3D.DLL in your system and, only if you find it, load it using "LoadLibrary" function. Use "GetProcAddress" to retrieve "Ctl3dRegister" and "Ctl3dAutoSubClass" functions and execute them. At the end of your application, use "Ctl3dUnregister" function and then "FreeLibrary". EnableCtl3d() runs well on Borland C++ 5.00 release. ----------------------------------------------------------------- ----- TI000006: (BUG for 5.0, 5.01 and 5.02 release) ------- ----------------------------------------------------------------- Q.: I tried to set a value on registry using SetValue function from TRegKey class. It doesn't run well. Why? A.: There is a bug on Borland C++ 5.0, 5.01 and 5.02 releases. If you want to set a value on Win16 target applications, you must change the file "REGISTRY.H" in this way: 1) Make a backup copy of file "REGISTRY.H" in directory "\BC5\INCLUDE\WINSYS". 2) Edit the file "registry.h" and go to "SetValue" function. 3) Change the line : #if defined(BI_PLAT_WIN16) return ::RegSetValue(Key, 0, type, (LPCSTR)data, dataSize); to : #if defined(BI_PLAT_WIN16) return ::RegSetValue(Key, valName, type, (LPCSTR)data, dataSize); Now this function runs well. ----------------------------------------------------------------- ----- TI000007: (BUG for 5.0, 5.01 and 5.02 release) ------- ----------------------------------------------------------------- Q.: I tried to read a value from registry using QueryValue function from TRegKey class. It doesn't run well. Why? A.: There is a bug on Borland C++ 5.0, 5.01 and 5.02 releases. If you want to read a value from registry on Win16 target applications, you must change the file "REGISTRY.H" in this way: 1) Make a backup copy of file "REGISTRY.H" in directory "\BC5\INCLUDE\WINSYS". 2) Edit the file "registry.h" and go to "QueryValue" function. 3) Change the line : #if defined(BI_PLAT_WIN16) return ::RegQueryValue(Key, 0, (LPSTR)data, (long*)dataSize); to : #if defined(BI_PLAT_WIN16) return ::RegQueryValue(Key, valName, (LPSTR)data, (long*)dataSize); Now this function runs well.