I've been experimenting with this simple Generic Windows tutorial program (Windows API Tutorial: Generic), and I was wondering if someone could help me understand something about it.
Basically in the process of experimenting with it, I've added the following code into main, which makes it draw loads of lines in spirals all over the screen:
First at the top of int main, I added:
Then in main, after "int status;", I added:
int x1=0, x2=0, y1=0, y2=0;
Now, if I run it like that, the lines will draw, but only if I move the mouse around in the process. I think that's due to BeginPaint and EndPaint getting run whenever I do that. But say I get rid of pCtrl->Paint (); in the following part of control.cpp:
HWND hwnd = topWinClass.GetRunningWindow ();
HDC _hdc = GetDC (hwnd);
while ((status = ::GetMessage (&msg, 0, 0, 0)) != 0)
::MoveToEx (_hdc, x1, y1, 0);
::LineTo (_hdc, x1, y1);
::LineTo (_hdc, x2, y2);
if (x2 < 800 && y2 == 0)
else if (x2 == 800 && y2 < 800)
else if (x2 > 0 && y2 == 800)
else if (x2 == 0 && y2 > 0)
if (x2 == 0 && y2 > 0 && y2 < 50)
x1 += 20;
y1 += 20;
if (status == -1)
Then, the lines get drawn all over the screen without me having to move the mouse around.
So my questions are:
1. If I resize the window with pCtrl->Paint() removed, all the previously-drawn lines disappear from the window. Why is this?
2. If I minimise and then bring the window back up, all my lines disappear, but the original text in the program (just the word generic in the top left of the window) stays there, fine. How come?
Sorry if this is a long-winded thing to ask about. It just seems like if I can get this stuff worked out, I could start using windows to display stuff instead of just the console, which would be awesome.