beautypg.com

Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 233

background image

10E. C Languages

II. SOFTWARE GUIDES - 10. Driver488/W31

II-218

Personal488 User’s Manual, Rev. 3.0

MSG msg;

/* MSG structure to store your messages

*/

int nRc;

/* return value from Register Classes

*/

strcpy(szAppName, “EXAMPLE2");
hInst = hInstance;
if (!hPrevInstance) {
/* register window classes if first instance of application

*/

if ((nRc = nCwRegisterClasses()) == -1) {

/* registering one of the windows failed

*/

LoadString(hInst,IDS_ERR_REGISTER_CLASS,szString,

sizeof(szString));

MessageBox(NULL, szString, NULL, MB_ICONEXCLAMATION);

return nRc;

}
}

/* create application’s Main window

*/

hWndMain = CreateWindow(

szAppName

/* Window class name

*/

“Driver488/W31 Simple Example”

, /* Window’s title

*/

WS_CAPTION |

/* Title and Min/Max

*/

WS_SYSMENU

/* Add system menu box

*/

WS_MINIMIZEBOX |

/* Add minimize box

*/

WS_MAXIMIZEBOX |

/* Add maximize box

*/

WS_THICKFRAME |

/* thick sizeable frame

*/

WS_CLIPCHILDREN |

/* don’t draw in child windows areas*/

WS_OVERLAPPED,

CW_USEDEFAULT, 0,

/* Use default X, Y

*/

CW_USEDEFAULT, 0,

/* Use default X, Y

*/

NULL,

/* Parent window’s handle

*/

NULL,

/* Default to Class Menu

*/

hInst,

/* Instance of window

*/

NULL);

/* Create struct for WM_CREATE

*/

if (hWndMain == NULL) {
LoadString(hInst, IDS_ERR_CREATE_WINDOW, szString,
sizeof(szString));
MessageBox(NULL, szString, NULL, MB_ICONEXCLAMATION);
return IDS_ERR_CREATE_WINDOW;
}

ShowWindow(hWndMain, nCmdShow)

/* display main window

*/

while (GetMessage(&msg, NULL, 0, 0)) { /* Until WM_QUIT message

*/

TranslateMessage(&msg);
DispatchMessage(&msg);
}

/* Do clean up before exiting from the application

*/

CwUnRegisterClasses();
return msg.wParam;
} /* End of WinMain

*/

/*******************************************************************/
/*

*/

/* Main Window Procedure

*/

/*

*/

/* This procedure provides service routines for the Windows events */
/* (messages)that Windows sends to the window, as well as the user */
/* initiated events (messages) that are generated when the user

*/

/* selectsthe action bar and pulldown menu controls or the

*/

/* corresponding keyboard accelerators.

*/

/*

*/

/*******************************************************************/

LONG FAR PASCAL WndProc(HWND hWnd, WORD Message, WORD wParam, LONG
lParam)