Ejemplo n.º 1
0
HWND OGLWindow::Init(HINSTANCE hInstance, HWND hParent, bool doubleBuf, int x, int y, int w, int h)
{
	if ( !InitWindowClass(hInstance) )
		return NULL;

	return InitInstance(hInstance, hParent, doubleBuf, x, y, w, h);
}
Ejemplo n.º 2
0
HWND CreateConsole(HINSTANCE hinst,HWND hwndParent,int columns,int lines,int bufferlines,int fontsize,
                   DWORD style)
{
  CONSOLE *con, *prev;

  /* allocate a structure to hold the information */
  con=malloc(sizeof(CONSOLE));
  if (con==NULL)
    return NULL;
  memset(con,0,sizeof(CONSOLE));

  /* link to the list */
  for (prev=&consoleroot; prev->next!=NULL; prev=prev->next)
    /* nothing */;
  prev->next=con;

  /* fill in information */
  if (lines>=bufferlines)
    lines=bufferlines;
  con->lines=bufferlines;
  con->columns=columns;
  con->winlines=lines;
  con->cheight=fontsize;
  con->attrib=0xf0;             /* black on white */
  con->autowrap=TRUE;
  con->buffer=malloc(bufferlines*columns*2*sizeof(TCHAR));
  /* clear in the console
   * just like the DOS console buffer, our console consists of character/
   * attribute pairs.
   */
  if (con->buffer!=NULL) {
    int i;
    int size=bufferlines*columns*2;
    for (i=0; i<size; i+=2) {
      con->buffer[i]=__T(' ');
      con->buffer[i+1]=con->attrib;
    } /* for */
  } /* if */

  if (style==0)
    style=WS_OVERLAPPEDWINDOW;
  if (hinst==NULL)
    hinst=GetModuleHandle(NULL);

  /* create the window */
  InitWindowClass(hinst);
  con->hwnd=CreateWindow(__T("TermWin:Console"),__T("Pawn console"),style,
                         CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
                         hwndParent,NULL,hinst,NULL);

  /* check whether all is ok */
  if (IsWindow(con->hwnd) && con->buffer!=NULL) {
    ShowWindow(con->hwnd,SW_SHOWNORMAL);
    return con->hwnd;
  } /* if */
  /* when we arrive here, something was initialized correctly and something else was not */
  DoDeleteConsole(con);
  return NULL;
}
Ejemplo n.º 3
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
	MSG msg;
	if (!InitWindowClass(hInstance, nCmdShow)){
		MessageBox(NULL, L"´´½¨´°¿Úʧ°Ü£¡", _T("´´½¨´°¿Ú"), NULL);
		return 1;
	}
	while (GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return (int) msg.wParam;
}
Ejemplo n.º 4
0
int __stdcall _tWinMain(
	HINSTANCE hInstanceExe,
	HINSTANCE, // should not reference this parameter
	PTSTR lpstrCmdLine,
	int nCmdShow
	)
{
	//
	// To enable a console project to compile this code, set
	// Project->Properties->Linker->System->Subsystem: Windows.
	//

	int nArgC = 0;
	PWSTR* ppArgV = CommandLineToArgvW(lpstrCmdLine, &nArgC);
	g_pszAppName = ppArgV[0];

	if (!InitWindowClass())
	{
		// InitWindowClass displays any errors
		return -1;
	}

	// Main app window

	HWND hWnd = CreateWindowEx(
		WS_EX_CLIENTEDGE | WS_EX_APPWINDOW,
		WND_CLASS_NAME,
		g_pszAppName,
		WS_OVERLAPPEDWINDOW, // style
		CW_USEDEFAULT, 0,
		640, 480,
		NULL, NULL,
		hInstanceExe,
		NULL);

	if (hWnd == NULL)
	{
		ErrorHandler(TEXT("CreateWindowEx: main appwindow hWnd"));
		return -1;
	}

	// Actually draw the window.

	ShowWindow(hWnd, SW_SHOWNORMAL);
	UpdateWindow(hWnd);

	// The message pump loops until the window is destroyed.

	MessagePump(hWnd);

	return 1;
}
Ejemplo n.º 5
0
bool Myazo::Init(void)
{
	Instance=GetModuleHandle(nullptr);
	std::vector<wchar_t> Temp(MAX_PATH,0);
	SHGetSpecialFolderPath(nullptr,Temp.data(),CSIDL_APPDATA,false);
	SettingFileDirectory=Temp.data();
	SettingFileDirectory+=(*--SettingFileDirectory.end()==L'\\'?L"":L"\\")+AppName;
	if(!ImageEncoder.Init()) return false;
	if(!InitWindowClass()) return false;
	InitSetting();
	if(FirstBoot) OpenAuthWindow();
	else if(CheckArgumentOrUpload()||!InitWindow()) return false;
	LayerWindowFont.reset(new Gdiplus::Font(L"Tahoma",8));
	UIFont.reset(new Gdiplus::Font(L"MS UI Gothic",9.75f));
	return true;
}
// param: PWCHAR, new volume's disk letter will be stored there.
static DWORD WINAPI DevNotifyThread(void *param)
{
    HWND hWnd;
    DWORD diskIndex = 0;

    g_NewVolumeBitmask = 0;

    if (!InitWindowClass())
        return 1;

    hWnd = CreateWindowEx(
        WS_EX_CLIENTEDGE | WS_EX_APPWINDOW,
        WND_CLASS_NAME,
        L"QDevNotify",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, 0,
        640, 480,
        NULL, NULL,
        GetModuleHandle(NULL),
        NULL);

    if (hWnd == NULL)
    {
        perror("CreateWindowEx: main appwindow hWnd");
        return 2;
    }

    MessagePump();

    if (g_NewVolumeBitmask == 0) // failed?
        return 3;

    // Translate bitmask into disk letter.
    BitScanForward(&diskIndex, g_NewVolumeBitmask);
    *(WCHAR *) param = L'A' + (WCHAR) diskIndex;

    return 0;
}
Ejemplo n.º 7
0
int WINAPI wWinMain(_In_ HINSTANCE Program, _In_opt_ HINSTANCE PreviousProgram, _In_ LPWSTR CommandLine, _In_ int ShowCommand)
{
	UNREFERENCED_PARAMETER(PreviousProgram);
	UNREFERENCED_PARAMETER(CommandLine);
	UNREFERENCED_PARAMETER(ShowCommand);

#ifndef _XBOX
	HRESULT hr = CoInitializeEx(nullptr, COINITBASE_MULTITHREADED);
	if (FAILED(hr))
		return 1;
#endif

	// make sure this is the only instance of this game running on the computer if not then close application
	const char szUniqueNamedMutex[] = "punchdrunksquirrelgames_bloodnoir";
	HANDLE hHandle = CreateMutex(NULL, TRUE, szUniqueNamedMutex);
	if (ERROR_ALREADY_EXISTS == GetLastError())
	{
		// Program already running somewhere
		return(1); // Exit program
	}

	// create the game object
	m_game = make_unique<Game>();

	// initialize the window class
	if (!InitWindowClass(Program))
		return 1;

	// display the window on the screen
	ShowWindow(m_window, SW_MAXIMIZE);
	SetWindowLongPtr(m_window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(m_game.get()));

	GetClientRect(m_window, &rc);

	// initialize the game
	if (!m_game->GameInitialize(m_window, rc.right - rc.left, rc.bottom - rc.top))
		return 0;

	// enter the message loop only leaving it when the Quit message is received
	MSG msg = { 0 };
	while (msg.message != WM_QUIT)
	{
		if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			m_game->GameRun();
		}
	}
	// if loop exists then reset game object
	m_game.reset();

	// release things that need to be released and return control to windows
	CoUninitialize();
	ReleaseMutex(hHandle); // Explicitly release mutex
	CloseHandle(hHandle); // close handle before terminating
	return (int)msg.wParam;
}