1 application - 4 tasks :: how to seperate?

This is a discussion on 1 application - 4 tasks :: how to seperate? within the Windows Programming forums, part of the Platform Specific Boards category; hi there! i want to program an application. this application supports 4 tasks which you can do. yet i didn't ...

  1. #1
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244

    1 application - 4 tasks :: how to seperate?

    hi there!

    i want to program an application. this application supports 4 tasks which you can do. yet i didn't separate them correctly. they were in different tab pages in one window and one 1200 lines code file.

    now i tried to separate them to mdi children (see here: MDI children always maximized? )
    which didnt work!

    now's the question: how do i separate this like the pros do?
    thanks

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Hard to design with this limited information...

    Generally the 'tasks' run in a window or dialog. Modal if other user actions need to be restricted.

    Create a base class for the shared / common functionality for this window / dialog (create, paint, size, close, etc). Other classes handle threading, signaling, logging etc.

    Derive from this class individual child classes for each task. Try to keep as much functionality in the base class, as this makes maintaining the code easier.

    Derive smaller classes for control specialization (ie edit control for currency)

    That should break the code up and make finding errors easier.

    Remember a method / function should do one thing well. Smaller methods are easier to re-use.

    More specific info will get a better answer...
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    this is my application yet:
    http://stuff.dev-ch.de/content/screenshots/eWork_4.jpg

    as you see, the four tasks are seperated by tabs. they all are melted into 1200 lines of messy code.

    as said before, i tried to seperate them to MDI children (see here: MDI children always maximized? )

    now's the question: how do i seperate them in the code, but still keep the user seeing the application as a whole all-in-one complex?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Find the common behaviors of 'tabs' in your system and place them into an interface. Derive your existing tabs from the interface. Keep all implementation of the specific tabs out of the interface.

    Some things that all tabs must do:
    • Initialize
    • Clean up
    • Draw
    • Accept input

  5. #5
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    this still sounds messy. maybe my idea of putting everything into separate MDI children would work, but there are some major problems, too.

    please help me out here, too: MDI children always maximized?

    thanks.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Handle the OnSize() / WM_SIZE msg and restrict the size?

    but MDI does not sound like the right tool for this job.

    Why not use a TAB control, with child dialogs overlayed? (which is easier than multiple runtime controls)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    Handle the OnSize() / WM_SIZE msg and restrict the size?
    any specific code example for that?
    restrict the size? i think i only need to restrict it to stay always maximized, even if i switch between those tasks using buttons.

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    something like this in the base (interface) class...(not tested)

    This is WIN32 as you have not mentioned a language, though it looks like managed C++.

    Code:
    case WM_SIZE:
    //try just bypassing the default processing that allows a window to change size
    if (wParam == SIZE_MINIMISED || wParam == SIZE_RESTORED)
    {
       //try just ignorting this msg
       return 0;
    
       //OR 
       //if above does not work 
       //may have to restrict size by setting the lParam to the required width and height.
       //set the flag to maximise
       wParam = SIZE_MAXIMISED;
       //set the size to the maximised size
       lParam = MAKELPARAM(iMaxWidth, iMaxHeight);
       //now let windows process the msg
       return true;
    
    }
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  9. #9
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    eh, well. i'm programming in managed c#. might shoulda have said it before sry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cleanup of the application...
    By Petike in forum Windows Programming
    Replies: 1
    Last Post: 08-16-2008, 05:23 PM
  2. Problem with com application
    By amardon in forum C++ Programming
    Replies: 3
    Last Post: 10-06-2005, 05:50 AM
  3. MFC run application by clicking on file...
    By dug in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2004, 03:33 AM
  4. Win application not very portable
    By swed in forum Windows Programming
    Replies: 5
    Last Post: 10-01-2001, 11:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21