Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems with a check box

Problems with a check box

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MaTrIX2k2
    wrote on last edited by
    #1

    I've made my own check box and put it into my dialog, everything is fine, but when i call the DDX_Check, this return no value, i've used a BOOL option to set as true or false, when is checked or unchecked, but nothing happens, nothing is registered, my check box is a CButton derived class, what's wrong?

    A 1 Reply Last reply
    0
    • M MaTrIX2k2

      I've made my own check box and put it into my dialog, everything is fine, but when i call the DDX_Check, this return no value, i've used a BOOL option to set as true or false, when is checked or unchecked, but nothing happens, nothing is registered, my check box is a CButton derived class, what's wrong?

      A Offline
      A Offline
      Alvaro Mendez
      wrote on last edited by
      #2

      Have you called UpdateData? Maybe show some code so we can help you better. Regards, Alvaro


      There are no stupid questions, but there are a lot of inquisitive idiots. -- despair.com

      M 1 Reply Last reply
      0
      • A Alvaro Mendez

        Have you called UpdateData? Maybe show some code so we can help you better. Regards, Alvaro


        There are no stupid questions, but there are a lot of inquisitive idiots. -- despair.com

        M Offline
        M Offline
        MaTrIX2k2
        wrote on last edited by
        #3

        this is my code: IMPLEMENT_DYNAMIC(CAUICheckBox, CButton) CAUICheckBox::CAUICheckBox() { m_bCheckBtn=FALSE; m_bPressBtn=FALSE; m_bOldTemp=FALSE; m_clrHigh=globalData.clrHilite; m_clrCheck=RGB(0,0,0);//RGB(0,170,170); m_bSelected=FALSE; m_Checked = FALSE; } CAUICheckBox::~CAUICheckBox() { } BEGIN_MESSAGE_MAP(CAUICheckBox, CButton) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_ERASEBKGND() ON_WM_MOUSEMOVE() ON_WM_MOUSEOUT() ON_WM_KEYDOWN() ON_MESSAGE(BM_SETCHECK, OnSetCheck) ON_MESSAGE(BM_GETCHECK, OnGetCheck) END_MESSAGE_MAP() // CAUICheckBox message handlers BOOL CAUICheckBox::OnEraseBkgnd(CDC *pDC) { return TRUE; } LRESULT CAUICheckBox::OnGetCheck(WPARAM wParam, LPARAM lParam) { return m_Checked; } // End of OnGetCheck void CAUICheckBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC); CRect m_rcClient=lpDrawItemStruct->rcItem; UINT m_State=lpDrawItemStruct->itemState; CBrush cb; CRect m_rcTemp=m_rcClient; CPoint pt; CSize m_Csize; CString m_szCaption; COLORREF m_Over=RGB(255,193,111); CPen cpOver(PS_SOLID,1,RGB(255,193,111)); int iMode=pDC->SetBkMode(TRANSPARENT); int iExtile=GetButtonStyle(); //obtenemos orientación del texto CRect m_rcText=m_rcClient; GetWindowText(m_szCaption); if(m_szCaption.GetLength() > 1) m_Csize= pDC->GetTextExtent(m_szCaption); //de acuerdo a la alineación del texto prepare la ubicación //del texto para Drawtex y DrawState if (m_rcClient.Height() > 13) { int Dif=m_rcClient.Height()-13; Dif/=2; m_rcTemp.top=Dif; m_rcTemp.bottom=m_rcTemp.top+13; } if (iExtile & BS_LEFTTEXT) { m_rcTemp.left= m_rcTemp.right-13; pt=CPoint(m_rcTemp.left,m_rcTemp.top+1); } else { m_rcTemp.right= m_rcTemp.left+13; pt=CPoint(m_rcTemp.right+2,m_rcTemp.top+1); m_rcText.left=m_rcTemp.right+1; } //draw frame of checkbox pDC->FillSolidRect(m_rcTemp,globalData.clrWindow); pDC->Draw3dRect(m_rcTemp,globalData.clrBtnDkShadow,globalData.clrBtnHilite);//clrBtnLight); m_rcTemp.DeflateRect(1,1); pDC->Draw3dRect(m_rcTemp,globalData.clrBtnShadow,globalData.clrBtnFace); //DrawOrange(pDC,m_rcTemp); m_rcTemp.DeflateRect(1,1); if (lpDrawItemStruct->itemState & ODS_DISABLED) pDC->DrawState(pt, m_Csize, m_szCaption, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL); else { pDC->DrawText(m_szCaption,m_rcText,DT_SINGLELINE|DT_LEFT|DT_VCENTER); if(lpDrawItemStruct->itemState & ODS_SELECTED||m_Checked) {

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups