Click here to Skip to main content
15,914,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: disappearing check boxes Pin
maladuk30-Jan-07 22:40
maladuk30-Jan-07 22:40 
QuestionRe: disappearing check boxes Pin
prasad_som30-Jan-07 17:19
prasad_som30-Jan-07 17:19 
AnswerRe: disappearing check boxes -code Pin
maladuk30-Jan-07 22:06
maladuk30-Jan-07 22:06 
QuestionRe: disappearing check boxes -code Pin
prasad_som30-Jan-07 22:31
prasad_som30-Jan-07 22:31 
AnswerRe: disappearing check boxes -code Pin
maladuk30-Jan-07 22:42
maladuk30-Jan-07 22:42 
AnswerRe: disappearing check boxes -code Pin
prasad_som30-Jan-07 23:07
prasad_som30-Jan-07 23:07 
GeneralRe: disappearing check boxes -code Pin
maladuk30-Jan-07 23:13
maladuk30-Jan-07 23:13 
AnswerRe: disappearing check boxes -code Pin
prasad_som30-Jan-07 23:28
prasad_som30-Jan-07 23:28 
Here it is, It was logical error, For time being I've removed a if case to modify code.

void CColorCheck::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rc;
	CRect rect(13,1,11,11);
	CRect focusRect, btnRect;
	focusRect.CopyRect(&lpDrawItemStruct->rcItem); 
	disabled = RGB(100,100,100);         // dark gray disabled text
	CSize captionSize;

 
	// Retrieve the button's caption
	//
    const int bufSize = 512;
    TCHAR buffer[bufSize];
    GetWindowText(buffer, bufSize);

	//
	// Set the Text Position more to the left
	//
	captionSize = pDC->GetTextExtent(buffer, strlen(buffer));
	btnRect.SetRect(16,1,16 + captionSize.cx + 9,15);

	//
	// Set the focus rectangle to just past the border decoration
	//
	focusRect.SetRect(18,0,16 + captionSize.cx +6, 15);

	//Get control's ID
	int id = GetDlgCtrlID();

	UINT state = lpDrawItemStruct->itemState;
	UINT action = lpDrawItemStruct->itemAction;

	// Don't redraw whole control if only focus has changed  
	if (action == ODA_FOCUS)
		drawFocus = TRUE;
	//Start drawing the check box
	CPen normRect(PS_SOLID, 1,NULL_PEN);
	CPen* m_normRect = pDC->SelectObject(&normRect);

	pDC->SelectStockObject(NULL_BRUSH);

	//draw the caption
	pDC->DrawText(buffer, strlen(buffer), btnRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);	
	DrawCheckCaption(pDC, btnRect, buffer, newTextColor);

		
	//draw the check rectangle
	pDC->FillSolidRect(2,2,11,11,newColor);
	normRect.DeleteObject();

	//draw the borders
	CPen normRect1(PS_SOLID, 1,RGB(80,80,80));
	CPen* m_normRect1 = pDC->SelectObject(&normRect1);

	CPoint startPt = pDC->MoveTo(1,13);

	pDC->LineTo(1,1);
	pDC->LineTo(13,1);
	normRect1.DeleteObject();							//release

	CPen normRect2(PS_SOLID, 1,RGB(100,100,100));
	CPen* m_normRect2 = pDC->SelectObject(&normRect2);

	CPoint startPt1 = pDC->MoveTo(0,14);

	pDC->LineTo(0,0);
	pDC->LineTo(14,0);
	normRect2.DeleteObject();							//release

	CPen normRect3(PS_SOLID, 1,RGB(255,255,255));
	CPen* m_normRect3 = pDC->SelectObject(&normRect3);

	CPoint startPt2 = pDC->MoveTo(14,0);

	pDC->LineTo(14,14);
	pDC->LineTo(0,14);
	normRect3.DeleteObject();							//release

	CPen normRect4(PS_SOLID, 1,RGB(180,180,180));
	CPen* m_normRect4 = pDC->SelectObject(&normRect4);

	CPoint startPt3 = pDC->MoveTo(13,1);

	pDC->LineTo(13,13);
	pDC->LineTo(13,1);
	normRect4.DeleteObject();							//release
	if (checkFlag == 1)
	{
		pDC->FillSolidRect(2,2,11,11,newColor);

		// draw the arrow
		CPen normRect5(PS_SOLID, 1, newArrowColor);//BLACK_PEN);
		CPen* m_normRect5 = pDC->SelectObject(&normRect5);

		CPoint startPt2 = pDC->MoveTo(4,7);

		pDC->LineTo(7,11);
		pDC->LineTo(10,3);

		CPoint startPt3 = pDC->MoveTo(4,8);

		pDC->LineTo(7,9);
		pDC->LineTo(9,4);
		normRect5.DeleteObject();	//release
	}



	//draw "checked" - arrow depending on state

	if (action & ODA_SELECT && checkFlag == 1)

		pDC->FillSolidRect(2,2,11,11,newColor);

	else if (action & ODA_SELECT && checkFlag == 0)
	{

		pDC->FillSolidRect(2,2,11,11,newColor);

		// draw the arrow
		CPen normRect5(PS_SOLID, 1, newArrowColor);//BLACK_PEN);
		CPen* m_normRect5 = pDC->SelectObject(&normRect5);

		CPoint startPt2 = pDC->MoveTo(4,7);

		pDC->LineTo(7,11);
		pDC->LineTo(10,3);

		CPoint startPt3 = pDC->MoveTo(4,8);

		pDC->LineTo(7,9);
		pDC->LineTo(9,4);
		normRect5.DeleteObject();	//release
	}

	if( ( state & ODS_FOCUS ) ^ ( oldState & ODS_FOCUS ) ||( !drawFocus && ( state & ODS_FOCUS ) ) )
			
		DrawFocusRect(lpDrawItemStruct->hDC, (LPRECT)&focusRect);

	else if (state & ODS_DISABLED)
	{
		pDC->FillSolidRect(2,2,11,12,RGB(192,192,192));  //grayed
		DrawCheckCaption(pDC, btnRect, buffer, GetDisabledColor());
	}

	oldState = state;
	oldAction = action;
}



