Question

i wanna make a windows database application with c++ builder. The idea is to have a static menu of 6 icons at the top (i need this to be constant in every screen) while the rest of the screen will host all user interactions and data regarding with the selected menu item. I have a litte experiece with SDI apps and as far as i know there is no way the whole application to be in a single screen / form. Should i build this like an MDI app or is there any other way to maintain a fixed icon based menu at top while the rest screen data to change for every different menu item? I dont want to be in a single window with no overlaping forms while user navigates through the application.

Was it helpful?

Solution

Although an MDI application is definitely possible, the interaction between the different forms sometimes is a little cumbersome. A tabbed page is easier to handle since everything then resides within the same TForm class. If you want to change the appearance of the individual tabs you can overload the 'PageControlDrawTab' Just add an event handler, get a handle to the Canvas of the tab itself and you are free to draw is as you want. See the example below:

void __fastcall TMainForm::PageControlDrawTab(TCustomTabControl *Control,
      int TabIndex, const TRect &Rect, bool Active)
{
/* OnDraw handler to change the appearance of the Tabs.
Change it to blue text on white background.
*/

  String s;
  TRect r;
  TTabControl * tTab =  (TTabControl *)Control; // Get a pointer to the tab itself
  s = tTab->Tabs->Strings[TabIndex];            // Retrieve the text of this tab
   Control->Canvas->Brush->Color = clWhite;     // Use  the Canvas to draw
   Control->Canvas->Font->Color = clBlue;       //  .. whatever you like  
   Control->Canvas->FillRect(Rect);
   Control->Canvas->TextRect(Rect,Rect.Left+4,Rect.Top+2,s);

}

OTHER TIPS

You will probably have to do it in a MDI format. I do not know of any way to share the menu across forms. The other option you could use though is to use a page control and have all the other "forms" live in a tab so the menu is the same all the time. The menu items could respond differently if you would like them to when the user is on a different tab, or they could do the same thing no matter what tab you are on. Sorry this is the form of an answer, I don't have comment rights yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top