iczelion tut34[4]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

all the above notifications will be sent as wm_notify message: you have to check the code member of nmhdr structure for the notification message. for example, if you want to register for mouse events (eg. you want to provide a context sensitive popup menu), you must do something like this:

	invoke sendmessage,hwndrichedit,em_seteventmask,0,enm_mouseevents
	.....
	.....
	wndproc proc hwnd:dword, umsg:dword, wparam:dword, lparam:dword
	.....
	....
		.elseif umsg==wm_notify
			push esi
			mov esi,lparam
			assume esi:ptr nmhdr
			.if [esi].code==en_msgfilter
				....
				[ do something here]
				....
			.endif
			pop esi

example:

the following example is the update of iczedit in tutorial no. 33. it adds search/replace functionality and accelerator keys to the program. it also processes the mouse events and provides a popup menu on right mouse click.

.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\gdi32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

winmain proto :dword,:dword,:dword,:dword

.const
idr_mainmenu                   equ 101
idm_open                      equ  40001
idm_save                       equ 40002
idm_close                      equ 40003
idm_saveas                     equ 40004
idm_exit                       equ 40005
idm_copy                      equ  40006
idm_cut                       equ  40007
idm_paste                      equ 40008
idm_delete                     equ 40009
idm_selectall                  equ 40010
idm_option 			equ 40011
idm_undo			equ 40012
idm_redo			equ 40013
idd_optiondlg                  equ 101
idc_backcolorbox               equ 1000
idc_textcolorbox               equ 1001
idr_mainaccel                 equ  105
idd_finddlg                    equ 102
idd_gotodlg                    equ 103
idd_replacedlg                 equ 104
idc_findedit                  equ  1000
idc_matchcase                  equ 1001
idc_replaceedit                 equ 1001
idc_wholeword                  equ 1002
idc_down                       equ 1003
idc_up                       equ   1004
idc_lineno                   equ   1005
idm_find                       equ 40014
idm_findnext                  equ  40015
idm_replace                     equ 40016
idm_gotoline                   equ 40017
idm_findprev                  equ  40018
richeditid 			equ 300

.data
classname db "iczeditclass",0
appname  db "iczedit version 2.0",0
richeditdll db "riched20.dll",0
richeditclass db "richedit20a",0
norichedit db "cannot find riched20.dll",0
asmfilterstring 		db "asm source code (*.asm)",0,"*.asm",0
				db "all files (*.*)",0,"*.*",0,0
openfilefail db "cannot open the file",0
wannasave db "the data in the control is modified. want to save it?",0
fileopened dd false
backgroundcolor dd 0ffffffh		; default to white
textcolor dd 0		; default to black
hsearch dd ?		; handle to the search/replace dialog box
haccel dd ?

.data?
hinstance dd ?
hrichedit dd ?
hwndrichedit dd ?
filename db 256 dup(?)
alternatefilename db 256 dup(?)
customcolors dd 16 dup(?)
findbuffer db 256 dup(?)
replacebuffer db 256 dup(?)
uflags dd ?
findtext findtextex <>

.code
start:
	mov byte ptr [findbuffer],0
	mov byte ptr [replacebuffer],0
	invoke getmodulehandle, null
	mov    hinstance,eax
	invoke loadlibrary,addr richeditdll
	.if eax!=0
		mov hrichedit,eax
		invoke winmain, hinstance,0,0, sw_showdefault
		invoke freelibrary,hrichedit
	.else
		invoke messagebox,0,addr norichedit,addr appname,mb_ok or mb_iconerror
	.endif
	invoke exitprocess,eax
	
winmain proc hinst:dword,hprevinst:dword,cmdline:dword,cmdshow:dword
	local wc:wndclassex
	local msg:msg
	local hwnd:dword
	mov   wc.cbsize,sizeof wndclassex
	mov   wc.style, cs_hredraw or cs_vredraw
	mov   wc.lpfnwndproc, offset wndproc
	mov   wc.cbclsextra,null
	mov   wc.cbwndextra,null
	push  hinst
	pop   wc.hinstance
	mov   wc.hbrbackground,color_window+1
	mov   wc.lpszmenuname,idr_mainmenu
	mov   wc.lpszclassname,offset classname
	invoke loadicon,null,idi_application
	mov   wc.hicon,eax
	mov   wc.hiconsm,eax
	invoke loadcursor,null,idc_arrow
	mov   wc.hcursor,eax
	invoke registerclassex, addr wc
	invoke createwindowex,null,addr classname,addr appname,           ws_

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top