Windows


WINTEST - 2


ySize = GetSystemMetrics(SM_CYSCREEN) ;

GetWindowRect(hWnd, &rc) ;

xPos = (xSize - (rc.right - rc.left)) / 2 ;

yPos = (ySize - (rc.bottom - rc.top)) / 2 ;

SetWindowRect(hWnd, NULL, xPos, yPos, 0, 0,

SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOZORDER) ;

}

 

LRESULT _loadds FAR PASCAL MainDlgProc(HWND hwndDlg,

UINT msg, WPARAM wParam, LPARAM lParam)

{

static WORD wCountTotal = 0;

WORD wCount ;

 

lParam = lParam ;

switch (msg)

{

case WM_INITDIALOG:

RemoveMenu(GetSystemMenu(hwndDlg,0),

SC_CLOSE,MF_BYCOMMAND) ;

BogusStart(hwndDlg, IDM_BOGUSEVENT) ;

break ;

 

case WM_SHOWWINDOW:

if (wParam)

CenterWindow(hwndDlg) ;

break ;

 

case WM_COMMAND:

switch (wParam)

{

case IDM_BOGUSEVENT:

wCount = BogusGetEvent() ;

while 9wCount)

{

wCountTotal += wCount ;

wCount = BogusGetEvent() ;

}

SetDlgItemInt(hwndDlg, IDM_COUNT, wCountTotal, FALSE);

break ;

 

case IDCANCEL:

EndDialog(hwndDlg, 0) ;

break ;

}

break ;

 

default:

return FALSE ;

}

return TRUE ;

}

 

int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,

LPSTR lpCmdLine, intnCmdShow)

{

hPgmInstance = hInstance ;

hPrevInstance = hPrevInstance ;

lpCmdLine = lpCmdLine ;

nCmdShow = nCmdShow ;

 

if (!hPrevInstance)

{

if (BogusCheck())

{

if (MessageBox(0, "Press OK to begin bogus I/O",

"WinTest", MB_OKCANCEL|MB_APPLMODAL) == IDOK)

{

DialogBox(hPgmInstance, "MainDlg", 0,

(FARPROC) MainDlgProc) ;

BogusStop() ;

}

}

else

MessageBox(0, "Bogus device not found", "WinTest",

MB_ICOMMAND|MB_OK|MB_APPLMODAL) ;

}

else

MessageBox(0, "Another instance already running",

"WinTest", MB_ICONEXCLAMATION|MB_OK|MB_APPLMODAL) ;

 

return 0 ;

}

______________________________________________________________________

 

5. wintest.c.

 




- -  - -  - -