Colored Background an Appframe-Window

In Clarion, the AppFrame window can hold an image, like your company logo, but the background can't have a color.
We all have seen windows like this before and they look really ugly!

What an ugly window!

Quite a while ago Jim Gambon posted a great solution for this on the Clarion Newsgroups.

First step:
In the After Global Includes: we add an EQUATE()
Then, in the Global Map:
! background color
GetClassLong        PROCEDURE(LONG thehWnd,LONG theIndex),LONG,PASCAL,NAME('GetClassLongA')
SetClassLong        PROCEDURE(LONG thehWnd,LONG theIndex,LONG theNewValue),LONG,PROC,PASCAL,NAME('SetClassLongA')
CreateSolidBrush    PROCEDURE(LONG TheColor),LONG,PASCAL,NAME('CreateSolidBrush')
DeleteObject        PROCEDURE(LONG theObject),LONG,PROC,PASCAL,NAME('DeleteObject')

! make sure that "Column 1" is ticked on

Add these two variable into your AppFrame window, either in the Data-Embed or the Data-Pad:
SaveNewBrush LONG
SaveOldBrush LONG
The color is obtained after the windows opens, so we put the following into the embed right after its opening in ThisWindow.Init:
 SaveOldBrush = GetClassLong(AppFrame{PROP:ClientHandle},GCL_HBRBACKGROUND)
 SaveNewBrush = CreateSolidBrush(0FFFFFFh) ! Solid White
 IF SaveNewBrush <> 0

Its always a good practice to clean up the mess when we leave, so in the TakeCloseEvent handler for ThisWindow object we reset and delete the brush objects:
 IF SaveOldBrush <> 0
    SaveOldBrush = 0

 IF SaveNewBrush <> 0
    SaveNewBrush = 0

The window looks much better now!

This looks much better, doesn't it?!

Thats all! Add salt and pepper as you like....

You can download the sample source (Clarion 6.3 EE). This page was made on 12.06.2013.

Here you find some more samples