News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

EM_EXSETSEL problem...

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

Previous topic - Next topic

jj2007

Normally in such a case I would construct the simplest setup that shows these symptoms.
Anyway: Have you tried PostMessage?

PsYcHoCoDe

a'right, here's an update... tried to use PostMessage... so it claims that is succeeds (eax == 01) LastError == ERROR_SUCCESS (0)... but still no text is actually being selected inside the richedit box...

MarkFoundString PROC rvaFound:DWORD
LOCAL dwTemp:DWORD
LOCAL rChar:CHARRANGE
int 3
    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 SendMessage, hTxt, EM_EXSETSEL, 0, addr rChar
    invoke PostMessage, hTxt, EM_EXSETSEL, 0, addr rChar
    ret
MarkFoundString ENDP

:dazzled:

PS: i just tried to eventually work around that, using SendDlgItemMessage like that: invokeSendDlgItemMessage, hWnd, ID_CTEXT, EM_EXSETSEL, 0, addr rChar (instead of postmessage/sendmessage...) -> returns eax == 00000005h/LastError ERROR_ACCESS_DENIED (00000005h)...  :icon_eek: still no text selection marked... hWnd is a GLOBAL variable, containing the MAIN window's handle...

PsYcHoCoDe

What's the probability of that being kinda related to me not bothering to embed a manifest inside the executable?! :icon_rolleyes: i'm going way too short on options on that problem already, so just wild guess...   :redface:

hutch--

You can test that out by using an external manifest file but I doubt thats the problem. I pointed you at the masm32 example for a reason, it WORKS correctly. If you use a riched 2 or later version, you can search both forwards and backwards with whole word and case options. Just do this the standard Microsoft way and you can do all of these things without having to guess what is happening.

PsYcHoCoDe

i'm using the most primitive/old school/whatever variant - "Riched32.dll", so it's not 2.0 or sth... finally, i may have to give up on the riched32 option and use 2.0 or sth, if it's working... but i still try to preserve backwards compatibility on this...

PsYcHoCoDe

@ hutch-- : btw the example 06 seems to also fail the SendMessage EM_EXSETSEL... return values: eax == 0000000Bh/LastError == ERROR_INVALID_HANDLE... string searched inside the buffer == "asdf"

PS: though the text actually get's selected... ?! ::)

hutch--

Richedit 1 worked fine in win9x but it is emulated in Win2000 onwards in the later DLL. The series of riched went up to about 3 then it changes to another version that I have avoided as I hear it has problems.

This is the Winhelp on the message EM_EXSETSEL.


The EM_EXSETSEL message selects a range of characters and/or OLE objects in a rich edit control.

EM_EXSETSEL 
wParam = 0;
lParam = (LPARAM) (CHARRANGE FAR *) ichCharRange;


Parameters

ichCharRange

Zero-based index of the character.



Return Values

Returns the zero-based index of the line.


You would check if the LastError value should be applied to a richedit message.

jj2007

Quote from: PsYcHoCoDe on September 23, 2012, 10:50:23 PM
a'right, here's an update... tried to use PostMessage... so it claims that is succeeds (eax == 01) LastError == ERROR_SUCCESS (0)... but still no text is actually being selected inside the richedit box...

Try something simple like
    ; edit contains "This is a test with Richedit"
    mov rChar.cpMin, 10
    mov rChar.cpMax, 14
with SendMessage, PostMessage, Riched20, ....

PsYcHoCoDe

i've read the official documentationi only wasn't sure about if i should set rva's (inside the memory buffer) or offsets... now i know, it's about offsets, so that calculated correctly... but when using SendMessage, yeah, the getlasterror is the way to check if everything went fine, and it gives me ERROR_ACCESS_DENIED (that applies to SendDlgItemText and PostMessage as well)... i'm sure it's something really tiny, but i still can't think of something, that could be possibly wrong with my current 'setup'... except probably this could be OS specific, since devel environment is Windows Embedded 2009 POSReady, updated to CURRENT... since the last update my 'axe hex editor (v3.0)' stopped actually displaying it's main window... except inside the taskbar... but that seems kinda odd, the updates i applied @ that time were only some stuff about ActiveX rollup (or something similar) and the ms malware remover for september...  :dazzled:

PsYcHoCoDe

@ jj2007: mate, just tried it with static values: cpMin == 04h, cpMax == 08h, using SendDlgItemMessage... again no text's being actually selected, eax == 08h (that would be cpMax i suppose)/LastError == ERROR_ACCESS_DENIED (00000005h)... the last error is actually being set from the SendDlgItemMessage... pretty sure, that plain old SendMessage gives the same result...

PsYcHoCoDe

allright... seems u must EXPLICITLY call SetFocus on the richedit control... how could i work it out, since i actually have to find it in 2 separate richedit's (they can't have the window focus concurrently...)?

TouEnMasm


Only one window could have the focus.If you want to write two differents richedit and you have need of setfocus with riched32.dll,invoke setfocus and then send message to the richedit.The two functions must used the same handle.
Fa is a musical note to play with CL

PsYcHoCoDe

@ ToutEnMasm : cool, mate, that's quite similar to what i had in mind, since i've two riched's that must have 'concurrent' view... it's something similar to a hex editor, but still not exactly... damn, what a mess for a first richedit project...  :t

P.S.: btw what riched window message could i use to scroll it down to the found position?

TouEnMasm


You made a scroll  with a richedit giving it the style  XX_scroll something.
Use msdn or any help file to have the exact name of the style to use.The style can be up-down  or left-right.
Fa is a musical note to play with CL

PsYcHoCoDe

@ ToutEnMasm : styles are both ES_AUTOVSCROLL/ES_AUTOVHORIZONTAL and WS_VSCROLL/WS_HSCROLL currently... and it still doesn't seem to do the AUTO part...  :icon_rolleyes:

P.S.: no problem to paste the whole rsrc.rc, if needed?