Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Background in an mdi form


Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2005, 03:47 AM
icampbell's Avatar
icampbell icampbell is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Northumberland, England
Posts: 236
Default Background in an mdi form


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.

Ian.
__________________
Were all going to heaven lads, wey heyy.....
Reply With Quote
  #2  
Old 11-23-2005, 06:22 AM
mcdonnc2004's Avatar
mcdonnc2004 mcdonnc2004 is offline
Junior Contributor
 
Join Date: Dec 2003
Location: Liverpool, UK
Posts: 276
Default

Simple bit of code will draw a gradient fill on your form:

Code:
Private Sub Form_Load() DrawBackGround End Sub 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 Next intY ' 'Print 'shadowed' appname ' CurrentX = intSHADOWSTART CurrentY = intSHADOWSTART ForeColor = QBColor(intSHADOWCOLOR) Print Caption CurrentX = intTEXTSTART CurrentY = intTEXTSTART ForeColor = QBColor(intTEXTCOLOR) Print Caption End Sub

You must set the AutoRedraw property on the form to True for it to work.
Reply With Quote
  #3  
Old 11-23-2005, 06:46 AM
icampbell's Avatar
icampbell icampbell is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Northumberland, England
Posts: 236
Default

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 ?
__________________
Were all going to heaven lads, wey heyy.....
Reply With Quote
  #4  
Old 11-23-2005, 10:50 AM
LaVolpe's Avatar
LaVolpe LaVolpe is offline
Ultimate Contributor

* Expert *
 
Join Date: Apr 2004
Location: Illinois
Posts: 2,499
Default

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; 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.
__________________
Insomnia is a simple byproduct of "it can't be done" {Window Shaper}

Last edited by LaVolpe; 11-23-2005 at 10:55 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->