Illustration of ccolordialog, Visual Basic Programming


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*/


COLORREF color = dlg.GetColor();

//color can be a var and assign value

CBrush mybrush(color);




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
In this unit you have learned how to develop Web pages which use VBScript. You have learned to insert logic to your Web pages as along with any other programming application. You h

A variation on the If...Then...Else statement lets you to choose from various alternatives. By adding up Else If clauses expands the functionality of the If...Then...Else statement

Cdatabase Class: The CDataBase class helps to connect to the data source. The Open member function opens a connection to the data source. CRecordset class is used for performi

VBScript Operators VBScript contain a full range of operators, including comparison operators, arithmetic operators, concatenation operators, and logical operators.

ToolTip: The ToolTip property is used to flash a message regarding a control object when the mouse pointer moves over that object for a couple of seconds. Pick a control and c

1.   Make project in Visual Studio 2008. 2.   Controller Class is used for functioning. 3.   Login Form where three people can login like manager, staff and receptionist we c

The user has to enter a starting balance, the dollar amount of deposits, and the dollar amount of withdrawals. the program then has to calculate the balance

Returns or sets a numeric value indicating an error. Number is the Err object's default property. While returning user-defined error from an Automation object, set Err.Number throu

Aim: To exhibit what is the day when the second command button is clicked and to clear the screen when the first command button is clicked. The functioning of this program is