home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 215 / DDJWIN.ZIP / MULTI.ASC < prev    next >
Text File  |  1993-08-31  |  4KB  |  157 lines

  1. _A MULTITOOL APPROACH TO WINDOWS DEVELOPMENT_
  2. by Al Stevens
  3.  
  4. [LISTING ONE]
  5.  
  6. #define APPLAPI /* */
  7.  
  8. void APPLAPI OpenDocuments(char *dbname);
  9. void APPLAPI CloseDocuments(void);
  10. void APPLAPI AddDocument(char *Subj, char *Text);
  11.  
  12. void APPLAPI DeleteDocument(void);
  13. void APPLAPI ChangeDocument(char *Subj, char *Text);
  14. int  APPLAPI FindDocument(char *key, char *Subj, char *Text);
  15. void APPLAPI GetFirstDocument(char *Subj, char *Text);
  16. void APPLAPI GetNextDocument(char *Subj, char *Text);
  17.  
  18.  
  19. [LISTING TWO]
  20.  
  21. void main()
  22. {
  23.    OpenDocuments("test.dat");
  24.    int done = 0;
  25.    while (!done)   {
  26.       cout << "\n ----------------------------------";
  27.       cout << "\n Add Srch Fst Nxt Chg Del List Quit ";
  28.       cout << "\n ----------------------------------\n";
  29.       switch (getch())   {
  30.          case 'a':
  31.             AddDocument(Subject, Text);
  32.             break;
  33.          case 's':
  34.             if (FindDocument(Keyword, Subject, Text)) 
  35.                DisplayDocument();
  36.             break;
  37.          case 'f':
  38.             GetFirstDocument(Subject, Text);
  39.             DisplayDocument();
  40.             break;
  41.          case 'n':
  42.             GetNextDocument(Subject, Text);
  43.             DisplayDocument();
  44.             break;
  45.          case 'c':
  46.             ChangeDocument(Subject, Text);
  47.             break;
  48.          case 'd':
  49.             DeleteDocument();
  50.             break;
  51.          case 'l':
  52.             GetFirstDocument(Subject, Text);
  53.             while (*Subject)   {
  54.                ShowSubject();
  55.                GetNextDocument(Subject, Text);
  56.             }
  57.             break;
  58.          case 'q':
  59.             done = 1;
  60.             break;
  61.          default:
  62.             break;
  63.       }
  64.    }
  65.    CloseDocuments();
  66. }
  67.  
  68.  
  69.  
  70.  
  71. [LISTING THREE]
  72.  
  73. .cpp.obj:
  74.    bcc -ml -c -v -DDOS_VERSION {$*.cpp }
  75.  
  76. OBJS=uistub.obj applapi.obj database.obj search.obj
  77.  
  78. memoir.exe : $(OBJS)
  79.    bcc -v -ml -ememoir.exe $(OBJS)
  80.  
  81.  
  82.  
  83. [LISTING FOUR]
  84.  
  85. #ifdef DOS_VERSION
  86. #define APPLAPI /* */
  87. #else
  88. #include <windows.h>
  89. #define APPLAPI FAR _export PASCAL
  90. #endif
  91.  
  92.  
  93.  
  94. [LISTING FIVE]
  95.  
  96. #include "memoir.h"
  97.  
  98. static HINSTANCE hInst = NULL;
  99.  
  100.  
  101. extern "C" {
  102. int FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDatSeg,
  103.                   WORD cbHeapSize, LPSTR lpCmdLine)
  104. {
  105.    if (hInst == NULL)   {
  106.       hInst = hInstance;
  107.       if (cbHeapSize > 0)
  108.          UnlockData(0);
  109.    }
  110.    return 1;
  111. }
  112. int FAR PASCAL WEP(int nParameter)
  113. {
  114.    return 1;
  115. }
  116. int FAR _export PASCAL RegisterAppl(HANDLE hWnd)
  117. {
  118.    static HANDLE semaphore = 0;
  119.    HANDLE sem = semaphore;
  120.    if (semaphore == 0)
  121.       semaphore = hWnd;
  122.    return sem;
  123. }
  124. }
  125.  
  126.  
  127. [LISTING SIX]
  128.  
  129. Declare Sub OpenDocuments Lib "memoir.dll" (ByVal db As String)
  130. Declare Sub CloseDocuments Lib "memoir.dll" ()
  131. Declare Sub GetFirstDocument Lib "memoir.dll" (ByVal Subj As String,    ByVal Text As String)
  132. Declare Sub GetNextDocument Lib "memoir.dll" (ByVal Subj As String,     ByVal Text As String)
  133. Declare Sub AddDocument Lib "memoir.dll" (ByVal Subj As String, ByVal   Text As String)
  134. Declare Sub DeleteDocument Lib "memoir.dll" ()
  135. Declare Sub ChangeDocument Lib "memoir.dll" (ByVal Subj As String, ByVal    Text As String)
  136. Declare Function FindDocument Lib "memoir.dll" (ByVal Key As String,    ByVal Subj As String, ByVal Text As String) As Integer  
  137.  
  138.  
  139. [LISTING SEVEN]
  140.  
  141. Sub Form_Load ()
  142.     Dim handle As Integer
  143.     handle = RegisterAppl(form1.hWnd)
  144.     If handle <> 0 Then
  145.         n = SetFocusAPI(handle)
  146.         shutdown
  147.     Else
  148.         ' ------ initialization code
  149.         OpenDocuments ("memoir.dat")
  150.         GetFirstDocument SubjBuffer, TextBuffer
  151.         DocumentSubject.Text = SubjBuffer
  152.         DocumentText.Text = TextBuffer
  153.     End If
  154. End Sub
  155.  
  156.  
  157.