Insert IUIX_PropSheetPage into DlgAppPrefs

PDF-XChange Editor SDK for Developers

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.
Post Reply
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Hi,

I am trying to add my own page of preferences to the existing preferences dialog. Is this possible?

So far I have been able to trap the beginPropDialog event when the dialog opens and get the IUIX_PropSheets interface. I can remove pages but have not been able to successfully insert a page. I tried using this method of creating the object params and then object, and casting it to IUIX_PropSheetPage but get an error that "The parameter is incorrect" when creating the object. See sample code below:

Code: Select all

 
UIX_CreateObjParams cp = new UIX_CreateObjParams();
cp.pParent = ps.Obj;
cp.nStdClass = (int)UIX_StdClasses.UIX_StdClass_PropSheetPage;
//cp.nObjStyle = 0;
//cp.nCreateFlags = (int)UIX_CreateObjFlags.UIX_CreateObj_MakeClientForParent;
cp.pID = "DlgAppPrefs.NewPropSheetPage";
cp.pImpl = pCustomImpl;
cp.rc = pRect;

IUIX_Obj obj;

try
{
	obj = uiInst.CreateObj(ref cp); // results in error "The parameter is incorrect"
}
catch (Exception err)
{
	Debug.WriteLine("Error: " + axPXV_Control1.Inst.GetTextFromHRes(err.HResult));
	throw;
}

IntPtr outPtr;
obj.Parent.QueryImpl(typeof(IUIX_PropSheetPage).GUID, null, out outPtr);
IUIX_PropSheetPage psPage = (IUIX_PropSheetPage)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
Is my understanding of creating a IUIX_PropSheetPage object correct, or is there another way to add a preferences page into the preferences dialog?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by Sasha - Tracker Dev Team »

Hello shaunh,

This is not a trivial task at all. To implement this functionality you must first create a class derived from the IUIX_PropSheetPage and implement it functionality.
Basically the CreateNewUI method does the dialog's object creation part.:

Code: Select all

HRESULT CreateNewUI(IUIX_PropSheets* pHost, IUIX_Obj* pParent, RECT* pPos, IUIX_Obj*& pNewUI)
{
	pNewUI = nullptr;
	UIX_CreateObjParams cp = { 0 };
	cp.nStdClass = UIX_StdClass_Dialog;
	cp.pParent = pParent;
	cp.pImpl = m_pParentDlg; //This is a class that implements the IUIX_Dialog interface by the XML scheme
	cp.nObjStyle = UIX_ObjStyle_Transparent | UIX_ObjStyle_TabStop;
	cp.nCreateFlags = UIX_CreateObj_Hidden;
	cp.pID = L"MyNewDialogID";
	cp.pDlgTemplates = (LPSTR)m_sXML.c_str(); //The XML should hold the dialog control placement like one you can find in the DlgTemplates.xml in the Resources.dat file
	cp.cbDlgTemplates = (LONG)m_sXML.size();
	t_pUIObj obj;
	HRESULT hr = m_uixInst->CreateObj(&cp, &obj);
	if (FAILED(hr))
		return hr;
	pNewUI = obj;
	pNewUI->AddRef();
	return S_OK;
}
Also, the class, that is derived from the IUIX_Dialog should be implemented and it will do all of the logic for your controls that are being defined in the XML.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Thank you for the feedback and code sample Alex. Will give this a go :D
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Insert IUIX_PropSheetPage into DlgAppPrefs

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Hi Alex,

I managed to get my custom dialog page inserted into the preferences dialog using the CreateNewUI method in my derived IUIX_PropSheetPage class. Thank you for your assistance there. I however lose functionality on the preferences dialog. Seems like the normal dialog events aren't being handled so clicking on buttons OK, Apply, Cancel or close dialog do nothing. Am I supposed to implement a custom event handler for the entire preference dialog or did I perhaps implement something incorrectly? Any suggestions would be greatly appreciated.
image.png
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Hi Alex,

Found the issue in my derived IUIX_PropSheetPage class that was preventing my dialog from closing.

public void OnPreEndDialog(IUIX_PropSheets pHost, bool bOK, out bool bBreak)

While testing I had bBreak = true, causing the break before closing the dialog.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by Sasha - Tracker Dev Team »

Hello shaunh,

Glad that you have found a solution by yourself. Wanted to ask you for a sample for investigation but yeah, you can change that behavior with that variable.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Hi Alex,

Do you have an example to add a custom settings section to pxvInst.Settings? I can retrieve settings but can't get my own section added to save my custom preferences. I tried using pxvInst.Settings.Add() but always get an error that the parameter is incorrect, whether passing a parameter or no parameter. Any guidance would be greatly appreciated.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by Sasha - Tracker Dev Team »

Hello shaunh,

While you cannot modify the Settings dictionary itself, you can modify the PluginsData sub-dictionary, as it's created for such cases. The only rule is to provide your own unique GUID first:

Code: Select all

       {GUID}
              MyCustomVal1 : int
              MyCustomVal2 : bool
The ICabNode::Insert should be used for the dictionary types and the ICabNode::Add should be used if your node is an array and you want to add elements to it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Hi Alex,

I have another question I hope you can assist with. In my derived IUIX_Dialog class I am trying to get the state of one of my checkboxes in the GetItemCheckState method. I can get the IUIX_Obj for the checkbox but not sure how to proceed from there. There is no checkbox object to cast it to that I can see. Can you point me in the right direction please?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by Sasha - Tracker Dev Team »

Hello shaunh,

The https://sdkhelp.pdf-xchange.com/vi ... CheckState method takes the ID of the control (in your case the checkbox - that is an IUIX_Label by the way) that you have assigned it when creating.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Insert IUIX_PropSheetPage into DlgAppPrefs

Post by shaunh »

Thank you Alex. The IUIX_Label was my missing link.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Insert IUIX_PropSheetPage into DlgAppPrefs

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply