سؤال

Ok, so my intention is to "prettify" a UI I'm working on. I'm familiar with using GDI+ to manually draw my controls but my target today is simply BitBlitting png's on my DC directly.

That works nice and fine with the main frame, a few buttons and perhaps some menus. My question is - how would you skin something more complicated like a combobox, listview or more "dynamic" controls using such skins?

Thank you. My target platform is Windows and I'm using C++ with the wxWidgets framework.

هل كانت مفيدة؟

المحلول

To 'skin' an existing control you'll have to subclass the window and catch the draw messages. roughly:

// Subclass the control 
WNDPROC lpfnOldCtrlProc;
lpfnOldCtrlProc = (WNDPROC)SetWindowLong(ControlHwnd, GWL_WNDPROC, 
                    (DWORD)WinSubClassFunc );

and in your WinSubClassFunc:

switch( message )
{
case WM_DRAWITEM: // owner-draw the item

However, if you want to fully 'skin' a control e.g. change all elements of a ComboBox (border, entrybox, dropdown button, droplist etc.) then this becomes really messy. Personally, I find it is easier to create your own control from scratch than try to subclass an existing control which consists of multiple window items.

The above methods works fine for e.g. using a standard combobox with a droplist and subclass it to make it contain a droplist of colour bars.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top