- This topic has 8 replies, 2 voices, and was last updated 7 years, 1 month ago by
HeDiBo.
-
AuthorPosts
-
February 20, 2018 at 8:24 am #57586
Support
KeymasterHello
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 #57593HeDiBo
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.
February 24, 2018 at 11:34 am #57596HeDiBo
ParticipantI'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 #57597HeDiBo
ParticipantI 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 #57598Support
KeymasterHello! Thank you for information.
February 26, 2018 at 4:24 pm #57601HeDiBo
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.
February 27, 2018 at 8:29 am #57603Support
KeymasterHello!
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 #57611HeDiBo
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
-
AuthorPosts
- You must be logged in to reply to this topic.