Program to zoom a rectangle as you drag - visual c++, Visual Basic Programming

PROGRAM TO ZOOM A RECTANGLE AS YOU DRAG

1. Generate a SDI application

2. Declare the 2 member variables clicked of Boolean type and m_ptoldpt of CPoint type. Use the class tab page and add member variables on the View Class by right clicking.

3. Using the Class wizard add the messages left button up, left button down and mouse move.

4. Type the below coding in the left button down the event handler.

void CDragView::OnLButtonDown(UINT nFlags, CPoint point)

{

clicked=true;

}

The Boolean variable clicked is put to true.

5. Type the below coding in the left button up event handler.

void CDragView::OnLButtonUp(UINT nFlags, CPoint point)

{

clicked=FALSE;

Invalidate(TRUE);

}

The Boolean variable clicked is set to FALSE and OnDraw() function is called using the Invalidate() function. The TRUE parameter clears the screen by calling the WM_PAINT.

6. Type the below coding in the Mouse Move event handler.

void CDragView::OnMouseMove(UINT nFlags, CPoint point)

{

if(clicked)

{

CDC *dc = GetDC();

dc->Rectangle(oldpt.x,oldpt.y,point.x,point.y);

oldpt=point;

}

}

When the mouse button is released with the end point as first point and where the mouse button was released a rectangle would be drawn.

Posted Date: 10/10/2012 1:38:19 AM | Location : United States







Related Discussions:- Program to zoom a rectangle as you drag - visual c++, Assignment Help, Ask Question on Program to zoom a rectangle as you drag - visual c++, Get Answer, Expert's Help, Program to zoom a rectangle as you drag - visual c++ Discussions

Write discussion on Program to zoom a rectangle as you drag - visual c++
Your posts are moderated
Related Questions
If Then Else: The control statement If Then Else is used for computing a condition and taking the action based on the condition. If the condition is true then the section will

INTRODUCTION TO CONTROLS AND TOOLBARS The Visual Basic programming is an event driven programming. In the form objects the termed controls are placed. We can put the properties

APPWIZARD   The Appwizard is a tool used for creating a project. It follows a series of steps to create a project. Steps Involved in Creating A Project: Step 1: Fr

what are the functions and the importance of hierarchy operators

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

Retrieval Methods: There are 3 ways to find a document. The primary method is a positional retrieval. This is achieved by keeping in mind where you left it. The next method is

I have a project due tomorrow that I am really struggling in. Please help.


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

Graphics Device Interface - GDI:   The GDI is a windows API. The GDI uses a set of generic graphics objects to draw to the screen, to the memory and printers. Therefore the p