I'm having trouble with a tree-view control. I'm trying to prevent the branch items from collapsing by processing TVN_ITEMEXPANDING, but it doesn't seem to work for me. According to win32.hlp I should process that message and return TRUE...

; -------------------------------------------------------------------------
PrefBox proc hwnd,umsg,wparam,lparam
mov eax,umsg
.if eax == WM_NOTIFY
mov edx,lparam
mov eax,(NM_TREEVIEW ptr [edx]).hdr.code
xor eax,eax
inc eax

; (...)

xor eax,eax
PrefBox endp
; -------------------------------------------------------------------------

Any help?
Posted on 2003-06-23 09:10:00 by QvasiModo
Presumably your treeview control is in a dialog. If so, you have to set returncode DWL_MSGRESULT and returning eax=true.
Posted on 2003-06-23 11:01:54 by japheth
Oops...! :o
Posted on 2003-06-25 19:42:53 by QvasiModo
Works on Win2K, the treeview in your example would not collapse.
Posted on 2003-06-25 23:12:04 by donkey
By the way, is there any way to set a background picture in a tree view control? It isn't like list view, and I found nothing about it in the board...
Posted on 2003-06-26 16:55:19 by QvasiModo
There is no message that will easily set a background image for a treeview. You can however subclass the treeview in order to process the WM_PAINT message. At that point you can bitblt a bitmap into the treviews DC or use a pattern brush to paint it. If you use a pattern brush be aware that in earlier versions of Windows you are limited to an 8x8 bitmap, so to be compatible with all versions you should use bitblt.
Posted on 2003-06-26 19:10:48 by donkey
Try here - As Donkey said there is no message to do it but it is possible by subclassing the control and painting the screen yourself

Posted on 2003-06-27 04:48:47 by taff
Thanks for your help!

Regarding your code, I think it is great (I once tried the same with a list view control, but my background just screwed up when scrolling the control :tongue: )

I've been experimenting a while with it and found out:

1) The background bitmap seems to be converted to 16 colors by BitBlt if the SRCAND flag is used. Does this happen in all Win32 versions?

2) Your "hardcoded value" 16 seems to be correct, but I couldn't figure out what it depends on. It isn't the font height, because I tried changing it (also setting a different font) and the background still worked correctly.

3) I tried to comment out the lines with the "#ME#" comment, but didn't work as expected. It just paints the bitmap up to the current size of the control, when I scroll it, the new areas of the bitmap that should be drawn are not... I can't post my code now (I'm not at home), but can anyone try it too, to see if I have done something wrong, or the code needs some other changes?

I was also wondering if there was a way to paint a 16M color background, that is without using BitBlt and SRCAND flag... but I think a direct access to the bitmap should be necessary, and probably I lack the skills in GDI. I'll appreciate any ideas, though :alright:
Posted on 2003-06-27 17:20:32 by QvasiModo
1) Not sure - I hacked it together on win2k and the picture I had worked

2) I'm still at a loss to what 16 depends on

3) These are the only bits I comment out to produce a static background

; The vertical movement on a treeview moves in blocks rather pixels.
; 16 is used after experimenting - might have something to do with font height
; If you prefer a static background comment out these 4 lines with #ME#
;*this* imul eax,16 ; #ME#
;*this* mov rect.top,eax ; to have static background #ME#
xor eax,eax
;*this* sub eax,rect.top ; #ME#

@@loop: ; loop through height of DC in increments
; of bitmap height
xor ecx,ecx ; reset counter width
;*this* sub ecx,rect.left ; #ME#
@@loop2: ;loop through width of DC in increments

If need be I can post the radasm project on here, though I've made some changes.

PS I'm not to good with the GDI yet either :(


Posted on 2003-06-30 06:40:36 by taff
Well, the lines I commented out were correct-but that was not the problem, I guess :)
I've found out it doesn't matter if the background is tiled or not, it just won't work if the bitmap is bigger than the control. I'm posting my code here... (it's not a ZIP file, it's a RAR file, I had to rename it or the board wouldn't let me post it)
Posted on 2003-07-02 10:25:09 by QvasiModo
ahh - now I see the problem :)

I'll see if I can come up with a solution

Posted on 2003-07-03 02:42:59 by taff
QvasiModo - try the thread I posted above

I've updated the project - I hope this is what you require :)

Posted on 2003-07-03 10:18:47 by taff
Thanks! Now it works just fine.:)
Posted on 2003-07-03 13:22:18 by QvasiModo