Illustration of ccolordialog, Visual Basic Programming

ILLUSTRATION OF CCOLORDIALOG

The constructor of the CColorDialog takes the initial parameter as the default color and the next parameter specifies how much the dialog is displayed. It is a modal dailog. The Modal dialogs are exhibited using the DoModal() function. The Modal dialog required to be disposed by clicking the ok or cancel button. To build a color dialog follow the steps as shown below.

1. Generate a SDI application.

2. Handle the Right button double click message for the CcolordlgView object id.

3. In response to Step 2 the event handler will be inserted in the colordlgView.cpp.

4. Generate a device context with which you can draw by using the CClientDC class.

5. Generate a color dialog object by using the CColorDialog class. In this situation dlg is the color dialog object.

6. The initial parameter RGB(255,0,0) shows that the Red is the default color.

7. The modal dialog is displayed by using the DoModal function as the dlg.DoModal()

8. We are going to choose a color from the color dialog.

9. Consequently create a variable color by using COLORREF.

10. The variable color is assigned the color by using the GetColor() function.

11. Generate a Cbrush object (mybrush) with the selected color to draw.

12. Use the selected color with the SelectObject function.

13. The SelectObject function will put into use of the new GDI object and return the present object.

14. By using the new color namely red, that is the default color, an ellipse would be drawn when the right button is double clicked.

15. Execute the project, double click the right button, select a color and click the ok button of the color dialog.

16. An ellipse would be filled with the selected color.

void CColordlgView::OnRButtonDblClk(UINT nFlags, CPoint point)

{

CClientDC dc(this);

CColorDialog dlg(RGB(255,0,0),CC_FULLOPEN);

/* RGB(255,0,0) red color, default also red color*/

dlg.DoModal();

COLORREF color = dlg.GetColor();

//color can be a var and assign value

CBrush mybrush(color);

dc.SelectObject(&mybrush);

dc.Ellipse(20,40,100,150);

}

Posted Date: 10/10/2012 1:40:02 AM | Location : United States







Related Discussions:- Illustration of ccolordialog, Assignment Help, Ask Question on Illustration of ccolordialog, Get Answer, Expert's Help, Illustration of ccolordialog Discussions

Write discussion on Illustration of ccolordialog
Your posts are moderated
Related Questions

RESOURCES The cursors, Icons, dialog, bitmaps accelerators, menu, table tool bar and string are the different resources. The resources are compiled by the resource compiler. Th

Hi, i need help in vb.net for the pelmanism game. I will appreciate if you can get back to me please

The scope of a variable is finding out by where you declare it. While you declare a variable in a procedure, only code in that procedure can access or alter the value of that varia

Question 1 Write about the Visual Basic Application Development Life cycle with a sample Forms development for performing integer arithmetic operations Question 2 Discuss the

Write a program that permits the user to order a product from inventory. The user selects the product and enters the quantity. If there is sufficient quantity on hand of the produc

Associating Toolbars for the menu: 1. Insert the tool bar control to your form. 2. Now follow the steps to append the tool bar control to your form. 3. Then, Right Click

You can control the flow of your script with conditional statements & looping statements.  By using conditional statements, you can write VBScript code which makes decisions and re

Input Box: To demonstrate the use of the Input Box as shown in figure. Now consider the illustration shown below: 1. Initiate a new project 2. Select the standard exe