c++ Code:
#include <windows.h>
#include <d3d9.h>
HWND hWnd;
bool Fullscreen_Enabled;
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
MSG msg;
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC, WindowProcedure, 0, 0, hInstance, NULL, NULL, NULL, NULL, "DX_TUT", NULL};
RegisterClassEx(&wc);
if (MessageBox(hWnd, "Click Yes to go to full screen (Recommended)", "", MB_ICONINFORMATION | MB_YESNO) == IDYES)
Fullscreen_Enabled = true;
if (Fullscreen_Enabled == true)
hWnd = CreateWindowEx (0, "DX_TUT", "DirectX9 Tutorial", WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hInstance, NULL);
else
hWnd = CreateWindowEx (0, "DX_TUT", "DirectX9 Tutorial", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP, NULL, hInstance, NULL);
ShowWindow (hWnd, nCmdShow);
while (true)
{
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
if (WM_QUIT == msg.message) break;
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage (0);
HANDLE Process;
Process = OpenProcess(PROCESS_ALL_ACCESS , true , GetCurrentProcessId());
TerminateProcess(Process , 0);
break;
default:
return DefWindowProc (hWnd, msg, wParam, lParam);
}
return 0;
}