Changing Trackbar Colors and Customization
Consistency is not a word in Microsoft's dictionary.  All the techniques used earlier in customizing the controls do not work for track bars.  One has to use custom draw techniques.  A track bar created by dialog box templates will not work at all.  This because after the initial message is sent, no further messages are sent.  Therefore changing the channel background color, and displaying the title and specified tick mark values are operational.

All parts of the track bar can be customized and different colors be assigned to different parts of the channel. 

A custom draw message is handled in the notification handler.  By using the class name of the control to differentiate other control types, TrackbarHandler is defined to handle the drawing of the track bar channel, the slider and tick marks.

The first message to the custom draw handler is OS.Windows.CustomDraw.Pre_Paint.  During this drawing cycle, the background of the control can be painted by a series of calls to OS.Text.Put.  By the same token, the title and specified tick mark values are processed here as well.

After handling the initial message, the returned result is set with the item draw indicator on, initiating another paint cycle and this time, a Item_Pre_Paint m?essage is sent.  Nothing interesting is happening here except returning another result with the post paint indicator on.  When this happens, the next cycle message is Item_Post_Paint.  By now various track bar parts are already drawn.  We can now impose our own drawing to erase them.  TrackbarHandler is where all the customization code reside.

NOTE:When the track bar is vertically orientated, the TrackbarHandler.DefiningRect.LeftTop and RightBottom coordinates are swapped.

Drawing tick marks is not implemented since I have no need to customize them at this time.

Home
Changing Statusbar Colors & Fonts
Back To Dialogs.PushButtons