Category : Files from Magazines
Archive   : CL-JAN88.ZIP
Filename : WINDOWS.LTG

 
Output of file : WINDOWS.LTG contained in archive : CL-JAN88.ZIP
Listings for Software Development under Windows
_______________________________________________________________________


/*
prompter dialog box resource to be included
in the application's resource (.RC) file
*/

#include "windows.h"
#include "prompt.h"

PROMPTER DIALOG PRELOAD 40,55,166,47
STYLE WS_POPUP | WS_DLGFRAME
BEGIN
edittext IDEDIT, 12, 18, 104, 12, WS_GROUP | ES_AUTOHSCROLL
ltext "", IDPROMPT, 1, 1, 88, 16
defpushbutton "Ok",IDOK, 120, 12, 35, 14, WS_GROUP
pushbutton "Cancel", IDCANCEL, 120, 28, 35, 14, WS_GROUP
END


Listing 1 - Prompter Resource
_______________________________________________________________________

_______________________________________________________________________


/*
prompt.c
formatted prompt dialog box module

note that function PromptHandler must be exported in the
application's definition file (.DEF)

*/

# include
# include
# include "prompt.h"

# define PROMPTMAX 64
# define PROMPTER "PROMPTER"
# define DEFPROMPT "Enter:"


static char *PromptBuf;
static char *PromptString;


char *Prompter( prompt,buf )
char *prompt;
char *buf;
{

Š HWND parent;
HANDLE inst;
BOOL FAR PASCAL PromptHandler( HWND,unsigned,WORD,LONG );
FARPROC lpproc;

PromptString = prompt;
PromptBuf = buf;
parent = GetActiveWindow( );
inst = GetWindowWord( parent,GWW_HINSTANCE );
lpproc = MakeProcInstance(( FARPROC )PromptHandler,inst );

DialogBox( inst,( LPSTR )PROMPTER,parent,lpproc );
FreeProcInstance( lpproc );

return (( *PromptBuf ) ? PromptBuf : ( char *)0 );

}



BOOL FAR PASCAL PromptHandler( hWnd,msg,wParam,lParam )
HWND hWnd;
unsigned msg;
WORD wParam;
LONG lParam;
{

char *p;
static HWND edit;

if ( msg == WM_INITDIALOG ) {
edit = GetDlgItem( hWnd,IDEDIT );
p = (( PromptString ) ? PromptString : DEFPROMPT );
SetDlgItemText( hWnd,IDPROMPT,( LPSTR )p );
SendMessage( edit,EM_LIMITTEXT,PROMPTMAX,0L );
if ( *PromptBuf )
SendMessage( edit,WM_SETTEXT,0,( LONG )PromptBuf );
return ( TRUE );
}
if ( msg == WM_COMMAND ) {
if ( wParam == IDOK ) {
if ( ! SendMessage( edit,WM_GETTEXT,PROMPTMAX+1,( LONG )PromptBuf ))
return ( TRUE );
EndDialog( hWnd,1 );
return ( TRUE );
}
if ( wParam == IDCANCEL ) {
*PromptBuf = NULL;
EndDialog( hWnd,1 );
return ( TRUE );
}
}

return ( FALSE );

Š}



Listing 2 - Prompter
_______________________________________________________________________

_______________________________________________________________________

/*

wprintf.c
formatted MessageBox print module
*/


# include
# include
# include


wprintf( msg )
char *msg;
{

HWND wnd;
va_list argList;
char prBuf[ 128 ];
char *Get_ST();

wnd = GetActiveWindow( );
va_start( argList,msg );
vsprintf( prBuf,msg,argList );
MessageBox( wnd,( LPSTR )prBuf,( LPSTR )"Message",MB_OK );

}


Listing 3 - wprintf Function
_______________________________________________________________________

_______________________________________________________________________

/*
PROMPT.H

prompter header file for use by PROMPT.C and the application
resource (.RC) file
*/



#define IDEDIT 8
#define IDPROMPT 9

Additional listing - Prompter Header File
Š_______________________________________________________________________

/*
prompt2.c
enhanced formatted prompt dialog box module
*/

# include
# include
# include "prompt.h"

# define PROMPTMAX 64
# define PROMPTER "PROMPTER"
# define DEFPROMPT "Enter:"

# define HourGlass( ) SetCursor( LoadCursor( 0,IDC_WAIT ))
# define Arrow( ) SetCursor( LoadCursor( 0,IDC_ARROW ))

static char *PromptBuf;
static char *PromptString;
static int PromptMax = PROMPTMAX;
static int ( *Scanner )( ) = NULL;
static char *Resource = PROMPTER;


char *Prompter( prompt,buf )
char *prompt;
char *buf;
{

HWND parent;
HANDLE inst;
BOOL FAR PASCAL PromptHandler( HWND,unsigned,WORD,LONG );
FARPROC lpproc;

PromptString = prompt;
PromptBuf = buf;
parent = GetActiveWindow( );
inst = GetWindowWord( parent,GWW_HINSTANCE );
lpproc = MakeProcInstance(( FARPROC )PromptHandler,inst );

DialogBox( inst,( LPSTR )Resource,parent,lpproc );
FreeProcInstance( lpproc );

PromptMax = PROMPTMAX;
Scanner = NULL;
Resource = PROMPTER;

return (( *PromptBuf ) ? PromptBuf : ( char *)0 );

}



BOOL FAR PASCAL PromptHandler( hWnd,msg,wParam,lParam )
ŠHWND hWnd;
unsigned msg;
WORD wParam;
LONG lParam;
{

char *p;
int n;
static HWND edit;
static HWND ok;

if ( msg == WM_INITDIALOG ) {
HourGlass( );
edit = GetDlgItem( hWnd,IDEDIT );
ok = GetDlgItem( hWnd,IDOK );
p = (( PromptString ) ? PromptString : DEFPROMPT );
SetDlgItemText( hWnd,IDPROMPT,( LPSTR )p );
SendMessage( edit,EM_LIMITTEXT,PromptMax,0L );
EnableWindow( ok,0 );
if ( *PromptBuf )
SendMessage( edit,WM_SETTEXT,0,( LONG )PromptBuf );
Arrow( );
return ( TRUE );
}
if ( msg == WM_COMMAND ) {
if ( wParam == IDOK ) {
if ( ! SendMessage( edit,WM_GETTEXT,PROMPTMAX+1,( LONG )PromptBuf ))
return ( TRUE );
if ( Scanner && ! ( *Scanner)( PromptBuf )) {
SetFocus( edit );
return ( TRUE );
}
EndDialog( hWnd,1 );
return ( TRUE );
}
else if ( wParam == IDCANCEL ) {
*PromptBuf = NULL;
EndDialog( hWnd,1 );
return ( TRUE );
}
else if ( HIWORD( lParam ) == EN_CHANGE ) {
n = SendMessage( edit,WM_GETTEXTLENGTH,0,0L );
EnableWindow( ok,( BOOL )n );
return ( TRUE );
}

}

return ( FALSE );

}

PromptSetMax( newMax )
int newMax;
{
Š
PromptMax = newMax;

}

PromptSetScanner( func )
int ( *func )( );
{

Scanner = func;

}

PromptAltRes( res )
char *res;
{
Resource = res;
}




Additional listing - Enhanced Prompter Function
_______________________________________________________________________


  3 Responses to “Category : Files from Magazines
Archive   : CL-JAN88.ZIP
Filename : WINDOWS.LTG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/