Trying to draw solid shapes in winapi

I am sure that I am missing something very simple. I am trying to draw a number of circles corresponding to nodes on a graph. Nothing is coming up. The drawing occurs in response to a winpaint message from a function which produces the various location variables for the circles. Big thanks to anyone who takes the time to help! Here is the code:


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
48
49
50
LRESULT CALLBACK VisProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	switch(msg)
	{
		case WM_CREATE:
		{
			break;
		}
		case WM_PAINT:
		{
			hdc=BeginPaint(hwnd,&ps);
			map<int,set<int>>::iterator l=wf.dag.layers.end();
			double layerNum=0;
			COLORREF col=RGB(22,28,218);
			for (map<int,set<int>>::iterator p=wf.dag.layers.begin();p!=l;++p)
			{
				double nodeNum=0;
				set<int>::iterator l2=(p->second).end();
				for (set<int>::iterator p2=(p->second).begin();p2!=l2;++p2)
				{
					int size=min(wf.dag.hunit,wf.dag.vunit);
					HBRUSH brush=CreateSolidBrush(col);
					LOGBRUSH blog;
					HPEN pen=ExtCreatePen (PS_GEOMETRIC,1,&blog,0,0);
					blog.lbColor=col;
					blog.lbStyle=BS_SOLID;
					blog.lbHatch=0;
					SelectObject(hdc,pen);
					int hNum=(nodeNum+.5)*wf.dag.hunit;
					int vNum=(layerNum+.5)*wf.dag.vunit;
					Ellipse(hdc,hNum-size,vNum-size,hNum+size,vNum+size);
				}
				++layerNum;
			}
		}

	case WM_SIZE:
		{
			//TO DO!!!
			break;
		}
	default:
		{
		return DefWindowProc(hwnd, msg, wParam, lParam);
		}
	}
	return 0;
}
closed account (z05DSL3A)
Just a quick look...I can't see an EndPaint()
1
2
3
4
5
6
7
8
     case WM_PAINT:
    {
          hdc = BeginPaint (hwnd, &ps) ;
          //
          // ...
          EndPaint (hwnd, &ps) ;
          break; // or return 0 ;  
    }
Thanks - have remedied that.

The problem, though, was something different: because the values are not initilised when the window is first created I needed to use InvalidateRect rather than simply sending a WM_PAINT message - otherwise it only drew when called to redraw by the system.
Topic archived. No new replies allowed.