Creating check boxes with CreateWindowEx()?

So, in the program I'm writing, I need to use several check boxes. I remember seeing how to create them somewhere, but I'm now unable to find how to do it anywhere. Anyone know how I would create them using the function CreateWindowEx(), or something similar? Thanks.
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

static char *title = TEXT("Check Box");

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nCmdShow )
{
  MSG  msg ;    
  WNDCLASS wc = {0};
  wc.lpszClassName = TEXT( "Check Box" );
  wc.hInstance     = hInstance ;
  wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  wc.lpfnWndProc   = WndProc ;
  wc.hCursor       = LoadCursor(0, IDC_ARROW);

  
  RegisterClass(&wc);
  CreateWindow( wc.lpszClassName, title,
                WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                150, 150, 230, 150, 0, 0, hInstance, 0);  

  while( GetMessage(&msg, NULL, 0, 0)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return (int) msg.wParam;
}

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    
  switch(msg)  
  {
      case WM_CREATE:
      {
	    CreateWindow(TEXT("button"), TEXT("Show Title"),
                     WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
                     20, 20, 185, 35,        
                     hwnd, (HMENU) 1, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
	    CheckDlgButton(hwnd, 1, BST_CHECKED);
	    break;
      }

      case WM_COMMAND:
      {
           BOOL checked = IsDlgButtonChecked(hwnd, 1);
	    if (checked) {
	        CheckDlgButton(hwnd, 1, BST_UNCHECKED);
		 SetWindowText(hwnd, TEXT(""));
	    } else {
		 CheckDlgButton(hwnd, 1, BST_CHECKED);
		 SetWindowText(hwnd, title);
	    }
	    break;
       }

      case WM_DESTROY:
      {
           PostQuitMessage(0);
           break;
      }
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}	


Hope that helps..
That's exactly what I needed and more. Thank you!
Why don't you use MSDN ?
Therer are hundreds of code for Buttons

http://msdn.microsoft.com/en-us/library/bb775949(v=vs.85).aspx
Topic archived. No new replies allowed.