Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old October 28th, 2003, 04:23 AM
rjstephens rjstephens is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Brisbane, Queensland, Australia
Posts: 54 rjstephens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Commondialg Control Colour codes

How do I turn the colour code returned by the commondialog control into 3 values for red, green and blue?

(i'm using VB5)

Thanks,
Richard

Reply With Quote
  #2  
Old October 28th, 2003, 08:04 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
the common dialog control returns a color code that is equivilant to a vb constant. You can use this value to set any control's color value, but I don't know of any way right off hand to convert this to a rgb value.

Reply With Quote
  #3  
Old October 28th, 2003, 08:05 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,171 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 37 sec
Reputation Power: 110
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
are you able to capture the color code? if so, what format is it currently in?
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #4  
Old October 28th, 2003, 08:53 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
The common dialog can be exteremly simiple to work with sometimes and other times you are thinking about giving up. Lets see if we can solve some of the problems that you are having with the common dialog. First we want to make sure that you have the common dialog compent added to your project. So goto Project -> Components -> add Microsoft Common Dialog Control6.0 (SP3).

Now we can get started first we are going to look at how to change the color of the form using the common dialog and a command button. Add a command button and the common dialog control.

The following are some flags for using the Color dialog boxes.

&H1 - This is one i personally like. This makes the common dialog start showing its current color.

&H2 - This starts with the custom color tab open.

&H4 - This makes it so they can not create custom colors.

&H8 - This adds a help button to the dialog.

&H10 - This will reset the common dialog to default.


Flags are simply options or choices you can use. To set them....

Code:'Setting it for use
CommonDialog.Flags = &H1
'Setting it for use of more than one
CommonDialog.Flags = &H1 Or &H4

Now that you have a foundation in what flags are lets change the color of the form. Copy the code below into the Command1_Click.

Code:With CommonDialog1
.Flags = &H4 Or &H8 'No custom colors and adds the help button
.ShowColor 'Show Dialog
Me.BackColor = .Color
End With

Wow! you changed the color of your form through a command button and the common dialog. I bet you are asking gee this is awesome I wonder what else I can do with it. Well, I am glad that you asked next we are going to change the font on the form and then I will show you how to change the font of a textbox.

The following are some flags for using the Font dialog boxes.

&H1 - Allows the dialog only to list fonts supported by the system.

&H2 - Allows the dialog only to list fonts supported by the printer.

&H3 - Lists the fonts from the two above.

&H4 - Adds a help button.

&H100 - Allows the choices of underline strike thru and color selection.

&H2000 - Shows only font sizes between the min and max.

&H20000 - Allows only fonts that can be scaled.

&H40000 - Allows only true type fonts


First we are going to change the font of a textbox, you can continue this on the same project as above but if you just another command button. For this we will need a text box Copy the code below in to command button click event.

Code:With CommonDialog1
.FontName = Me.FontName
.Flags = &H100 Or &H4 Or &H3
.ShowFont
Text1.FontName = .FontName
Text1.FontItalic = .FontItalic
Text1.FontBold = .FontBold
Text1.FontStrikethru = .FontStrikethru
Text1.FontUnderline = .FontUnderline
Text1.FontSize = .FontSize
Text1.ForeColor = .Color
End With

To change the font of the form is rather similar to what we have above the only difference would be that we use Me. instead of Text1. That code would look like this (still in the command button click event)

Code:With CommonDialog1
.FontName = Me.FontName
.Flags = &H100 Or &H4 Or &H3
.ShowFont
Me.FontName = .FontName
Me.FontItalic = .FontItalic
Me.FontBold = .FontBold
Me.FontStrikethru = .FontStrikethru
Me.FontUnderline = .FontUnderline
Me.FontSize = .FontSize
Me.ForeColor = .Color
End With

Now we are going to the world of saving and opening files.

The following are some flags for using the Open dialog boxes.

&H2 - Forces a warning before overwriting a file

&H8 - Stops default directory from changing

&H10 - Shows help button.

&H200 - This makes it so more than one file can be selected.

&H1000 - This makes it so the file must exist.

&H2000 - This warns the user before creating a new file.


The code below is just an example of opening a text file and placing in a text box. The code below belongs in a command button or menu, but if you wish you can have it on form load. Your options are endless with visual basic.

Code:CommonDialog1.ShowOpen
Open CommonDialog1.FileName for Input as #1 'Opens The File
Do until Eof(1) 'Loops till complete file added to Textbox
Line Input #1, Tmp
Text1.Text = Text1.Text & Tmp
Loop
Close #1 'Closes the file

Now for saving files.... As I said just ealier this code does belong with a command button or a menu. Just remember that nothing is impossible your imagination is your limits.

Code:CommonDialog1.ShowSave
Open CommonDialog1.FileName for Output as #1 'Opens The File
Print #1, Text1.Text 'Creates The File
Close #1 'Closes the file

Now for all the people that want to show the printer.

The following are some flags for using the Printer dialog boxes.

&H4 - Makes it so they cant choose to print only selected text.

&H8 - Does not allow you to choose to print certain pages like 4-7.

&H800 - This shows the help button.

&H40 - This shows the print setup dialog box rather than the printer dialog box.

&H100000 - This gets rid of the print to file option box.


Code:Printing Landscape - Printer.Orientation = 2
Printing Portrait - Printer.Orientation = 1

Reply With Quote
  #5  
Old October 28th, 2003, 08:54 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Thumbs up More Help!

Microsoft - HOWTO: Use a Common Dialog File Open Dialog with Win32 API
http://support.microsoft.com/defaul...B;en-us;q161286
__________________
Being a Code Headman !

Reply With Quote
  #6  
Old October 28th, 2003, 09:18 AM
Unkie Unkie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 32 Unkie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 27 sec
Reputation Power: 5
HOHOH, that was fun to read
:'-)

Reply With Quote
  #7  
Old October 28th, 2003, 02:59 PM
rjstephens rjstephens is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Brisbane, Queensland, Australia
Posts: 54 rjstephens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
thanks for all the hellp guys

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Commondialg Control Colour codes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway