Clarion
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()
GCL_HBRBACKGROUND            EQUATE(-10) 
Then, in the Global Map:
! background color
   MODULE('Win32API')
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')
   END !MODULE

! 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
    SetClassLong(AppFrame{PROP:ClientHandle},GCL_HBRBACKGROUND,SaveNewBrush)
 END !IF

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
    SetClassLong(AppFrame{PROP:ClientHandle},GCL_HBRBACKGROUND,SaveOldBrush)
    SaveOldBrush = 0
 END !IF

 IF SaveNewBrush <> 0
    DeleteObject(SaveNewBrush)
    SaveNewBrush = 0
 END !IF

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