home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
215
/
DDJWIN.ZIP
/
MULTI.ASC
< prev
next >
Wrap
Text File
|
1993-08-31
|
4KB
|
157 lines
_A MULTITOOL APPROACH TO WINDOWS DEVELOPMENT_
by Al Stevens
[LISTING ONE]
#define APPLAPI /* */
void APPLAPI OpenDocuments(char *dbname);
void APPLAPI CloseDocuments(void);
void APPLAPI AddDocument(char *Subj, char *Text);
void APPLAPI DeleteDocument(void);
void APPLAPI ChangeDocument(char *Subj, char *Text);
int APPLAPI FindDocument(char *key, char *Subj, char *Text);
void APPLAPI GetFirstDocument(char *Subj, char *Text);
void APPLAPI GetNextDocument(char *Subj, char *Text);
[LISTING TWO]
void main()
{
OpenDocuments("test.dat");
int done = 0;
while (!done) {
cout << "\n ----------------------------------";
cout << "\n Add Srch Fst Nxt Chg Del List Quit ";
cout << "\n ----------------------------------\n";
switch (getch()) {
case 'a':
AddDocument(Subject, Text);
break;
case 's':
if (FindDocument(Keyword, Subject, Text))
DisplayDocument();
break;
case 'f':
GetFirstDocument(Subject, Text);
DisplayDocument();
break;
case 'n':
GetNextDocument(Subject, Text);
DisplayDocument();
break;
case 'c':
ChangeDocument(Subject, Text);
break;
case 'd':
DeleteDocument();
break;
case 'l':
GetFirstDocument(Subject, Text);
while (*Subject) {
ShowSubject();
GetNextDocument(Subject, Text);
}
break;
case 'q':
done = 1;
break;
default:
break;
}
}
CloseDocuments();
}
[LISTING THREE]
.cpp.obj:
bcc -ml -c -v -DDOS_VERSION {$*.cpp }
OBJS=uistub.obj applapi.obj database.obj search.obj
memoir.exe : $(OBJS)
bcc -v -ml -ememoir.exe $(OBJS)
[LISTING FOUR]
#ifdef DOS_VERSION
#define APPLAPI /* */
#else
#include <windows.h>
#define APPLAPI FAR _export PASCAL
#endif
[LISTING FIVE]
#include "memoir.h"
static HINSTANCE hInst = NULL;
extern "C" {
int FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDatSeg,
WORD cbHeapSize, LPSTR lpCmdLine)
{
if (hInst == NULL) {
hInst = hInstance;
if (cbHeapSize > 0)
UnlockData(0);
}
return 1;
}
int FAR PASCAL WEP(int nParameter)
{
return 1;
}
int FAR _export PASCAL RegisterAppl(HANDLE hWnd)
{
static HANDLE semaphore = 0;
HANDLE sem = semaphore;
if (semaphore == 0)
semaphore = hWnd;
return sem;
}
}
[LISTING SIX]
Declare Sub OpenDocuments Lib "memoir.dll" (ByVal db As String)
Declare Sub CloseDocuments Lib "memoir.dll" ()
Declare Sub GetFirstDocument Lib "memoir.dll" (ByVal Subj As String, ByVal Text As String)
Declare Sub GetNextDocument Lib "memoir.dll" (ByVal Subj As String, ByVal Text As String)
Declare Sub AddDocument Lib "memoir.dll" (ByVal Subj As String, ByVal Text As String)
Declare Sub DeleteDocument Lib "memoir.dll" ()
Declare Sub ChangeDocument Lib "memoir.dll" (ByVal Subj As String, ByVal Text As String)
Declare Function FindDocument Lib "memoir.dll" (ByVal Key As String, ByVal Subj As String, ByVal Text As String) As Integer
[LISTING SEVEN]
Sub Form_Load ()
Dim handle As Integer
handle = RegisterAppl(form1.hWnd)
If handle <> 0 Then
n = SetFocusAPI(handle)
shutdown
Else
' ------ initialization code
OpenDocuments ("memoir.dat")
GetFirstDocument SubjBuffer, TextBuffer
DocumentSubject.Text = SubjBuffer
DocumentText.Text = TextBuffer
End If
End Sub