; Place the LIBRARY & EXPORTS in your Projects xxxx.def file.

;------------------
;LIBRARY (your Project name.dll)
;EXPORTS DllProc
;------------------

         title   xxxx

         .586
         .model flat, stdcall
         option casemap:none   ; Case sensitive

            include  G:\WebPage\AsmEdit\include\windows.inc
            include  user32.inc
            include  kernel32.inc
            include  advapi32.inc

            include  G:\WebPage\AsmEdit\include\DSPMACRO.asm

         includelib  user32.lib
         includelib  kernel32.lib
         includelib  advapi32.lib

;===================================================
; PROTO, MACRO, and Data section
;===================================================
Initilize    PROTO   :DWORD
NewProject   PROTO   :DWORD
GetRegPaths  PROTO   :DWORD

.const
; Messages sent to AsmEdit
IDM_GETDWORDS           equ WM_USER+50
IDM_GETPROC             equ WM_USER+51
IDM_GETDATA             equ WM_USER+52

IDM_NEW                 equ 6001
IDM_OPEN                equ 6002
IDM_CLOSE               equ 6004
IDM_SAVEAS              equ 6006
IDM_PRINT               equ 6010

; IDM_GETDWORDS returns a poiner to the following Handle & dword structure.
ASMDWORDS struct
      hWnd              dd 0   ; Handle of AsmEdit.
      hMenu             dd 0   ; Handle of AsmEdit Menu.
      hToolBar          dd 0   ; Handle of AsmEdit ToolBar.
      hStatus           dd 0   ; Handle of AsmEdit StatusBar.
      hREdit            dd 0   ; Handle of RichEdit window.
      MenuID            dd 0   ; Addin/Project menu item ID.
      ProjType          dd 0   ; Project type from create (.dll or .exe)
ASMDWORDS ends

; IDM_GETPROC returns a poiner to the following Procedure structure.
ASMEPROC struct
      lpBaseAscii       dd 0   ; Pointer to BaseAscii Proc.
      lpAsciiBase       dd 0   ; Pointer to AsciiBase Proc.
      lpEnaDisMenu      dd 0   ; Pointer to EnableDisableEditMenu Proc.
ASMEPROC ends

; IDM_GETDATA returns a poiner to the following Data structure.
ASMEDATA struct
      lpRootDir         dd 0   ; Pointer to root dir, ends with \.
      lpPathName        dd 0   ; Pointer to current full path.
      lpFileName        dd 0   ; Pointer to FileName.
      lpProjectName     dd 0   ; Pointer to Project Name.
      lpProjectPath     dd 0   ; Pointer to Project Path.
      lpRegKey          dd 0   ; AsmEdit registry key.
ASMEDATA ends

.data
AppName                 db 'xxxx',0

.data?
hInst                   dd ?   ; AsmEdit's instance
hREdit                  dd ?   ; Handle of RichEdit
dwHStruct               dd ?   ; Pointer to handles struct
dwPStruct               dd ?   ; Pointer to proc struct
dwDStruct               dd ?   ; Pointer to data struct

.code

;===============================================================
; DLL Entry
;===============================================================
DllEntry PROC hInstance:DWORD, reason, reserved1

      .if reason == DLL_PROCESS_ATTACH  ; When the dll is loaded
           push     hInstance
            pop     hInst
            mov     eax, TRUE
      .endif
         ret

DllEntry ENDP

;===============================================================
; Initilize Proc loads pointers for various handles, and
; data areas. Is called from the DllProc
;===============================================================
Initilize PROC  hWnd:DWORD

      INVOKE     SendMessage, hWnd, IDM_GETDWORDS, 0, 0
         mov     dwHStruct, eax
      INVOKE     SendMessage, hWnd, IDM_GETPROC, 0, 0
         mov     dwPStruct, eax
      INVOKE     SendMessage, hWnd, IDM_GETDATA, 0, 0
         mov     dwDStruct, eax
         ret

Initilize ENDP

;===============================================================
; DllProc Receives WM_COMMAND messages from AsmEdit
;===============================================================
DllProc PROC  uses edi hWnd:DWORD, wMsg, wParam, lParam

      .if wMsg == WM_COMMAND

         .if !dwHStruct                  ; Check if Initilize has been run
            INVOKE     Initilize, hWnd
         .endif
            mov     eax, wParam
           cwde
            mov     wParam, eax

; NOTE! The wParam & lParam value will be whatever you specified in the menu command.

;---------- [New Tab] ----------
         .if eax == xxxx
               jmp     Ret1

;---------- [Open File] ----------
         .elseif eax == xxxx
               jmp     Ret1

;---------- [Close Tab] ----------
         .elseif eax == xxxx
               jmp     Ret1

;---------- [Save As] ----------
         .elseif eax == xxxx
               jmp     Ret1

         .endif

;---------- [AsmEdit closing down] ----------
      .elseif wMsg == WM_CLOSE
; Do cleanup work
            jmp     Ret0
      .endif

Ret0:
         xor     eax, eax
         ret

Ret1:
         mov     eax, TRUE
         ret

DllProc ENDP

End DllEntry
