RegisterClassEx(&wndclass) ;
hwnd=CreateWindow(szAppName,"P1602 Demo1 Program",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;
ShowWindow(hwnd,SW_SHOWMAXIMIZED);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
/* ---------------------------------------------------------------- */
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM
lParam)
{
static int cxChar, cyChar, cxClient, cyClient,cxBuffer;
static int cyBuffer, xCaret, yCaret;
static char
cBuf[80];
HDC
hdc;
TEXTMETRIC tm;
PAINTSTRUCT ps;
int
i;
switch (iMsg)
{
case WM_CREATE : // window initial
/**************************************************************/
/* NOTICE: call P1602_DriverInit() to initialize the driver. */
/**************************************************************/
// Initialize the device driver, and return the board number in the PC
wInitialCode=P1602_DriverInit(&wTotalBoard);
if( wInitialCode!=NoError )
{
MessageBox(hwnd,"No P1602 card in this system !!!",
"P1602 Card Error",MB_OK);
}
hdc=GetDC(hwnd);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc, &tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight;
ReleaseDC(hwnd, hdc);
return 0;
case WM_SIZE :
cxClient=LOWORD(lParam);
// window size in pixels
cyClient=HIWORD(lParam);
cxBuffer=max(1,cxClient/cxChar); // window size in characters
cyBuffer=max(1,cyClient/cyChar);
return 0;
case WM_SETFOCUS :
CreateCaret(hwnd, NULL, cxChar, cyChar);
SetCaretPos(xCaret * cxChar, yCaret * cyChar);
25
Содержание OME-PCI-1602
Страница 37: ... Demo Program DEMO9 C 37 ...