|
-
Nov 15th, 2005, 09:50 AM
#1
Thread Starter
Frenzied Member
Form With 2 Back Colors!
I want the BackColor of a Form to be a haphazard combination of 2 colors. Can this be done? Of course, an image can be added to the Form so that it looks like the Form's background but apart from this, is there any way to set the BackColor of a Form with 2 colors?
Thanks,
Arpan
-
Nov 15th, 2005, 09:53 AM
#2
Re: Form With 2 Back Colors!
hello arpan
You mean like gradient forms?
-
Nov 15th, 2005, 09:55 AM
#3
Re: Form With 2 Back Colors!
-
Nov 15th, 2005, 09:57 AM
#4
Re: Form With 2 Back Colors!
I like to use this in my About boxs
VB Code:
Private Sub Form_Paint()
Dim lngY As Long
Dim intColor As Integer
ScaleMode = vbPixels
DrawStyle = 5
FillStyle = 0
For lngY = 0 To ScaleHeight
intColor = (255 - (lngY * 255) \ ScaleHeight)
FillColor = RGB(intColor, intColor, intColor)
Line (-1, lngY - 1)-(ScaleWidth, lngY + 1), , B
Next lngY
End Sub
-
Nov 15th, 2005, 10:13 AM
#5
Re: Form With 2 Back Colors!
Simple and Sweet - if you can change directions that would be like honey.
-
Nov 15th, 2005, 10:28 AM
#6
Thread Starter
Frenzied Member
Re: Form With 2 Back Colors!
I had a look at all the 3 codes & all 3 seems to do almost the same thing but Hack's example is the shortest one; so I will go for that!
Hack, how do I change the colors to blue & lime using your code? I tried changing a few values here & there but wasn't successful!
Thanks to all,
Regards,
Arpan
-
Nov 15th, 2005, 10:39 AM
#7
Re: Form With 2 Back Colors!
To create a little color effect using Hack's code try changing values for RGB function. Here are few to begin with:
FillColor = RGB(0, intColor, 255) ' blue
FillColor = RGB(0, 255, intColor) ' green
FillColor = RGB(255, intColor, intColor) 'red
FillColor = RGB(255, 0, intColor) ' magenta/red
FillColor = RGB(255, intColor, 0) ' yellow/red
and so on ...
-
Nov 15th, 2005, 10:53 AM
#8
Re: Form With 2 Back Colors!
You are not stuck with standard RGB colors either. You can use the ShowColor feature of the commondialog to create your own colors. If you want, play around with this
VB Code:
Private Sub Command1_Click()
CommonDialog1.ShowColor
Text1.Text = CommonDialog1.Color
Text2.Text = Hex(Val(Text1.Text))
End Sub
Using that, I've come up with some of my own color concoctions that I really like and use as follows
VB Code:
Option Explicit
Private Enum MyOwnColors
clrMistyRose = &HE1E4FF
clrSlateGray = &H908070
clrDodgerblue = &HFF901E
clrDeepSkyBlue = &HFFBF00
clrSpringGreen = &H7FFF00
clrForestGreen = &H228B22
clrGoldenrod = &H20A5DA
clrFirebrick = &H2222B2
End Enum
Private Sub Form_Load()
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is Textbox Then
ctrl.Backcolor = MyOwnColors.clrMistyRose
End If
Next
End Sub
-
Nov 15th, 2005, 10:58 AM
#9
Thread Starter
Frenzied Member
Re: Form With 2 Back Colors!
Here are few to begin with:
FillColor = RGB(0, intColor, 255) ' blue
FillColor = RGB(0, 255, intColor) ' green
FillColor = RGB(255, intColor, intColor) 'red
FillColor = RGB(255, 0, intColor) ' magenta/red
FillColor = RGB(255, intColor, 0) ' yellow/red
and so on ...
I tried out some combinations & permutations but I can't seem to get blue & lime.
FillColor = RGB(0, 0, intColor) 'this renders blue & black
FillColor = RGB(0, 255, intColor) 'this renders cyan & lime
FillColor = RGB(intColor, 255, intColor) 'this renders white & lime
But somehow I am not getting the blue & lime combination! Any idea what could be that combination?
Thanks,
Arpan
-
Nov 15th, 2005, 11:16 AM
#10
PowerPoster
Re: Form With 2 Back Colors!
-
Nov 15th, 2005, 11:19 AM
#11
Re: Form With 2 Back Colors!
 Originally Posted by Pasvorto
I like it!!!
Which part?
-
Nov 15th, 2005, 11:31 AM
#12
Thread Starter
Frenzied Member
Re: Form With 2 Back Colors!
FillColor = RGB(25, intColor, 140)
The above renders lime & blue but the blue is the navy blue or dark blue. Have a look at the image below:
I want that shade of blue & lime.
Arpan
-
Nov 15th, 2005, 11:37 AM
#13
Re: Form With 2 Back Colors!
It appears to me arpan that you may mark this thread as [RESOLVED] - all that's left for you is to play with numbers.
-
Nov 15th, 2005, 11:40 AM
#14
Re: Form With 2 Back Colors!
 Originally Posted by RhinoBull
It appears to me arpan that you may mark this thread as [RESOLVED] - all that's left for you is to play with numbers. 
I'm actually playing around to see if I can add a clrBlueLime to my bag of color tricks, but I would agree with your assessment.
-
Nov 15th, 2005, 11:41 AM
#15
PowerPoster
Re: Form With 2 Back Colors!
I put Hack's code into an obscure form as a test. Man, does that look nice! Maybe I have just gotten too bored with the "Button face" color scheme.
-
Nov 15th, 2005, 11:53 AM
#16
Frenzied Member
Re: Form With 2 Back Colors!
 Originally Posted by Pasvorto
