Example #1
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	// Prevent multiples instances of this app.
	CreateMutexA(NULL, TRUE, APPTITLE);

	if (GetLastError() == ERROR_ALREADY_EXISTS)
		return 0;

	RegisterDialogClass("SRB2MP", MainWndproc, hInstance);

	DialogBoxA(hInstance, (LPCSTR)IDD_MAIN, NULL, DialogProc);

	return 0;
}
Example #2
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    // Prevent multiples instances of this app.
    CreateMutex(NULL, true, APPTITLE);

    if(GetLastError() == ERROR_ALREADY_EXISTS)
        return 0;

    g_hInst = hInstance;

    RegisterDialogClass("SRB2Launcher", MainProc);

    DialogBox(g_hInst, (LPCSTR)IDD_MAIN, NULL, (DLGPROC)MainProc);

    return 0;
}
Example #3
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) {

	HDC ContextHandle;
	PAINTSTRUCT PaintStructure;
	RECT ClientRectangle;
	LPCWSTR MyText = L"Done with Pride and Prejudice by Danny!";
	int cxClient, cyClient;



	switch (Msg)
	{
	////////////////////////////////////
	case WM_SIZE:
		cxClient = LOWORD(lParam);
		cyClient = HIWORD(lParam);
		break;
	////////////////////////////////////
	case WM_CREATE:
	{

		RegisterDialogClass(hwnd);
		HMENU menu =  GetSystemMenu(hwnd, TRUE);
		LPCWSTR button01_ID = L"BUTTON";
		LPCWSTR button01_text = L"FONT";
		HWND button01 = CreateWindowEx(WS_EX_WINDOWEDGE, button01_ID, button01_text, BS_DEFPUSHBUTTON | WS_VISIBLE | WS_BORDER | WS_CHILD, 5, 5, 105, 25, hwnd, (HMENU)BUTTON_01, NULL, NULL);

		LPCWSTR button02_ID = L"BUTTON";
		LPCWSTR button02_text = L"DIALOG BOX";
		HWND button02 = CreateWindowEx(NULL, button02_ID, button02_text, BS_DEFPUSHBUTTON | WS_VISIBLE | WS_BORDER | WS_CHILD, 5, 35, 105, 25, hwnd, (HMENU)BUTTON_02, NULL, NULL);

		hWndSizeBox = CreateWindowEx(NULL, TEXT("Scrollbar"), 0, WS_CHILD | WSF_VISIBLE | WS_VISIBLE | SBS_SIZEBOXTOPLEFTALIGN, 50, 100, 0, NULL, hwnd, (HMENU)NULL, NULL, NULL);
		

	}
	break;
	//////////////////////////////////
	case WM_PAINT:
		ContextHandle = BeginPaint(hwnd, &PaintStructure);
		GetClientRect(hwnd, &ClientRectangle);
		/*DrawText(ContextHandle, MyText, -1,
			&ClientRectangle, DT_SINGLELINE | DT_CENTER | DT_VCENTER);*/

		EndPaint(hwnd, &PaintStructure);

		return 0;
	//////////////////////////////////
	case WM_COMMAND:

	{
		switch (LOWORD(wParam)) {

		
		case BUTTON_01: {
			
			HFONT Font = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Times New Roman"));
			SendMessage(TextBox, WM_SETFONT, (WPARAM)Font, TRUE);
			break; }
		case BUTTON_02: {
			
			CreateDialogBox(hwnd);
			
			break; }
		}
	}

	break;

	//////////////////////////////
	case WM_KEYDOWN:   // keyboard input
	{
		switch (wParam)
		{
		case KEY_C: {  // LeftSHIFT + E
			if (GetAsyncKeyState(VK_LSHIFT)) {
				if (MessageBox(hwnd, L"Do you want to exit?", L"Exit", MB_OKCANCEL) == IDOK)
					DestroyWindow(hwnd);
			}
			break;
		}
		case KEY_SPACE:
			if (GetAsyncKeyState(VK_LCONTROL)) {
				HBRUSH brush = CreateSolidBrush(RGB(100, 23, 31));

				SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)brush);
				RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
				MessageBox(NULL, L"Background color changed", L"ATENTION", NULL);
			}
			break;
		}
	}
	/////////////////////////////
	case WM_SYSCOMMAND:
		switch (LOWORD(wParam)) {
		case IDM_SYS_CHANGE: {
			HBRUSH brush1 = (HBRUSH)GetStockObject(WHITE_BRUSH);
			SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)brush1);
			RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
			break;
		}
		case IDM_SYS_ABOUT: {
			MessageBox(NULL, L"Done by FaF sTudent!", L"ATENTION", NULL);
		}
							return 0;
		case IDM_SYS_HELP: {
			TextBox = CreateWindowEx((DWORD)NULL, TEXT("EDIT"), TEXT("DEFAULT FONT"), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | DT_VCENTER,

			5, 65, 200, 25, hwnd, (HMENU)NULL, NULL, NULL);
			RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
			
			break;
		}
		}
		break;
	/////////////////////////////
	case WM_CLOSE:
	{
		if (MessageBox(hwnd, L"Do you want to exit?", L"Exit", MB_OKCANCEL) == IDOK)
			DestroyWindow(hwnd);
	}

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