Index   Commented   Search   About

MainWndProc

As its name implies, the MainWndProc function handles messages sent to the program's parent (main) window. These messages signal that the user has made a menu selection, resized the window, or changed the pen system through Control Panel. These actions generate, respectively, the following messages:

  • WM_COMMAND message. If the user selects a command from the Options menu, the program notes the selection in the global flag viMenuSel. The state of this flag determines whether subsequent input goes to the system recognizer or the sample recognizer SREC, or is collected into an HPENDATA object for conversion to a mirror image.

  • WM_SIZE message. PENAPP resizes its windows according to the information in the lParam variable.

  • WM_PENMISCINFO message. The procedure allows this message to fall through to DefWindowProc for default handling.

LRESULT CALLBACK MainWndProc(

HWND hwnd, // Window handle

UINT message, // Message

WPARAM wParam, // Varies

LPARAM lParam ) // Varies

{

LONG lRet = 0L;

.

.

.

switch (message)

{

case WM_COMMAND:

switch (wParam)

{

case miExit:

DestroyWindow( vhwndMain );

break;

case miSample:

case miSystem:

case miMirror:

ResetWindow( wParam );

break;

}

break;

.

.

.

case WM_DESTROY:

if (vhpendata)

{

// PKPD.DLL API: function pointer not needed:

DestroyPenData( vhpendata );

  • hpendata = NULL;

}

//

// Unload sample recognizer. (Don't

// unload system default recognizer.)

//

UninstallRecognizer( vhrec );

  • hrec = NULL;

PostQuitMessage( 0 );

break;

default:

lRet = DefWindowProc( hwnd, message, wParam, lParam );

break;

}

return lRet;

}

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference (win32.hlp)
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun