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:
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:
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!