Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ 6.0 and 64 bit Pin
Randor 16-Jan-09 4:01
professional Randor 16-Jan-09 4:01 
GeneralRe: VC++ 6.0 and 64 bit Pin
Hamid_RT17-Jan-09 20:26
Hamid_RT17-Jan-09 20:26 
GeneralRe: VC++ 6.0 and 64 bit Pin
Randor 19-Jan-09 4:14
professional Randor 19-Jan-09 4:14 
GeneralRe: VC++ 6.0 and 64 bit Pin
Hamid_RT20-Jan-09 19:10
Hamid_RT20-Jan-09 19:10 
Questionopening Multiple files through a folder Pin
ritu rana15-Jan-09 13:38
ritu rana15-Jan-09 13:38 
AnswerRe: opening Multiple files through a folder Pin
CPallini15-Jan-09 21:18
mveCPallini15-Jan-09 21:18 
Questionopening Multiple files from a folder Pin
ritu rana15-Jan-09 13:37
ritu rana15-Jan-09 13:37 
QuestionProblem with 3-State Check Box (push style) with common controls 6.0 Pin
Software200715-Jan-09 9:44
Software200715-Jan-09 9:44 
I have a problem with a 3 state check box (push style) with new common controls 6.0 vista look, no problem with older common controls. I have created a very simple application of one button if someone needs the code, where I want the check box(which really looks like a push button) to behave as 3 different state, ( ON -I set to a color), (OFF- I set it to another color), (INdeterminate- I want it to be Gray or something), works fine for ON & OFF, but 3rd state, somehow the text seems to get shifted or something on the button, it shows half gray, half red..... Anyone with similar problem...here is the meat of the code...Keep in mind, it works fine if I don't use it as tri-state, or if I don't use common controls 6.0 with the linker.
Thanks
void CColoredButton::OnClicked() 
{
	// TODO: Add your control notification handler code here
	if(!m_IsEnabled){
		SetCheck(FALSE);
		return;
	}
	if(GetCheck()==2){
		ModifyStyle(BS_BITMAP,0);
		InvalidateRect(NULL);
	}

	else{
		ModifyStyle(0,BS_BITMAP);

		SetColoredCheck(GetCheck(),m_FontSize);
	}
	WPARAM wParam=MAKEWPARAM(GetDlgCtrlID( ),BN_DOUBLECLICKED); 

    //In order to pass a click message back to the owner window I have to send a message other
   	//than BN_CLICKED, because the message would come back here instead. So I choose Double Click.
	//There must be a way to pass this message to the owner, but this works
	GetParent()->SendMessage(WM_COMMAND,wParam  ,(LPARAM)m_hWnd);
}

/////////////////////////
void CColoredButton::SetColoredCheck(int nCheck,int FontSize)
{
	

	COLORREF Color = m_UpColor;
	if(nCheck==1)
		Color=m_DownColor;
	if(nCheck==2)
		Color=RGB(255,0,0);
	
	
	CString Label=GetText(FALSE);

	
	CRect Client;
	GetClientRect(Client);
	CClientDC dc(this);
	CDC dcMem;
	dcMem.CreateCompatibleDC(&dc);

	CFont* pFont = GetFont();
	CFont MyFont;
	m_FontSize=FontSize;
	

	

	CBitmap* pOldBitmap = dcMem.SelectObject(&m_Bitmap);



	// draw a rectangle in the background (window) color
	//CRect rect(0, 0, 16,16);
	CBrush brBackground(Color);
	CBrush *OldBrush=dcMem.SelectObject(&brBackground);
	dcMem.SetBkColor(Color);


	dcMem.FillRect(Client, &brBackground);
	

	if(!m_IsEnabled){
		CBrush *PHalfBrush=dcMem.GetHalftoneBrush( );
		if(PHalfBrush!=NULL)
			dcMem.FillRect(Client, PHalfBrush);
	}
	
	CFont *OldFont=dcMem.SelectObject(pFont);

	int OldBkMode = dcMem.SetBkMode(TRANSPARENT);
	dcMem.DrawText( Label, Client, DT_CENTER | DT_VCENTER |DT_SINGLELINE );
	dcMem.SetBkMode(OldBkMode);
	dcMem.SelectObject(pOldBitmap);
	dcMem.SelectObject(OldFont);
	dcMem.SelectObject(OldBrush);
	

	if(FontSize>0)
		MyFont.DeleteObject();


	dcMem.DeleteDC();
	

	SetBitmap( HBITMAP(m_Bitmap) );

	SetWindowText(Label);

	SetCheck(nCheck);

}


sft

AnswerRe: Problem with 3-State Check Box (push style) with common controls 6.0 Pin
Software200715-Jan-09 15:33
Software200715-Jan-09 15:33 
Questionhow to contact outlook calender from VC++ ? Pin
spicy_kid200015-Jan-09 6:32
spicy_kid200015-Jan-09 6:32 
AnswerRe: how to contact outlook calender from VC++ ? Pin
Cedric Moonen15-Jan-09 7:15
Cedric Moonen15-Jan-09 7:15 
AnswerRe: how to contact outlook calender from VC++ ? Pin
Stuart Dootson15-Jan-09 9:11
professionalStuart Dootson15-Jan-09 9:11 
Questionlimiting print margins Pin
TClarke15-Jan-09 4:43
TClarke15-Jan-09 4:43 
AnswerRe: limiting print margins Pin
Iain Clarke, Warrior Programmer15-Jan-09 5:17
Iain Clarke, Warrior Programmer15-Jan-09 5:17 
GeneralRe: limiting print margins Pin
TClarke15-Jan-09 5:48
TClarke15-Jan-09 5:48 
AnswerRe: limiting print margins Pin
Rajkumar R15-Jan-09 7:16
Rajkumar R15-Jan-09 7:16 
GeneralRe: limiting print margins [modified] Pin
TClarke15-Jan-09 23:14
TClarke15-Jan-09 23:14 
QuestionWM5 dev, Problem with C++ FindFirstFile returning 0xffffffff Pin
uzziah015-Jan-09 3:48
uzziah015-Jan-09 3:48 
AnswerRe: WM5 dev, Problem with C++ FindFirstFile returning 0xffffffff Pin
Randor 15-Jan-09 4:20
professional Randor 15-Jan-09 4:20 
GeneralRe: WM5 dev, Problem with C++ FindFirstFile returning 0xffffffff Pin
uzziah015-Jan-09 4:46
uzziah015-Jan-09 4:46 
QuestionAccess Database: Create Table Pin
SutterA15-Jan-09 3:14
SutterA15-Jan-09 3:14 
AnswerRe: Access Database: Create Table Pin
David Crow15-Jan-09 4:20
David Crow15-Jan-09 4:20 
Questionwindows Loader Pin
Member 342050915-Jan-09 1:44
Member 342050915-Jan-09 1:44 
AnswerRe: windows Loader Pin
Iain Clarke, Warrior Programmer15-Jan-09 2:04
Iain Clarke, Warrior Programmer15-Jan-09 2:04 
AnswerRe: windows Loader Pin
Naveen15-Jan-09 2:07
Naveen15-Jan-09 2:07 

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.