How to gain access to IUIX_COMBO interface

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
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

How to gain access to IUIX_COMBO interface

Post by dkeith2 »

I'm working out code for reading from and writing to form fields in a PDF. I've been able to access/read/write several types of fields, but I can't seem to find an interface that allows me to write to the combo box.

Using the GetOpt function of the IPXC_FormField interface has enabled me to read entries in the drop down list of values. However I can't seem to set the text value of the combo box. I've tried to select an item from the list, I've tried using the SetValueText function, I've tried accessing the Edit property of the IUIX_Combo after typecasting the IPXC_FormField as an IUIX_Combo, but it's always nil.

Below is the code I've used so far, that works with other types of fields:

Code: Select all

var
  i: Integer;
  b: WordBool;
  PFormField: IPXC_FormField;
  iCombo: IUIX_Combo;
  iEdit: IUIX_Edit;
  s,s2: WideString;
begin
  // Set field values
  for i := 0 to Pred(FPDFEdit.Doc.CoreDoc.AcroForm.FieldsCount) do
  begin
    PFormField := FPDFEdit.Doc.CoreDoc.AcroForm.Field[i];
    case PFormField.type_ of
      FFT_RadioButton: PFormField.CheckWidget(1,True);
      FFT_CheckBox: PFormField.CheckWidget(0,True);
      FFT_ComboBox: begin
                      iCombo := IUIX_Combo(PFormField); // this has an instance pointer but a nil Edit interface (IUIX_OBJECT)
                      iCombo.Edit.QueryInterface(IID_IUIX_Edit,iEdit); // this doesn't work
                      PFormField.GetOpt(1,s,s2,b); // := 'MyOhMy'; // this works
                      iEdit.SetText(PChar(s),Length(s)); // iEdit is null
//                      PFormField.SetValueText(s); // this doesn't work
Please explain how to set the text value of the combo box; how to select a value from the list and have that populate the text box etc.

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to gain access to IUIX_COMBO interface

Post by Sasha - Tracker Dev Team »

Hello dkeith2,

You've misunderstood what the IUIX level is. It controls all of the Editors' commands, dialogs etc (for example zoom level combo box).
In your case, you were in the right direction, though to properly modify the fields' values on the Editor's level, the op.fields.modify should be used (I've included a sample for you there):
https://sdkhelp.pdf-xchange.com/vie ... lds_modify

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

Re: How to gain access to IUIX_COMBO interface

Post by dkeith2 »

Hi Alex!

I must apologize for not giving a clear explanation. Let me try again.

I want to set the value of a text box that happens to be part of a combobox.

In Delphi, here's the code you have to write:

Code: Select all

// fills the text box portion of the combo box with a value
ComboBox1.Text := 'Hello World'; 
or to set the value by making a choice from the list of values:

Code: Select all

// fills the text box portion of the combo box with a value from the drop down list of values
ComboBox1.ItemIndex := 1;
As illustrated in the code previously provided, I am able to set field values by doing one of the following:

Code: Select all

// Set a radio button to selected or a check box to checked
PFormField.CheckWidget(1,True);
or

Code: Select all

// Set a text edit field value
PFormField.SetValueText('Hello World');
Please provide an example as to how to accomplish this with a combo box that is on a PDF Form.

Thanks!
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to gain access to IUIX_COMBO interface

Post by Sasha - Tracker Dev Team »

Hello dkeith2,

Please follow the link provided - there is a sample included that selects one of the items in the combo box. Also check out the operation's options - there is an option to set the value directly.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

Re: How to gain access to IUIX_COMBO interface

Post by dkeith2 »

Wow... Is it possible to put in a change request or feature addition request that these two operations:

Set text value of combo box
Set text value of combo box by selecting a value from the drop down list

Be performed using only one line of code?

Thanks.
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

Re: How to gain access to IUIX_COMBO interface

Post by dkeith2 »

Also, how do I read the current text value of a combo box?
Thanks.
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

Re: How to gain access to IUIX_COMBO interface

Post by dkeith2 »

In the generated interface file (PDFXEdit_TLB.pas) I do not find the list of available options such as:
'op.fields.modify'
'Input'
'Options'
'Value'
'Selection'
'Mask'

...could you please provide documentation for the available.... params? Options? Masks?

Since this is not documented in the interface, from the example provided could you please provide the alternate lines of code for setting the text value of the combo box using a string?
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

Re: How to gain access to IUIX_COMBO interface

Post by dkeith2 »

Okay, found documentation for the verbs, so I'm good there. Also figured out how to write to combo box control directly with text.

I'm already reading text values from the combo box, so I'm good there too.

Is there a method/interface/property that provides access to the display text for a radio button or a check box?

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to gain access to IUIX_COMBO interface

Post by Sasha - Tracker Dev Team »

Hello dkeith2,

Glad that you have found a solution. You can always try searching the forums - there are plenty of solved problems and samples here.
As for your last question - there is no display text of the checkbox or the radio button - it's only a label near it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
dkeith2
User
Posts: 46
Joined: Mon Aug 14, 2017 8:28 pm

Re: How to gain access to IUIX_COMBO interface

Post by dkeith2 »

That's what I surmised. Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to gain access to IUIX_COMBO interface

Post by Sasha - Tracker Dev Team »

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