home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Loisirs 18
/
cd.iso
/
PLANETE
/
MUDWIN
/
SOURCE.ZIP
/
ABOUTEST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-27
|
3KB
|
139 lines
// MODULE Main.c
//
// PURPOSE Main processing loop and general utilities
//
// EXPORTS WinMain()
// MsgBox()
// SockerrToString()
// CreateSocket()
// ResetSocket()
//
#include "defcon.h"
#include "global.h"
#pragma hdrstop
#include <stdarg.h>
/* note when we were last compiled */
TS(Main)
//long FAR PASCAL ShellAbout(LPCSTR, LPCSTR, HWND);
long FAR PASCAL
MainWndProc(HWND hwnd,
UINT nMessage,
WPARAM wParam,
LPARAM lParam)
{
switch (nMessage)
{
case WM_LBUTTONUP:
//ShellAbout("Hello","World",hwnd);
AboutDialog(NULL);
return 0;
case WM_DESTROY:
MessageBeep(-1);
PostQuitMessage(0);
return 0;
default:
//return DefWindowProc(hwnd, nMessage, wParam, lParam);
return CallWindowProc((FARPROC) gComboProc,
hwnd, nMessage, wParam, lParam);
}
}
/*******************************************************************
NAME: WinMain
SYNOPSIS: Normal Windows application entry point
PURPOSE Does some initialization and enters the message loop.
ENTRY: hInstance - The current application instance
hPrev - The previous instance. Don't depend on this
value, as under Win32 it is always NULL
pszCmdLine - Points to command line arguments
nCmdShow - Specifies how the initial window should
be displayed. Should just be passed onto
ShowWindow
********************************************************************/
int PASCAL
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
MSG msg;
WNDCLASS wc;
FARPROC lpfn;
hInst = hInstance;
if (!hPrevInstance)
{
if (!GetClassInfo(NULL, "Button", &wc))
return FALSE;
gComboProc = (WNDPROC) wc.lpfnWndProc;
wc.style &= ~CS_GLOBALCLASS;
wc.lpfnWndProc = MainWndProc;
wc.hInstance = hInstance;
wc.lpszClassName= "About:Button";
if (!RegisterClass(&wc))
return FALSE;
}
hMainWnd = CreateWindow(
"About:Button", "About",
WS_POPUPWINDOW | WS_CAPTION,
CW_USEDEFAULT, 0, 64, 64,
NULL, NULL, hInstance, NULL);
if (!hMainWnd) return 0;
ShowWindow(hMainWnd, nCmdShow);
while (GetMessage (&msg, NULL, NULL, NULL)) {
if(hAbout == NULL || !IsDialogMessage(hAbout,&msg))
{
TranslateMessage(&msg); /* Translat virtual key codes */
DispatchMessage(&msg); /* Dispatches message to window */
}
}
return (msg.wParam); /* Returns the value from
PostQuitMessage */
}
// FUNCTION MsgBox
//
// PURPOSE Flashes a Message Box to the user
// The format string is taken from the STRINGTABLE
//
// PARAMETERS fuStyle - Style flags for MessageBox
// id - String used as format spec
// ... - Zero or more arguments passed to wvsprintf
//
// RETURNS The value returned by MessageBox()
short FAR CDECL
MsgBox2(WORD fuStyle, LPCSTR lpszFmt,...)
{
char szTxt[240];
va_list ArgList;
va_start(ArgList, lpszFmt);
/* This next bit is slightly non-portable... */
wvsprintf(szTxt, lpszFmt, ArgList);
va_end(ArgList);
MessageBeep(fuStyle & MB_ICONMASK);
return MessageBox(hMainWnd, szTxt, "Hey!", fuStyle);
}