I have a problem, it's simply to change the colors (background, text) of a Listbox-control.
I think it can be done using the LBS_OWNERDRAW style, the problem is I don't know how to do it. I have tried but failed. :(
The listbox's purpose is to be filled with data and always show the last added line, should I realy use a listbox for this task or should I use another control?
Any tips, help, thoughts regarding this would be appreciated.
I think it can be done using the LBS_OWNERDRAW style, the problem is I don't know how to do it. I have tried but failed. :(
The listbox's purpose is to be filled with data and always show the last added line, should I realy use a listbox for this task or should I use another control?
Any tips, help, thoughts regarding this would be appreciated.
Ok, I might be able to help here, but I will need just a little more information. My answer depends on yours :grin:
Are you simply changing the background and text color to something new? Or are you trying to code each line with a different c o l o r ?
The first is quite easy, the second requires the LBS_OWNERDRAW style and drawing it all yourself which is a pain.
Are you simply changing the background and text color to something new? Or are you trying to code each line with a different c o l o r ?
The first is quite easy, the second requires the LBS_OWNERDRAW style and drawing it all yourself which is a pain.
Simply changing the background and text color to something new is what I would like to start with, it would be enougth to resume the project.
Coloring each line different could be usefull for instance, red text color when reporting an error or such, but that is not urgent.
So for now I'll be satisfied with only changing bg and text color, but you could if you don't think it's to much work you can include the other one too.
Thanks for takeing time to help me! :)
Coloring each line different could be usefull for instance, red text color when reporting an error or such, but that is not urgent.
So for now I'll be satisfied with only changing bg and text color, but you could if you don't think it's to much work you can include the other one too.
Thanks for takeing time to help me! :)
Bah, its no trouble at all. Im usually quite good at the API but I suck at assembly so I hang around the board alot to learn.
Let me see. The easiest way to make changes to the colors (IMHO) is to capture the WM_CTLCOLORLISTBOX message sent to the parent WndProc.
wParam ; handle of list box display context
lParam ; handle of list box
something like this should work:
Make hBrush a global and on application exit call DeleteObject on it. Note: This proc (as is) will color *all* the listboxes on this parent. If you only want a particular one, compare the lParam to the listbox's hWnd.
Enjoy.
Let me see. The easiest way to make changes to the colors (IMHO) is to capture the WM_CTLCOLORLISTBOX message sent to the parent WndProc.
wParam ; handle of list box display context
lParam ; handle of list box
something like this should work:
WndProc proc hWin :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD
.if uMsg == WM_CTLCOLORLISTBOX
; set the text color for an item
invoke SetTextColor, wParam, 0FF0000h
; set the text back color for an item
invoke SetBkColor, wParam, 000FF00h
; set the background of the listbox
mov eax, hBrush
cmp eax, 0
jne BrushAlreadyCreated
invoke CreateSolidBrush, 00000FFh
mov hBrush, eax
BrushAlreadyCreated:
mov eax, hBrush
ret
.endif
WndProc endp
Make hBrush a global and on application exit call DeleteObject on it. Note: This proc (as is) will color *all* the listboxes on this parent. If you only want a particular one, compare the lParam to the listbox's hWnd.
Enjoy.
Thanks again!
It works, WM_CTLCOLORLISTBOX, I never would have thought of that (didn't even know it existed).
Thanks again, what else is there to say but thanks.
:) :) :)
Btw, I'm quite a newbie too.
It works, WM_CTLCOLORLISTBOX, I never would have thought of that (didn't even know it existed).
Thanks again, what else is there to say but thanks.
:) :) :)
Btw, I'm quite a newbie too.
Afternoon, scientica.
It's always good to see newbies here:).
Don't be worried about asking any questions you may have.
To help you along in finding more information regarding listboxes, I'll remind you that our search feature, at the top-right of this messageboard, has a wealth of hidden talent in supplying you with "heaps of tasty tid-bits" (<- I couldn't think of something fancy or profound to say ;) ).
Click (HERE ) for an example of a coloured listbox.
Cheers,
Scronty
It's always good to see newbies here:).
Don't be worried about asking any questions you may have.
To help you along in finding more information regarding listboxes, I'll remind you that our search feature, at the top-right of this messageboard, has a wealth of hidden talent in supplying you with "heaps of tasty tid-bits" (<- I couldn't think of something fancy or profound to say ;) ).
Click (HERE ) for an example of a coloured listbox.
Cheers,
Scronty
Here are other two threads. My examples are always in C ( :rolleyes: ) , so less interesting in an assembly board, but maybe you will find anyway some useful tips.
http://www.asmcommunity.net/board/index.php?topic=1519
http://www.asmcommunity.net/board/index.php?topic=1447
http://www.asmcommunity.net/board/index.php?topic=1519
http://www.asmcommunity.net/board/index.php?topic=1447