|
-
September 23rd, 2009, 02:25 AM
#16
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 :-)
-
September 24th, 2009, 04:35 AM
#17
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?...
-
September 24th, 2009, 11:53 AM
#18
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.
-
October 1st, 2009, 10:43 AM
#19
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
-
October 1st, 2009, 12:34 PM
#20
Re: MFC TabControl Pages
CDC* pDC = new CDC();
pDC->Set TextColor(RGB(255,0,0));
it doesn't change the background at all
Doesn't this sound any bells?
Best regards,
Igor
-
October 2nd, 2009, 01:29 AM
#21
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?...
-
October 2nd, 2009, 11:04 AM
#22
Re: MFC TabControl Pages
 Originally Posted by npuleio
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.
-
October 5th, 2009, 10:46 AM
#23
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|