|
- by BPak |
A simple method of putting a Graduation Tint on a Window using Creative Basic commands

To make the Graduation Tint -
like you see in the Installation Package Window when installing using the
Installshield Program - the Creative Basic RECT function and the RGB color
function are all that are needed!
| STEP
1
Define the Window |
DEF Main:WINDOW
SETID "WM_EXITSIZEMOVE",0x232 WINDOW Main,150,150,400,350,@CAPTION|@SYSMENU|@SIZE,0,"Graduation
Tint",MainWindow
|
| STEP 2
Start Window and create Tint at start up of program. |
run = 1
' initialise the tint on start up MakeBackground waituntil run=0
|
| STEP 3
Code the Main Window Message Event Handler WM_EXITSIZEMOVE
Window is centered in the @IDCREATE Message |
SUB MainWindow
SELECT @CLASS CASE @IDCLOSEWINDOW run = 0 CASE @IDMENUPICK SELECT@MENUNUM CASE 1 run = 0 ENDSELECT ' check for an > exit size move < from Window Message CASE @WM_EXITSIZEMOVE ' if finished changing the Window size then repaint Tint MakeBackground CASE @IDCREATE CENTERWINDOW Main ENDSELECT RETURN |
| STEP 4 (a)
Code the Sub MakeBackground Part (a) of the Sub is where the Graduation Tint is made and applied to the Client Area of the Window. Actually it is applied to a RECT that covers the Client Area of the Window. Comments explaining each process are made in GREEN print throughout the code. Basically the Screen Height is divided into 255 RECTangles (dif
= height / 255) which are drawn one above the other - each one having
a different color - so as to give the Graduation Effect.
|
SUB MakeBackground
DEF left, top, width, height:INT DEF dif:FLOAT DEF newtop, newheight, dz, fx, gx, bt:INT ' get Client Area
to place Tint into
|
| STEP 4 (b)
Continuing with the Sub, Text is added on top of the Graduation Tinted RECT. First two RECT are Drawn to give a Drop Shadow Effect to the Box where the type will be placed. Next the Text is Printed too the above RECT as Black Print, which will be used to give Shadow to the Type. Finally the MOVE statement offsets the type to PRINT the text in RED above the Black Text. |
Continued from the SUB above
' put rect to hold text on screen - Black RECT for Shadow RECT Main, left+22, top+12, width-40, 33, RGB(0,0,0),RGB(0,0,0) ' Yellow Rect with Red Border - offset on top of Black RECT RECT Main, left+20, top+10, width-40, 33, RGB(255,0,0),RGB(255,255,0) ' Set the font to use for text SETFONT Main, "Arial", 18, 900, @SFITALIC ' Draw Mode set to Transparent so type uses existing background DRAWMODE Main, @TRANSPARENT ' set color for the typeface - black for drop shadow FRONTPEN Main, RGB(0,0,0) ' Position on screen to print text MOVE Main, 26,13 ' Place the text on screen PRINT Main, "Graduation Tint - by Bizzy" ' set color for the typeface - red for type FRONTPEN Main, RGB(255,0,0) ' Position on screen to print text - ' offset from above text to produce shadow MOVE Main, 25,12 ' Place the text on screen PRINT Main, "Graduation Tint - by Bizzy" RETURN |
Use the Mouse to Re-Size the Window and see the Graduation Tint re-painted to the screen.
Graduation Tints can also be added to any area on the window in the same way simply be specifying the RECT area of the Screen to work with. For Example the RECT where the Type was printed could have its own Graduation Tint instead of the Solid Yellow simply by working another Tint to the size of the RECT.