Announcement

Collapse
No announcement yet.

Technique needed for single window with multiple form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Technique needed for single window with multiple form

    I'm looking for a better way to handle having 3 different user interface screens in one main application window. Basically only one of the screens needs to be active at any given point. The application is a card game similar to MSHearts. The three screens will be:
    - a setup screen (Number players, names, network setup)
    - main card playing screen( deal, play cards, count tricks)
    - a score screen (scores for last game, previous game, totals, etc.)

    I've tried disabling a form full of all the controls for one screen and generating all the controls for the second screen in a second form. This worked but I ended up with two entries on the windows taskbar and some of windows maximize, move, resize, restore functionality behaved in unexpected ways when switching between screens. With some extra code to fix the taskbar issue and sync the move/restore locations between all three forms this could work... but isn't there a simpler way?

    Another thought I had was to reuse the same form and just disable or enable the different sets of controls as needed. I'm sure this would work, but it will likely be a pain to maintain. Two of the screens will have a 100's of controls on them.

    I also cound have the "PlayGame" as the main form and pop-up the "Setup" and "Scores" forms as needed - but that seems to make it difficult to allow standard windows minimize, restore, move, etc. functions to affect the whole program.

    What other techniques are there to do this?

    I'm currently using firefly on this project, but I could go back to DDT if that will make it simpler.

  • #2
    I'm looking for a better way to handle having 3 different user interface screens in one main application window.
    Better than what? A screen shot of what you have might help us understand the problem.

    That said, you can use...MDI ...that's what it's made for. Multiple screens with different controls... one active at one time... easy to switch between for the user or to do so programmatically... exactly one entry on the taskbar....

    OR...

    Create each user interface screen as needed and destroy when done (as child of main screen)

    OR...
    Create all three screens (again as child of main screen) and use ShowWindow() to control which screen(s) are currently visible.

    BTW:
    >Two of the screens will have a 100's of controls on them

    Hundreds of separate controls? Sure you can't use a listview or listbox or something to combine a few of em?

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Originally posted by Michael Mattias View Post
      Hundreds of separate controls? Sure you can't use a listview or listbox or something to combine a few of em?
      hundreds of controls (in a few arrays) seems to work well for me.

      How to do it would depend upon the functionality required and performance observed, start with the simplest approach and refine it as performance dictates.

      Comment


      • #4
        The following code moves 47 different controls outside the window or into the window depending on the odd/even click of the stats button. In this case the controls are moved into the play area which is vacant. The Showstats button is only enabled between games, hence the vacant game area. You could adjust to suit your needs, like move out the game details, move in the scores/setup in similar fashion.

        All IDs in the Stats are sequential to facilitate this move. Works like a charm.
        Code:
        CASE %IDC_STATS
                  IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                    IF ISTRUE(stats) THEN
                      stats=0
                    ELSEIF ISFALSE(stats) THEN
                      stats=1
                    END IF
                    SELECT CASE stats
                      CASE 0
                        PRINTCCm (%IDC_STATS,"SHOW STATS")
                        FOR xx=2000 TO 2046      'get the present location and add 1000 to move it out of the window
                          CONTROL GET LOC CB.HNDL, xx TO xspot,yspot
                          CONTROL SET LOC CB.HNDL, xx, xspot+1000,yspot
                        NEXT xx
                      CASE 1
                        PRINTCCm (%IDC_STATS,"HIDE STATS")
                        FOR xx=2000 TO 2046      'get the present location and minus 1000 to set it in the window
                          CONTROL GET LOC CB.HNDL, xx TO xspot,yspot
                          CONTROL SET LOC CB.HNDL, xx, xspot-1000,yspot
                        NEXT xx
                    END SELECT
                  END IF
        The PRINTCCm is a multiline macro I use for setting text in most controls in a callback, as shown below, but other code would work.
        Code:
        MACRO PRINTCCm (eyeD,txt)
          CLEARCCm (eyeD,txt)
          CONTROL SET TEXT CB.HNDL, eyeD, txt
        END MACRO
        
        MACRO CLEARCCm (eyeD,txt)
          CONTROL SET TEXT CB.HNDL, eyeD, ""
          CONTROL REDRAW CB.HNDL, eyeD
        END MACRO
        Rod
        I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

        Comment


        • #5
          screenshots and questions

          Attached are shots of the 2 screens so far. The third one I haven't even started on until I figure out how to manipulate the screens beyond the first one.

          Click image for larger version

Name:	playgame.GIF
Views:	1
Size:	35.8 KB
ID:	725953


          Click image for larger version

Name:	scores.GIF
Views:	1
Size:	6.3 KB
ID:	725954


          Thanks for the replies and yes most of the controls are in arrays.

          I don't think it's a good candidate for an MDI interface, I'll check into it a bit more before I totally discount it though.

          Michael,
          can you clarify something for me with the create and destroy (or showwindow) technique. When I attempted this method and hid the main window and showed another the entry on the windows task manager vanished. Have I goofed something up or is there a trick to hiding the window without hiding the program from the windows taskbar.



          Rodney,
          I assume when you move the controls off-screen you also disable them so they don't accidentally get keyboard focus. I'd like to stay with firefly rather than go back to DDT but I don't think this technique will work well with firefly's wysiwyg enviroment. Main app window is pretty cluttered with 70+ controls on it as you can see.

          Click image for larger version

Name:	firefly-ide.GIF
Views:	1
Size:	40.0 KB
ID:	725955

          Any other simply ways to do this?

          Comment


          • #6
            Thanks again - I figured out what knowlege I was missing. Child windows do exactly what I need, especially when they've got the %WS_CHILD property set on them!

            Comment


            • #7
              I am not familiar with Firefly's specifics.
              However, the controls must have IDs, and I assume that Firefly must have some method of moving a control via a "SET LOCATION" of some sort, and if all controls are sequential it should be easy to put something similar under the menu item that will show the stat/score page, or the setup page. I don't disable the items in my apps but I could, but that too is easy enough at the same time that they are moved off the page.

              I use a button to toggle the action in mine, but it could be similar using the menu item. As for cluttered, my 47 controls fit in an area about the size of the cards in the partner's hand. Because they all move the same distance both directions (off and on) there is no messing with layout. And yours is a nice layout.
              Rod
              I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

              Comment


              • #8
                Bid? Pass?

                Brings back some memories for me. I haven't played competively for a long time but I can still hear those words it seems started every sentence after a session.....

                "You hold...."
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment

                Working...
                X