Clearing a Window with win 32

Hey there,

I am new to this and am teaching myself. I have been searching the internet but cannot find a reference to what I am trying to do. I have learned how to create a window, buttons, and menu for a win32 app so far. I wanted to write a program that would give someone a test. So my problem is now how do I keep a single window with radio buttons that changes each time the user enters an answer. Thank you for your help.

Will

p.s. I am just looking for a command that will clear the screen and maybe some advice on how to repopulate it thank you.
What do you mean by "clearing a window"? If you add a STATIC control to the dialog window, then you can use SetWindowText() to modify the text displayed in it at will. You would set it to "" to clear it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <windows.h>

void ClearScreen()
  {
  HANDLE                     hStdOut;
  CONSOLE_SCREEN_BUFFER_INFO csbi;
  DWORD                      count;
  DWORD                      cellCount;
  COORD                      homeCoords = { 0, 0 };

  hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
  if (hStdOut == INVALID_HANDLE_VALUE) return;

  /* Get the number of cells in the current buffer */
  if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return;
  cellCount = csbi.dwSize.X *csbi.dwSize.Y;

  /* Fill the entire buffer with spaces */
  if (!FillConsoleOutputCharacter(
    hStdOut,
    (TCHAR) ' ',
    cellCount,
    homeCoords,
    &count
    )) return;

  /* Fill the entire buffer with the current colors and attributes */
  if (!FillConsoleOutputAttribute(
    hStdOut,
    csbi.wAttributes,
    cellCount,
    homeCoords,
    &count
    )) return;

  /* Move the cursor home */
  SetConsoleCursorPosition( hStdOut, homeCoords );
  }


int main()
{
  
  ClearScreen();

  return 0;
}
@Michael: Your code is about clearing a console window, and the OP states it is a GUI window.
Can't you just clear a console window by doing a simplesystem("CLS");?
@BrokenSilenceDev. Again, this is NOT a console application.
@forloopfreak
GUI windows aren't typically meant to be "cleared" and repopulated. Repaint issues are specific to the GUI system you are working with -- with Win32 most standard controls know how to paint themselves, so you only need to do special painting when you handle your window's WM_PAINT event.

What exactly are you trying to accomplish with this?
Check out Qt.

If you build a QtWidget Based Application things are pretty much done for you. You just need to drag and drop the radio-buttons on text windows to where you want them to be. It's an easy way of getting a descent GUI.
Topic archived. No new replies allowed.