Skip to content

Instantly share code, notes, and snippets.

@Polaringu
Created January 24, 2017 16:12
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/cc5a04b576bd44c1ba13d170ec6161c3 to your computer and use it in GitHub Desktop.
Save Polaringu/cc5a04b576bd44c1ba13d170ec6161c3 to your computer and use it in GitHub Desktop.
private void searchPaneAutoCompleteToolStripMenuItem_Click(object sender, EventArgs e)
{
pdfCtl.Inst.ExecUICmd("cmd.search", pdfCtl.Frame.View.Obj);
int nID = pdfCtl.Inst.Str2ID("searchView");
PDFXEdit.IPXV_View view = pdfCtl.Frame.View.Panes.Active[nID];
if (view != null)
{
IntPtr outPtr;
view.Obj.QueryImpl(typeof(PDFXEdit.IPXV_SearchView).GUID, null, out outPtr);
PDFXEdit.IPXV_SearchView SV = (PDFXEdit.IPXV_SearchView)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
if (SV != null)
{
//Getting the dialog that is inside of the Search View
IntPtr p;
SV.Obj.QueryImpl(typeof(PDFXEdit.IUIX_Dialog).GUID, null, out p);
PDFXEdit.IUIX_Dialog dlg = (PDFXEdit.IUIX_Dialog)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(p);
if (dlg != null)
{
//Filling the text box with the needed word
dlg.SetItemText("cb.simple", "stream is defined");
PDFXEdit.UIX_RawEvent evt = new PDFXEdit.UIX_RawEvent();
//Imitating the button click event (without timer like AutoClick does)
PDFXEdit.UIX_NotifyInfo ni = new PDFXEdit.UIX_NotifyInfo();
ni.nCode = (int)PDFXEdit.UIX_NotifyCodes.UIX_Notify_Clicked;
ni.pFrom = dlg.GetItem("btn.startStop");
IntPtr ptr;
ni.pFrom.QueryImpl(typeof(PDFXEdit.IUIX_ObjImpl).GUID, null, out ptr);
PDFXEdit.IUIX_ObjImpl uiObjImpl = (PDFXEdit.IUIX_ObjImpl)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(ptr);
ni.pFromImpl = uiObjImpl;
ni.nFromID = ni.pFrom.get_ID();
ni.pData = 0;
evt.nCode = (int)PDFXEdit.UIX_EventCodes.e_Notify;
IntPtr resPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ni));
System.Runtime.InteropServices.Marshal.StructureToPtr(ni, resPtr, false);
evt.nParam1 = (uint)resPtr;
SV.Obj.SendRawEvent(ref evt);
Marshal.FreeHGlobal(resPtr);
resPtr = IntPtr.Zero;
System.Runtime.InteropServices.Marshal.Release(ptr);
}
System.Runtime.InteropServices.Marshal.Release(p);
}
System.Runtime.InteropServices.Marshal.Release(outPtr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment