GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Oct-2011, 23:42
TransformedBG TransformedBG is offline
Member
 
Join Date: Oct 2006
Posts: 118
TransformedBG is on a distinguished road

How to check and uncheck check boxes?


So ive been writing a menu
CPP / C++ / C Code:
void mainMenu(HWND& hwnd,HINSTANCE& hinstance, LPCSTR windowName, LPCSTR winClass)
{
	counter ++;
	ScreenX = checkX(ScreenX);
	ScreenY = checkY(ScreenY);
	hwnd = CreateWindowEx(NULL,	                // extended style
                              winClass,			// class
			      windowName,		// title
			      WS_SYSMENU | WS_VISIBLE,
			      10,10,			// initial x,y
			      ScreenX, ScreenY,		// initial width, height
			      NULL,			// handle to parent
			      NULL,			// handle to menu
			      hinstance_app,		// instance of this application
			      NULL);   
	
	main_window_handle = hwnd;

	#define BUTTON_BASE_ID 100
	#define NUM_BUTTONS 13

	char *button_names[NUM_BUTTONS] = 
	{	"Class Rooms",
		"Restrooms",
		"Hall Ways",
		"Elevator",
		"Closets",
		"Office",
		"Auditorum",
		"Display Area",
		"Server Room", 
		"Stairs",
		"Unknown",
		"Push to load map",
		"Clear All Checks"};

	long button_types[NUM_BUTTONS] = 
	{	BS_AUTOCHECKBOX, 
		BS_AUTOCHECKBOX,
		BS_AUTOCHECKBOX,
		BS_AUTOCHECKBOX, 
		BS_AUTOCHECKBOX,
		BS_AUTOCHECKBOX,
		BS_AUTOCHECKBOX, 
		BS_AUTOCHECKBOX,
		BS_AUTOCHECKBOX,
		BS_AUTOCHECKBOX, 
		BS_AUTOCHECKBOX,
		BS_PUSHBUTTON,
		BS_PUSHBUTTON};
	
	for(int button = 0; button < NUM_BUTTONS; button++)
	{
		CreateWindowEx(NULL,											// extended style
					   "button",										// class
					   button_names[button],							// title
					   WS_CHILD | WS_VISIBLE | button_types[button],	// Child, Visible, of button types
					   10,10+button*36,									// initial x,y
					   /*strlen(button_names[button])*16*/200,24,		// initial width, height
					   main_window_handle,								// handle to parent
					   (HMENU)(BUTTON_BASE_ID + button),				// handle to menu
					   hinstance,										// instance of this application
					   NULL);											// extra creation parms
	}// end for button
}

Im in the Call back function trying to get the clear all checkboxes button to work.

CPP / C++ / C Code:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	PAINTSTRUCT ps;
	HDC		hdc;

	switch(msg)
	{
		case(WM_CREATE): //Create Class
		{
			return(0);
		}break;

		case(WM_PAINT): // Paint the Class
		{
			hdc = BeginPaint(hwnd,&ps);
			EndPaint(hwnd,&ps);
			return(0);
		}break;

		case(WM_COMMAND): //For Buttons
		{
			hdc = GetDC(hwnd);  // get the dc
			SetBkMode(hdc, OPAQUE); // set background mode
			SetTextColor(hdc, RGB(0.0,0.0,0.0));  // select a text color
			SetBkColor(hdc, RGB(255,255,255));  // select a random background color
			ReleaseDC(hwnd, hdc); //release DC


			switch(LOWORD(wparam))
			{
				case 100:
				{
					classRooms = checkState(classRooms);
				}break;

				case 101:
				{
					restRooms = checkState(restRooms);

				}break;

				case 102:
				{
					hallways = checkState(hallways);
				}break;

				case 103:
				{
					elevator = checkState(elevator);
				}break;

				case 104:
				{
					closet = checkState(closet);
				}break;

				case 105:
				{
					office = checkState(office);
				}break;

				case 106:
				{
					auditorium = checkState(auditorium);
				}break;

				case 107:
				{
					displayArea = checkState(displayArea);
				}break;

				case 108:
				{
					serverRoom = checkState(serverRoom);
				}break;

				case 109:
				{
					stairs = checkState(stairs);
				}break;

				case 110:
				{
					unknown = checkState(unknown);
				}break;
				case 111: //case for button to create map
				{ 
                                    //draw some stuff
                                 }
				case 112:
				{
					if(SendMessage(main_window_handle,BM_GETCHECK,101,0) == BST_UNCHECKED)
						SendMessage(hwnd,BM_CLICK,101,0);
				}break;

//... more stuff follows

Ive set my check boxes each as an autocheckbox so i can see the check appear in my box when i push the check box.

So my questions are:
1) is there a way to use checkbox and have the box fill when you check it?
2) how do i get the state of the box (or all boxes) to uncheck all 10 cases before it?

any incite would be appreciated
 
 

Recent GIDBlogCompress Your Web Site by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:06.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.