FD.ASM
上传用户:ys_happy
上传日期:2007-01-09
资源大小:20k
文件大小:7k
源码类别:

汇编语言

开发平台:

Asm

  1. .386
  2. .model flat,STDCALL
  3. extrn Dispatch : PROC, handlesb : proc, scrollkeys : proc
  4. extrn CreateDrawWindow : PROC, RegisterDrawWindow : PROC
  5. extrn numberofdrawwindows : dword
  6. extrn WaitingProc : proc, YesNoProc : proc
  7. extrn SaveFileDialog : PROC
  8. public hwndFrame, hwndClient
  9. include win32.asi           ; some 32-bit constants and structures
  10. include win32.ase
  11. include commdlg.asi
  12. include fdid.asi
  13. include fdui.asi
  14. .DATA
  15. copyright        db 'Fractal Designer 1.0 Copyright (c) LADsoft, 1998',0
  16. hInst            dd 0
  17. hMenuMain dd ?
  18. hwndClient dd ?
  19. hwndFrame dd ?
  20. hAccel dd ?
  21. childxpos dd ?
  22. childypos dd ?
  23. szTitleName      db 'Fractal Designer 1.0',0
  24. szFrameClassName      db 'LADsoftFDFrame',0
  25. szDrawClassName      db 'LADsoftFDDraw',0
  26. szClientClassName db 'MDICLIENT',0
  27. szMainAccel db 'MAINACCELERATORS',0
  28. szMainMenu db 'MAINMENU',0
  29. szAboutDialog db 'ABOUTDLG',0
  30. szAbortDialog db 'ABORTDLG',0
  31. szAboutCapt db 'About Fractal Designer',0
  32. szFDIcon db 'FDICON',0
  33. psShow db  'SHOW',0
  34. extrn DrawProc : PROC, IntFromProfile : PROC, IntToProfile : PROC
  35. .CODE
  36. ;-----------------------------------------------------------------------------
  37. ;
  38. ; This is where control is received from the loader.
  39. ;
  40. start PROC
  41. LOCAL hAceel : dword, 
  42. msg : MSGSTRUCT, wc : WNDCLASS
  43.         call    GetModuleHandle,0         ; get hmod (in eax)
  44.         mov     [hInst], eax            ; hInst is same as HMODULE
  45.                                         ; in the Win32 world
  46.         call    FindWindow,offset szFrameClassName,0
  47.         or      eax,eax
  48.         jnz      no_reg_class
  49. ;
  50. ;
  51. ; initialize the WndClass structure
  52. ;
  53.         mov     [wc.clsStyle], CS_HREDRAW + CS_VREDRAW + CS_GLOBALCLASS
  54.         mov     [wc.clsLpfnWndProc], offset WndProc
  55.         mov     [wc.clsCbClsExtra], 0
  56.         mov     [wc.clsCbWndExtra], 0
  57.         mov     eax, [hInst]
  58.         mov     [wc.clsHInstance], eax
  59.         call    LoadIcon,[hInst],offset szFDIcon
  60.         mov     [wc.clsHIcon], eax
  61.         call    LoadCursor,0,IDC_ARROW
  62.         mov     [wc.clsHCursor], eax
  63.         mov     [wc.clsHbrBackground], COLOR_APPWORKSPACE + 1
  64.         mov     [dword ptr wc.clsLpszMenuName], 0
  65.         mov     [dword ptr wc.clsLpszClassName], offset szFrameClassName
  66. lea eax,[wc]
  67.         call    RegisterClass,eax
  68. call RegisterDrawWindow, [hInst]
  69. no_reg_class:
  70. ; load resources and open frame
  71. ;
  72. call LoadMenu,[hInst],offset szMainMenu
  73. mov [hMenuMain],eax
  74. call LoadAccelerators, [hInst],offset szMainAccel
  75. mov [hAccel],eax
  76.         call    CreateWindowEx, 0, offset szFrameClassName, offset szTitleName, 
  77. WS_OVERLAPPEDWINDOW OR WS_CLIPCHILDREN, 
  78. CW_USEDEFAULT, 
  79. CW_USEDEFAULT, 
  80. CW_USEDEFAULT, 
  81. CW_USEDEFAULT, 
  82. 0,[hMenuMain],[hInst],0
  83.         mov     [hwndFrame], eax
  84. lea esi,[psShow]
  85. mov eax,SW_SHOWNORMAL
  86. call IntFromProfile
  87.         call    ShowWindow, [hwndFrame],eax
  88.         call    UpdateWindow, [hwndFrame]
  89. ;
  90. ; handle messages
  91. ;
  92. msg_loop:
  93. lea eax,[msg]
  94.         call    GetMessage,eax,0,0,0
  95.         cmp     ax, 0
  96.         je      end_loop
  97. lea eax,[msg]
  98. call TranslateMDISysAccel,[hwndClient],eax
  99. or eax,eax
  100. jnz msg_loop
  101. lea eax,[msg]
  102. call TranslateAccelerator,[hwndFrame],[hAccel],eax
  103. or eax,eax
  104. jnz msg_loop
  105. lea eax,[msg]
  106.         call    TranslateMessage, eax
  107. lea eax,[msg]
  108.         call    DispatchMessage, eax
  109.         jmp     msg_loop
  110. end_loop:
  111.         call    ExitProcess, [msg.msWPARAM]
  112.         ; we never get to here
  113. start endp
  114. ;-----------------------------------------------------------------------------
  115. public WndProc
  116. WndProc PROC uses ebx edi esi, hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
  117. ;
  118. ; WARNING: Win32 requires that EBX, EDI, and ESI be preserved!  We comply
  119. ; with this by listing those regs after the 'uses' statement in the 'proc'
  120. ; line.  This allows the Assembler to save them for us.
  121. ;
  122.         LOCAL   csx : CLIENTCREATESTRUCT, 
  123. mf_state : DWORD
  124. mov eax,[wmsg]
  125. call Dispatch
  126. dd 6
  127. dd WM_COMMAND,wmcommand
  128. dd WM_DESTROY,wmdestroy
  129. dd WM_CREATE,wmcreate
  130. dd WM_QUERYENDSESSION,wmqueryend
  131. dd WM_INITMENUPOPUP,wminitmenupopup
  132. dd WM_SIZE,wmsize
  133. jnc finish
  134. call wmdefault
  135. finish:
  136. ret
  137. wmdefault PROC
  138.         call    DefFrameProc,[hwnd],[hwndClient],[wmsg],[wparam],[lparam]
  139. ret
  140. wmdefault ENDP
  141. wmcreate PROC
  142. mov eax,[hMenuMain]
  143. mov [csx.hWindowMenu],eax
  144. mov [csx.idFirstChild],IDM_FIRSTCHILD
  145. lea eax,[csx]
  146.         call    CreateWindowEx, 0, offset szClientClassName, 0, 
  147. WS_CHILD OR WS_CLIPCHILDREN OR WS_VISIBLE, 
  148. CW_USEDEFAULT, 
  149. CW_USEDEFAULT, 
  150. CW_USEDEFAULT, 
  151. CW_USEDEFAULT, 
  152. [hwnd],1,[hInst],eax
  153. mov [hwndClient],eax
  154. ;
  155. ; set up the window for the project list
  156. ;
  157. call GetSubMenu,[hMenuMain],ProjectsMenuItem
  158. call SendMessage,[hwndClient],WM_MDISETMENU,hMenuMain,eax
  159. ;
  160. sub eax,eax
  161. ret
  162. wmcreate ENDP
  163. wmdestroy PROC
  164.         call    PostQuitMessage,0
  165. sub eax,eax
  166. ret
  167. wmdestroy ENDP
  168. wmqueryend PROC
  169.        call DialogBoxParam,[hInst],offset szAbortDialog,[hwnd],offset YesNoProc,0
  170. ret
  171. wmqueryend ENDP
  172. wminitmenupopup PROC
  173. mov [mf_state],MF_GRAYED
  174. test [numberofdrawwindows],-1
  175. jz wmimpz
  176. mov [mf_state],MF_ENABLED
  177. wmimpz:
  178. call EnableMenuItem,[hMenuMain],IDM_CLOSE,[mf_state]
  179. call EnableMenuItem,[hMenuMain],IDM_SAVEAS,[mf_state]
  180. call EnableMenuItem,[hMenuMain],IDM_SAVE,[mf_state]
  181. call EnableMenuItem,[hMenuMain],IDM_CASCADE,[mf_state]
  182. call EnableMenuItem,[hMenuMain],IDM_TILE,[mf_state]
  183. call EnableMenuItem,[hMenuMain],IDM_ARRANGE,[mf_state]
  184. sub eax,eax
  185. ret
  186. wminitmenupopup ENDP
  187. wmsize PROC
  188. cmp [wparam],SIZEFULLSCREEN
  189. jnz wmsnma
  190. mov eax,SW_SHOWMAXIMIZED
  191. jmp wmsx
  192. wmsnma:
  193. cmp [wparam],SIZEICONIC
  194. jnz wmsnmi
  195. mov eax,SW_SHOWMINIMIZED
  196. jmp wmsx
  197. wmsnmi:
  198. cmp [wparam],SIZENORMAL
  199. jnz wmsnmx2
  200. mov eax,SW_SHOWNORMAL
  201. wmsx:
  202. push esi
  203. push edi
  204. lea esi,[psShow]
  205. call IntToProfile
  206. pop edi
  207. pop esi
  208. wmsnmx2:
  209. call wmdefault
  210. sub eax,eax
  211. ret
  212. wmsize ENDP
  213. wmcommand PROC
  214. mov eax,[wparam]
  215. movzx eax,ax ; get rid of accel flag
  216. call Dispatch
  217. dd 6
  218. dd IDM_ABOUT,wmcabout
  219. dd IDM_NEWDRAW,wmcnewdraw
  220. dd IDM_EXIT,wmcexit
  221. dd IDM_CASCADE,wmccascade
  222. dd IDM_TILE,wmctile
  223. dd IDM_ARRANGE,wmcarrange
  224. jnc wmcx
  225. ;
  226. ; we didn't interp, send to active window
  227. ;
  228. call SendMessage,[hwndClient],WM_MDIGETACTIVE,0,0
  229. push eax
  230. call IsWindow,eax
  231. or eax,eax
  232. pop eax
  233. jz wmcnx
  234. call SendMessage,eax,WM_COMMAND,[wparam],[lparam]
  235. wmcnx:
  236. ;
  237. ; and to DefFrameProc
  238. ;
  239. call wmdefault
  240. sub eax,eax
  241. wmcx:
  242. ret
  243. wmcommand ENDP
  244. wmcabout PROC
  245.        call DialogBoxParam,[hInst],offset szAboutDialog,[hwnd],offset WaitingProc,0
  246. sub eax,eax
  247. ret
  248. wmcabout ENDP
  249. wmcnewdraw PROC
  250. call CreateDrawWindow, [hInst]
  251. sub eax,eax
  252. ret
  253. wmcnewdraw ENDP
  254. wmcexit PROC
  255. call SendMessage,[hwnd],WM_QUERYENDSESSION,0,0
  256. jz wmcnex
  257.        call SendMessage,[hwnd],WM_CLOSE,0,0
  258. wmcnex:
  259. sub eax,eax
  260. ret
  261. wmcexit ENDP
  262. wmccascade PROC
  263. call SendMessage,[hwndClient],WM_MDICASCADE,0,0
  264. sub eax,eax
  265. ret
  266. wmccascade ENDP
  267. wmctile PROC
  268. call SendMessage,[hwndClient],WM_MDITILE,0,0
  269. sub eax,eax
  270. ret
  271. wmctile ENDP
  272. wmcarrange PROC
  273. call SendMessage,[hwndClient],WM_MDIICONARRANGE,0,0
  274. sub eax,eax
  275. ret
  276. wmcarrange ENDP
  277. WndProc ENDP
  278. end start