Beispiel #1
0
/**
 * Yet another app gets born!
 */
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
	MSG msg;
	HACCEL hAccelTable;
	WSAData wsaData;
	if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
		MessageBox(NULL, "WSAStartup (sockets) failed.", "A FREAKING SERIOUS ERROR", MB_ICONEXCLAMATION | MB_OK);
		PostQuitMessage(0);
	}
	InitCommonControls();
	myRegisterClass(hInstance, "myWinClass", (WNDPROC)WndProc, IDC_WAAPIX);
	myRegisterClass(hInstance, "myAboutBoxClass", (WNDPROC)aboutBoxProc, 0);

	//creating the VAPIX object
	vapix = new Vapix();

	//struct for opening the browser
	memset(&execInfo, '\0', sizeof(execInfo));
	execInfo.nShow = SW_SHOWNORMAL;
	execInfo.cbSize = sizeof(execInfo);

	//creating the http handler
	httpReader = new HttpReader();

	if (!showMainWnd (hInstance, nCmdShow)) {
		MessageBox(NULL, strcat(itoc((int)GetLastError()), "\r\n\r\nError creating main window"), "Cataclysmic error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}

	//use for language files? or make own and remove this?
	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WAAPIX);

	//doing the same shit that's been done for 30 years
	while (GetMessage(&msg, NULL, 0, 0)) {
		if (IsDialogMessage(hWnd, &msg) != 0)
			continue;
		else if (IsDialogMessage(hWnd, &msg) != 0)
			continue;
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	//free up memory
	delete vapix;
	delete httpReader;

	//gerrarre!!!
	return (int) msg.wParam;
}
Beispiel #2
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrecInstance, 
					LPWSTR lpCmdLine, int nShowCmd) {
	MSG msg;

	//注册窗口
	if(!registerWnd(hInstance))
		return 1;

	//显示窗口
	if(!showMainWnd(hInstance, lpCmdLine, nShowCmd))
		return 2;

	//消息循环
	while( GetMessage(&msg, NULL, 0, 0) ) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	
	//退出窗口
	return quitMainWnd(hInstance, msg.wParam);
}