Page 1 of 1

Using custom WNDCLASS for wxFrame subclass (MSW)

Posted: Wed Mar 13, 2019 10:03 am
by pete_b
Just trying to implement a derived class of wxFrame that has CS_DROPSHADOW specified in its WNDCLASS. MSW specific for now.

Is there a DRY way to do this? Looking through wx sources (3.0.4), it looks to me like I'm going to have top copy/paste an awful lot of code from wxFrame to do that. And then I have a maintenance issue.

MSWCreate is not virtual (and clearly cannot be as it is called from the ctor). AFAICS there is no way of overriding wxWindowMSW::MSWGetRegisteredClassName either.

Is there something obvious I'm missing here?

If not then I wonder if perhaps window creation could be reworked a bit do decouple window creation from the window class itself. There could be a wxWindowCreator class that has virtual functions to customize this process (template method pattern).
Then it would be trivial to do this kind of thing - just inject a new window creator that overrides wxWindowCreator::MSWGetRegisteredClassName and you avoid the issue of virtual behaviour in the ctor.

Even just being able to set a function pointer to override MSWCreate or MSWGetRegisteredClassName before calling Create would be really handy.

Re: Using custom WNDCLASS for wxFrame subclass (MSW)

Posted: Wed Mar 13, 2019 1:01 pm
by pete_b
Just did copy and paste but the shadow looks so feeble I decided to do it a different way with a layered window.