GeneralRe: disappearing check boxes -code Pin
maladuk30-Jan-07 23:39
maladuk30-Jan-07 23:39 
GeneralProblem solved ! Pin
maladuk31-Jan-07 3:57
maladuk31-Jan-07 3:57 
AnswerRe: disappearing check boxes Pin
Hamid_RT30-Jan-07 18:05
Hamid_RT30-Jan-07 18:05 
GeneralRe: disappearing check boxes Pin
maladuk30-Jan-07 23:15
maladuk30-Jan-07 23:15 
QuestionIs it Possible to monitor Actions Taken by a Third Party Software? Pin
Khoramdin30-Jan-07 11:03
Khoramdin30-Jan-07 11:03 
AnswerRe: Is it Possible to monitor Actions Taken by a Third Party Software? Pin
James R. Twine30-Jan-07 11:16
James R. Twine30-Jan-07 11:16 
AnswerRe: Is it Possible to monitor Actions Taken by a Third Party Software? Pin
benjymous30-Jan-07 21:49
benjymous30-Jan-07 21:49 
Questionmulti-thread question, perhaps Pin
goodoljosh198030-Jan-07 7:56
goodoljosh198030-Jan-07 7:56 
AnswerRe: multi-thread question, perhaps Pin
James R. Twine30-Jan-07 8:13
James R. Twine30-Jan-07 8:13 
GeneralRe: multi-thread question, perhaps Pin
goodoljosh198030-Jan-07 8:16
goodoljosh198030-Jan-07 8:16 
GeneralRe: multi-thread question, perhaps Pin
James R. Twine30-Jan-07 8:23
James R. Twine30-Jan-07 8:23 
GeneralRe: multi-thread question, perhaps Pin
goodoljosh198030-Jan-07 8:30
goodoljosh198030-Jan-07 8:30 
GeneralRe: multi-thread question, perhaps Pin
James R. Twine30-Jan-07 8:37
James R. Twine30-Jan-07 8:37 
GeneralRe: multi-thread question, perhaps Pin
goodoljosh198030-Jan-07 8:40
goodoljosh198030-Jan-07 8:40 
GeneralRe: multi-thread question, perhaps Pin
James R. Twine30-Jan-07 11:18
James R. Twine30-Jan-07 11:18 
AnswerRe: multi-thread question, perhaps Pin
goodoljosh19801-Feb-07 0:59
goodoljosh19801-Feb-07 0:59 
QuestionHow to get all the hardware configuration details using VC++? Pin
V.Natarajan30-Jan-07 7:44
V.Natarajan30-Jan-07 7:44 

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.