Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed SOLVED
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Hi,
[Q1] It seems the pxv_control cannot pick up the e.mainFrame.beforeClose event through EnableEventListening ?
Also, since one can EnableEventListening only when the Control is already created - obviously e.mainFrame.initialized does not get caught when having one Control instance (for the MainFrame hosted by the Control).
[Q2] Is it ok to assume that e.mainFrame.initialized happens only once per MainFrame (it seems so, but I'll better double check)?
When having multiple Control instances e.mainFrame.initialized fires ok (for the second, third, and so on), the OnEvent's pFrom parametar is IPXV_MainFrame.
[Q3] Why is EnableEventListening a method of pxv_Control and not IPXV_Inst - when after all if you have multiple Controls / MainFrames all will respond to an event that happened in only one Control/MainFrame - so events are not tied to a Control/MainFrame but rather to the IPXV_Inst.
[Q1.1]An extension to the 1st question: it seems e.mainFrame.beforeClose does fire but only for those MainFrame's that are auto-created when one drag-drops a document tab out of the IPXV_DocumentViewsArea. Correct?
-žarko
[Q1] It seems the pxv_control cannot pick up the e.mainFrame.beforeClose event through EnableEventListening ?
Also, since one can EnableEventListening only when the Control is already created - obviously e.mainFrame.initialized does not get caught when having one Control instance (for the MainFrame hosted by the Control).
[Q2] Is it ok to assume that e.mainFrame.initialized happens only once per MainFrame (it seems so, but I'll better double check)?
When having multiple Control instances e.mainFrame.initialized fires ok (for the second, third, and so on), the OnEvent's pFrom parametar is IPXV_MainFrame.
[Q3] Why is EnableEventListening a method of pxv_Control and not IPXV_Inst - when after all if you have multiple Controls / MainFrames all will respond to an event that happened in only one Control/MainFrame - so events are not tied to a Control/MainFrame but rather to the IPXV_Inst.
[Q1.1]An extension to the 1st question: it seems e.mainFrame.beforeClose does fire but only for those MainFrame's that are auto-created when one drag-drops a document tab out of the IPXV_DocumentViewsArea. Correct?
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Hello žarko,
As for you 3 questions - as I said before, the IPXV_Control is a helper class - thus it has the EnableEventListening event that eases up the usage of the event handlers.
If you want to listen to the events that are being fired before the control creation or after it's destruction, you can do this after the Inst has been initialized:
But you will have to implement the Event handler class by implementing the IEventHandler interface (OnEvent method is the only one there - so not a big problem) and pass it as a second parameter.
As for the last question - the id_e_mainFrame_beforeClose is being fired on both occasions - when you dragged the frame out and closed it or closed your form itself.
PS: I think that you already know this, but pFrom is IPXV_MainFrame in both of these events.
Cheers,
Alex
As for you 3 questions - as I said before, the IPXV_Control is a helper class - thus it has the EnableEventListening event that eases up the usage of the event handlers.
If you want to listen to the events that are being fired before the control creation or after it's destruction, you can do this after the Inst has been initialized:
Code: Select all
Inst.EventServer.RegisterNativeEventHandler(id_e_mainFrame_initialized, myHandler, EventHandler_SyncCall);
As for the last question - the id_e_mainFrame_beforeClose is being fired on both occasions - when you dragged the frame out and closed it or closed your form itself.
PS: I think that you already know this, but pFrom is IPXV_MainFrame in both of these events.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Alex,
Thanks for Event register.
Btw,
I have a sample app, handling all three events:
Have an axPXV_Control1 on a form, run the above - none of the message boxes will show - expected behavior for "initialized" but not for beforeClose/closed.
Only if you have multiple documents loaded and tab-out one to a new frame - all 3 events will be recorded for that "floating" frame.
If you instantiate a new pxv_control: initialized and closed are reported but not beforeclose.
-žarko
Thanks for Event register.
Btw,
I think not.As for the last question - the id_e_mainFrame_beforeClose is being fired on both occasions - when you dragged the frame out and closed it or closed your form itself.
I have a sample app, handling all three events:
Code: Select all
private void MainForm_Shown(object sender, EventArgs e)
{
axPXV_Control1.Inst.Settings["Docs.SingleWnd"].v = false;
axPXV_Control1.Inst.FireAppPrefsChanged(PDFXEdit.PXV_AppPrefsChanges.PXV_AppPrefsChange_Documents);
axPXV_Control1.EnableEventListening("e.mainFrame.beforeClose");
axPXV_Control1.EnableEventListening("e.mainFrame.closed");
axPXV_Control1.EnableEventListening("e.mainFrame.initialized");
}
private void axPXV_Control1_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
if (e.nEventID == axPXV_Control1.Inst.Str2ID("e.mainFrame.initialized"))
{
MessageBox.Show("e.mainFrame.initialized");
}
if (e.nEventID == axPXV_Control1.Inst.Str2ID("e.mainFrame.beforeClose"))
{
MessageBox.Show("e.mainFrame.beforeClose");
}
if (e.nEventID == axPXV_Control1.Inst.Str2ID("e.mainFrame.closed"))
{
MessageBox.Show("e.mainFrame.closed");
}
}
Only if you have multiple documents loaded and tab-out one to a new frame - all 3 events will be recorded for that "floating" frame.
If you instantiate a new pxv_control: initialized and closed are reported but not beforeclose.
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Hello žarko,
I've looked at our inner code - you should be able to catch the events I described when registering via Inst, not control.
Cheers,
Alex
I've looked at our inner code - you should be able to catch the events I described when registering via Inst, not control.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Hi Alex,
Great, works!
-ž
Great, works!
-ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Hi Alex,
Unfortunately the "e.mainFrame.beforeClose" when done via Inst.EventServer.RegisterNativeEventHandler, still does not work/fire, for "true" MainFrames (it does work only for auto-tab-out-floating ones).
I can live with that - but just for info - can you double check (make a test)?
-žarko
Unfortunately the "e.mainFrame.beforeClose" when done via Inst.EventServer.RegisterNativeEventHandler, still does not work/fire, for "true" MainFrames (it does work only for auto-tab-out-floating ones).
I can live with that - but just for info - can you double check (make a test)?
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed SOLVED
Hello žarko,
The id_e_mainFrame_beforeClose event is being fired when the frame is closing in the End-User Editor - thus it will be fired in the SDK also.
Cheers,
Alex
The id_e_mainFrame_beforeClose event is being fired when the frame is closing in the End-User Editor - thus it will be fired in the SDK also.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
ok, as I said I can live with e.mainFrame.closed - so no need (at the moment) to investigate further...
-žarko
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Events e.mainFrame.beforeClose and e.mainFrame.initialized/closed
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