101 lines
2.3 KiB
C++
101 lines
2.3 KiB
C++
// synctracker2.cpp : Defines the entry point for the console application.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include <windows.h>
|
|
|
|
#include "trackview.h"
|
|
|
|
const char *mainWindowClassName = "MainWindow";
|
|
|
|
HWND trackViewWin;
|
|
LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
switch(msg)
|
|
{
|
|
case WM_CREATE:
|
|
trackViewWin = createTrackViewWindow(GetModuleHandle(NULL), hwnd);
|
|
break;
|
|
|
|
case WM_SIZE:
|
|
{
|
|
int width = LOWORD(lParam);
|
|
int height = HIWORD(lParam);
|
|
MoveWindow(trackViewWin, 0, 0, width, height, TRUE);
|
|
}
|
|
break;
|
|
|
|
case WM_SETFOCUS:
|
|
SetFocus(trackViewWin); // needed to forward keyboard input
|
|
break;
|
|
|
|
default:
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
ATOM registerMainWindowClass(HINSTANCE hInstance)
|
|
{
|
|
WNDCLASSEX wc;
|
|
|
|
wc.cbSize = sizeof(WNDCLASSEX);
|
|
wc.style = 0;
|
|
wc.lpfnWndProc = mainWindowProc;
|
|
wc.cbClsExtra = 0;
|
|
wc.cbWndExtra = 0;
|
|
wc.hInstance = hInstance;
|
|
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
wc.hbrBackground = (HBRUSH)0;
|
|
wc.lpszMenuName = NULL;
|
|
wc.lpszClassName = mainWindowClassName;
|
|
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
|
|
|
return RegisterClassEx(&wc);
|
|
}
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
HWND hwnd;
|
|
MSG Msg;
|
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
|
|
ATOM mainClass = registerMainWindowClass(hInstance);
|
|
ATOM trackViewClass = registerTrackViewWindowClass(hInstance);
|
|
if(!mainClass || ! trackViewClass)
|
|
{
|
|
MessageBox(NULL, _T("Window Registration Failed!"), _T("Error!"), MB_ICONEXCLAMATION | MB_OK);
|
|
return 0;
|
|
}
|
|
|
|
// Step 2: Creating the Window
|
|
hwnd = CreateWindowEx(
|
|
0,
|
|
mainWindowClassName,
|
|
_T("SyncTracker 3000"),
|
|
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
|
CW_USEDEFAULT, CW_USEDEFAULT, // x, y
|
|
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
|
NULL, NULL, hInstance, NULL
|
|
);
|
|
|
|
if (NULL == hwnd)
|
|
{
|
|
MessageBox(NULL, _T("Window Creation Failed!"), _T("Error!"), MB_ICONEXCLAMATION | MB_OK);
|
|
return 0;
|
|
}
|
|
|
|
ShowWindow(hwnd, TRUE);
|
|
UpdateWindow(hwnd);
|
|
|
|
// Step 3: The Message Loop
|
|
while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
|
{
|
|
TranslateMessage(&Msg);
|
|
DispatchMessage(&Msg);
|
|
}
|
|
|
|
UnregisterClass(mainWindowClassName, hInstance);
|
|
return int(Msg.wParam);
|
|
} |