コード例 #1
0
ファイル: win_main.cpp プロジェクト: ArkyRomania/ufoai
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
	global_hInstance = hInstance;

	Sys_ConsoleInit();

	/* always change to the current working dir */
	FixWorkingDirectory();

	Qcommon_Init(__argc, __argv);

	/* main window message loop */
	while (1)
		Qcommon_Frame();

	/* never gets here */
	return FALSE;
}
コード例 #2
0
ファイル: win_main.c プロジェクト: chrisglass/ufoai
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	/* previous instances do not exist in Win32 */
	if (hPrevInstance)
		return 0;

	global_hInstance = hInstance;

	ParseCommandLine(lpCmdLine);

	Sys_ConsoleInit();

	/* always change to the current working dir */
	FixWorkingDirectory();

	Qcommon_Init(argc, argv);

	/* main window message loop */
	while (1)
		Qcommon_Frame();

	/* never gets here */
	return FALSE;
}
コード例 #3
0
ファイル: ColourPicker.c プロジェクト: MJPA/Colour-Picker
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	int i;
	HWND hWnd;
	MSG msg;
	WNDCLASS cls;
	RECT desktop_area;
	int win_x, win_y;
	HICON load,save;

	InitCommonControls();
	FixWorkingDirectory(hInstance);
	SystemParametersInfo(SPI_GETWORKAREA, 0, &desktop_area, 0);

	// Register class for our window
	cls.style = CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
	cls.lpfnWndProc = MainDlgProc;
	cls.cbClsExtra = 0;
	cls.cbWndExtra = 0;
	cls.hInstance = hInstance;
	cls.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	cls.hCursor = LoadCursor (NULL, IDC_ARROW);
	cls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
	cls.lpszMenuName = NULL;
	cls.lpszClassName = "ColourPicker";
	RegisterClass(&cls);

	// Create our window
	win_x = desktop_area.left + ((desktop_area.right - desktop_area.left) / 2) - 245;
	win_y = desktop_area.top + ((desktop_area.bottom - desktop_area.top) / 2) - 125;
	hWnd = CreateWindow(cls.lpszClassName, "Colour Picker", DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU,
												win_x, win_y, 490, 251, NULL, NULL, hInstance, 0);
	GetWindowRect(hWnd, &session.window);

	// Add icon
	SetClassLong(hWnd, GCL_HICONSM, (LONG)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, 16, 16, 0));
	SetClassLong(hWnd, GCL_HICON, (LONG)LoadIcon(hInstance, (LPCTSTR)IDI_MAIN));

	// Set modes
	clds[LINE_H].mode = LINE_MODE_H;
	clds[LINE_S].mode = LINE_MODE_S;
	clds[LINE_V].mode = LINE_MODE_V;
	clds[LINE_R].mode = LINE_MODE_R;
	clds[LINE_G].mode = LINE_MODE_G;
	clds[LINE_B].mode = LINE_MODE_B;

	// Add Controls
	hColourSquare = ColourSquare_Create(hInstance, 7, 7, hWnd, &csd);
	csd.c = &session.current_colour;
	hColourChannel = ColourChannel_Create(hInstance, 217, 7, 10, hWnd, &ccd);
	ccd.c = &session.current_colour;
	for (i = 0; i < 6; i++)
	{
		// Radio buttons
		hColourSquareModes[i] = CreateWindow("BUTTON", ColourSquare_Titles[i], 
																					WS_VISIBLE|BS_AUTORADIOBUTTON|WS_CHILD|(i==0?WS_GROUP|WS_TABSTOP:0),
																					243, (i * 22) + 9, 25, 15, hWnd, NULL, hInstance, 0);
		SendMessage(hColourSquareModes[i], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	}
	for (i = 0; i < 6; i++)
	{
		// Lines
		clds[i].c = &session.current_colour;
		hColourLines[i] = ColourLine_Create(hInstance, 272, (i * 22) + 7, 15, hWnd, &clds[i]);

		// Line values
		hColourLineValues[i] = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "0", WS_VISIBLE|WS_CHILD|ES_NUMBER|WS_TABSTOP,
																						430, (i * 22) + 7, 45, 19, hWnd, NULL, hInstance, 0);
		SendMessage(hColourLineValues[i], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
		SendMessage(hColourLineValues[i], EM_SETLIMITTEXT, (WPARAM) 3, 0);
		SetOverrideEditCtrlWndProc(hColourLineValues[i]);

		// Line value up/downs
		hColourLineValueUpDowns[i] = CreateWindow(UPDOWN_CLASS, NULL,
																							WS_VISIBLE|WS_CHILD|UDS_ALIGNRIGHT|UDS_SETBUDDYINT|UDS_ARROWKEYS,
																							0, 0, 0, 0, hWnd, NULL, hInstance, 0);
		SendMessage(hColourLineValueUpDowns[i], UDM_SETBUDDY, (WPARAM)hColourLineValues[i], 0);
	}
	// Current colour
	hCurrentColourLabel = CreateWindow("STATIC", "Current colour:", WS_VISIBLE|WS_CHILD, 258, 141, 
																			69, 20, hWnd, NULL, hInstance, 0);
	SendMessage(hCurrentColourLabel, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	// Current colour block
	hCurrentColourBlock = ColourBlock_Create(hInstance, 271, 158, 43, 36, hWnd, &session.current_colour);

	// Add to previous button
	hAddToPreviousButton = CreateWindow("BUTTON", ">", WS_VISIBLE|WS_CHILD|WS_TABSTOP, 334, 151, 18, 23, hWnd, 
																				NULL, hInstance, 0);
	SendMessage(hAddToPreviousButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);

	// Previous colours
	for (i = 0; i < 4; i++)
	{
		csed[i].current = &session.current_colour;
		csed[i].mine = &session.prev_colours[i];
		hPreviousColours[i] = ColourSelectable_Create(hInstance, 357 + (i * 25), 142, 18, 16, hWnd, &csed[i]);
	}
	for (i = 4; i < 8; i++)
	{
		csed[i].current = &session.current_colour;
		csed[i].mine = &session.prev_colours[i];
		hPreviousColours[i] = ColourSelectable_Create(hInstance, 357 + ((i-4) * 25), 165, 18, 16, hWnd, &csed[i]);
	}

	// Open previous colours
	hLoadPreviousColours = CreateWindow("BUTTON", "Open", WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_ICON, 457, 142, 20, 20, 
																				hWnd, NULL, hInstance, 0);
	load = LoadImage(hInstance, MAKEINTRESOURCE(IDI_OPEN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
	SendMessage(hLoadPreviousColours, BM_SETIMAGE, IMAGE_ICON, (LPARAM)load);

	// Save previous colours
	hSavePreviousColours = CreateWindow("BUTTON", "Save", WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_ICON, 457, 165, 20, 20, 
																				hWnd, NULL, hInstance, 0);
	save = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SAVE), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
	SendMessage(hSavePreviousColours, BM_SETIMAGE, IMAGE_ICON, (LPARAM)save);

	// Hex Label
	hCurrentColourHexLabel = CreateWindow("STATIC", "Hex:", WS_VISIBLE|WS_CHILD, 257, 202, 32, 20, hWnd, NULL, hInstance, 0);
	SendMessage(hCurrentColourHexLabel, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	// Hex Value
	hCurrentColourHexValue = CreateWindow("EDIT", "#FF0000", WS_VISIBLE|WS_CHILD|ES_READONLY,
																				282, 202, 65, 19, hWnd, NULL, hInstance, 0);
	SendMessage(hCurrentColourHexValue, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);

	// Colour Target
	ctd.c = &session.current_colour;
	hColourPickLabel = CreateWindow("STATIC", "Screen Pick:", WS_VISIBLE|WS_CHILD,
																		372, 199, 65, 23, hWnd, NULL, hInstance, 0);
	SendMessage(hColourPickLabel, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
	hColourPickTarget = ColourTarget_Create(hInstance, 442, 194, hWnd, &ctd);

	// UpDown ranges
	SendMessage(hColourLineValueUpDowns[LINE_H], UDM_SETRANGE, 0, MAKELONG(359, 0));
	SendMessage(hColourLineValueUpDowns[LINE_S], UDM_SETRANGE, 0, MAKELONG(100, 0));
	SendMessage(hColourLineValueUpDowns[LINE_V], UDM_SETRANGE, 0, MAKELONG(100, 0));
	SendMessage(hColourLineValueUpDowns[LINE_R], UDM_SETRANGE, 0, MAKELONG(255, 0));
	SendMessage(hColourLineValueUpDowns[LINE_G], UDM_SETRANGE, 0, MAKELONG(255, 0));
	SendMessage(hColourLineValueUpDowns[LINE_B], UDM_SETRANGE, 0, MAKELONG(255, 0));

	// Load last session
	LoadSession(hWnd);

	// Set some controls to what the session info is
	SendMessage(hColourSquareModes[session.square_mode], BM_SETCHECK, BST_CHECKED, 0);
	SendMessage(hColourLineValueUpDowns[LINE_H], UDM_SETPOS32, 0, (LPARAM)session.current_colour.h);
	SendMessage(hColourLineValueUpDowns[LINE_S], UDM_SETPOS32, 0, (LPARAM)session.current_colour.s);
	SendMessage(hColourLineValueUpDowns[LINE_V], UDM_SETPOS32, 0, (LPARAM)session.current_colour.v);
	SendMessage(hColourLineValueUpDowns[LINE_R], UDM_SETPOS32, 0, (LPARAM)session.current_colour.r);
	SendMessage(hColourLineValueUpDowns[LINE_G], UDM_SETPOS32, 0, (LPARAM)session.current_colour.g);
	SendMessage(hColourLineValueUpDowns[LINE_B], UDM_SETPOS32, 0, (LPARAM)session.current_colour.b);

	// Show the window finally
	ShowWindow(hWnd, SW_SHOW);

	// Wait for messages
	while (GetMessage(&msg, hWnd, 0, 0))
	{
		if (!IsDialogMessage(hWnd, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		
		if (!IsWindow(hWnd)) break;
	}

	return 0;
}
コード例 #4
0
ファイル: sys_win.c プロジェクト: chrisnew/quake2
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG				msg;
	unsigned int	time, oldtime, newtime;
//	char			*cddir;

    /* previous instances do not exist in Win32 */
    if (hPrevInstance)
        return 0;

	global_hInstance = hInstance;

	// done before Com/Sys_Init since we need this for error output
	Sys_CreateConsole();

	// no abort/retry/fail errors
	SetErrorMode (SEM_FAILCRITICALERRORS);

	ParseCommandLine (lpCmdLine);

	FixWorkingDirectory ();

	// if we find the CD, add a +set cddir xxx command line
#if 0
	cddir = Sys_ScanForCD ();
	if (cddir && argc < MAX_NUM_ARGVS - 3)
	{
		int		i;

		// don't override a cddir on the command line
		for (i=0 ; i<argc ; i++)
			if (!strcmp(argv[i], "cddir"))
				break;
		if (i == argc)
		{
			argv[argc++] = "+set";
			argv[argc++] = "cddir";
			argv[argc++] = cddir;
		}
	}
#endif
	#ifdef USE_DBGHELP
#ifdef _MSC_VER
	__try {
#else
	__try1( Sys_ExceptionHandler );
#endif
#endif /* USE_DBGHELP */
	Qcommon_Init (argc, argv);
	oldtime = Sys_Milliseconds ();

	//Com_Error (ERR_FATAL, "Testing");

	if (dedicated->integer) {
		Sys_ShowConsole(1, false);
	}
	else if(!win_consolelogging->integer) {
		qDedConsole = false;
		Sys_DestroyConsole();
	}


	//_controlfp( _PC_24, _MCW_PC );

    /* main window message loop */
	while (1)
	{
		// if at a full screen console, don't update unless needed
		if (!ActiveApp || dedicated->integer)
			Sleep (3);

		while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
			sys_msg_time = msg.time;
			TranslateMessage(&msg);
   			DispatchMessage(&msg);
		}

		do
		{
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);

		_controlfp( _PC_24, _MCW_PC );
		Qcommon_Frame( time );

		oldtime = newtime;
	}
#ifdef USE_DBGHELP
#ifdef _MSC_VER
	} __except( Sys_ExceptionHandler( GetExceptionCode(), GetExceptionInformation() ) ) {
		return 1;
	}
#else
	__except1;
#endif
#endif /* USE_DBGHELP */
	// never gets here
    return 0;
}