BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department...

50
BZUPAGES.COM Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

Transcript of BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department...

Page 1: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Lecture – 6- 7 Miss. SADAF MAJEED SIAL

Computer Science Department Bahauddin Zakariya University Multan.

Page 2: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

It’s a Software tools with which using step by step procedure.

Wizard creates a full environment for application designs.

For dialog based programming Wizard programming is used.

In which we design applications with using such types of applications as ◦ SDI (Single document)◦ MDI (Multiple Document)◦ Dialog Based

Page 3: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

SDI stands for Single document interface. An Application which perform operation on one document at one time….eg Notepad

In which data is used as Text, Graphics, Sound etc

For used SDI programming we want to help with the AppWizard.

AppWizard is used to write a great deal of code in our program.

Page 4: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Simultaneously more than one files can be opened in one application.

In which the programs will automatically create a new document object for each new object.

This means that pure data storage and display. Eg….. MS-WORD Using two different window type raises as

interesting issue in MDI programming when the user is working on the document and also want certain menus as File, Edit….etc

Page 5: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

This is one of the rectangle area that is used for a purpose of input.

Graphics tools are used in it. For dialog based programming also used

AppWizard. In dialog Based programming controls are

used for input and create our own application through Wizard.

These controls are of many types. Such as Buttons, Radio, Check Boxes …etc

Page 6: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

For create application through Wizard two classes are used in which

CWinApp CDialog

CWinApp in used for the handle the full application and next CDialog Class is used for handle the dialog boxes.

These are the base classes of Wizard.

Page 7: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

“Test” name of application Wizard will design this using 2 base classes.

◦ CTestApp (derived from WinApp) Test.h Test.cpp

◦ CTestDlg (derived from WinApp) Testdlg.h Testdlg.cpp

Page 8: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Is automatically generates a basic framework for the windows programs. Infect, the framework is itself a complete, executable windows programmes.

In Wizard, further capabilities for managing , modifying and extended code is provided by the Wizard bar, Which is optionally displayed in the toolbar area of Vc++ window.

It’s a particularly used in the context of MFC and API based programming

Page 9: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Classes are the most important language feature of c++ and are fundamental to Windows programming with Visual C++.

The class wizard provides an easy means of extending the classes by AppWizard as a part of basic windows application and also helps to add new classes based on MFC Classes.

And also the ClassWizard neither recognizes nor deals with the classes that are not based on MFC Classes.

Page 10: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 11: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Dialog: this is one of the rectangle area that is used for the purpose of input.

In dialog based programming such controls are used.

Apart from these forms of input, then also supply input through user interface objects like.

Page 12: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Controls/Buttons WNDCLASS

1. Buttons2. List Boxes3. Edit Controls4. Combo

Boxes5. Scroll bars6. Static

Controls7. Check Box8. Slider9. Radio

Buttons

BUTTON LISTBOX EDIT

COMBOBOX SCROLLBAR STATIC BUTTON SLIDER BUTTON

MFC ClASS

• CBUTTON• CLISTBOX• CEDIT

CCOMBOBOX• CSCROLLBAR• CSTATIC• CBUTTON• CSLIDER• CBUTTON

Page 13: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

For any application, we have to attach variables with IDs in control.

IDs can’t directly be process so we attach variables as: variable name, category and type.

Data to be stored in variables from controls & variables are then attached.

Page 14: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

For that, functions which used for that processing.

UpdateData(true)◦ Transfer data from control to be respected

variables.

UpdateData(false)◦ Transfer data from variable to controls.

Page 15: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

MFC provides for creating and communicating. This involves constructing an object from a control class and calling that object’s create () function.

All the MFC control classes override the create () function inherited from cwnd to simplify creation of control.

E.g. mybutton in an object of the type cbutton, mybutton.

Create (“ok”, WS-CHILDIWS-VISIBLE BS-PUSHBUTTON, CRECT (100, 100, 150, 150), This 1),

Page 16: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

This statement create a push button control.

1.The first parameter in the text that will appear on the face of button.

2.The 2nd in the button style.3.Third parameter specifies the control’s

location and size.4. ‘this’ identifies the parent window.5. ‘1’ in the identifier for the control. This

value in abo knows as child window ID.

Page 17: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Controls:-

Page 18: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

button controls are of four types1. Push button2. Check boxes3. Radio buttons4. Group boxes

Page 19: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Push buttons are 3D rectangle that appear to go up and down when clicked as if they were push buttons on a control panel.

Check boxes•Check boxes are small squares in which check marks can be toggled on and off.

