How to go about this?

This is a discussion on How to go about this? within the Windows Programming forums, part of the Platform Specific Boards category; I writing this program that tests the user on the given questions and answers. Now, I'm giving them the option ...

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    How to go about this?

    I writing this program that tests the user on the given questions and answers. Now, I'm giving them the option to have multiple choice, fill in the blank, True and Fasle, etc. My question is this...

    So, just imagine a static (with the question) and, for example, four radio buttons for multiple choice. But! The next question is a fill-in-the-blank! Which is a static and a text box. How would I go about changing/hiding the four radio buttons from the previous type of question? What I mean is, there are going to be a couple of controls, but then when the type of question changes, there are going to have to be different controls for the different types of questions. How would I do this? Hide all of the controls and then when I need them hide the ones that are on and make the ones needed unhidden? How would I do this?
    1978 Silver Anniversary Corvette

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hmmm, i would suggest writing your own function and passing it some data telling it what the type of question is.

    Then use the function ShowWindow() to show/hide your controls.

    Say for instance:

    Code:
    void UpdateDisplayControls(int qtype)
    {
    if(qtype == 1)
    {
    //say 1 is fill in the blank so use ShowWindow() to hide your radio 
    //buttons
    }
    
    else
    {
    //say 2 is mutlipe radio choice, so use ShowWindow() to hide the 
    //edit box
    
    }
    
    }

    Hope that helps, ShowWindow should look like this:

    ShowWindow(hWndRadio1, SW_HIDE);

    SW_SHOW is the other param


    Cheers,
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Okay, I'll go off from here. Thanks, TNT!
    1978 Silver Anniversary Corvette

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,657
    Another thing you could do Garf is to create separate arrays for each "screen". Two simple functions like these could be used:

    void Show( HWND array[], int thisMany)
    {
    int c = 0;

    while(c < thisMany)
    ShowWindow(array[c++], SW_SHOW);
    }




    void Hide( HWND array[], int thisMany)
    {
    int c = 0;

    while(c < thisMany)
    ShowWindow(array[c++], SW_HIDE);
    }

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    That's a good idea, Sebastiani. But, the array (you var 'array') would have to be an array of hwnds, because that is the param of ShowWindow. Thanks! I'm going to do it that way.
    1978 Silver Anniversary Corvette

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    I would create small dialogs for the answer part. ie one with a static and edit for the fill in the blanks and one with the radio buttons for the multi choice.

    Create all the answer dlgs at WM_INIT to the correct ratio based on screen size.

    Hide them all.

    When a question is asked just use SetWindowPos() to paste the right answer dlg to the right place on screen and show it.

    Set them up with the same parent and winproc.

    This way there is no wasted space where ctrls are there but hidden. (as all the crls are stacked on top of each other in small dlg's)
    "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
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I'm not sure I understand what you are saying. So you make it so that there are separate dlgs besides the main window? I think I might see if I can do it that way.
    1978 Silver Anniversary Corvette

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    57
    Wow, I was getting ready to make a topic like this... I have almost the same problem. Whenever the player clicks a button on the main screen, my clear screen function i made just covers everything up, so the next screen if you click where that button was it appears again and does whatever it does. So I am not sure how to do this... is there anyway to program this stuff into my clear screen function? btw, here is what it is:

    Code:
    void ClearWindow(HWND hwnd)
    {
    	HDC hdc = GetDC(hwnd); 
    	RECT rect = {0}; 
    	GetClientRect(hwnd,&rect); 
    	FillRect(hdc,&rect,(HBRUSH)GetStockObject(WHITE_BRUSH));
    	ReleaseDC(hwnd,hdc);
    }
    Thanks lot. and im using C++ regular windows btw.
    Last edited by Tazar_Azar; 04-15-2002 at 03:47 PM.
    Language: C++
    Compiler: Visual C++ 6.0
    Currently Working On: Simple OpenGL aspects

  9. #9
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Garfield,
    Yes. A seperate dlg for each combination of controls. That is, one for each type of answer. Hide the ones you don't need, show and set position of the one you do as each new question is 'asked'.

    Tazar,
    If I understand correctly, you need to UpdateWindow() or InvalidateRect() on the button after clearing the screen to make it reappear.
    "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

  10. #10
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> Tazar,
    If I understand correctly, you need to UpdateWindow() or InvalidateRect() on the button after clearing the screen to make it reappear. <<

    Wouldn't you need to do both? Invalidating it will only clear it, you'll have to call the procedure's WM_PAINT message to redraw.
    1978 Silver Anniversary Corvette

  11. #11
    Registered User
    Join Date
    Feb 2002
    Posts
    57
    I want the buttons to be erased for good once they click on the Start Game button. I tried the InvalidateRect Function, but it requires 3 arguments according to the yellow thing that popped up on VC++. The hwnd is ok, then it said
    "CONST RECT *lpRect, BOOL bErase);"
    So what would i put for them two?
    I moved the ShowWindow(hwndStart, SW_HIDE); for all of the buttons into the Clear Screen function, so I guess I put the InvalidateRect Function above them inside the ClearWindow function? thanx!
    Language: C++
    Compiler: Visual C++ 6.0
    Currently Working On: Simple OpenGL aspects

  12. #12
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Use GetClientRect (this is the function, I recall) to get the rectangle.
    1978 Silver Anniversary Corvette

  13. #13
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    >> Tazar, If I understand correctly, you need to UpdateWindow() or InvalidateRect() on the button after clearing the screen to make it reappear. <<

    >> Garfield Wouldn't you need to do both? Invalidating it will only clear it, you'll have to call the procedure's WM_PAINT message to redraw.

    Both are different methods of sending a paint msg. Paint only draws the invalidated area.
    "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

Popular pages Recent additions subscribe to a feed

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