예제 #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    userName = QString("_");
    setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
    PrepareField();
}
예제 #2
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
    switch (message)
    {
	case WM_CREATE:
		bombField.setHdc(GetDC(hWnd));
		bombField.setHWnd(hWnd);
		bombField.determinateCells(9,9,10); 
		currentGameMode = NEWBIE;
		CreateWindow(_T("button"), _T(""), WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
			135, 10, 60, 30, hWnd, (HMENU)IDM_STARTBUTTON, NULL, NULL);
		CreateWindow(_T("EDIT"), NULL, WS_BORDER | WS_VISIBLE | WS_CHILD | ES_READONLY,
			40, 10, 60, 30, hWnd, (HMENU)IDM_TIMERTEXTBOX, NULL, NULL);
		CreateWindow(_T("EDIT"), NULL, WS_BORDER | WS_VISIBLE | WS_CHILD | ES_READONLY,
			230, 10, 60, 30, hWnd, (HMENU)IDM_BOMBSCOUNTTEXTBOX, NULL, NULL);
		SetDlgItemText(hWnd, IDM_TIMERTEXTBOX, L"0");
		SetDlgItemText(hWnd, IDM_BOMBSCOUNTTEXTBOX, L"0");

	case WM_PAINT:
	{
		BeginPaint(hWnd, &ps);
		bombField.repaint();
		EndPaint(hWnd, &ps);
		return 0;
	}

    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
			case IDM_STARTBUTTON:
				if (bombField.loseScreen || bombField.gameStarted)
				{
					PrepareField(hWnd, currentGameMode);
				}
				break;

			case IDM_NEWBIE:
					PrepareField(hWnd, GAME_MODE::NEWBIE);
					//TODO SET CORINATES TO BUTTONS TEXT BOXes
					MoveWindow(hWnd, 250, 160, 342, 345, true);

					break;

			case IDM_AMATEUR:
					PrepareField(hWnd, GAME_MODE::AMATEUR);
					MoveWindow(hWnd, 250, 160, 542, 500, true);
				break;

			case IDM_PROFESSIONAL:
					PrepareField(hWnd, GAME_MODE::PROFESSIONAL);
					MoveWindow(hWnd, 250, 160, 707, 625, true);
				break;

            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;

	case WM_LBUTTONDOWN:
		if (!bombField.loseScreen && !bombField.winScreen)
		{
			if (bombField.firstClick)
			{
				CreateThread(NULL, 0, Clock, hWnd, 0, NULL);
			}
			bombField.activateButton(GetCursorPosition(hWnd));
		}
		break;

	case WM_RBUTTONDOWN:
		if (!bombField.loseScreen && !bombField.winScreen)
		{
			if (bombField.firstClick)
			{
				CreateThread(NULL, 0, Clock, hWnd, 0, NULL);
			}
			bombField.setFlag(GetCursorPosition(hWnd));
			appendFlagCount(hWnd);
			if (bombField.isWin())
			{
				SetDlgItemText(hWnd, IDM_BOMBSCOUNTTEXTBOX, L"WIN");	
			}
		}

		break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}