Delete Selected on Keyup Freezes App

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

baldevraj
User
Posts: 3
Joined: Mon Aug 15, 2011 6:12 pm

Delete Selected on Keyup Freezes App

Post by baldevraj »

Hi Guys,

I've been testing your free version of the activeX viewer in the app that I'm developing. Everything works great, except for 2 things that I just can't figure out why; and both problems are to do with the two event types, i.e., PXCVA_OnNamedNotify and PXCVA_OnDisplayPrompt

1. Delete Selected Feeze on KeyUp:
  • I set axCoPDFXCview1.SetProperty("Notifications.Keyboard.Filter", "Up", 0); in the Form_Load.
  • I get the keycode for the delete button -> axCoPDFXCview1.GetProperty("Notifications.Keyboard.Code", out vKeyCode, 0);
  • and I do a ExecuteCommand(33136); i.e., comand code for deleteSelected.
  • The selected object (whether it is a line, text, highlight, etc) just freezes and the app freezes as well.

Initially I thought it might be something to do with my app, so I tried it in one of your sample apps and it did the same. If instead I put a button and do the ExecuteCommand(33136); on the click event it works fine. I know I'm missing something here in the event types, because I have a similar situation in the second issue I'm having, detailed below.


2. Prompts.ConfirmDocumentSave:

In my app, the user modifies the document with highlights etc, and leaves the document to move to another window or panel of the app. When doing so I intercept the Prompts.ConfirmDocumentSave event and display our custom prompt for the user to save the document. If the user clicks "Yes" to save, I save the document and bypass the viewer's default save prompt; but for some reason the default save prompt triggers and the app freezes. An excerpt of the code is below:

case (int)PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnDisplayPrompt:
switch (e.name) {
case "Prompts.ConfirmDocumentSave":
DialogResult res = MessageBox.Show("Would you like to save changes?",
"Save",
MessageBoxButtons.YesNo);
if (res == DialogResult.Yes) {
axCoPDFXCview1.SaveDocument(mDocID);// if I comment this line out, it doesn't freeze, but still displays the default save prompt
axCoPDFXCview1.SetProperty("Prompts.ConfirmDocumentIncSave.UserChoice",
6, 0);
}
else {
axCoPDFXCview1.SetProperty("Prompts.ConfirmDocumentIncSave.UserChoice",
7, 0);
}
break;
}
These are so far the only two issues that have stumped me; and I know it's something I'm overlooking. Once I resolve these two issues, I intend to purchase the license and deploy the app for beta testing. Please advise.

Thank you.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Delete Selected on Keyup Freezes App

Post by Vasyl - PDF-XChange »

Hi, baldevraj
1. Delete Selected Feeze on KeyUp:
I set axCoPDFXCview1.SetProperty("Notifications.Keyboard.Filter", "Up", 0); in the Form_Load.
I get the keycode for the delete button -> axCoPDFXCview1.GetProperty("Notifications.Keyboard.Code", out vKeyCode, 0);
and I do a ExecuteCommand(33136); i.e., comand code for deleteSelected.
The selected object (whether it is a line, text, highlight, etc) just freezes and the app freezes as well.
To solve your problem - you may use next workaround (pseudocode):

Code: Select all

your_com_event_handler OnEvent(type, name...)
{
     if ((type == PXCVA_OnNamedNotify) AND (name == "Notifications.Keyboard"))
     {
          int key;
          ctrl.GetProperty("Notifications.Keyboard.Code", out key, 0); 
          if (key == 'Del')
          {
              PostMessage(yourFormWindow, msg_RunDeleteSelCmdByKey, 0, 0);
          }
     }
}
////////////////////////////////////////////////////////
class YourForm
{
     void OnRunDeleteSelCmdByKey()
     {
         ctrl.ExecuteCommand(33136);
     }
}
- Essence of this: you may send the custom asynchronous message to your form and execute the PDF-Viewer command in the safe time...
2. Prompts.ConfirmDocumentSave:
In my app, the user modifies the document with highlights etc, and leaves the document to move to another window or panel of the app. When doing so I intercept the Prompts.ConfirmDocumentSave event and display our custom prompt for the user to save the document. If the user clicks "Yes" to save, I save the document and bypass the viewer's default save prompt; but for some reason the default save prompt triggers and the app freezes.
The correct code for your case:

Code: Select all

case (int)PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnDisplayPrompt:
	switch (e.name) 
	{
	case "Prompts.ConfirmDocumentSave":
	case "Prompts.ConfirmDocumentIncSave":
		DialogResult res = MessageBox.Show("Would you like to save changes?", "Save", MessageBoxButtons.YesNo);
		string propName = e.name + ".UserChoice";
		if (res == DialogResult.Yes)
			axCoPDFXCview1.SetProperty(propName, 6, 0);
		else 
			axCoPDFXCview1.SetProperty(propName, 7, 0);
		break;
	}
HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
baldevraj
User
Posts: 3
Joined: Mon Aug 15, 2011 6:12 pm

Re: Delete Selected on Keyup Freezes App

Post by baldevraj »

Hi Vasyl,

Thanks for your feed back, really appreciate it. The Prompts.ConfirmDocumentSave code snippet you provided works perfectly. However, I couldn't get the workaround for the delete functionality for the KeyUp event to work. Could you please elaborate on the pseudocode? I'm not sure how to pass the msg_RunDeleteSelCmdByKey to the PostMessage function. If you could send me a c# example, I would really appreciate it.

Thanks.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Delete Selected on Keyup Freezes App

Post by Corwin - Tracker Sup »

Hello baldevraj,

Here is small sample of using PostMessage function for C#.

HTH.
You do not have the required permissions to view the files attached to this post.
baldevraj
User
Posts: 3
Joined: Mon Aug 15, 2011 6:12 pm

Re: Delete Selected on Keyup Freezes App

Post by baldevraj »

Thanks a million guys!!! Works like a charm.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7362
Joined: Wed Mar 25, 2009 10:37 pm

Re: Delete Selected on Keyup Freezes App

Post by Paul - PDF-XChange »

:D
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com