Thread: Borland c++ Enable/Disable

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    12

    Borland c++ Enable/Disable

    Hi,

    I've created a MDI application using the Borland C++ Wizard. I've added my own toolbuttons, but i want to enable/disable them when they are in use.

    So when there is no child form on screen i want eg. the save button to be disabled, but enabled when 1 or more child forms are on screen. I tried enabling the buttons when a child form is loaded, then disabled the buttons in the OnClose function of the Child form. This worked, however if i have multiple child forms open and i close one, then all the toolbar buttons are disabled, even though there is other child forms still on screen.

    Any help would be very, very grateful as i'm close to my deadline date, and would like to have all the little bits tidyed up and perfect.

    Thanks in advance for any help!!
    icc_81

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    I would create an int variable to hold the number of child windows that are still active at any time and make it local to the base window. Every time a child window is created I'd increase the variable in the base window. Everytime a child window is closed I'd decrease the value of the variable in the base window. I'd have the constructor and destructor of the child windows do the dirty work. Within the constructor and destructor of the child windows I'd also have a function that calls a checkVariableValue function from the base window. If the value of the variable is zero then the save button on the base window is not shown. However, if the size of the list is greater than zero then the save button on the base window isn't shown. It's been too long since I've done anything in BCB to know whether this type of sequence will actually work, but its a scheme you can brood upon and maybe if it doesn't work, you can come up with a scheme that will.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    12
    Hi,

    There's a function called MDIChildCount which counts all the different child processes open , however when i try to use an if statement, saying disable the buttons when MDIChildCount < 1 it does not work. It also does not let me state the MDIChildCount = 0.

    Any possible code idea that i may use would be very grateful. Thanks
    icc_81

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. enable/disable mouse cursor
    By toaster in forum C++ Programming
    Replies: 2
    Last Post: 08-22-2002, 10:47 AM
  2. Enable/Disable Frame Buttons :: MFC
    By kuphryn in forum Windows Programming
    Replies: 6
    Last Post: 06-24-2002, 08:14 AM
  3. Enable/Disable A Window in SplitView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 05-06-2002, 10:26 PM
  4. Enable/Disable Toolbar *Buttons* :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-08-2002, 11:20 PM