Jump to content
Tuts 4 You

How to use FindText / ReplaceText / FINDREPLACE?


LCF-AT

Recommended Posts

Posted

Hi guys,

I am playing around with that functions & struct to get a dialog same as in notepad to find / repleace etc.I get the new dialog to see where I can enter stuff etc.My  problem now is how to catch the messages if I press OK / chancel etc to get the entered data and where?Can anyone post a example code of this?

Thank you

Posted (edited)

i might have something there actually cos i used it in the log window in protectionid, but i truly have no idea if it works as i umm never used it heh

 

damnit, i got 'lcf-at can not recieve messages'.. i've kept the message window open though so if you clear your inbox i can send you the code

edit 2 : actually its pretty well documented here -> https://msdn.microsoft.com/en-us/library/windows/desktop/ms646918(v=vs.85).aspx and theres sample code in the link, pay attention to the registerwindowmessage part

Edited by evlncrn8
  • Like 1
Posted

Hi evlncrn8,

I still have problems to get any messages I could catch.I made something like this...

		        invoke RtlZeroMemory,addr FR,sizeof FR
                invoke GlobalAlloc, GMEM_FIXED,100
                mov FindBuf,eax		
                mov FR.lStructSize,sizeof FR                
                push hWnd
                pop FR.hwndOwner
                mov FR.Flags,FR_DOWN or FR_NOWHOLEWORD ;or FR_ENABLEHOOK;FR_HIDEUPDOWN or FR_HIDEMATCHCASE or FR_HIDEWHOLEWORD;
                push FindBuf
                pop FR.lpstrFindWhat
                mov FR.wFindWhatLen, 100
                invoke RegisterWindowMessage,chr$("commdlg_FindReplace")
                mov uFindReplaceMsg,eax
                invoke FindText,addr FR
                mov findDBHandle,eax

Now I try in the proc to catch any message from the new search dialog or handle etc but I dont get any.

             mov eax, uFindReplaceMsg
     .elseif uMsg == eax

Also tried to catch BN_CLICKED anywhere but also nothing.I think I still do something wrong etc but what.

greetz

Posted

only thing i can see is that you're missing the part that states "When the dialog box is open, your main message loop must include a call to the IsDialogMessagefunction. Pass a handle to the dialog box as a parameter in the IsDialogMessage call.", which seems critical

  • Like 1
Posted

Hi again,

ok stupid me again so I see the problem in my code now.Just did set the uFind.. in eax on wrong line.Now I fixed that and I get the handle to check it with uMsg.Now I have a small another question about checking the flags from the FINDREPLACE struct in lparam.In my example I did set this flags FR_DOWN or FR_NOWHOLEWORD = 1001h.Now if I wanna check the flags after something was entered etc then they are changed and now I wanna check which flag was set new etc.Example, 1001h was changed to 1009h = FR_FINDNEXT flag was added.My stupid question now is how to check that single flag of FR_FINDNEXT now?

             mov edi,lParam
             mov esi,[edi].FINDREPLACE.Flags
             .if  esi == FR_FINDNEXT  ; <---
             .endif

I can use all 3 paramters...

.if  esi == FR_DOWN or FR_NOWHOLEWORD or FR_FINDNEXT

...then its working but anyhow else it should be more right or better only to check FR_FINDNEXT alone.Dont remember anymore.Do you have a short idea how to check that flags more correctly?

PS: I dont use message loops GetWindow / Tanslate... in my codes.

greetz

Posted
 mov esi,[edi].FINDREPLACE.Flags
             .if  esi == FR_FINDNEXT  ; <---

lets change it then

mov esi, [edi].FINDREPLACE.Flags

and esi, FR_FINDNEXT

cmp esi, FR_FINDNEXT

jne itsnotfindnextsorestoreesianddootherstuff

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...