News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

EM_EXSETSEL problem...

Started by PsYcHoCoDe, September 21, 2012, 09:31:21 PM

Previous topic - Next topic

PsYcHoCoDe

- what i'm trying to actually do: implement search algo (already did it), from a secondary DlgProc (separate dialog, of course), then display the result as a MARKED/SELECTED TEXT in the ascii buffer of the rich edit control using EM_EXSETSEL (this should 'select the defined text, right?)...
- what actually happens: if result is found, the secondary dlgProc closes the dlg, storing the found result's RVA (it's GlobalAlloc'd buff) in a global dword... after that the MAIN dlg proc call the calculation of parameters and actually sending the msg (posted just below is this proc...)...
- result of SendMessageTimeout: returns TRUE (it worked?!), GetLastError: (ERROR_ACCESS_DENIED)... and there's no text actually being selected in the richedit == it actually didn't worked...

- yeah, this is my first meeting with RICHEDIT controls' coding, i'm not really into sophisticated gui stuff usually...

P.S.: yep, i've tryed to load the structure (wParam of msg) with RVA's, tried it with OFFSET's too... nothing happens in both occasions... any ideas, guys?!

MarkFoundString PROC rvaFound:DWORD
LOCAL dwTemp:DWORD
LOCAL rChar:CHARRANGE
    invoke szLen, addr srchString
    mov edx, txtAddr
    mov ecx, rvaFound
    sub ecx, edx ; getting offsets...
    mov rChar.cpMin, ecx
    add eax, ecx
    mov rChar.cpMax, eax
    invoke SendMessageTimeout, hTxt, EM_EXSETSEL, 0, addr rChar, SMTO_NORMAL, 30*1000, addr dwTemp
    ret
MarkFoundString ENDP

MichaelW

If SendMessageTimeout returned true, then the function succeeded and your call to GetLastError is meaningless, because functions that succeed do not necessarily clear the last-error code value. You can test this by using SetLastError to clear the last-error code value immediately before the SendMessageTimeout call.
Well Microsoft, here's another nice mess you've gotten us into.

PsYcHoCoDe

@MichaelW, yes, i know about that, so it's tested... by saying the SendMessageTimeout returns GetLastError, i actually mean that the particular function returns this last error...i always do that, when necessary  :t

P.S: OS = Windows 2009 Embedded (xp-alike), SDK = masm v10 with ml v.10x and updated linker (ms link.exe)...  + i always check everything with immunity dbgr... ;)

qWord

Why are using  SendMessageTimeout()? - AFAICS it makes only sense, if the destination window is created from another thread - otherwise it behaves like SendMessage().
MREAL macros - when you need floating point arithmetic while assembling!

PsYcHoCoDe

@qWord: sometimes hepled me in the past, so i just thought it'ld be kinda 'safer' if i use the timeout... now as u mention it, yeah, it doen't really make much sense, indeed... i just need to get it done somehow, though... maybe i should indeed try this with 'plain' SendMessage?

PsYcHoCoDe

come on, won't someone giva a actual solution to this?! :redface:

sinsi

Well, what are srchString, txtAddr and rvaFound?
Not enough code.

PsYcHoCoDe

@sinsi: srchString is  a pointer, txtAddr & rvaFound too are pointers, mate ;)Allocated , using GlobalAlloc..

sinsi


PsYcHoCoDe

srchString is a pointer to default allocated memory. rvaFound is too the same... txtAddr ir allocated using GlobalAlloc...

P.S: everithin's either dinamically allocated(the usual idea), or statically defined inside the source...  8)

hutch--

Psycho,

If successful search in a richedit control is what you are after, look in the example code of MASM32, "example06\riched". It works fine.

PsYcHoCoDe

i just tested it with using SendMessage api instead of sendMessageTimeout... it seems the same - LastError == ERROR_ACCESS_DENIED....

@hutch:  of the examples seems that it's actually using offsets, so i didi it that way... alas, still ain't working...

P.S.: eax == 05h and LastError == ERROR_ACCESS_DENIED...

any ideas about that?! (it's being called from the main dialog procedure, that manages the actual richedit controls)...

TouEnMasm


At this time , the ACCESS is only DENIED to your code.
To got an answer post it here.
Fa is a musical note to play with CL

jj2007

Psycho,

Your problem can have a dozen different causes. RichEd is an ill-mannered pig, but your chances are good to get an answer because both hutch and myself (and I guess, a few others here) have an awful lot of (bad) experience with RichEd.

However, guessing is not our strong point. Strip your code from anything that you consider valuable and/or confidential, and post the complete source.

Cheers,
jj

PsYcHoCoDe

alas, i pasted ony this piece, cuz almost all of anything else would be considered confidential atm... :/ if it wasn't i would upload somewere the whole thing and post a link... :/

P.S: ye, i wouldn't really mess with richedit items, if i have hadn't do it that way...