goody11 -2 Junior Poster

Hey, I'm having some troubles with my hangman game i'm making. I want it to display dashes for the number of characters that there are in the word which that part works fine. but then if they guess the right letter, I want the dash to be replaced with the letter, which is not working. Also, it is not telling if the person has already used the letter if they click on the same letter more than once.

Here is the .cpp:

#include "windows.h"
#include "windef.h"
#include "resource.h"
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>

using namespace std;

HBITMAP g_hbmHang0 = NULL;
HBITMAP g_hbmHang = NULL;
HBITMAP g_hbmHang2 = NULL;
HBITMAP g_hbmHang3 = NULL;
HBITMAP g_hbmHang4 = NULL;
HBITMAP g_hbmHang5 = NULL;
HBITMAP g_hbmHang6 = NULL;
HBITMAP g_hbmHang7 = NULL;
HBITMAP g_hbmHang8 = NULL;
int errors = 0;
int i = 0;

BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{

const int MAX_WRONG = 8;
vector<LPCSTR> words;
words.push_back("hola");
words.push_back("hangman");
words.push_back("dificult");
if(i = 0)
{
srand(time_t(0));
random_shuffle(words.begin(),words.end());
i = 1;
}
const string THE_WORD = words[0];
string soFar(THE_WORD.size(),'-');
string used = "";
HWND handle2 = GetDlgItem(hwnd, IDC_THEWORD);
SetWindowText(handle2, soFar.c_str());

	switch(Message)
	{
		case WM_INITDIALOG:
			g_hbmHang0 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG0));
			g_hbmHang = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG));
			g_hbmHang2 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG2));
			g_hbmHang3 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG3));
			g_hbmHang4 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG4));
			g_hbmHang5 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG5));
			g_hbmHang6 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG6));
			g_hbmHang7 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG7));
			g_hbmHang8 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_HANG8));
			if(g_hbmHang == NULL || g_hbmHang2 == NULL || g_hbmHang3 == NULL || g_hbmHang4 == NULL || g_hbmHang5 == NULL || g_hbmHang6 == NULL || g_hbmHang7 == NULL || g_hbmHang8 == NULL)
				MessageBox(hwnd, "Could not load IDB_HANG!", "Error", MB_OK |MB_ICONEXCLAMATION);
		break;
		case WM_CLOSE:
			DestroyWindow(hwnd);
		break;
		case WM_PAINT:
		{
			BITMAP bm;
			PAINTSTRUCT ps;
			
			if(errors == 0)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang0);

				GetObject(g_hbmHang0, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}
			if(errors == 1)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang);

				GetObject(g_hbmHang, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}
			if(errors == 2)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang2);

				GetObject(g_hbmHang2, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}
			
			if(errors == 3)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang3);

				GetObject(g_hbmHang3, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}
			
			if(errors == 4)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang4);

				GetObject(g_hbmHang4, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}

			if(errors == 5)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang5);

				GetObject(g_hbmHang5, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}

			if(errors == 6)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang6);

				GetObject(g_hbmHang6, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}

			if(errors == 7)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang7);

				GetObject(g_hbmHang7, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}
			
			if(errors >= 8)
			{
				HDC hdc = BeginPaint(hwnd, &ps);

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmHang8);

				GetObject(g_hbmHang8, sizeof(bm), &bm);

				BitBlt(hdc, 100, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

				SelectObject(hdcMem, hbmOld);
				DeleteDC(hdcMem);

				EndPaint(hwnd, &ps);
			}
		}
		break;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
			case IDC_A:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'a';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_B:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'b';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_C:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'c';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_D:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'd';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_E:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'e';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_F:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'f';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_G:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'g';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_H:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'h';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_I:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'i';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

					if(THE_WORD.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "CORRECT! That letter was in the word.");
					}
					else
					{
						++errors;
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "WRONG! That letter is not in the word.");
						InvalidateRect(hwnd, NULL, true);
					}
					}
				}
			break;
			case IDC_J:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'j';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_K:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'k';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_L:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'l';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_M:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'm';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_N:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'n';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_O:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'o';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_P:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'p';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_Q:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'q';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_R:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'r';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_S:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 's';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_T:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 't';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_U:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'u';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_V:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'v';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_W:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'w';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_X:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'x';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_Y:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'y';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_Z:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'z';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_AA:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'á';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_EE:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'é';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_II:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'í';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_OO:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'ó';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_UU:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'ú';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_NN:
				if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = 'ñ';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that letter.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That letter was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That letter is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_EXEX:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = '¡';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that character.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That character was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That character is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_EX:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = '!';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that character.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That character was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That character is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_QUQU:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = '¿';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that character.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That character was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That character is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
			case IDC_QU:
								if((errors < MAX_WRONG) && (soFar != THE_WORD))
				{
					char guess = '?';
					if(used.find(guess) != string::npos)
					{
						HWND handle = GetDlgItem(hwnd, IDC_WORD);
						SetWindowText(handle, "You already used that character.");
					}
					else
					{
						used += guess;

						if(THE_WORD.find(guess) != string::npos)
						{
							HWND handle = GetDlgItem(hwnd, IDC_WORD);
							SetWindowText(handle, "CORRECT! That character was in the word.");
						}
						else
						{
							++errors;
								HWND handle = GetDlgItem(hwnd, IDC_WORD);
								SetWindowText(handle, "WRONG! That character is not in the word.");
							InvalidateRect(hwnd, NULL, true);
						}
					}
				}
			break;
		}
		break;
		case WM_DESTROY:
			DeleteObject(g_hbmHang8);
			PostQuitMessage(0);
		break;
		default:
			return FALSE;
	}
	return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
}

By the way, each of the one cases that are repetitious are each pushbuttons.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.