15 #include "pandatoolbase.h"
17 #include "winStatsServer.h"
18 #include "config_pstats.h"
23 static const char *toplevel_class_name =
"pstats";
31 toplevel_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
45 return DefWindowProc(hwnd, msg, wparam, lparam);
55 create_toplevel_window(HINSTANCE application) {
58 ZeroMemory(&wc,
sizeof(WNDCLASS));
59 wc.lpfnWndProc = (WNDPROC)toplevel_window_proc;
60 wc.hInstance = application;
61 wc.lpszClassName = toplevel_class_name;
63 if (!RegisterClass(&wc)) {
64 nout <<
"Could not register window class!\n";
68 DWORD window_style = WS_POPUP | WS_SYSMENU | WS_ICONIC;
71 strm <<
"PStats " << pstats_port;
72 string window_name = strm.str();
74 HWND toplevel_window =
75 CreateWindow(toplevel_class_name, window_name.c_str(), window_style,
76 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
77 NULL, NULL, application, 0);
78 if (!toplevel_window) {
79 nout <<
"Could not create toplevel window!\n";
83 return toplevel_window;
91 #ifndef DEVELOP_WINSTATS
92 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR,
int)
94 int main(
int argc,
char *argv[])
97 HINSTANCE application = GetModuleHandle(NULL);
98 HWND toplevel_window = create_toplevel_window(application);
100 ShowWindow(toplevel_window, SW_SHOWMINIMIZED);
107 <<
"Unable to open port " << pstats_port
108 <<
". Try specifying a different\n"
109 <<
"port number using pstats-port in your Config file.";
110 string str = stream.str();
111 MessageBox(toplevel_window, str.c_str(),
"PStats error",
112 MB_OK | MB_ICONEXCLAMATION);
117 SetTimer(toplevel_window, 1, 200, NULL);
122 retval = GetMessage(&msg, NULL, 0, 0);
123 while (retval != 0) {
125 nout <<
"Error processing message queue.\n";
128 TranslateMessage(&msg);
129 DispatchMessage(&msg);
130 retval = GetMessage(&msg, NULL, 0, 0);
The class that owns the main loop, waiting for client connections.
void poll()
Checks for any network activity and handles it, if appropriate, and then returns. ...
bool listen(int port=-1)
Establishes a port number that the manager will listen on for TCP connections.