Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: interesting question Pin
neodeaths6-Jan-06 21:38
neodeaths6-Jan-06 21:38 
AnswerRe: question about class/object passing by pointers Pin
Curtis Schlak.8-Jan-06 8:24
Curtis Schlak.8-Jan-06 8:24 
QuestionLoading Bitmap from Harddisk instead from resource file Pin
Anu_Bala6-Jan-06 20:00
Anu_Bala6-Jan-06 20:00 
AnswerRe: Loading Bitmap from Harddisk instead from resource file Pin
Gavin Taylor7-Jan-06 2:10
professionalGavin Taylor7-Jan-06 2:10 
AnswerRe: Loading Bitmap from Harddisk instead from resource file Pin
#realJSOP7-Jan-06 3:05
professional#realJSOP7-Jan-06 3:05 
AnswerRe: Loading Bitmap from Harddisk instead from resource file Pin
ThatsAlok9-Jan-06 17:22
ThatsAlok9-Jan-06 17:22 
QuestionList box background Pin
sthalasayanam6-Jan-06 19:43
sthalasayanam6-Jan-06 19:43 
AnswerRe: List box background Pin
Gavin Taylor7-Jan-06 2:51
professionalGavin Taylor7-Jan-06 2:51 
The best way is to override the WM_CTLCOLORLISTBOX[^] message.

You'll need something like HBRUSH m_hBrush = NULL; in your class definition and check you set it to NULL in your classes constructor. Once done, override the DefWindowProc for your controls parent window and add to it...

switch( message )
{
	case WM_CTLCOLORLISTBOX:
	{
		if( m_hBrush == NULL )
		{ // Fist time we're called so create the brush
			LOGBRUSH lb;
			ZeroMemory( & lb, sizeof( LOGBRUSH ) );
			lb.lbStyle = BS_SOLID;
			lb.lbColor = RGB( 0, 0, 255 );
			m_hBrush = CreateBrushIndirect( & lb );
		}
	
		SetBkColor( ( HDC ) wParam, RGB( 0, 0, 255 ) ); // Text background to Blue
		SetTextColor( ( HDC ) wParam, RGB( 255, 255, 255 ) ); // Text color to white
	
		return ( LRESULT ) m_hBrush;
	}; break;
}

Obviously when the window / class is destroyed you'll need to destroy the brush you've alllocated so add something like if( m_hBrush != NULL ) DestroyObject( m_hBrush ); aswell.

This will currently set every list box on your window to the colour Blue, if you want to be more selective all you need to do is compare the list boxes handle to the lParam of the WM_CTLCOLORLISTBOX message.


Gavin Taylor
w: http://www.gavspace.com

GeneralRe: List box background Pin
sthalasayanam8-Jan-06 15:59
sthalasayanam8-Jan-06 15:59 
Questionhow to add checkmark on selecting menu item Pin
Laxman96-Jan-06 18:44
Laxman96-Jan-06 18:44 
AnswerRe: how to add checkmark on selecting menu item Pin
Owner drawn8-Jan-06 17:15
Owner drawn8-Jan-06 17:15 
AnswerRe: how to add checkmark on selecting menu item Pin
ThatsAlok9-Jan-06 17:27
ThatsAlok9-Jan-06 17:27 
QuestionHalp regarding setting /NOENTRY resource DLL Pin
nitin_ap6-Jan-06 18:06
nitin_ap6-Jan-06 18:06 
AnswerRe: Halp regarding setting /NOENTRY resource DLL Pin
Prakash Nadar6-Jan-06 19:52
Prakash Nadar6-Jan-06 19:52 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
nitin_ap8-Jan-06 18:12
nitin_ap8-Jan-06 18:12 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
ThatsAlok9-Jan-06 17:58
ThatsAlok9-Jan-06 17:58 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
Prakash Nadar9-Jan-06 18:00
Prakash Nadar9-Jan-06 18:00 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
ThatsAlok9-Jan-06 18:06
ThatsAlok9-Jan-06 18:06 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
Prakash Nadar9-Jan-06 18:08
Prakash Nadar9-Jan-06 18:08 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
ThatsAlok9-Jan-06 18:13
ThatsAlok9-Jan-06 18:13 
GeneralRe: Halp regarding setting /NOENTRY resource DLL Pin
Prakash Nadar9-Jan-06 18:47
Prakash Nadar9-Jan-06 18:47 
Questionhow to implement a time delay? Pin
ewighell6-Jan-06 17:12
ewighell6-Jan-06 17:12 
AnswerRe: how to implement a time delay? Pin
KellyR6-Jan-06 17:18
KellyR6-Jan-06 17:18 
GeneralRe: how to implement a time delay? Pin
ewighell6-Jan-06 18:35
ewighell6-Jan-06 18:35 
GeneralRe: how to implement a time delay? Pin
KellyR6-Jan-06 19:02
KellyR6-Jan-06 19:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.