iczelion tut34[9]

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

本文简介:选择自 jimgreen 的 blog

	invoke isdlgbuttonchecked,hwnd,idc_down
		.if eax==bst_checked
			or uflags,fr_down
			mov eax,findtext.chrg.cpmin
			.if eax!=findtext.chrg.cpmax
				push findtext.chrg.cpmax
				pop findtext.chrg.cpmin
			.endif
			mov findtext.chrg.cpmax,-1
		.else
			mov findtext.chrg.cpmax,0
		.endif

the next part is a little tricky. we check the direction radio button to ascertain which direction the search should go. if the downward search is indicated, we set fr_down flag to uflags. after that, we check whether a selection is currently in effect by comparing the values of cpmin and cpmax. if both values are not equal, it means there is a current selection and we must continue the search from the end of that selection to the end of text in the control. thus we need to replace the value of cpmax with that of cpmin and change the value of cpmax to -1 (0ffffffffh). if there is no current selection, the range to search is from the current caret position to the end of text.

if the user chooses to search upward, we use the range from the start of the selection to the beginning of the text in the control. that's why we only modify the value of cpmax to 0. in the case of upward search, cpmin contains the character index of the last character in the search range and cpmax the character index of the first char in the search range. it's the inverse of the downward search.

		invoke isdlgbuttonchecked,hwnd,idc_matchcase
		.if eax==bst_checked
			or uflags,fr_matchcase
		.endif
		invoke isdlgbuttonchecked,hwnd,idc_wholeword
		.if eax==bst_checked
			or uflags,fr_wholeword
		.endif
		mov findtext.lpstrtext,offset findbuffer

we continue to check the checkboxes for the search flags, ie, fr_matchcase and fr_wholeword. lastly, we put the offset of the text to search for in lpstrtext member.

		invoke sendmessage,hwndrichedit,em_findtextex,uflags,addr findtext
		.if eax!=-1
			invoke sendmessage,hwndrichedit,em_exsetsel,0,addr findtext.chrgtext
		.endif
	.endif

we are now ready to issue em_findtextex. after that, we examine the search result returned by sendmessage. if the return value is -1, no match is found in the search range. otherwise, chrgtext member of findtextex structure is filled with the character indices of the matching text. we thus proceed to select it with em_exsetsel.

the replace operation is done in much the same manner.

	invoke getdlgitemtext,hwnd,idc_findedit,addr findbuffer,sizeof findbuffer
	invoke getdlgitemtext,hwnd,idc_replaceedit,addr replacebuffer,sizeof replacebuffer

we retrieve the text to search for and the text used to replace.

	mov findtext.chrg.cpmin,0
	mov findtext.chrg.cpmax,-1
	mov findtext.lpstrtext,offset findbuffer

to make it easy, the replace operation affects all the text in the control. thus the starting index is 0 and the ending index is -1.

	mov settext.flags,st_selection
	mov settext.codepage,cp_acp

we initialize settextex structure to indicate that we want to replace the current selection and use the default system code page.

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

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

go top