Hi,

Something very odd happens in my program:

I am using instance subclassing of an edit control with SetWindowLong CallWindowProc &c.

I add text to the control using:



invoke SendMessage,hEB,EM_SETSEL,0,-1 ; select all
invoke SendMessage,hEB,EM_SETSEL,-1,0 ; deselect; caret <- end of text
invoke SendMessage,hEB,EM_REPLACESEL,FALSE,szText


and in the subclass windowproc i catch WM_KEYDOWN with VK_RETURN and append "\r\n" uusing that method. The proxlem is that if you press return many times the editbox goes nuts (see the screenshots). I founh that the appending is causing this, as when commented it doesn't happens. I tred other append methods to no avail :(

http://stormix.webhop.info/shot.png
http://stormix.webhop.info/shot2.png

Interestingly, the problem messes up other apps' menus even after i quit it.

http://stormix.webhop.info/menu.png

When I pressed printscreen, the messagebox came up saying this then went blank

"Insufficient memory to create the bitmap. Close one or more applications to increase available."

but taskmanager said only 3Megs used... and gimp took the shot OK.

notice also that the 'crazy' box doesn't match the real one (aiaiaiaiai instead of iiiiiiiiiiiiiiii) - see shot2

So does anyone has a clue about this? :confused:

It seeme quite serious that it messes up other programs!

thanks.
Posted on 2004-02-04 11:04:21 by stormix
"/r/n" as in CRLF? Weird..
Posted on 2004-02-05 07:12:24 by roticv
yeah, crlf. It happens with other appends too.. maybe i have to write my own control :( but that it messes up other apps suggests that it's not my code's fault... or? Also the box was black with grey "Fixedsys" text but after it goes nuts becomes white with black text and starts looking Win3.1-esque.
Posted on 2004-02-05 07:23:37 by stormix
Anyway why are you manually converting "Enter" into CRLF? Isn't there something call ES_MULTILINE?
Posted on 2004-02-05 07:28:51 by roticv
Yeah but some times and positions i don't want to let the return go ahead because the edit box is acting like the console. I did do a way round that, but then it messes up after other appends anyway :(
Posted on 2004-02-05 07:31:50 by stormix
Just a question, did you do the subclassing properly?
Posted on 2004-02-05 07:36:06 by roticv
I hope so :o I did:

in WM_INITDIALOG of my dialog proc:



invoke SetWindowLongPtr,g_hEB, GWLP_WNDPROC,EditboxProc
mov lpOldWndProc,eax


and on the editbox proc has



mov eax,uMsg
; ... some stuff missed
.elseif eax == WM_COMMAND
mov edx,wParam
.if edx == VK_RETURN
invoke editbox_append,g_hEB,SADD("\r\n")
; ..some stuff missed..
.elseif ...
; ..some stuff missed


and ends with



invoke CallWindowProc,lpOldWndProc,hWnd,uMsg,wParam,lParam
ret
Posted on 2004-02-05 07:47:07 by stormix
If I am not wrong, if you handled the WM_KEYDOWN, I do not think you should return the msg, but instead 0 for the message. That's if my memory can recall. My subclass code was
EditSubClass proc uses ebx hwnd:DWORD, message, wparam, lparam

mov eax, message
cmp eax, WM_CHAR
jnz _wmdlgcode
mov eax, wparam
lea ecx, [eax-'0']
cmp ecx, '9' - '0'
jna @F
cmp eax, VK_BACK
jz @F
and eax, 0FFFFFFDFh
lea ecx, [eax-'A']
cmp ecx, 'F' - 'A'
jna @F
xor eax, eax
jmp @F
_wmdlgcode:
cmp eax, WM_GETDLGCODE
jnz @F
mov eax, DLGC_WANTALLKEYS
@@:
mov ebx, offset EditControlInfo
mov edx, [ebx+4]
mov ecx, [ebx]
cmp ecx, hwnd
cmovnz edx, [ebx+12]
mov ecx, wparam
cmp eax, message
cmovz eax, ecx
invoke CallWindowProc, edx, hwnd, message, eax, lparam
ret
EditSubClass endp

The reson for the mov ebx, offset EditControlInfo is that I made use of the same EditSubClass function for 2 editbox that I subclassed.
Posted on 2004-02-05 08:16:44 by roticv
I found that if I remove my manifest.xml then it works!!!!! And no matter whether I call InitCommonControls or InitCommonControlsEx!

I tried the manifest it says here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/xptheming.asp to no avail.

While i hesitate to say it, surely that it messes other programs is a problem with windows?

Any ideas?
Posted on 2004-02-05 11:44:12 by stormix
easier method to append... saves a 'flicker' when updating it

; in this example i setup an ebp frame, im sure you can get the idea tho

; EBP+8 = edit window handle
; ebp+0ch = text to set
; ebp-4 = used for storage of text length




push 0
push 0
push WM_GETTEXTLENGTH
push dword ptr [ebp+08h]
call SendMessageA

MOV [ebp-4],eax ; store window text length

push dword ptr [ebp-4] ; last char ;)
push dword ptr [ebp-4] ; last char ;)
push EM_SETSEL
push dword ptr [ebp+08h]
call SendMessageA

push dword ptr [ebp+0ch] ; data to append
push FALSE
push EM_REPLACESEL
push dword ptr [ebp+08h]
call SendMessageA

push 0
push 0
push EM_SCROLLCARET
push dword ptr [ebp+08h]
call SendMessageA

Posted on 2004-02-05 13:05:19 by evlncrn8
Thanks :alright: that works nicely nicely :grin: Still have the problems when I use xp styles though :(
Posted on 2004-02-05 13:37:13 by stormix
i've had problems with some of the themes too, infact some seem to be highly buggy.. like list views having the first column totally black background, black text, and on some tab control windows, try using a different theme, see if the problem persists, you might just have a dodgy theme ;)

invoke editbox_append,g_hEB,SADD("\r\n")

just wondering, would that perhaps use sendmessagea, if so that might be the cause of the wierdness, try changing any sendmessagea's in that proc to callwindowproc and see if that clears things up
Posted on 2004-02-05 15:26:16 by evlncrn8
Yeah I wondered that too so I tried but to no avail :(
Posted on 2004-02-06 07:56:56 by stormix
Does anyone knows how to use all other things XP style but the edit box using the old comctl32.dll? And if it is likely a ms bug or mine?
Posted on 2004-02-06 11:47:37 by stormix
I found the problem-
There was a 'handle leak': i was calling CreateSolidBrush and never deleting the result before making a new one :o The same problem did happen with no manifest but took longer to 'manifest' itself ;) Doh!
:stupid:
Posted on 2004-02-07 15:07:01 by stormix
Hi, I was using this code:
 invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR sEdit,NULL,ES_MULTILINE or ES_READONLY or WS_VISIBLE or WS_CHILD,100,10,300,300,hWin,0,hInstance,0

to create an edit control after teh WM_CREATE message. I'm not using any brushes or anything sophisticated! It works fine, until I put in the xptheme.xml maifest in my resource, then I get the error that the "Class does not exist". So, to quote stormix:
Does anyone knows how to use all other things XP style but the edit box using the old comctl32.dll?
Or should I/we move to richedit controls or something? (A little OTT for what I require...).
Thanks,
~Adam

The problem has gone now, I think that I wasn't calling InitCommonControls... :stupid:
Posted on 2004-04-09 08:55:07 by adamjjackson