c++buildermdisdi

c++ builder MDI / SDI or other approach?


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.


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);
    
    }