- This topic has 8 replies, 2 voices, and was last updated 6 years, 8 months ago by HeDiBo.
-
AuthorPosts
-
February 15, 2018 at 11:12 am #37733HeDiBoParticipant
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.
February 20, 2018 at 8:24 am #57586SupportKeymasterHello
You trying to change active page by mouse or keyboard in this case?
Or by code like “ActivePage := …” ?
February 20, 2018 at 3:45 pm #57593HeDiBoParticipant'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.
February 24, 2018 at 11:34 am #57596HeDiBoParticipantI'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?
February 24, 2018 at 4:24 pm #57597HeDiBoParticipantI 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.
February 25, 2018 at 8:12 am #57598SupportKeymasterHello! Thank you for information.
February 26, 2018 at 4:24 pm #57601HeDiBoParticipant'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.
February 27, 2018 at 8:29 am #57603SupportKeymasterHello!
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.
February 27, 2018 at 10:37 am #57611HeDiBoParticipant'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
-
AuthorPosts
- You must be logged in to reply to this topic.