Hi. I am using SetTextColor for a listbox. How do I use it? I tried this:
HDC hWin;
hWin = GetDC(listWin);
SetTextColor(hWindows, COLOR_BTNFACE + 2);
But nothing happens. What do I do?
Hi. I am using SetTextColor for a listbox. How do I use it? I tried this:
HDC hWin;
hWin = GetDC(listWin);
SetTextColor(hWindows, COLOR_BTNFACE + 2);
But nothing happens. What do I do?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Well first of all, I'm pretty sure that SetTextColor takes an RGB value, so you'd want more like RGB(10,0,0) over COLOR_BTNFACE+2, secondly you're setting it to the [glaringly obvious]WRONG DC[/glaringly obvious], and third, I dunno if it works on listboxes.
What DC do I need?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
>>hWin = GetDC(listWin);
SetTextColor(hWindows, COLOR_BTNFACE + 2);<<
you're storing the value in hWin but setting the text of hWindows.
You'll need to trap the WM_CTLCOLORLISTBOX message in your message handler function. The WPARAM in this message is the DC for the list box and the LPARAM is the window handle. It is sent whenever a listbox is redrawn.
zen
Oh yeah, that was my second guess...
Can I have a short example on trapping it and changing the text color?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
probably (but don't quote me on this...)
Code:case WM_CTLCOLORLISTBOX: hDC = (HDC)WParam; //if this doesn't work mess aorund with HIWORD and LOWORD SetTextColor(hDC, RGB(255,0,0)); return 0;
That didn't work at all.
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
well I didn't think so...I was just taking a stab in the dark. :stabstabstab:
Red text -
Code:case WM_CTLCOLORLISTBOX: SetTextColor((HDC)wParam,RGB(255,0,0)); return (LRESULT)GetStockObject(WHITE_BRUSH);
zen
How do I fill the whole background of the listbox with black?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
same way only SetBkColor?
I tried that but it only changes text background.
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
If you want a different colour brush, return a different brush to the one I returned in the above example. If the colour isn't one of the stock ones you'll have to create your own and return it.
zen