Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created three property pages on propertysheet,and intializing a bool Value on the parent class of the propertysheet .Now, When accessing that Bool value under InitDialog()Second property page it always return TRUE and while comparing that value in the if statement ,Condition returns false. But if the same procedure, when repeated on third property page Everything works fine.
C#
//My code
//CPage is Parent of propertysheet
// BtnState is Bool value initialized on CPage of Propertysheet
BOOL CGs::OnInitDialog()
{
  CPropertyPage::OnInitDialog();
  CPage * m_pg = ((CPage*)((CGSPropertySheet*)GetParent())->GetParent());
  if(m_pg->BtnState == true)
  {
    m_set.EnableWindow(false);
  }
Posted
Updated 2-Sep-11 1:48am
v2

what type is BtnState? If it's not a bool, and it's not set to null (or zero), it will evaluate to true.

EDIT ======================

0) Are you sure m_pg isn't null?

1) Try it this way:

C++
CPage* m_pg = ((CPage*)((CGSPropertySheet*)GetParent())->GetParent());
if (m_pg)
{
    m_set.EnableWindow(!m_pg->BtnState);
}
 
Share this answer
 
v3
Comments
Albert Holguin 2-Sep-11 11:57am    
looks like the OP is getting the reverse situation, getting false... +5 anyway, I actually thought of this initially too... OP posted a follow up below as a solution.
Hey John Simmons Thanks for the reply:
As I Have already written above that BtnState is BOOL variable which is being initialized in Parent page of propertysheet

My question is even when the BtnState is having value true and while comparing it in the if statement(As Below) the condition comes out to be FALSE ? WHY WHY WHY
if(m_pg->BtnState == true)
{
m_set.EnableWindow(false);
}
 
Share this answer
 
Comments
André Kraak 2-Sep-11 8:32am    
If you have a question about or comment on the given solution use the "Have a Question or Comment?" option beneath the solution. When using this option the person who gave the solution gets an e-mail message and knows you placed a comment and can respond if he/she wants.

Please move the content of this solution to the solution you are commenting on and remove the solution. Thank you.
Albert Holguin 2-Sep-11 11:58am    
Did you confirm with the debugger that BtnState has the value you expect?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900