Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GUI frame work

GUI frame work

Scheduled Pinned Locked Moved C / C++ / MFC
c++ooptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dennis L
    wrote on last edited by
    #1

    Hi all! I'm working on a GUI frame work using Win32 C++. This GUI is based on classes and inheritance. I have stacked on something that might seem to be a little stupid! What's the best way to have access to the controls the most, and other vars of a window from another window! For example: // File Window.h class CWindow { // Functions public: // Vars private: // Other vars protected: } // File status.h class CStatusBar : CWindow { // Functions public: // Vars private: // Other vars protected: } // File MainFrame.h class CMainFrame : CWindow { // Functions public: // Vars private: // Other vars protected: // Status bar control CStatusBar* sb; } // File dialog.h class CDialogBox : CWindow { // Functions public: // Vars private: // Other vars protected: } I want the members of CDialogBox to have access to the status bar of the CMainFrame, even if the CMainframe is the parent of the parent of the CDialogBox I don't want to use MFC way or a way like: Constructor(CWindow* parent, ..), or global variables. If there's no such a way then what of the ways that I mensioned (and I don't like) would be more professional?? Thanks very much On whatever reply!

    C M 2 Replies Last reply
    0
    • D Dennis L

      Hi all! I'm working on a GUI frame work using Win32 C++. This GUI is based on classes and inheritance. I have stacked on something that might seem to be a little stupid! What's the best way to have access to the controls the most, and other vars of a window from another window! For example: // File Window.h class CWindow { // Functions public: // Vars private: // Other vars protected: } // File status.h class CStatusBar : CWindow { // Functions public: // Vars private: // Other vars protected: } // File MainFrame.h class CMainFrame : CWindow { // Functions public: // Vars private: // Other vars protected: // Status bar control CStatusBar* sb; } // File dialog.h class CDialogBox : CWindow { // Functions public: // Vars private: // Other vars protected: } I want the members of CDialogBox to have access to the status bar of the CMainFrame, even if the CMainframe is the parent of the parent of the CDialogBox I don't want to use MFC way or a way like: Constructor(CWindow* parent, ..), or global variables. If there's no such a way then what of the ways that I mensioned (and I don't like) would be more professional?? Thanks very much On whatever reply!

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Dennis L wrote:

      I don't want to use MFC way

      Is there a reason why ?

      Dennis L wrote:

      what of the ways that I mensioned (and I don't like) would be more professional??

      Use MFC. Why reinvent the wheel ?? Create a set of classes for a GUI framework is something very difficult. You will never be able to have something as powerfull as the MFC (or at leat not without spending a LOT of hours of work).

      D 1 Reply Last reply
      0
      • C Cedric Moonen

        Dennis L wrote:

        I don't want to use MFC way

        Is there a reason why ?

        Dennis L wrote:

        what of the ways that I mensioned (and I don't like) would be more professional??

        Use MFC. Why reinvent the wheel ?? Create a set of classes for a GUI framework is something very difficult. You will never be able to have something as powerfull as the MFC (or at leat not without spending a LOT of hours of work).

        D Offline
        D Offline
        Dennis L
        wrote on last edited by
        #3

        I have worked on MFC and I think that is a powerful package, but I'd like to create a very simple framework for now to check my abilities and what it would be like to create your own framework! If you please could tell me a way other than MFC I would appreciate it! Thanks again!

        1 Reply Last reply
        0
        • D Dennis L

          Hi all! I'm working on a GUI frame work using Win32 C++. This GUI is based on classes and inheritance. I have stacked on something that might seem to be a little stupid! What's the best way to have access to the controls the most, and other vars of a window from another window! For example: // File Window.h class CWindow { // Functions public: // Vars private: // Other vars protected: } // File status.h class CStatusBar : CWindow { // Functions public: // Vars private: // Other vars protected: } // File MainFrame.h class CMainFrame : CWindow { // Functions public: // Vars private: // Other vars protected: // Status bar control CStatusBar* sb; } // File dialog.h class CDialogBox : CWindow { // Functions public: // Vars private: // Other vars protected: } I want the members of CDialogBox to have access to the status bar of the CMainFrame, even if the CMainframe is the parent of the parent of the CDialogBox I don't want to use MFC way or a way like: Constructor(CWindow* parent, ..), or global variables. If there's no such a way then what of the ways that I mensioned (and I don't like) would be more professional?? Thanks very much On whatever reply!

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          First, why would a dialog need access to the mainframe's statusbar ? Second, I think that you need to have a parent window for a child dialog box, me think that win32 needs it ( I'm no expert on win32, so YMMV ). If your dialog box doesn't have a pointer to the mainframe, you will need to keep a global variable to the mainframe ( either a variable, or a global scope function that returns a pointer to the mainframe ) one other way would be to use some kind of messaging mecanism, either with ::SendMessage/::PostMessage or with a Observer/Observable pattern. for example ( high level pseudo code )

          CDialog::DoSomethingToMainFrameStatusBar()
          {
          CStatusBar* pStatusBar = YourMainFrameManager::GetStatusbar();

          }

          // where YourMainFrameManager is a class that contains pointers to "windows" ( or componements ) of the mainframe ( this class will need to know about the mainframe.
          CStatusBar* YourMainFrameManager::GetStatusbar()
          {
          return pMainFrame->getStatusBar();
          }


          Maximilien Lincourt Your Head A Splode - Strong Bad

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups