- •The ministry of education and science of ukraine kharkiv national university of radio electronics
- •1. The Basics of Microsoft Foundation Classes
- •Mfc general information
- •A Framework of mfc-program
- •Creating the Application Class
- •Creating the Frame-Window Class
- •Declaring a Message Map and instantiation of application object global instance
- •Defining a Message Map
- •Messages and their processing in mfc-programs
- •Writing Message Map Functions
- •Message boxes and menus in mfc-programs
- •2. Dialog windows
- •2.1 Modal and modeless dialog windows
- •2.2 The control elements of dialog window
- •CListBox::AddString (lpctstr lpszItem ); // Call this member function to add a string (lpszItem) to a list box;
- •3. Additional control elements in mfc-programs. Working with icons, cursors, raster images
- •3.1 Additional control elements
- •Radio buttons
- •Afx_msg void cWnd::OnVScroll( uint nSbCode, uint nPos, cScrollBar* pScrollBar ); afx_msg void cWnd::OnHScroll( uint nSbCode, uint nPos, cScrollBar* pScrollBar );
- •Afx_msg void OnVScroll( uint nSbCode, uint nPos, cScrollBar* pScrollBar );
- •Working with icons, cursors, raster images
- •The icons and cursor registration
- •Icon and cursor loading
- •4. The elements of text processing in mfc
- •The redrawing problem decision
- •5. The Elements of working with graphics
- •5.1 The graphics functions.
- •Working with brushes
- •5.2 The mapping modes and output regions
- •6. Common control elements
- •Windows Common Controls
- •6.2 The toolbar using
- •On resizing, the message wm_size is sent and the standard handler OnSize() is called.
- •The working with Spins
- •The working with slider
- •To set the range (minimum and maximum positions) for the slider in a slider control use the following function:
- •The working with progress bar
- •The tree control using in mfc programs
- •Adding elements to the tree
- •The status bars usage
- •Bool cStatusBarCtrl::SetParts( int nParts, int* pWidths );
- •Tab controls using in mfc-programs
- •Int cTabCtrl::GetCurSel(); To Selects a tab in a tab control use SetCurSel() function:
- •Int cTabCtrl::SetCurSel( int nItem );
- •The property sheets and wizards
- •7. Thread multitasking and it’s implementation in mfc
- •7.1 The basic features of multitasking
- •7.2 The Synchronization
- •7.3 The working with semaphore
- •7. 4 The working with event object
- •8. The concept of Document view
- •8.1 Introduction to document conception
- •The control of documents storing
- •8.2 The dynamic creation of objects
- •The application framework creation
- •The main window and application classes creation
- •Listing 8.1 The example of main window class in Document / View concept
- •Listing 8.2 The example of document class in Document / View concept
- •8.3 The document framework creation
- •8.4 The initiation of application
- •8.5 The standard id’s, used in Document / View concept
- •9. The special types of menu and their implementation in mfc
- •9.1 The description of special menu styles
- •The mechanism to make changes in menus
- •9.2 The dynamic and floating menus implementation
- •CMenu::CreatePopupMenu
- •The example programs to work with dynamic menus
- •10. The system of help
- •10.1 The basic information on help structures
- •The call of help
- •The file of help
- •The Help file creating
- •The example of rtf file
- •10.2 The Help system including to the mfc-program
- •Parameters:
- •Return Values: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
- •10.3 The handlers of help messages
- •The processing of help calls
- •Wm_commandhelp message processing
- •10.4 Wm_contextmenu message processing
- •11. Manipulating Device-Independent Bitmaps
- •11.1 The types of bitmap
- •11.2 The structures included to bitmap
- •Introducing the cDib Class
- •11.3 Programming the cDib Class
- •Loading a dib into Memory
- •Other cDib Member Functions
- •Creating ShowDib program
- •Modifying ShowDib's Resources
- •Adding Code to ShowDib
- •Examining the OnFileOpen() Function
- •Examining the OnDraw() Function
- •12. The elements of Database Programming
- •12.1 Understanding Database Concepts
- •Accessing a Database
- •12.2 Mfc odbc Classes
- •Registering the Database
- •Creating the Basic Employee Application
- •Creating the Database Display
- •Adding and Deleting Records
- •12.4 Sorting and Filtering
- •12.5 Odbc versus dao
- •13. Remote Automation
- •13.1 The introduction to Remote Automation
- •13.2 The Remote Automation Connection Manager and user components
- •13.3 Automation
- •Automation Clients
- •13.4 ActiveX
- •ActiveX Document Servers
- •ActiveX Document Containers
- •ActiveX Document Views
- •13.5 ActiveX Documents
- •ActiveX Controls
- •Interaction Between Controls with Windows and ActiveX Control Containers
- •13.6 Optimization of ActiveX Controls
- •13.7 Automation Servers
- •13.8 Connection Points
- •14. Microsoft DirectX and the main items of its using
- •14.2 The Component Object Model
- •IUnknown Interface
- •DirectX com Interfaces
- •DirectDraw Architecture
- •Other DirectDraw Features
- •Width and Pitch
- •14.5 Support for 3d Surfaces in DirectX
- •14.6 Direct3d Integration with DirectDraw
- •Direct3d Device Interface
- •Direct3d Texture Interface
- •The Basics of DirectDraw
- •Step 6: Writing to the Surface.The first half of the wm_timer message in ddex1 is devoted to writing to the back buffer, as shown in the following example:
- •Loading Bitmaps on the Back Buffer
- •Step 1: Creating the Palette. The ddex2 sample first loads the palette into a structure by using the following code:
- •Step 4: Flipping the Surfaces. Flipping surfaces in the ddex2 sample is essentially the same process as that in the first example. Blitting from an Off-Screen Surface
- •Step 1: Creating the Off-Screen Surfaces. The following code is added to the doInit function in ddex3 to create the two off-screen buffers:
- •Color Keys and Bitmap Animation
- •Dynamically Modifying Palettes
- •Optimizations and Customizations
- •Blitting with Color Fill
- •Determining the Capabilities of the Display Hardware
- •Storing Bitmaps in Display Memory
- •Triple Buffering
- •15. General information on OpenGl
- •15.1 Common information
- •Primitives and Commands
- •OpenGl Graphic Control
- •Execution Model
- •15.2 Basic OpenGl Operation
- •OpenGl Correctness Tips
- •15.3 OpenGl example program
- •Ph.D. Assosiate prof. Tsimbal Alexander m. System software, summary of lectures.
Step 4: Flipping the Surfaces. Flipping surfaces in the ddex2 sample is essentially the same process as that in the first example. Blitting from an Off-Screen Surface
The sample in Tutorial 2 (DDEX2) takes a bitmap and puts it in the back buffer, and then it flips between the back buffer and the primary buffer. This is not a very realistic approach to displaying bitmaps. The sample in this tutorial (DDEX3) expands on the capabilities of DDEX2 by including two off-screen buffers in which the two bitmaps—one for the even screen and one for the odd screen—are stored. It uses the IDirectDrawSurface::BltFast method to copy the contents of an off-screen surface to the back buffer, and then it flips the buffers and copies the next off-screen surface to the back buffer.
The new functionality demonstrated in considered below is shown in the following steps:
Step 1: Creating the Off-Screen Surfaces
Step 2: Loading the Bitmaps to the Off-Screen Surfaces
Step 3: Blitting the Off-Screen Surfaces to the Back Buffer
Step 1: Creating the Off-Screen Surfaces. The following code is added to the doInit function in ddex3 to create the two off-screen buffers:
// Create an offscreen bitmap.
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwHeight = 480;
ddsd.dwWidth = 640;
ddrval = lpDD->CreateSurface(&ddsd, &lpDDSOne, NULL);
if(ddrval != DD_OK)
{ return initFail(hwnd);
}
// Create another offscreen bitmap.
ddrval = lpDD->CreateSurface(&ddsd, &lpDDSTwo, NULL);
if(ddrval != DD_OK)
{ return initFail(hwnd);
}
The dwFlags member specifies that the application will use the DDSCAPS structure, and it will set the height and width of the buffer. The surface will be an off-screen plain buffer, as indicated by the DDSCAPS_OFFSCREEN flag set in the DDSCAPS structure. The height and the width are set as 480 and 640, respectively, in the DDSURFACEDESC structure. The surface is then created by using the IDirectDraw::CreateSurface method.
Because both of the off-screen plain buffers are the same size, the only requirement for creating the second buffer is to call IDirectDraw::CreateSurface again with a different pointer name.
You can also specifically request that the off-screen buffer be placed in system memory or display memory by setting either the DDSCAPS_SYSTEMMEMORY or DDSCAPS_VIDEOMEMORY capability in the DDSCAPS structure. By saving the bitmaps in display memory, you can increase the speed of the transfers between the off-screen surfaces and the back buffer. This will become more important when using bitmap animation. However, if you specify DDSCAPS_VIDEOMEMORY for the off-screen buffer and not enough display memory is available to hold the entire bitmap, a DDERR_OUTOFVIDEOMEMORY error value will be returned when you attempt to create the surface.
Step 2: Loading the Bitmaps to the Off-Screen Surfaces. After the two off-screen surfaces are created, DDEX3 uses the InitSurfaces function to load the bitmaps from the Frntback.bmp file onto the surfaces. The InitSurfaces function uses the DDCopyBitmap function located in Ddutil.cpp to load both of the bitmaps, as shown in the following example:
// Load the bitmap resource.
hbm = (HBITMAP)LoadImage(GetModuleHandle(NULL), szBitmap,
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (hbm == NULL)
return FALSE;
DDCopyBitmap(lpDDSOne, hbm, 0, 0, 640, 480);
DDCopyBitmap(lpDDSTwo, hbm, 0, 480, 640, 480);
DeleteObject(hbm);
return TRUE;
If you look at the Frntback.bmp file in Microsoft Paint or another drawing application, you can see that the bitmap consists of two screens, one on top of the other. The DDCopyBitmap function breaks the bitmap in two at the point where the screens meet. In addition, it loads the first bitmap into the first off-screen surface (lpDDSOne) and the second bitmap into the second off-screen surface (lpDDSTwo).
Step 3: Blitting the Off-Screen Surfaces to the Back Buffer. The WM_TIMER message contains the code for writing to and flipping surfaces. In the case of DDEX3, it contains the following code to select the proper off-screen surface and to blit it to the back buffer:
rcRect.left = 0;
rcRect.top = 0;
rcRect.right = 640;
rcRect.bottom = 480;
if(phase)
{ pdds = lpDDSTwo;
phase = 0;
}
else
{ pdds = lpDDSOne;
phase = 1;
}
while(1)
{ ddrval = lpDDSBack->BltFast(0, 0, pdds, &rcRect, FALSE);
if(ddrval == DD_OK)
{
break;
}
The phase variable determines which off-screen surface will be blitted to the back buffer. The IDirectDrawSurface::BltFast method is then called to blit the selected off-screen surface onto the back buffer, starting at position (0, 0), the upper-left corner. The rcRect parameter points to the RECT structure that defines the upper-left and lower-right corners of the off-screen surface that will be blitted from. The last parameter is set to FALSE (or 0), indicating that no specific transfer flags are used.
Depending on the requirements of your application, you could use either the IDirectDrawSurface::Blt method or the IDirectDrawSurface::BltFast method to blit from the off-screen buffer. If you are performing a blit from an off-screen plain buffer that is in display memory, you should use IDirectDrawSurface::BltFast. Although you will not gain speed on systems that use hardware blitters on their display adapters, the blit will take about 10 percent less time on systems that use hardware emulation to perform the blit. Because of this, you should use IDirectDrawSurface::BltFast for all display operations that blit from display memory to display memory. If you are blitting from system memory or require special hardware flags, however, you have to use IDirectDrawSurface::Blt.
After the off-screen surface is loaded in the back buffer, the back buffer and the primary surface are flipped in much the same way as shown in the previous tutorials.
