Welcome to Dream.In.Code
Getting Help is Easy!

Join 105,775 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,277 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Common Dialog Control (VB6)

 
Reply to this topicStart new topic

> Common Dialog Control (VB6), What it is, example of using it

benpap
Group Icon



post 18 Dec, 2007 - 01:23 PM
Post #1


Hello there, in this tutorial we will be discussing the common dialog control.

I'll first explain what this is.

Common dialog control is a component that allows us to access inbuilt libraries.
If you don't know what these are let me explain it to you with an example.

Open the notepad go to File and click Save As... A window will pop up with a couple
of components (command buttons, combo boxes, etc). You will face other programmes having
the same kind of window with these components. If you have TextPad, an editor that comes
in handy for programmers, you will see the same.

The reason why to use common dialog controls is that you won't need to spend time making
your custom libraries, just use the inbuilt ones, but it's up to you.

Lets get started!

We will now built a small application that changes the colour of a picture box

Open a new project, select Standart.exe. Right click on the tools list, go to components,
find and select Microsoft Common Dialog Control (6.0 in my case). Add a picture box name
it to "picbox" and also change the AutoRedraw to true. Then add a command button, name it
"cmdsetcol". In the end add a common dialog control and name it "cmdlg".

Now we'll go to the coding.

Use the following code for the command button:
CODE

cmdlg.ShowColor
picbox.BackColor = cmdlg.Color


Now by pressing the button an inbuilt library of colour selection will pop up. You might
have come across it in several painting applications and several times colour changing
is involved. After selecting a colour and proceeding to our form the pictures box colour
will automatically change to the colour we selected due to the second line of code.
Its very easy!

Let us add a text box and another two command buttons and add the following code the them:
CODE

Private Sub Command1_Click()
cmdlg.ShowColor
Text1.ForeColor = cmdlg.Color
End Sub

Private Sub Command2_Click()
cmdlg.ShowColor
Text1.BackColor = cmdlg.Color
End Sub


Now we can change the back and character colour of the text box.

Hope you understood it all briefly and i wish you learning and coding!
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

Gin13lind
*



post 15 Feb, 2008 - 06:53 AM
Post #2
NC man tnx. simple but great help... biggrin.gif coz Im trying 2 imitate paint application.. icon_up.gif icon_up.gif icon_up.gif
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 8/21/08 04:14PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month