|
|
Microsoft Windows NT Build 328 10-12-1992
/******************************************************************************\
*
* PROGRAM: SPINTEST.C
*
* PURPOSE: Demonstrates the use of the SPINCUBE custom control.
*
* FUNCTIONS: WinMain - standard stuff; also loads the
* SPINCUBE.DLL and creates a couple
* of spincube controls.
* MainWndProc - generic window procedure.
* SpintestDlgProc- generic dialog procedure.
* AboutDlgProc - processes about dialog messages
*
*
* Microsoft Developer Support
* Copyright (c) 1992 Microsoft Corporation
*
\******************************************************************************/
#include <windows.h>
#include "spintest.h"
/******************************************************************************\
*
* FUNCTION: WinMain (standard WinMain INPUTS/RETURNS)
*
* GLOBAL VARS: hInst - Handle of program instance
*
\******************************************************************************/
int WINAPI WinMain (HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wc;
HWND hwnd;
MSG msg;
HANDLE hLib;
RECT rect;
WORD i;
wc.style = NULL;
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (hInstance, "spintesticon");
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject (WHITE_BRUSH);
wc.lpszMenuName = (LPSTR) "Menu";
wc.lpszClassName = (LPSTR) "Main";
if (!RegisterClass (&wc))
{
MessageBox (NULL, "WinMain(): RegisterClass() failed",
"Err! - SPINTEST", MB_OK | MB_ICONEXCLAMATION);
return(FALSE);
}
ghInst = hInstance;
if (!(hwnd = CreateWindow ("Main", "spintest Sample Application",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, ghInst, NULL)))
return (NULL);
if (!(hLib = LoadLibrary ((LPTSTR) "SPINCUBE.DLL")))
MessageBox (NULL, "WinMain(): LoadLibrary (SPINCUBE.DLL) failed",
"Err! - SPINTEST", MB_OK | MB_ICONEXCLAMATION);
for (i = 0; i < 3; i++)
gahwndSpin[i] = CreateWindow ("Spincube", "", WS_VISIBLE | WS_CHILD,
0, 0, 0, 0, hwnd, NULL, hLib, NULL);
GetClientRect (hwnd, &rect);
SendMessage (hwnd, WM_SIZE, 0,
MAKELONG((WORD)rect.right,(WORD)rect.bottom));
ShowWindow (hwnd, nCmdShow);
while (GetMessage (&msg, NULL, NULL, NULL))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
FreeLibrary (hLib);
return (msg.wParam);
}
/******************************************************************************\
*
* FUNCTION: MainWndProc (standard window procedure INPUTS/RETURNS)
*
* GLOBAL VARS: ghInst - Handle of program instance
*
\******************************************************************************/
LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDM_DLGEDITDIALOG:
DialogBox (ghInst, (LPCTSTR)"SpintestDlg", hwnd,
(DLGPROC) SpintestDlgProc);
break;
case IDM_ABOUT:
DialogBox (ghInst, (LPCTSTR)"About", hwnd, (DLGPROC) AboutDlgProc);
break;
}
break;
case WM_SIZE:
{
int width = (int) LOWORD(lParam);
int height = (int) HIWORD(lParam);
SetWindowPos (gahwndSpin[0], NULL,
BORDER, BORDER,
width/4 - BORDER, height/4 - BORDER,
SWP_SHOWWINDOW);
SetWindowPos (gahwndSpin[1], NULL,
width/4 + BORDER, height/4 + BORDER,
width/2 - BORDER, height/4 - BORDER,
SWP_SHOWWINDOW);
SetWindowPos (gahwndSpin[2], NULL,
3*width/4 + BORDER, height/2 + BORDER,
width/4 - 2*BORDER, height/2 - 2*BORDER,
SWP_SHOWWINDOW);
break;
}
case WM_DESTROY:
PostQuitMessage (NULL);
break;
default:
return (DefWindowProc (hwnd, msg, wParam, lParam));
}
return (NULL);
}
/******************************************************************************\
*
* FUNCTION: SpintestDlgProc (standard dialog procedure INPUTS/RETURNS)
*
\******************************************************************************/
LRESULT CALLBACK SpintestDlgProc (HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return (TRUE);
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EndDialog (hwnd, TRUE);
return (TRUE);
}
return (TRUE);
}
return (FALSE);
}
/******************************************************************************\
*
* FUNCTION: AboutDlgProc (standard dialog procedure INPUTS/RETURNS)
*
* COMMENTS: Displays "about" message
*
\******************************************************************************/
LRESULT CALLBACK AboutDlgProc (HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{ switch (message)
{
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EndDialog(hwnd, TRUE);
return (TRUE);
}
return (TRUE);
}
return (FALSE);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.