CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Join Date
    Aug 2009
    Posts
    84

    Re: MFC TabControl Pages

    Oh well... I abandoned the idea of child container for controls and I implemented MoveWindow for each control from a reference control calculating moving space difference then I used before and after LockWindowUpdate() and UnlockWindowUpdate() and it works.... :-) Thanks :-)

  2. #17
    Join Date
    Aug 2009
    Posts
    84

    Re: MFC TabControl Pages

    Hello again....

    I'm trying to communicate between two CPropertyPage's pages...I tried to include the .h of the other page then doing this:

    (CButton*) checkbasic = (CButton*)GetDlgItem(IDD_CONFIG_BASIC::IDC_CHECK_BASIC); <--- it's a checkbox
    if (checkbasic->GetCheck() == BST_CHECKED)
    CConfig_Basic::ActivateBasicControls(FALSE);

    but seems it doesn't work since returns an illegal token on right side of '::' when calling GetDlgItem...and plus, looks like I can't call ActivateBasicControls method because if I declare methods as static I can't call the controls inside the function like GetDlgItem(IDC_CHK_PSE)...

    Any suggest?...

  3. #18
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MFC TabControl Pages

    There's really a quite simple approach in dealing passing data between property pages.

    Most folks take the wrong approach and try to read data in the controls of one page, from another page. This is usually problematic, introduces complexity, and tight coupling between the pages. It's often a mess.

    The simple approach is to copy the MFC doc/view architecture and treat the property sheet as the document and read/write the data to the propertysheet (i.e document).

    By creating control variables (rather than using the old fashioned GetDlgItem method), you can leverage the DDX data xfer mechanism of MFC to read and write data to the 'document' variables contained in the property sheet as such:

    Code:
    void CPropPage1::DoDataExchange( CDataExchange* pDX )
    {
      ASSERT( NULL != m_pPropSheet );
      CPropertyPage::DoDataExchange( pDX );
    
      DDX_Text(pDX, IDC_NAME_FIRST, m_pPropSheet->GetNameFirst( ) );
      DDX_Text(pDX, IDC_NAME_LAST, m_pPropSheet->GetNameLast( ) );
    }
    In the code above, the m_pPropSheet pointer is passed into each sheet, variable accessor methods are created around the data and the DDX entries read and write the data to the accessor method.

    If another page needs some data from a different page, it simple calls the appropriate accessor method in the propertysheet.

    Here's the code. See the PropPageDocument.zip attachment in my reply about 2/3 of the way down the page.

  4. #19
    Join Date
    Aug 2009
    Posts
    84

    Re: MFC TabControl Pages

    Hello again...

    I've read about drawing stuffs on the device context so when I have to draw something on a control inside a CPropertyPage then I have to use OnCtlColor. BUT when I want to draw something, or to change background color of the canvas of CPropertyPage itself, how I can do?... If I call:


    CDC* pDC = new CDC();
    pDC->SetTextColor(RGB(255,0,0));

    it doesn't change the background at all....ah I put this code inside BN_CLICKED event of a checkbox I put in this canvas...
    Any suggest?...

    Thanks!!
    Luigi

  5. #20
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: MFC TabControl Pages

    CDC* pDC = new CDC();
    pDC->SetTextColor(RGB(255,0,0));

    it doesn't change the background at all
    Doesn't this sound any bells?
    Best regards,
    Igor

  6. #21
    Join Date
    Aug 2009
    Posts
    84

    Re: MFC TabControl Pages

    Yea in fact I wanted to say SetBkColor... just it doesn't color anything when I click on a checkbox I have on the canvas...
    I tried with CClientDC too but same result... putting also Invalidate(); before and UpdateWindow(); after....

    Any suggest?...

  7. #22
    Join Date
    Feb 2005
    Posts
    2,160

    Re: MFC TabControl Pages

    Quote Originally Posted by npuleio View Post
    Hello again...

    I've read about drawing stuffs on the device context so when I have to draw something on a control inside a CPropertyPage then I have to use OnCtlColor. BUT when I want to draw something, or to change background color of the canvas of CPropertyPage itself, how I can do?... If I call:


    CDC* pDC = new CDC();
    pDC->SetTextColor(RGB(255,0,0));

    it doesn't change the background at all....ah I put this code inside BN_CLICKED event of a checkbox I put in this canvas...
    Any suggest?...

    Thanks!!
    Luigi
    You need to do any custom painting in a paint handler (WM_PAINT). Set a flag in your BN_CLICKED event and call Invalidate() or InvalidateRect(), then in your paint routine, check for the flag, and if set, paint your color, else paint it normally.

  8. #23
    Join Date
    Aug 2009
    Posts
    84

    Re: MFC TabControl Pages

    In fact you both of you, hoxsiew and Vartanov,are right: first I had to write SetBkColor...plus now I am trying do it in a MFC ActiveX Control so I can use that in different applications or windows...
    but when I compile the component, even if I put a static Text Control and a Slider Control, when I put the component compiled in a MFC application test, it shows only a white rectangle when it should show those two controls and plus the MFC ActiveX Control has Style's property set as Child.... I thought it was maybe the absence of AfxEnableControlContainer(); but looks like it isn't that... maybe a certain project setting that I have missed?....

    Thanks
    Luigi

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured