///////////////////////////////////////////////////////////////////////// // dcrtapp.cpp Source for decorate.exe sample application // demonstrating, // 1) how to paint the status bar in a decorated frame // window to have hints displayed in a sunken frame, // just like the BC++ IDE. // 2) how to implement a handler for WM_MENUSELECT // so that hints are displayed as the mouse is // dragged over the top level menu items in a // TDecoratedFrame // // Written by : George Cross, Borland C++ Developer Support // Date : June 14, 1996 // Compiler : Borland C++ 5.0, but is valid for 4.x and above ///////////////////////////////////////////////////////////////////////// #include #include //TControlBar #include "decrtapp.h" //DecorateApp #include "sdidecfr.h" //SDIDecFrame #include "pstatbar.h" //TProStatusBar #include "decrtapp.rh" //Resource identifiers DEFINE_RESPONSE_TABLE1 (SDIDecFrame, TDecoratedFrame) EV_WM_MENUSELECT, END_RESPONSE_TABLE; ////////////////////////////////////////////////////////// // SDIDecFrame // ===== // EvMenuSelect - Facilitates proper hint text appearing in the status // bar by setting the the TDecoratedFrame::MenuItemId // data member to the appropriate top level menu item // ID in either 16 or 32 bit. // void SDIDecFrame::EvMenuSelect(UINT menuItemId, UINT flags, HMENU hMenu) { // //If menu selection tracking is turned on, then. . . // if (TrackMenuSelection) // //If the top level of a pop-up menu was selected, then. . . // if (! (flags == 0xFFFF && hMenu == 0) && (flags & MF_POPUP)) { // //If we are in WIN32, use "menuItemId" and GetSubMenu to //obtain a handle to the pop-up menu. Then set the MenuItemId //member to the ID of the first item of the pop-up menu minus 1 // #ifdef __FLAT__ HMENU submenu = TMenu(hMenu).GetSubMenu(menuItemId); MenuItemId = ::GetMenuItemID(submenu, 0) - 1; #else // //Otherwise, if we are in 16-bit, the first parameter "menuItemId" //is set to the handle of the pop-up menu already. Set the //MenuItemId member to the ID of the first item in the pop-up, //minus one. // MenuItemId = TMenu((HMENU)menuItemId).GetMenuItemID (0) - 1; #endif } // //If the top level of a pop-up menu was not selected, then call //the base class function // else TDecoratedFrame::EvMenuSelect (menuItemId, flags, hMenu); } ////////////////////////////////////////////////////////// // DecorateApp // ===== // Constructor // DecorateApp::DecorateApp () : TApplication("Decorate") { } ////////////////////////////////////////////////////////// // DecorateApp // ===== // Application intialization. // void DecorateApp::InitMainWindow () { SDIDecFrame *frame = new SDIDecFrame(0, GetName(), new TWindow(0, ""), TRUE); nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWNORMAL : nCmdShow; // // Assign ICON w/ this application. // frame->SetIcon(this, IDI_SDIAPPLICATION); // // Menu associated with window // frame->AssignMenu(SDI_MENU); // // Associate with the accelerator table. // frame->Attr.AccelTable = SDI_MENU; // //Insert a status bar derived from TStatusBar in order to allow //us to override the TStatusBar::Paint function and display the //hint text in a sunken frame. // TProStatusBar *sb = new TProStatusBar(frame, TGadget::Recessed, TStatusBar::CapsLock | TStatusBar::NumLock | TStatusBar::ScrollLock | TStatusBar::Overtype); frame->Insert(*sb, TDecoratedFrame::Bottom); MainWindow = frame; } ////////////////////////////////////////////////////////// // OwlMain // =========== // Application entry point // int OwlMain (int , char* []) { DecorateApp App; int result; result = App.Run(); return result; }