CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    [RESOLVED] Set Flag in PropertyPage

    Hi,
    I have 3 pages. I like to set a flag = TRUE when i'm in page3 and set flag = FALSE when i'm in page1 & Page2.

    I tried like below,
    I set the flag = FALSE in OnInitDialog & OnTimer of Page1 & Page2.
    and also set the flag = TRUE in OnInitDialog & OnTimer of Page3.

    When i cross Page3 the the flag value changing both true/false when i'm in Page1.
    How is possible?
    Regards,

    SaraswathiSrinath

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Set Flag in PropertyPage

    In what class did you want to set such a flag?
    In what class(es) did you set it?
    How did you check it?
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: Set Flag in PropertyPage

    Quote Originally Posted by VictorN View Post
    In what class did you want to set such a flag?
    In what class(es) did you set it?
    How did you check it?
    Kindly find the attachment, and notice the lamp and messagebox in Page 3.
    Attached Files Attached Files
    Regards,

    SaraswathiSrinath

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Set Flag in PropertyPage

    Quote Originally Posted by saraswathisrinath View Post
    Kindly find the attachment, and notice the lamp and messagebox in Page 3.
    I looked at your "Page 3" (Page3.cpp, Page3.h, and even NewWizPage.h).
    Neither of these files contains declaration of the "flag".

    BTW, what is "the lamp" in this context?
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: Set Flag in PropertyPage

    Quote Originally Posted by VictorN View Post
    I looked at your "Page 3" (Page3.cpp, Page3.h, and even NewWizPage.h).
    Neither of these files contains declaration of the "flag".
    extern bool flag; - declared in Wiz.h.

    Quote Originally Posted by VictorN View Post
    BTW, what is "the lamp" in this context?
    run the application, if the flag = true, the left side bitmap indication sets green color and false sets to red color. That is i mean it by lamp.
    Regards,

    SaraswathiSrinath

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Set Flag in PropertyPage

    Quote Originally Posted by saraswathisrinath View Post
    extern bool flag; - declared in Wiz.h.
    And where and how do you initialize it?

    Quote Originally Posted by saraswathisrinath View Post
    run the application...
    I'm not going to run it until I understand your "logic" there.
    Victor Nijegorodov

  7. #7
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: Set Flag in PropertyPage

    Quote Originally Posted by VictorN View Post
    And where and how do you initialize it?
    I'm not going to run it until I understand your "logic" there.
    I like to use the bool variable "flag" in all pages (page 1, page 2, ... page5).
    Its declared as a extern variable and initialize false from wiz.cpp & wiz.h.
    wiz.h
    Code:
    extern bool flag;
    wiz.cpp
    Code:
    bool flag = false;
    Now, i like to change the flag value to true from page3 and flase from page1, page2, page4 & page5.
    so i used the OnTimer methord to set the flag = true/false from pages.
    But Ontimer's of Page3 set to flag = true. but the data was changing both true and false. how is possible?
    Regards,

    SaraswathiSrinath

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: Set Flag in PropertyPage

    but the data was changing both true and false. how is possible
    and what debugging of the code has been done? Where and under what circumstances does the debugger indicate that the value is changed?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Set Flag in PropertyPage

    Quote Originally Posted by saraswathisrinath View Post
    But Ontimer's of Page3 set to flag = true. but the data was changing both true and false. how is possible?
    Just because of your poor design!
    Every page that was activated has its own OnTimer that sets flag to either true for page5 or to false for the others.
    All these "processes" run simultaneously so the flag changes quasi-randomly from true to false and back.
    Try to stop the timer before leaving the page and restart it after entering (override CPropatyPage::OnKillActive, CPropatyPage::OnSetActive methods)
    Victor Nijegorodov

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Set Flag in PropertyPage

    Quote Originally Posted by 2kaud View Post
    and what debugging of the code has been done? Where and under what circumstances does the debugger indicate that the value is changed?
    Exactly. Use the debugger to let you know whenever the flag value changes then use the call stack to see you how got there.

  11. #11
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: Set Flag in PropertyPage

    Quote Originally Posted by 2kaud View Post
    and what debugging of the code has been done? Where and under what circumstances does the debugger indicate that the value is changed?
    I can not find where the value was changed. but when i was run the application, the flag = false in page1 and 2, so the left side bitmap indication sets red color and page3 sets only green color but the result is both red and green indications. This indicates that the value is changed.

    Code:
    void CMasterDlg::OnTimer(UINT_PTR nIDEvent)
    {
    	// TODO: Add your message handler code here and/or call default
    	if(flag) m_flagstatus.SetBitmap( hGOnBitmap);
    	else  m_flagstatus.SetBitmap( hGOffBitmap);
    	CNewWizDialog::OnTimer(nIDEvent);
    }
    Regards,

    SaraswathiSrinath

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Set Flag in PropertyPage

    Quote Originally Posted by saraswathisrinath View Post
    I can not find where the value was changed. but when i was run the application, the flag = false in page1 and 2, so the left side bitmap indication sets red color and page3 sets only green color but the result is both red and green indications. This indicates that the value is changed.
    Insert TRACE macro to indicate the place and the value in all places where you set this flag. Then start debugging and look at the "output" window...
    Don't forget to remove (or, at least comment out) all the afxmessagebox call, since they only disturb debugging.
    Victor Nijegorodov

  13. #13
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: Set Flag in PropertyPage

    Quote Originally Posted by VictorN View Post
    Insert TRACE macro to indicate the place and the value in all places where you set this flag. Then start debugging and look at the "output" window...
    Don't forget to remove (or, at least comment out) all the afxmessagebox call, since they only disturb debugging.
    only used break points and watch window to debug my code. don't know, how to use other debugging tools. Today only i used the trace. Its helps me to view the real changes. Thanks and also i will study the documents about how to use the call stack method.

    Quote Originally Posted by VictorN View Post
    Just because of your poor design!
    Every page that was activated has its own OnTimer that sets flag to either true for page5 or to false for the others.Try to stop the timer before leaving the page and restart it after entering (override CPropatyPage::OnKillActive, CPropatyPage::OnSetActive methods)
    Yes. Your Correct. I used ON_WM_SHOWWINDOW() method to kill the timer when leave the page and start the timer when enter the page. Its working. Thank you so much.
    Last edited by saraswathisrinath; March 13th, 2015 at 11:56 PM.
    Regards,

    SaraswathiSrinath

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