Skip to content

Instantly share code, notes, and snippets.

@Polaringu
Created June 13, 2018 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Polaringu/50579899d2fa228948076ecbc902bb36 to your computer and use it in GitHub Desktop.
Save Polaringu/50579899d2fa228948076ecbc902bb36 to your computer and use it in GitHub Desktop.
class CustomComboCommandHandler : IUIX_CmdHandler
{
public IPXV_Inst m_Inst = null;
public IUIX_Inst m_uiInst = null;
public CustomComboCommandHandler(IPXV_Inst Inst)
{
m_Inst = Inst;
m_uiInst = (IUIX_Inst)Inst.GetExtension("UIX");
}
public void OnCreateNewCtl(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdBar pParent, out PDFXEdit.IUIX_Obj pCtl)
{
//Here the combo box is created and initialized
tagRECT rc;
rc.left = 0;
rc.right = 0;
rc.top = 0;
rc.bottom = 0;
IUIX_Combo cmb = m_uiInst.CreateCombo(pParent.Obj, ref rc, m_Inst.ID2Str(pCmd.ID), (long)UIX_ComboStyleFlags.UIX_ComboStyle_Editable, null);
cmb.InsertItem(-1, "A");
cmb.InsertItem(-1, "B");
cmb.InsertItem(-1, "C");
pCtl = cmb.Obj;
}
public void OnGetCtlSizes(PDFXEdit.IUIX_CmdItem pItem, ref PDFXEdit.tagSIZE nSize, ref PDFXEdit.tagSIZE nMinSize, ref PDFXEdit.tagSIZE nMaxSize)
{
nSize.cx = 100;
nSize.cy = pItem.Bar.Font.LineHeight + 4;
nMaxSize.cy = nSize.cy;
}
public void OnGetItemState(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, out int nState)
{
nState = (int)PDFXEdit.UIX_CmdItemState.UIX_CmdItemState_Normal;
}
public void OnGetItemSubMenu(PDFXEdit.IUIX_CmdItem pItem, out PDFXEdit.IUIX_CmdMenu pSubMenu)
{
pSubMenu = null;
}
public void OnNotify(int nCode, PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, uint nNotifyData)
{
if (nCode == (int)UIX_NotifyCodes.UIX_Notify_SelChanged)
{
//Check for selection change and act accordingly
}
}
public void OnDrawItemIcon(PDFXEdit.IUIX_RenderContext pRC, PDFXEdit.IUIX_CmdItem pItem, ref PDFXEdit.tagRECT stIconRect, ref PDFXEdit.tagRECT stClip)
{
}
}
private void addComboBoxTypeCommandToolStripMenuItem_Click(object sender, EventArgs e)
{
pdfCtl.Inst.LockCmdCustomizationEvent();
IUIX_Inst uiInst = (IUIX_Inst)pdfCtl.Inst.GetExtension("UIX");
uiInst.CmdManager.LockAllPanesUpdates();
IPXV_MainFrame firstMainFrame = pdfCtl.Inst.MainFrm[0];
IUIX_CmdBar fileBar = firstMainFrame.View.CmdBar["cmdbar.file"];
CustomComboCommandHandler hnd = new CustomComboCommandHandler(pdfCtl.Inst);
IUIX_Cmd cmd = uiInst.CmdManager.CreateNewCmd("cmd.customCombo", "", hnd, null, "", 0);
fileBar.InsertItem(cmd);
uiInst.CmdManager.UnlockAllPanesUpdates();
pdfCtl.Inst.UnlockCmdCustomizationEvent();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment