home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CICA 1995 May
/
cica_0595_4.zip
/
cica_0595_4
/
UTIL
/
REGM151
/
DEMOWIN.C_
/
DEMOWIN.C
Wrap
Text File
|
1995-03-03
|
6KB
|
151 lines
#include <windows.h> /* Window's header file - always included */
#include "demowin.h" /* Demo's header file */
/*
******************************************************************
This is a demo program which checks the Keywords
******************************************************************
*/
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wndclass; /* window class structure */
/* fill in class data for new class */
char Keyword [40];
int i;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (hInstance, "ICON_BRITE");
wndclass.hCursor = LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH);
wndclass.lpszMenuName = "MyMenu";
wndclass.lpszClassName = "MyClass";
/* register the new window class */
if (!RegisterClass (&wndclass))
return (0); /* quit if can't register class */
}
/* Create main windows */
hWnd = CreateWindow ("MyClass",
"Demo of Remote Control Validation",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, // Default horizontal pozition.
CW_USEDEFAULT, // Default vertical pozition.
CW_USEDEFAULT, // Default wigth.
CW_USEDEFAULT, // Default height.
NULL, // Overlapped windows have no parents.
NULL, // Use the window class menu.
hInstance, // This unstance owns this window.
NULL); // Pointer not needed.
ShowWindow (hWnd, nCmdShow); // display the window
/* Get the Keyword */
lstrcpy (Keyword, lpszCmdLine);
for (i = 0; i < strlen (Keyword) && Keyword [i] != ' '; i++);
Keyword [i] = 0x00;
if (strcmp (Keyword, "DemoUser") == 0)
MessageBox (hWnd,
"This program is running successfully!!!",
"Program OK",
MB_OK | MB_ICONEXCLAMATION);
else
{
MessageBeep (0);
MessageBox (hWnd,
"This program needs validation.\n See the documentation.",
"Warning",
MB_OK | MB_ICONSTOP);
return (msg.wParam); /* quit */
}
while (GetMessage (&msg, NULL, NULL, NULL)) /* message loop */
{
TranslateMessage (&msg); /* translate keyboard message */
DispatchMessage (&msg); /* send message to WndProc () */
}
return (msg.wParam); /* quit */
}
/* WndProc () is a custom function for processing messages from Windows */
long FAR PASCAL _export WndProc (HWND hWnd, unsigned int wMessage,
unsigned int wParam, LONG lParam)
{
FARPROC lpfnDlgProc; /* far pointer to a function */
HINSTANCE hInstance;
switch (wMessage) /* process windows messages */
{
case WM_COMMAND:
switch (wParam)
{
case IDM_QUIT: /* quit menu item */
DestroyWindow (hWnd); /* destroy window, */
break; /* terminate application */
case IDM_ABOUT: /* about menu item */
hInstance = GetWindowWord (hWnd, GWW_HINSTANCE);
lpfnDlgProc = MakeProcInstance ((FARPROC) About,
hInstance);
DialogBox (hInstance, "DIALOG_1", hWnd, lpfnDlgProc);
FreeProcInstance (lpfnDlgProc);
break; /* continue application */
}
break;
case WM_DESTROY: /* stop application */
PostQuitMessage (0); /* this will exit message loop */
break;
default: /* default windows message processing */
return DefWindowProc (hWnd, wMessage, wParam, lParam);
}
return (0L);
}
/**/
/*
********************************************
Dialog box ABOUT
********************************************
*/
BOOL FAR PASCAL About (HWND hDlg, unsigned int wMessage,
unsigned int wParam, LONG lParam)
{
HINSTANCE hInstance;
FARPROC lpfnDlgProc; /* far pointer to a function */
char str [3];
switch (wMessage)
{
case WM_INITDIALOG:
return (TRUE);
case WM_COMMAND: /* controls in dialog box activated */
switch (wParam)
{
case ABOUT_OK: /* OK button */
EndDialog (hDlg, 0); /* exit the dialog box */
return (TRUE);
}
case WM_DESTROY: /* stop application */
EndDialog (hDlg, 0); /* exit the dialog box */
break;
}
return (FALSE); /* return FALSE to signify message not processed */
}