|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
||||
|
||||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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 !
|
|
#6
|
|||
|
|||
|
HOHOH, that was fun to read
![]() :'-) |
|
#7
|
|||
|
|||
|
thanks for all the hellp guys
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Commondialg Control Colour codes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|