Opened 2 years ago

Closed 2 years ago

#1098 closed Bug Report (fixed)

Windows: do not create a window class per window

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

Description

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”;

WNDCLASSEX wc;
memset(&wc,0,sizeof(wc));
wc.cbSize=sizeof(wc); //You seem to have forgotten this!!!
wc.style = 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;

RegisterClassEx(&wc);

wc is no longer needed…

Change History (3)

comment:1 Changed 2 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 2 years ago by dave

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

comment:3 Changed 2 years ago by dave

  • Resolution set to fixed
  • Status changed from new to closed

Implemented in 95a42df/pugl, thanks.

Note: See TracTickets for help on using tickets.