TsPageControl refuses to turn a page

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #37733
    HeDiBo
    Participant

    In my program I rely heavily on TsPageControl. It is the fundament. The main screen is already a TsPageControl and every page contains a frame which in turn will contain a TsPageControl.

    I have this strange phenomenon that many times the TsPageControl will refuse to turn to the page that the user selects (he has to click the Tab twice).

    The OnChanging event occurs, the AllowChange is set to True, but after that the OnChange event does not occur.

    I know that you want a demo project, but I do not think I can reproduce this behavior in a simple project.

    Can you point me at key points in TsPageCount, that should be executed after OnChanging returns? So, I can try to pinpoint where the bug is? Or do you already have an idea? I'm stil on AC 12.22. The modified sPageControl that you sent me for the color of the tabs does not cure this problem.

    I can reproduce this also if sSkinManager.Active is false. But it takes more tries than.

    #57586
    Support
    Keymaster

    Hello

    You trying to change active page by mouse or keyboard in this case?

    Or by code like “ActivePage := …” ?

    #57593
    HeDiBo
    Participant
    'Support' wrote:

    Hello

    You trying to change active page by mouse or keyboard in this case?

    Or by code like “ActivePage := …” ?

    As I Said: “he has to click the Tab twice” that's with the mouse of course.

    #57596
    HeDiBo
    Participant

    I've made a message trace (with Application.OnMessage) which comes up with some strange messages if the page refuses to turn:

    [attachment=8643:PageChangeBug.pdf]

    The trace is made with CodeSite. I have eliminated the WM_MOUSEMOVE, WM_NCMOUSEMOVE, WM_MOUSELEAVE and WM_TIMER messages.

    Whenever the OnChanging event occurs, the message “Start Tracing” is logged, followed by the message “**** OnChanging ****”.

    Whenever the OnChange event occurs, the message “*** OnChange event ***” is logged followed by the message “”**** Trace Stopped *****”.

    As you can see, in the first two case, the OnChange event does not occur. But we have the strange messages 1848 and 96. And these messages do not occur if the page is correctly changed!

    I don't know what these messages are. Do you recognize them?

    #57597
    HeDiBo
    Participant

    I found the cause of this problem.

    I change the appearance of the page upon the OnPageChanging event. That apparently is a no-no. Changing the page layout or anything like that is to be postponed until the OnChange event. By implementing it this way, the problem was solved.

    However, as the docs state: “The event (OnChange) is not called if you change the active page in code, for example, by setting the value of ActivePage”. So that's a catch-22 then. The only way to solve this is to call the OnChange event in code when the ActivePage is changed in code. What a stupid implementation of Delphi.

    #57598
    Support
    Keymaster

    Hello! Thank you for information.

    #57601
    HeDiBo
    Participant
    'Support' wrote:

    Hello! Thank you for information.

    Hi Serge,

    I do not know very well, why OnChange and OnChanging need a third event OnPageChanging.

    What does this event bring that the others cannot? Please, explain.

    #57603
    Support
    Keymaster

    Hello!

    OnChanging is a standard event which occurs before switching of pages and allows to cancel this switching.

    The OnPageChanging event has been added in the package with additional “NewPage” parameter. So, developer can check a new tab and decide – cancel changing to this page or allow it.

    #57611
    HeDiBo
    Participant
    'Support' wrote:

    Hello!

    OnChanging is a standard event which occurs before switching of pages and allows to cancel this switching.

    The OnPageChanging event has been added in the package with additional “NewPage” parameter. So, developer can check a new tab and decide – cancel changing to this page or allow it.

    I see, thank you Serge.

    OnPageChange is a very nice addition to the pagecontrol.

    So now there are two possible ways to prevent a tab from being changed:

    • If you do not want a user to leave the current page, use OnChanging (for instance if the user has to complete some info on the current page).
    • If you do not want a user to go to a certain page, use OnPageChanging (for instance if the attempted new page depends on info that's not completed yet).

    A third observation I made in this exercise: if you want the appearance of a page to be adjusted when changing page to it, use the OnChange event. The OnChanging and OnPageChanging events come to early for that and may result in unwanted side effects.

    Thanks bravo.gif

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.