home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aztec Masterblend
/
aztecmasterblendazteknewmediaj
/
lc
/
source.txt
< prev
Wrap
Text File
|
1992-11-04
|
19KB
|
425 lines
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
This text file contains four source files. Use your editor to
cut this file into these:
lc_samp.c
lc_samp.h
lc_samp.mak
lc_samp.rc
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
------------------ HERE BEGINS THE LC_SAMP.C FILE -------------
/*
Sample Non-DDE client program for LC.EXE
Garry J. Vass [72307,3311]
This program (cloned from generic.c) uses the LC.EXE
Winapp to perform calculations on strings containing
expressions of the form:
3+4+5+6
3*4
3/sin(3)*log(2)
and so on.
For locating code that is specific to this application
(i.e., not generic), set your Search function for "COMMENT".
Why not DDE?
1. This particular client-server relationship
is straightforward, well structured,
predictable, and requires expedience.
2. About 12 lines of code for this versus
300+ lines to implement DDE.
3. The downside is that the messages WM_USER+63
(request), and WM_USER+64 (reply) are
looked upon as private channels. This is
conceptually similar to the old-world situation
where DOS resident programs argued over who
owned what hotkey (sigh). I use a recognition
signature 0x4C43, 'L'<<4 + 'C', in the message
to establish ownership.
*/
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
#include "windows.h"
#include "lc_samp.h"
int request_calculation( HWND sender, char *str );
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
HANDLE hInst;
FARPROC Lproc;
char Inputstring[ 255 ] = "2+2";
char Resultstring[ 255 ] = "Result: 4";
char Anystring[ 255 ];
#define WAK( a ) MessageBox( GetFocus( ), a, "WIN-ACK", MB_OK );
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
/* COMMENT:
This variable is used to specify the handle (HWND) of
the LC application.
*/
static HWND Lchwnd = -1;
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
if( !hPrevInstance ) {
if( !InitApplication( hInstance ) )
return( FALSE );
/* COMMENT:
This code starts the LC application. If Windows
cannot start the program, she returns a value
less than 32.
*/
if( WinExec( "LC", SW_SHOWMINNOACTIVE ) < 32 ) {
MessageBox( GetFocus(),
(LPSTR)"I cannot find my server",
(LPSTR)"ShowStopper",
MB_OK );
return( FALSE );
}
}
if( !InitInstance( hInstance, nCmdShow ) )
return( FALSE );
while( GetMessage( &msg, NULL, NULL, NULL ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return( msg.wParam );
}
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
BOOL InitApplication( HANDLE hInstance )
{
WNDCLASS wc;
wc.style = NULL;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = GetStockObject( WHITE_BRUSH );
wc.lpszMenuName = "lcmenu";
wc.lpszClassName = "lcclass";
return( RegisterClass( &wc ) );
}
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
BOOL InitInstance( HANDLE hInstance, int nCmdShow )
{
HWND hWnd;
hInst = hInstance;
hWnd = CreateWindow( "lcclass",
"LC Sample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL );
if( !hWnd )
return( FALSE );
ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );
return( TRUE );
}
/**************************************************************/
/* */
/* */
/* */
/* */
/* */
/**************************************************************/
long FAR PASCAL MainWndProc( HWND hWnd, unsigned message, WORD wParam, LONG lParam )
{
switch( message ) {
case WM_COMMAND:
if( wParam == IDM_ABOUT ) {
Lproc = MakeProcInstance(