Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Visual Basic Expert

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);

}

Visual Basic, Programming

  • Category:- Visual Basic
  • Reference No.:- M9510964

Have any Question?


Related Questions in Visual Basic

Assignment virtual storeuse the concepts and scenario from

Assignment: Virtual Store Use the concepts and scenario from Assignment 1 to help "Your" Virtual Business to increase the functionality of its online shopping cart. When a customer checks out, the shopping cart must stor ...

Please show how to do the belowvisual basic net application

Please show how to do the below: Visual Basic .NET Application - Coding Exercise 1 (Exercise 13, Zak, 2016, p. 347) For this coding exercise, write the Visual Basic code for a pretest loop that uses an Integer variable n ...

Assignment frans virtual fruit standfrans virtual fruit

Assignment: Fran's Virtual Fruit Stand Fran's Virtual Fruit Stand is an online store that sells several types of dried fruit. Based on the needs of Fran's Virtual Fruit stand, you must design a flowchart using Visual Log ...

Pitch amp game design documentthe assignment is about

Pitch & Game Design Document The assignment is about educational driver for teenagers Assignment Brief: In groups you will: - present a pitch and produce a one sheet - provide a demonstration of your game - produce a hig ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As