Friday, December 16, 2005

Windows NT Programming Fundamentals

LRESULT - typedef ; another name for long int

all messages are 32-bit integer values

registering a window class - telling Windows NT about the form and function of the window

message loop :
reads pending message from application's message queue -> dispatches it back to Windows NT -> call to program's window function with that message as a parameter

HANDLE - a 32-bit integer; a value that identifies some resource

HWND - 32-bit integer that is used as a window handle

BYTE - 8-bit unsigned character

WORD - 16-bit unsigned short integer

DWORD - unsigned long integer

UINT - unsigned 32-bit integer

LONG - long

BOOL - integer

LPSTR - pointer to a string

LPCSTR - const pointer to a string


MSG - holds a Windows NT message

WNDCLASSEX - defines a window class

Windows NT Skeleton
Contains 2 functions: WinMain() and Window Function

WinMain()'s functions:
  1. Define a window class
  2. Register the class with Windows NT
  3. Create a window of that class
  4. Display the window
  5. Begin running the message loop

LoadIcon() - returns a handle to an icon; loads the STYLE of each icon used
HICON LoadIcon(HINSTANCE hInst, LPCSTR lpszName)
hInst - specifies the handle of the module that contains the icon
lpszName - icon's name

CW_USEDDEFAULT - macro while creating a window; tells Windows NT to select an appropriate size and location for the window

CreateWindow() - returns the handle of the window it creates

ShowWindow() - to display the window
BOOL ShowWindow(HWND hwnd, int nHow);

UpdateWindow() - needed by almost all window applications; tells windows nt to send a message to your application that the main window needs to be updated

Message Loop - final part of the skeletal WinMain() ; receives and processes messages sent by the Windows NT; the messages are stored in the application's message queue until they can be read and processed
BOOL GetMessage(LPMSG msg, HWND hwnd, UINT min, UINT max);

GetMessage() - specifies for which window the messages will be obtained

TranslateMessage() - translates virtual key codes generated by Windows NT into character messages; facilitates full integration of keyboard into your application program

DispatchMessage() - the message which has been read and translated is dispatched back to the Windows NT, which holds this message until it can pass it to the program's window function

WM_DESTROY - sent when the user terminates the program; the program executes a call to the API function PostQuitMessage()

WM_CHAR - generated when a key is pressed
wParam - contains the ASCII value of the key pressed
LOWORD(lParam) - number of times the key has been repeated as a result of the key being held down
HIWORD(lParam) - the bits are encoded in a pre-determined format


Post a Comment

<< Home