I put Hack's code into an obscure form as a test. Man, does that look nice! Maybe I have just gotten too bored with the "Button face" color scheme.
Yep, me too! I never even thought of trying to make my own colors.
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
-
Nov 15th, 2005, 11:55 AM
#17
Re: Form With 2 Back Colors!
Yea but you have to be carefull with multicolor schemas - lot of people hate'm so you might want to give a choice. Besides, if you're business user then you are most likely to get tired from just looking at that rainbow day long ... Greyish colors were choosen to be default for a reason: they are not pretty but relaxing.
-
Nov 15th, 2005, 11:58 AM
#18
Re: Form With 2 Back Colors!
 Originally Posted by RhinoBull
Yea but you have to be carefull with multicolor schemas - lot of people hate'm so you might want to give a choice. Besides, if you're business user then you are most likely to get tired from just looking at that rainbow day long ...  Greyish colors were choosen to be default for a reason: they are not pretty but relaxing.
Sage advice my friend, which is why I only use a form covering color scheme for my Aboutbox (really now, how many people ever bother to look at the Aboutbox, or, for that matter, know what it is or where it is).
The individual colors I will use to for things like highlighting a textbox that has focus (and returning the backcolor to the standard vbWhite on LostFocus) or highlighting required fields.
-
Nov 15th, 2005, 12:02 PM
#19
PowerPoster
Re: Form With 2 Back Colors!
Microsoft Great Plains software uses a Blue scheme. I have not heard any complaints from any of ther users about it. Certainly you have to be careful about "known" bad combinations (eg; red and green) and people who are color blind. But on the whole, I think color is good.
A couple issues, however. Command buttons, for one, do not have a background color that I can change. So I am stuck with a cool color scheme, and a "Button Face" command button. So, I either have to get a different control, or make my own. I thought I read somewhere that I could change the back & fore colors of the command buttons in VB.NET 2005. Anyone else hear that?
Now, how to modify this so that it will work with the background of an MDI parent. There is no "ScaleMode" property.
-
Nov 15th, 2005, 12:04 PM
#20
Re: Form With 2 Back Colors!
If you set a command button to Graphical, you CAN change the colors of it. Enjoy!
-
Nov 15th, 2005, 12:06 PM
#21
PowerPoster
Re: Form With 2 Back Colors!
WOW!! Man, I learn something new everyday. There's no stopping me now :-)
-
Nov 15th, 2005, 12:45 PM
#22
Addicted Member
Re: Form With 2 Back Colors!
The best way is to use a photo editor which has an eye dropper that you can select the part of an image and it will display the RGB values.
(I know the problem has been resolved, just adding my 2 cents)
-
Nov 15th, 2005, 12:46 PM
#23
Thread Starter
Frenzied Member
Re: Form With 2 Back Colors!
It appears to me arpan that you may mark this thread as [RESOLVED] - all that's left for you is to play with numbers.
That's exactly what I have been doing but I guess you are right.....it's high time I mark this post [RESOLVED]. Actually I thought that there must be a specific combination for blue which, maybe, I am not aware of......that's the reason I asked you. Anyways, as I already said, you are right RhinoBull 
Thanks to all for your ideas, suggestions & comments,
Regards,
Arpan
-
Nov 15th, 2005, 01:23 PM
#24
Thread Starter
Frenzied Member
Re: Form With 2 Back Colors!
(I know the problem has been resolved, just adding my 2 cents)
Well, Jason, to be very honest, it hasn't been resolved yet. Till now I must have tried 500 combinations but I don't know why, either I am getting blue or lime but not the 2 of them together. Driving me crazy......will have to start pulling my hair soon I guess
& the worst thing is my work is getting hampered on this trivial issue as I am not able to proceed forward with the other aspects of the project!
Arpan
-
Nov 15th, 2005, 01:26 PM
#25
Re: Form With 2 Back Colors!
 Originally Posted by arpan_de
Well, Jason, to be very honest, it hasn't been resolved yet. Till now I must have tried 500 combinations but I don't know why, either I am getting blue or lime but not the 2 of them together. Driving me crazy......will have to start pulling my hair soon I guess
& the worst thing is my work is getting hampered on this trivial issue as I am not able to proceed forward with the other aspects of the project!
Arpan
As I said earlier, I've been playing around with it as well and so far I've had no more success than have you. What is so important about this particular color that the entire project is being hung up? I've had plenty of stumbling blocks thrown at me before, but I've never been hung up on a color.
-
Nov 15th, 2005, 01:36 PM
#26
Thread Starter
Frenzied Member
Re: Form With 2 Back Colors!
What is so important about this particular color that the entire project is being hung up?
My boss wants me to go step by step! Quite unbelievable, isn't it but that's the fact!!
The best way is to use a photo editor which has an eye dropper that you can select the part of an image and it will display the RGB values.
Jason, I implemented your idea & used PhotoImpact to get the RGB values. For blue, R=0, G=0 & B=255 & for green, R=0, G=255 & B=0 but how do I combine these 2 RGB values to paint the Form?
Arpan
-
Nov 15th, 2005, 06:03 PM
#27
Re: Form With 2 Back Colors!
Hack's version worked on greyscale, so the RGB parameters were all the same value, but your new values vary.
The R is always 0, so that can be fixed inside the RGB() function. The G and B are (luckily) exact opposites, so for a gradient between them you can decrease one while increasing the other, eg:
VB Code:
FillColor = RGB(0, intColor, 255 - intColor)
-
Nov 15th, 2005, 06:57 PM
#28
Re: Form With 2 Back Colors!
The blue is 2, 3, 253
The green is 2, 254, 2
Hope this helps you. (They are in RGB format, thanks to Photoshop CS2)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|