Opened 6 years ago

Closed 6 years ago

#1098 closed Bug Report (fixed)

Windows: do not create a window class per window

Reported by: milasudril@… Owned by: David Robillard
Priority: minor Component: Pugl
Keywords: Cc:


On Windows: Do not create one “window class” per window. Register the class on library initialisation. Then use that class every time you create a new window. This solves your problem with the static variable.

static const TCHAR* PUGL_CLASSNAME=”pugl_window_class”;

wc.cbSize=sizeof(wc); //You seem to have forgotten this!!! = CS_OWNDC;
wc.lpfnWndProc = wndProc;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); //Implement a way so the icon can be set. This makes things more user friendly [Icon shows up in task bar and ALT+TAB on GNU/Linux too].
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszClassName = PUGL_CLASSNAME;


wc is no longer needed…

Change History (3)

comment:1 Changed 6 years ago by falkTX

what happens when 2 different plugins are built with the same pugl code? shouldn't the classname be unique?

comment:2 Changed 6 years ago by David Robillard

There would need to be API for setting it, puglInitWindowClassName or some such.

comment:3 Changed 6 years ago by David Robillard

Resolution: fixed
Status: newclosed

Implemented in 95a42df/pugl, thanks.

Note: See TracTickets for help on using tickets.