11-23-2005, 03:47 AM
Can anyone tell me if you can have the background in an mdi form to have 2 colours merged.
By that i mean like you see in installation programs where the top half of the screen is a light blue and the bottom part is dark blue and they fade into each other.
I have tried to change the colour using the back colour pallet but it only allows me to select 1 colour.
Any advice would be helpful.
11-23-2005, 06:22 AM
Simple bit of code will draw a gradient fill on your form:
Private Sub Form_Load()
Private Sub DrawBackGround()
Const intBLUESTART% = 255
Const intBLUEEND% = 0
Const intBANDHEIGHT% = 2
Const intSHADOWSTART% = 8
Const intSHADOWCOLOR% = 0
Const intTEXTSTART% = 4
Const intTEXTCOLOR% = 15
Dim sngBlueCur As Single
Dim sngBlueStep As Single
Dim intFormHeight As Integer
Dim intFormWidth As Integer
Dim intY As Integer
'Get system values for height and width
intFormHeight = ScaleHeight
intFormWidth = ScaleWidth
'Calculate step size and blue start value
sngBlueStep = intBANDHEIGHT * (intBLUEEND - intBLUESTART) / intFormHeight
sngBlueCur = intBLUESTART
'Paint blue screen
For intY = 0 To intFormHeight Step intBANDHEIGHT
Line (-1, intY - 1)-(intFormWidth, intY + intBANDHEIGHT), RGB(0, 0, sngBlueCur), BF
sngBlueCur = sngBlueCur + sngBlueStep
'Print 'shadowed' appname
CurrentX = intSHADOWSTART
CurrentY = intSHADOWSTART
ForeColor = QBColor(intSHADOWCOLOR)
CurrentX = intTEXTSTART
CurrentY = intTEXTSTART
ForeColor = QBColor(intTEXTCOLOR)
You must set the AutoRedraw property on the form to True for it to work.
11-23-2005, 06:46 AM
Yes this works great on a normal form.
But there is no autodraw on an MDI Form, so it does not run.
any other ideas ?
11-23-2005, 10:50 AM
The MDI background is really another window. A somewhat simple, non-subclassing approach to fill the background with other colors or images is to draw what's needed on a memory DC and then convert the DC's bitmap to a stdPicture object; then setting that picture object to the MDIForm's.Picture property. A good example can be found at a MVPS website (http://www.mvps.org/vbvision/Sample_Projects.htm#MDI_Background_Demo); however, you'll need to cut & paste some of the code; not all would be appropriate. Between similar code posted above (gradients) & the non-subclassing approach in the link's sample, you'll be able to set up your gradient background.
P.S. for the sample at the website, also extract the exe found in the zip file. You don't need to run the exe, but to run the sample in IDE, it will be looking for images inside of that exe's compiled resources.