Professional Documents
Culture Documents
1.What is GDI?
Many MS-DOS programs wrote directly to the video memory and the printer port. The
disadvantage of this technique was the need to supply driver software for every video
board and every printer model. Windows introduced a layer of abstraction called the
Graphics Device Interface (GDI).
Windows provides the video and printer drivers, so your program doesn\'t need to know
the type of video board and printer attached to the system. Instead of addressing the
hardware, your program calls GDI functions that reference a data structure called a
device context. Windows maps the device context structure to a physical device and
issues the appropriate input/output instructions. The GDI is almost as fast as direct video
access, and it allows different applications written for Windows to share the display.
3.What is DLL?
Windows allows dynamic linking, which means that specially constructed libraries can be
loaded and linked at runtime. Multiple applications can share dynamic link libraries
(DLLs), which saves memory and disk space. Dynamic linking increases program
modularity because you can compile and test DLLs separately. Designers originally
created DLLs for use with the C language, and C++ has added some complications. The
MFC developers succeeded in combining all the application framework classes into a few
ready-built DLLs. This means that you can statically or dynamically link the application
framework classes into your application. In addition, you can create your own extension
DLLs that build on the MFC DLLs..
WINDOWS.H is a master include file that includes other Windows header files, some of
which also include other header files. The most important and most basic of these header
files are:
The MessageBox function is designed to display short messages. The little window that
MessageBox displays is actually considered to be a dialog box, although not one with a
lot of versatility. The first argument to MessageBox is normally a window handle.. The
second argument is the text string that appears in the body of the message box, and the
third argument is the text string that appears in the caption bar of the message box. In
HELLMSG.C, each of these text strings is enclosed in a TEXT macro.
• GetStockObject Obtains a graphic object, in this case a brush used for painting the
window\'s background.
After the UpdateWindow call, the window is fully visible on the video display. The
program must now make itself ready to read keyboard and mouse input from the user.
Windows maintains a \"message queue\" for each Windows program currently running
under Windows. When an input event occurs, Windows translates the event into
a \"message\" that it places in the program\'s message queue.
A program retrieves these messages from the message queue by executing a block of
code known as the \"message loop\":
The WM_DESTROY message is another important message. This message indicates that
Windows is in the process of destroying a window based on a command from the user.
The message is a result of the user clicking on the Close button or selecting Close from
the program\'s system menu. (Later in this chapter, I\'ll discuss in more detail how the
WM_DESTROY message gets generated.)
PostQuitMessage (0) ;
In WM_PAINT messages. Two functions are involved: BeginPaint and EndPaint. These
two functions require the handle to the window, which is passed to the window procedure
as an argument, and the address of a structure variable of type PAINTSTRUCT, which is
defined in the WINUSER.H header file.
• Filled areas
• Bitmaps
• Text
11.What is TextOut?
TextOut is the most common GDI function for displaying text. Its syntax is
The first argument is the handle to the device context—either the hdc value returned from
GetDC or the hdc value returned from BeginPaint during processing of a WM_PAINT
message.
The device context also defines the font that Windows uses when you call TextOut to
display text. The default is a font called the \"system font\" or (using the identifier in the
WINGDI.H header file) SYSTEM_FONT. The system font is the font that Windows uses
by default for text strings in title bars, menus, and dialog boxes.
• Provide a reverse-video \"flash\" when the user clicks the scroll bar.
• Move the thumb as the user drags the thumb within the scroll bar.
• Send scroll bar messages to the window procedure of the window containing the scroll
bar.
\"Build a better mousetrap and the world will beat a path to your door,\" my mother told
me, unknowingly paraphrasing Emerson. Of course, nowadays it might make more sense
to build a better mouse.The Microsoft IntelliMouse features an enhancement to the
traditional mouse in the form of a little wheel between the two buttons. You can press
down on this wheel, in which case it functions as a middle mouse button, or you can turn
it with your index finger. This generates a special message named
WM_MOUSEWHEEL. Programs that use the mouse wheel respond to this message by
scrolling or zooming a document.
When you create or change menus in a program, it\'s useful to think of the top-level menu
and each popup menu as being separate menus. The top-level menu has a menu handle,
each popup menu within a top-level menu has its own menu handle, and the system menu
(which is also a popup) has a menu handle.
Each item in a menu is defined by three characteristics. The first characteristic is what
appears in the menu. This is either a text string or a bitmap. The second characteristic is
either an ID number that Windows sends to your program in a WM_COMMAND
message or the handle to a popup menu that Windows displays when the user chooses
that menu item. The third characteristic describes the attribute of the menu item,
including whether the item is disabled, grayed, or checked.
PART – B
Procedure. (8)
b. What are the methods available to get the DC and various types of DC
Handle? (14)
• Unit I
• Unit II
• Unit III
• Unit IV
• Unit V
PART - A
1.What are the primary windows inside the Visual Basic environment.?
Form
Toolbox
Project
Properties
Code
2. What is a form?
Forms are the basic element of the user interface in a Visual Basic application. They
provide a framework you can use throughout your application to give a consistent look
and feel. Differences in user interface design and behavior from one application to
another, or within one application, can result in increased training and support costs. In a
corporate environment, enforcing a consistent user interface across all of your
applications can help reduce those costs.
• Initialize
• Load
• Activate
• Deactivate
• QueryUnload
• Unload
• Terminate
• Load
• Unload
• Hide
• Show
Appearance
AutoRedraw
BackColor
BorderStyle
Caption
Integer
Long
Single
Double
Currency
7. What is DIM?
Dim—short for dimension—is a Visual Basic statement that you write in an application\'s
Code window. Whenever you learn a new statement, you need to learn the format for that
statement. Here is the format of the Dim statement:
9. What is Sub?
Subs enable you to change code easily. If you have a body of code that you need to use
repeatedly, put the code in a sub. Then, if you need to make a change in the code, simply
go to the sub to make changes. If you don\'t put the code in a sub, you will have to go to
every instance of the code in your program to make the required change. The more
dispersed your code is, the harder it is to make changes effectively and efficiently.
A sub is a procedure that executes the lines of code within its block but doesn\'t return a
value. The syntax for a simple sub is as follows:
.....lines of code
End Sub
If condition Then
If another_condition Then
statement
Else
another statement
End If
End If
Case Value1
Statement_Group_1
Case Value2
Statement_Group_2
End Select
When you place more than one control of the same control type on a form and assign the
same Name property to those controls, you\'re creating a control array. As with variable
arrays, a subscript that begins at 0 differentiates one control from another. The Index
property of each control in the array contains that control\'s subscript location in the
array. If you want to renumber the controls in the array to begin at 1, you can do so by
changing the first zero-based control\'s Index value to 1.
If there were five text boxes in a control array named txtBoxes, the individual controls
would be named txtBoxes(0), txtBoxes(1), txtBoxes(2), txtBoxes(3), and txtBoxes(4).
The Menu Editor window is a dialog box that you access from the Form window by
pressing Ctrl+E or by selecting Tools Menu Editor from Visual Basic\'s own menu bar.
Editor window and names the parts of the Menu Editor window.
The Menu Editor window creates your menu, but you still need to write event procedures
that tie menu command selections to actions taken by your application. When the user
selects a menu command, Visual Basic generates an event, just as it generates an event
when the user clicks a command button.
A dialog box is a small window used to display or accept information. Its name comes
from the fact that it is, in essence, a dialog (or conversation) with the user. A dialog box
is usually shown modally, which means the user must close it (or \"answer the dialog\")
before continuing with any other part of the program. This chapter looks at two dialog
boxes built in to the Visual Basic language: the message box and the input box. Next, you
use the CommonDialog custom control, which allows you to place four types of standard
dialog boxes in your program. Finally, you see some guidelines for creating your own
Unlike check boxes, option buttons give your users a list from which to choose, but they
can select exactly one option out of the list. Often, the option button controls are known
as mutually-exclusive controls. Unless you group sets of option buttons in frames
(described later in this unit), the user can select one and only one option
button at a time.
Click the Next Control command button to see the CONTROLS.VBP option buttons on
your screen With the mouse, click one of the option buttons. Click another option button.
At once, Visual Basic deselects the first option button and selects the one you just
clicked. Select another option button to change the selected option once again. As you
can see, Visual Basic ensures that you can select only one option at a time. Instead of
check boxes, which permit multiple selections, you would display option buttons for the
user whenever he can make only one choice out of several.
16. What is a frame?
Although the user can select only one option button at a time, you can set up groups of
option buttons on the same form. The user can then select one option button at a time
from within each frame.
You must always enclose the group within a frame by using the Frame Control. If you
press the Next Control button again, you will see a frame appear in the middle of the
form If three frames of option button groups appeared on the form, you could select a
maximum of three option buttons on the form—one in each framed set.
Definition—A debugger is the integrated tool that helps you find program bugs.
there are two general categories of errors that you\'ll often run across as you use Visual
Basic. The debugger can help you locate and fix these errors. You will find both syntax
errors and logic errors.
18. What are the events most often associated with the mouse.
Click
DblClick
MouseDown
MouseMove
Generated when the user moves the mouse
MouseUp
RightClick
The grid control produces a table of rows and columns in which you can display text,
numeric values, and even graphics.
When you must display several values at once, the grid control is one of the handiest
controls to use. Although labels are great for messages and individual data items, and
scrolling list boxes are fine for lists of values from which the user can select, the grid
gives your application a two-dimensional table display of data.
Suppose that you just started a lawn fertilization company, and you begin with an initial
route of eight customers. Each customer requires five annual fertilizations. That\'s a total
of 40 applications that you need to track for the upcoming year. Each yard size differs
and each application requires different amounts and kinds of fertilization mixtures.
The common dialog box control produces these kinds of dialog boxes that look and act
just like other Windows 95 programs\' equivalent dialog boxes: Color: Displays a
selection of colors from which the user can select. File Open: Displays the File Open
dialog box from which the user can select (or type) a file to open.
File Save: Displays the File Save dialog box in which the user can select (or type) file in
which to save the current data.
Fonts: Displays a list of fonts available on the target system from which the user can
select.
Printer: Displays a Printer dialog box from which the user can select printing choices
such as the number of copies desired.
WinHelp: Starts the WinHelp program, a program that asks the user for a help file that
the WinHelp program will then open.
Recordset
A group of records, created by a query, from one or more tables in a database. The
records in a recordset are typically a subset of all the records in a table. When the
recordset is created, the number of records and the order in which they\'re presented can
be controlled by the query that creates the recordset.
PART – B
PART - A
1.What are the Two parameters are passed to the list view control?
Two parameters are passed to the list view control: the address of the image list and a
style parameter that indicates the type of images stored in the image list
LVSIL_NORMAL is used for the image list used in the icon view.
LVSIL_SMALL is used for the image list used in the small icon view.
m_listItem.InsertItem( &listItem );
listItem.mask = LVIF_TEXT;
listItem.iItem = 0;
listItem.pszText = szText;
m_listCtrl.InsertItem( &listItem );
In a tree view, parent items are located at the root, or top level, of the tree. In a tree view,
child items are located under parent items.
Items in a tree view control are arranged into groups, with child items located under
parent items. Child items are also indented, or nested, under a parent. A child item at one
level can be the parent of child items at lower levels. The Windows Explorer is one of the
applications that uses the new tree control
The tree control is a popular control because it enables you to display a great deal of
information in a hierarchy. Unlike a list box, a small amount of high-level information
can be presented initially, enabling the user to decide which parts of the tree should be
expanded. The tree control also enables information to be displayed so that relationships
between different items in the control can be seen. For example, in the Explorer,
subdirectories are nested in order to show their positions in the directory.
5. How to Apply Styles to a Tree View Control?
TVS_LINESATROOT adds lines for the root items in the tree control. This attribute is
ignored if TVS_HASLINES is not selected.
TVS_HASBUTTONS adds the plus and minus buttons for items that can be expanded.
A slider control, also known as a trackbar control, is a control that contains a slide bar
that you can move between two points. A slider is used in the Display applet that is part
of the Windows Control Panel. The Settings property page uses a slider to set the screen
resolution.
The user moves the slide bar by dragging it with the mouse or by setting the keyboard
focus to the slider and using the arrow keys on the keyboard. You can create sliders with
optional tick marks that help the user to judge the position of the slide bar.
A progress control, also known as a progress bar, is commonly used to indicate the
progress of an operation and is usually filled from left to right as the operation is
completed. You can also use progress controls to indicate temperature, water level, or
similar measurements. In fact, an early term for this type of control was \"Gas Gauge,\"
back in the old days when programmers had mules and most Windows programs were
written in C.
Progress controls are used in Developer Studio to indicate the progress of saving or
loading a project workspace. Progress controls are also used by the Windows Explorer
when copying or moving files.
A progress control is added to a dialog box in the same way as the up-down and slider
controls discussed earlier. Using the Developer Studio dialog box editor, add a progress
control to the Controls project main dialog box.
The CDialog base class supports both modal and modeless dialogs. With a modal dialog,
such as the Open File dialog, the user cannot work elsewhere in the same application
(more correctly, in the same user interface thread) until the dialog is closed. With a
modeless dialog, the user can work in another window in the application while the dialog
remains on the screen. Microsoft Word\'s Find and Replace dialog is a good example of a
modeless dialog; you can edit your document while the dialog is open.
1. Add an embedded control window data member to your dialog class. The MFC control
window classes include CButton, CEdit, CListBox, and CComboBox. An embedded
control C++ object is constructed and destroyed along with the dialog object.
2. Choose Resource Symbols from Visual C++\'s View menu. Add an ID constant for the
new control.
4. In your derived dialog class, manually add the necessary notification message handlers
for your new control.
10.What is a progress indicator control?
The progress indicator is the easiest common control to program and is represented by the
MFC CProgressCtrl class. It is generally used only for output. This control, together with
the trackbar, can effectively replace the scroll bar controls you saw in the previous
example. To initialize the progress indicator, call the SetRange and SetPos member
functions in your OnInitDialog function, and then call SetPos anytime in your message
handlers. The progress indicator shown in Figure 6-2 has a range of 0 to 100, which is the
default range.
The trackbar control (class CSliderCtrl), sometimes called a slider, allows the user to set
an \"analog\" value. (Trackbars would have been more effective than sliders for Loyalty
and Reliability in the EX06A example.) If you specify a large range for this control—0 to
100 or more, for example—the trackbar\'s motion appears continuous. If you specify a
small range, such as 0 to 5, the tracker moves in discrete increments. You can program
tick marks to match the increments. In this discrete mode, you can use a trackbar to set
such items as the display screen resolution, lens f-stop values, and so forth. The trackbar
does not have a default range.
The trackbar is easier to program than the scroll bar because you don\'t have to map the
WM_HSCROLL or WM_VSCROLL messages in the dialog class. As long as you set the
range, the tracker moves when the user slides it or clicks in the body of the trackbar. You
might choose to map the scroll messages anyway if you want to show the position value
in another control. The GetPos member function returns the current position value. The
top trackbar in Figure 6-2 operates continuously in the range 0 to 100. The bottom
trackbar has a range of 0 to 4, and those indexes are mapped to a series of double-
precision values (4.0, 5.6, 8.0, 11.0, and 16.0).
The spin button control (class CSpinButtonCtrl) is an itsy-bitsy scroll bar that\'s most
often used in conjunction with an edit control. The edit control, located just ahead of the
spin control in the dialog\'s tabbing order, is known as the spin control\'s buddy. The idea
is that the user holds down the left mouse button on the spin control to raise or lower the
value in the edit control. The spin speed accelerates as the user continues to hold down
the mouse button.
If your program uses an integer in the buddy, you can avoid C++ programming almost
entirely. Just use ClassWizard to attach an integer data member to the edit control, and
set the spin control\'s range in the OnInitDialog function. (You probably won\'t want the
spin control\'s default range, which runs backward from a minimum of 100 to a
maximum of 0.) Don\'t forget to select Auto Buddy and Set Buddy Integer in the spin
control\'s Styles property page. You can call the SetRange and SetAccel member
functions in your OnInitDialog function to change the range and the acceleration profile.
13.What is tree control?
The MFC CTreeCtrl class makes it easy to add this same functionality to your own
programs The user can expand and collapse elements by clicking the + and - buttons or
by double-clicking the elements. The icon next to each item is programmed to change
when the user selects the item with a single click.
The list control and the tree control have some things in common: they can both use the
same image list, and they share some of the same notification messages. Their methods of
identifying items are different, however. The tree control uses an HTREEITEM handle
instead of an integer index. To insert an item, you call the InsertItem member function,
but first you must build up a TV_INSERTSTRUCT structure that identifies (among other
things) the string, the image list index, and the handle of the parent item (which is null for
top-level items).
Class Purpose
CFontDialog Allows the user to select a font from a list of available fonts
CPrintDialog Allows the user to set up the printer and print a document
After the UpdateWindow call, the window is fully visible on the video display. The
program must now make itself ready to read keyboard and mouse input from the user.
Windows maintains a \"message queue\" for each Windows program currently running
under Windows. When an input event occurs, Windows translates the event into
a \"message\" that it places in the program\'s message queue.
A program retrieves these messages from the message queue by executing a block of
code known as the \"message loop\":
PART – B
time (6)
b. What are the steps involved in OLE Drag & Drop (10)
example (16)
9. Write down the steps to create a VC++ program that encapsulates the
PART - A
1.What is a linker?
The linker reads the OBJ and RES files produced by the C/C++ compiler and the
resource compiler, and it accesses LIB files for MFC code, runtime library code, and
Windows code. It then writes the project\'s EXE file. An incremental link option
minimizes the execution time when only minor changes have been made to the source
files. The MFC header files contain #pragma statements (special compiler directives) that
specify the required library files, so you don\'t have to tell the linker explicitly which
libraries to read.
Advanced developers can build custom AppWizards. Microsoft Corporation has exposed
its macro-based system for generating projects. If you discover that your team needs to
develop multiple projects with a telecommunications interface, you can build a special
wizard that automates the process.
• Definitions and References—You select any function, variable, type, macro, or class
and then see where it\'s defined and used in your project.
• Derived Classes and Members/Base Classes and Members—These are graphical class
hierarchy diagrams. For a selected class, you see the derived classes or the base classes
plus members. You can control the hierarchy expansion with the mouse.
• File Outline—For a selected file, the classes, functions, and data members appear
together with the places in which they\'re defined and used in your project.
The Visual C++ Components and Controls Gallery lets you share software components
among different projects. The Gallery manages three types of modules:
• C++ source modules—When you write a new class, you can add the code to the
Gallery. The code can then be selected and copied into other projects. You can also add
resources to the Gallery.
• Visual C++ components—The Gallery can contain tools that let you add features to
your project. Such a tool could insert new classes, functions, data members, and
resources into an existing project. Some component modules are supplied by Microsoft
(Idle time processing, Palette support, and Splash screen, for example) as part of Visual
C++. Others will be supplied by third-party soft-ware firms.
The MFC library supports two distinct application types: Single Document Interface
(SDI) and Multiple Document Interface (MDI). An SDI application has, from the user\'s
point of view, only one window. If the application depends on disk-file \"documents,\"
only one document can be loaded at a time. The original Windows Notepad is an example
of an SDI application. An MDI application has multiple child windows, each of which
corresponds to an individual document. Microsoft Word is a good example of an MDI
application.
When you run AppWizard to create a new project, MDI is the default application type.
For the early examples in this book, you\'ll be generating SDI applications because fewer
classes and features are involved. Be sure you select the Single Document option (on the
first AppWizard screen) for these examples. The MFC library application framework
architecture ensures that most SDI examples can be upgraded easily to MDI applications.
. OnDraw is a virtual member function of the CView class that the application framework
calls every time the view window needs to be repainted. A window needs to be repainted
if the user resizes the window or reveals a previously hidden part of the window, or if the
application changes the window\'s data. If the user resizes the window or reveals a hidden
area, the application framework calls OnDraw, but if a function in your program changes
the data, it must inform Windows of the change by calling the view\'s inherited Invalidate
(or InvalidateRect) member function. This call to Invalidate triggers a later call to
OnDraw.
Even though you can draw inside a window at any time, it\'s recommended that you let
window changes accumulate and then process them all together in the OnDraw function.
That way your program can respond both to program-generated events and to Windows-
generated events such as size changes.
The most efficient place to initialize a class data member is in the constructor, like this:
CMyView::CMyView() : m_rectEllipse(0, 0, 200, 200) {...}
You could initialize m_nColor with the same syntax. Because we\'re using a built-in type
(integer), the generated code is the same if you use an assignment statement in the
constructor body.
• CBitmap—A bitmap is an array of bits in which one or more bits correspond to each
display pixel. You can use bitmaps to represent images, and you can use them to create
brushes.
• CBrush—A brush defines a bitmapped pattern of pixels that is used to fill areas with
color.
• CPalette—A palette is a color mapping interface that allows an application to take full
advantage of the color capability of an output device without interfering with other
applications.
• CPen—A pen is a tool for drawing lines and shape borders. You can specify a pen\'s
color and thickness and whether it draws solid, dotted, or dashed lines.
Fonts are an integral part of the Windows GDI. This means that fonts behave the same
way other GDI objects do. They can be scaled and clipped, and they can be selected into
a device context as a pen or a brush can be selected. All GDI rules about deselection and
deletion apply to fonts.
A monochrome bitmap has only one plane. Each pixel is represented by a single bit that
is either off (0) or on (1). The CDC::SetTextColor function sets the \"off\" display color,
and SetBkColor sets the \"on\" color. You can specify these pure colors individually with
the Windows RGB macro
PART – B
4. What is meant by Modal & Modeless dialog control? Explain Modal dialog
9. a. What is Rich Edit control & Discuss the supporting MFC classes for
10.What are the functions performed in SDI application and Explain that
2 Marks
A process is a running program that owns its own memory, file handles and other
system resources. The separate execution paths that an individual process can contain are
called as threads.
i) Works threads
124.Define ODBC?
SQL grammar and also the c-language programming interface to any SQL database. Any
DBMS that has an ODBC driver can be occurred by a single compiled c or c++ program
odbc thus separate the user interface from the actual database management process.
instance.
same COM object, some synchronization mechanisms needs to be provided to protect the
data. A partment is logical grouping of object that share the same concurrency
constraints, every COM process can have at most one multithread apartment but it can
127.What is MTS?
MTS stands for Microsoft Transaction Server provides another style of server
programming. MTS provides server objects, must be implemented in the form of DLLs
that are to be hosted by MTS surrogate processes. MTS provides context objects for these
RFX is the acronym for Record Field Exchange. The MFC framework can move data
back and forth between the database and the member variables of your CRecordSet by
using record field exchange which works very much like the Dialog Data Exchange
This type uses a dynamic cursor which allows scrolling in both directions. This type
of record set allow only forward scrolling will not reflect any changes made to the
database.
i) Start MS Access
131. Write the general syntax to create a table. Give one example.
Example:-
EmpID INTEGER,
EmpName VARCHAR(50)
Salary NUMERIC(6,2)
Exp NUMERIC(5) }
For functions such as CRecordSet:: GetField Value () which work on a single row
then you set the current row within row set. This is done with the set row
Transferring data between application are accomplished through the one data
object interface which provides a mechanism for transferring data and also for
i) FORMATETC
ii) STGMEDIUM
i) CInternetSession
ii) CHttpConnectin
iii) CFtpConnection
iv) CGopherConnection
v) CInternetFile
vi) ChttpFile
vii) CFtpFileFind
viii) CGopherFileFind
ix) CinternetException
1. Caching
2. Security
4. Buffered I/O
5. Easy API
6. User Friendly
request from a client program. The Browser can pass parameters to the programs, which
are often values that the browser user types into edit, controls, selects from list boxes and
so forth. It typically sends back HTML code based on those parameter values.
i) CHttpServer
ii) CHttpServerContext
iii) CHtmlStream
Winsock is the lowest level Windows API for TCP/IP programming. Part of the
i. Enumerators
ii. Data source objects
iii. Commands
v. Errors
140.What is WinInet?
collection of high-level functions that assist a programmer in using three popular Internet
protocols: the Hypertext Transfer Protocol (HTTP) used for the World Wide Web, the
File Transfer Protocol (FTP), and another file transfer protocol known as Gopher in both
completion ports, the win32 function TransmitFile, file-handle caching, and CPU scaling
for threads. IIS is a special kind of Win32 program called a service actually three
142.Define ISAPI.
It is the ability for a program to multitask within itself. The program can split
NTFS
More Secured •
FAT
File Allocation Table •
Less Secured •
Snapshot is a RecordSet type. Snapshot downloads the entire query in one shot.
But occupy more memory to hold data. It has data as a static copy. When any changes
Dynaset is a RecordSet type. In Dynaset only the records you actually need to fill
the screen will get downloaded. Constantly resynchronizes the recordset, so that any
16 Marks
1. What is a DBMS? What is an SQL? Explain MFC ODBC classes? Explain filter
Answer
i) Database creation
i) Audio file