Page 20: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Onchkclick(){Update data (true);If (m-chk ==)m-text = “checkbox checked”;Elsem-text = “unchecked”;update data (false);}

Page 21: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Radio buttons are small circles that are checked with a solid dot when clicked. Radio buttons are usually used to present a list of mutually exclusive option to the user. That is , checking one radio button unchecks the others in the group.

Radio buttons are provide multiple selection b/w catagories.

Page 22: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Ans For handling and grouping of radio buttons, in one line

all radio buttons are considered in one group and If we want to make a group, in an application then we make different groups in this dialog box to select more then one radio buttons at atime. But each in every group. That’s because the three radio buttons already function as a group automatically. They are all in the same window, so they are already coordinated. When the click one of these radio buttons, the program de-selects the other automatically, because they are all share the same window.

In that variable is of into type & is attached only with the group’s checked button which is checked in a particular group.

Page 23: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Group boxes are nothing but rectangles used for visual effect.

A button can be clicked with the left mouse button or the spacebar works only if the button has the input focus. A button indicates that it has the input focus by displaying a thin dotted rectangle known as a focus rectangle.

Page 24: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

A list box is used to display a list of text strings called Items.

An item can be anything that we can describe with the string, a file, name, rno, address…etc

A list box can have capabilities like sorted strings or scroll bars if required.

When the no of choices in list are extended on dialogue box becomes difficult then list box is used.

It takes less area. List box can also be used as radio buttons or

checkboxes of selection point of view.

Page 25: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

For a List boxes, in there properties checked in the selection check box is extended.

A list box is very useful for presenting a list of items and enabling the user to select items from the list.

A standard list box displays strings in a vertical column and allows only one item to be selected at a time.

The currently selected item in a list box is highlighted usually with blue color.

Page 26: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

For list boxes such functions will be used for add,, selection, get text and counting…etc

These functions are used with the control variables.

Without attach variables with these functions the functions can’t work properly.

Page 27: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Used for add elements in list boxes.

m_list.AddString(string)Eg:

m_list.AddString(“one”);m_list.AddString(“two”);m_list.AddString(“three”);

Page 28: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Used for get text of particular elements through index number.

m_list.GetText(index,string);Eg:

m_list.GetText(3, str);m_list.GetText(2, str);

Page 29: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Used for get current selection.

This will return index of currently selected element. If single selection option is used.

m_list.GetText();

Page 30: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

This will count total number of elements in the list.

m_list.GetCount();

Page 31: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

This will be used to delete a particular element whose index is passed as parameter.

m_list.DeleteString(index);

Indexes are rearranged after deleting.

Page 32: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

A function is used to check which element is selected.

This will return 0 or 1.

int= GetCount(index);

Page 33: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

This will return the number of currently selected elements.

m_list.GetSelCount(index);

Page 34: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

This is a dropdown list. A combo box control is a combination of a

single line edit control and a list box. The edit control sits on the top of the

listbox. There are three types of combo boxes.

1. Simple2. Drop-Down3. Drop-down list

Page 35: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

The list is displayed permanently. When the user selects an item from the list

box, the item is automatically copied in the Edit control.

Text may also be typed in the simple combo box.

Page 36: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Is similar to a simple combo box.

but the list box is displayed only when the user clicks the downward pointing arrow to the right of the Edit box.

Page 37: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Works similar but does not permit text to be typed in the edit control.

As a result, the user’s selection is restricted to only items that appearing in the list box.

Page 38: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

The functions of combo box is same as list box control,

Just for text another function is used.

m_list.GetLBText(index, str)

Page 39: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Edit controls are used for text entry and editing. These controls have built-in support for

operations like cut, copy, paste, undo..etc Edit control can be either single or multi line. Single line edit control are usually used to

receive one line text strings like name, password……etc

Multi-line edit control are used to accepting longer text strings like addresses, product info ……etc

Page 40: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 41: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Text Strings:◦ Are usually used alongside other controls like Edit

Boxes or list boxes describing their purposes.

Rectangles:◦ Are used to group together related controls by

drawing rectangle around them.

Images:◦ Static controls can also be used to display images

formed from bitmap, icons, cursors, or metafiles.

Page 42: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Scroll bar controls are similar to the scroll bars attached to the window.

The difference is that the scroll bars attached to the window are obtained by specifying a window style.

ScrollBar::Create()

Page 43: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

For manage the controls on Dialog Box with respect to the specific application variables are attached with these controls to following such steps.

Page 44: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 45: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 46: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 47: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 48: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 49: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM

Page 50: BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM