21 static const char *toplevel_class_name =
"pstats";
28 toplevel_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
42 return DefWindowProc(hwnd, msg, wparam, lparam);
50 create_toplevel_window(HINSTANCE application) {
53 ZeroMemory(&wc,
sizeof(WNDCLASS));
54 wc.lpfnWndProc = (WNDPROC)toplevel_window_proc;
55 wc.hInstance = application;
56 wc.lpszClassName = toplevel_class_name;
58 if (!RegisterClass(&wc)) {
59 nout <<
"Could not register window class!\n";
63 DWORD window_style = WS_POPUP | WS_SYSMENU | WS_ICONIC;
65 std::ostringstream strm;
66 strm <<
"PStats " << pstats_port;
67 std::string window_name = strm.str();
69 HWND toplevel_window =
70 CreateWindow(toplevel_class_name, window_name.c_str(), window_style,
71 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
72 nullptr,
nullptr, application, 0);
73 if (!toplevel_window) {
74 nout <<
"Could not create toplevel window!\n";
78 return toplevel_window;
81 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR,
int) {
82 HINSTANCE application = GetModuleHandle(
nullptr);
83 HWND toplevel_window = create_toplevel_window(application);
85 ShowWindow(toplevel_window, SW_SHOWMINIMIZED);
90 std::ostringstream stream;
92 <<
"Unable to open port " << pstats_port
93 <<
". Try specifying a different\n" 94 <<
"port number using pstats-port in your Config file.";
95 std::string str = stream.str();
96 MessageBox(toplevel_window, str.c_str(),
"PStats error",
97 MB_OK | MB_ICONEXCLAMATION);
102 SetTimer(toplevel_window, 1, 200,
nullptr);
107 retval = GetMessage(&msg,
nullptr, 0, 0);
108 while (retval != 0) {
110 nout <<
"Error processing message queue.\n";
113 TranslateMessage(&msg);
114 DispatchMessage(&msg);
115 retval = GetMessage(&msg,
nullptr, 0, 0);
125 int main(
int argc,
char *argv[]) {
126 return WinMain(
nullptr,
nullptr,
nullptr, 0);
The class that owns the main loop, waiting for client connections.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.