Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29386 Discussions

How to customize dialog box colors using subclassing II

bearoflittlebrain_ol
691 Views

Thank you Anthony Richards for a very clear exposition on subclassing and colouring dialogue box controls. It has explained at last what this subclassing is all about. I have modified BackColour to make it easier to follow the steps in colouring the controls, using a function that may be called to colour a dialogue controls windows background colour, text background colour and text colour.

The function CtrlColoursCtrlColours(hdcControl, hControl, BackBrushColour, BackColour, TextColour, HideTextBack) is called from MyDlgProc with a typical call:

! BLUE brush for window background, BLUE text background, YELLOW text.

MyDlgProc = CtrlColours(wParam, lParam, RGB(0, 0, 255), RGB(0, 0, 255), RGB(255,255,0))

The first two input arguments are the last two arguments of MyDlgProc:

The three colours are the controls windows background colour, text background colour and text colour respectively. HideTextBack is a flag which if set, hides the text background colour. The last four arguments are optional.

Instead of the RGB function, I personally prefer to use colour values eg #FF00FF rather than RGB(255, 0, 255) for your PURPLE, but my favourite method is to use my library file CVFColours.f90 that contains the values of the 140 HTML colours, so that the function call above may be:

MyDlgProc = CtrlColours(wParam, lParam, BLUE, BLUE, YELLOW)

(Dont forget that HTML colours are in RGB order, but CVF colours are in BGR order, so that BLUE = #FF0000).

I attach a zip file with the modified f90 files - other files are unchanged.

Bear of Little Brain

0 Kudos
2 Replies
anthonyrichards
New Contributor III
691 Views
Thanks, I am glad to have been of assistance.

A single query: is 'HideTextBack' an optional argument? Otherwise it is missing from the function call.

Anyway, please continue to feel free to do what you will with the code that I posted.
0 Kudos
bearoflittlebrain_ol
691 Views
Yes, 'HideBackText' is optional as are the colours. See my modified file MydlgprocX.f90. A typical call is:


case (IDC_STATIC_SCROLLBAR)

! YELLOW brush for window background, TRANSPARENT text background.

MyDlgProc = CtrlColours(wParam, lParam, RGB(255, 255, 0), HideTextBack = .TRUE.)

I have always wanted to customise the dialogue boxes that I use, so I will be busy subclassing as so well explained by you.

Bear

0 Kudos
Reply