Professional Documents
Culture Documents
Gdi.exe
Gdi32.exe
Kernel386.exe
Kernel32.exe.dll
Win API was created for 16-bit processors (current generations) and it relies on 16-bit values. Although, Win16 versions of these components cant run on their own. Win 32 is future. Dynamic Link Library (DLL) is a binary file that provides a library of functions, objects and resources. All API functions are contains in DLL. The functions present in DLL can be linked during execution. These functions can also be shared between several applications running in windows. Since linking is done dynamically, functions dont become a part of executable file. As a result size of exe files dont go out of hand.
Breaking an application into component parts to provide a way to easily upgrade application component. Keeping resources data out of application executable but still readily accessible to an application
WIN MAIN
The WinMain function is called by the system as the initial entry point for a Win-32 based application. Int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdline, Int nCmdShow ); //handle to current instance instance //handle to previous instance //pointer to command line //show state of window
Parameters
hInstance Handle to the current instance of the application. hPrevInstance Handle to the previous instance of the application. For a Win32 based app, this parameter is always NULL. To detect whether another instance already exists, create a uniquely named mutex using the CreateMutex() function. This will succeed even if the mutex already exists, but the GetLastError() function will return ERROR_ALREDY_ EXISTS. This indicates another instance of the applicant exists, coz it created the mutex first. lpCmdLine Pointer to a null-terminated string specifying the command line for the app, excluding the program name. To retrieve the entire command line, use the Get CommandLine() function. nCmdShow
Specifies how the window is to be shown. This parameter can be one of the Following values: Values Meaning SW_HIDE Hides the window and activates another window. SW_MINIMIZE Minimizes the specified window and activates the top-level window in the systems list. SW_RESTORE Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position(same as SW_SHOWNORMAL) SW_SHOW Activates a window and display it in its current size and position. SW_SHOWMAXIMIZED Activates a window and displays it as a maximized window SW_SHOWMINIMIZED Activates a window and displays it as a icon SW_SHOWNNOACTIVE Displays a window as a icon. The active window remains active. SW_SHOWNA Displays a window in its current state. The active window remains active. SW_SHOWNOACTIVATE Displays window in its most recent size & position. The active window remains active. SW_SHOWNORMAL Activates & display a window. If the window is minimized or maximized, the system restores it to its original size & position (same as SE-RESTORE)
Return Values
If the function succeeds, terminating when it receives a WM_QUIT message, it should return the exit value contained in that message wParam parameter. If the function terminates before entering the message loop, it should return zero.
Remarks
WinMain should initialize the app, displays its main window, and enter a msg retrieval and dispatch loop that is the top level control structure for the remainder of the apps execution. Terminate the msg loop when it receives the WM_QUIT msg. At the point WinMain should exit the app, returning the value passed in the WM_QUIT msgs wParam parameter. If WM_QUIT was received as a result of calling PostQuitMessage, the value of wParam is the value of the PostQuitMessage functions nExitCode parameter.
ANSI app can use the lpCmdLine parameter of the WinMain function to access the command line string, excluding the program name. The reason that WinMain cannot return Unicode string that lpCmdLine uses the LPSTR data type, not the LPSTR data type. The GetCommandLine function can be used to access Unicode strings in the command line, coz it uses the LPSTR data type.
ContainedWindow::WindowProc
Static LPESULT CALLBACKM WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); Return Value The result of the msg processing. Parameters hWnd [in]The handle to the window. wMsg [in]The msg sent to the window. wParam [in]Additional msg-specific information. lParam [in]Additional msg-specific information. Remarks This static method implements the window procedure. WindowProc directsmsgs to the msg map identified by m_dwMsgMapID. If necessary, WindowProc calls DefWindowProc for additional msg processing.
translate these yourself, the easiest way to access the windows API is by using the predefined declares included with Visual Basic. The file Win32api txt, located in the \Winapi subdirectory of the main Visual Basic directory, contains declarations for many of the Windows API procedures commonly used in Visual Basic. To use a function, Type, or other feature from this file, simply copy it to your Visual Basic module. You can view and copy procedures from Win32api.txt by using the API Viewer application, or by loading the file in any text editor. Note: The Windows API contains a vast amount of code. To find reference information on the procedures and other details included in this API set, refer to the Win 32 SDK, included on the Microsoft Developer Network Library CD.
MFC: Overview
The Microsoft Foundation Class Library (MFC) is an application framework for programming in the Microsoft Windows. Written in C++, MFC provides much of the code necessary for managing windows, menus, and dialog boxes; performing basic input/output; storing collections of data objects; and so on. All you need is to do is add your application-specific code into this framework, and given the nature of C++ class programming, its easy to extend or override the basic functionality the MFC framework supplies. The MFC framework is a powerful approach that lets you build upon the work of expert programmers for windows. MFC shortens development time; makes code more portable; provides tremendous support without reducing programming freedom and flexibility; and gives easy access to hard to program user-interface elements and technologies, like Active technology, OLE, and Internet programming. Furthermore, MFC simplifies database programming through Data Access Objects (DAO) and Open Database Connectivity (ODBC), and network programming through Windows Sockets. MFC makes it easy to program features like property sheets (tab dialogs), print preview, and floating, customizable toolbars.
The Framework
Your work with the Microsoft foundation Class Library (MFC) framework is based largely on a few major classes and several visual C++ tools. Some of the classes encapsulate a large portion of the Win32 application programming interface (API). Other classes encapsulate application concepts such as documents, views, and the application itself. Still others encapsulate Ole features and ODBC and DAO data-access functionality. For example, Win32s concept of window is encapsulated by MFC class CWnd. That is, a C++ class called CWnd encapsulates or wraps the HWND handle that represent a Windows window. Likewise, class CDialog encapsulates Win32 dialog boxes. Encapsulation means that the C++ class CWnd, for example, contains a member variable of type HWND, and the classs member functions encapsulate calls to Win32 functions that take an HWND as a parameter. The class member functions typically have the same name as the Win32 function they encapsulate.
SDI and MDI. Documents, views, and the framework. Wizards, WizardBar, and resource editors. Building on the framework. How the framework calls my code. CWinApp: the application class. Document templates and the document/view creation process. Messages and commands. Windows.
(Most often, the main window is derived from CFrameWnd, CMdIFrameWnd, or CDialog, all of which are derived from CWnd.) Applications that use document/view architecture contain additional objects. The principal objects are as follows: An application object derived from the class CWinApp, as mentioned before. One or more document class objects derived from class CDocument. Document class objects are responsible for the internal representation of the data manipulated in the views. They may be associated with a data file. One or more view objects derived from class CView. Each view is a window that is attached to a document and associated with a frame window. Views display and manipulate the data contained in a document class object. Document/view applications also contain frame windows (derived from CFrameWnd) and document templates (derived from CDocTemplate).