bb.donnay-software.com
http://bb.donnay-software.com/Donnay/

send CTRL-C to dchtmlviewer
http://bb.donnay-software.com/Donnay/viewtopic.php?f=2&t=2707
Page 3 of 3

Author:  skiman [ Fri Mar 20, 2020 7:12 am ]
Post subject:  Re: send CTRL-C to dchtmlviewer

Hi,

Sending the key was working, the problem I had was setting focus to the PDF control in the htmlviewer. It seems as this isn't possible.

Once you click somewhere on an xbase++ control, the pdfcontrol loses the focus. There seems no way to set it back.

However, I found a solution for this with an eventhandler.

When a user select something in the pdfcontrol, the control has focus. As soon as the mouse cursor is out of the range of that pdfcontrol, the eventhandler detects this movement. The only thing you have to do is 'detecting' this and sending the CTRL-C. The PDFcontrol still has focus, and the CTRL-C is send to it.

Now I have the solution I want:
1. user clicks in the PDF control to select a word.
2. Moves the mouse cursor to a get. (CTRL-C is send by the event handler, so the selected text is put in the clipboard)
3. User clicks on the get, and in the gotfocus block, I read the clipboard.

My customer processes about 600 invoices a day, where ther need to copy/paste about 5 elements. This is about 3000 times a day to copy/paste. Now they can do it without these 3000 clicks.

Author:  rdonnay [ Fri Mar 20, 2020 7:26 am ]
Post subject:  Re: send CTRL-C to dchtmlviewer

I tried using the event handler and made no progress.

Show me your solution.

Author:  skiman [ Fri Mar 20, 2020 7:46 am ]
Post subject:  Re: send CTRL-C to dchtmlviewer

Hi Roger,

In attachment the fileviewer with a handler. According to the needs, you can detect on mouse move, buttonclick.

In my application I have added a big vertical button with a width of 10 pixels. When you move the mouse from the PDF to the input fields, the mouse move above that button. This is my handler to detect this.

Code:
STATIC FUNCTION PDFHandler ( nEvent, mp1, mp2, oXbp, _oDlg, GetList, aApp )
***************************************************************************
IF Valtype(oXbp) = 'O' .and. oXbp:ClassName() = 'DC_XbpPushButton' .and. valtype(oXbp:caption)=="C" .and. DC_GetProperty( oXbp, cGETLIST_TITLE )="xpdfx"
   SendCtrlKey( VK_C )
endif

RETURN DCGUI_NONE


See the button with yellow line in the screenshot. It has as title 'xpdfx', so I can select on it. So I select text on the right side, and move the cursor to the left. When it passes the button, the CTRL-C is send and selected text is copied. Each field at the left has a gotfocus with a 'getclipboard' function.

Attachment:
samplepdf.PNG
samplepdf.PNG [ 91.47 KiB | Viewed 933 times ]


Attachments:
fileviewer.zip [460.89 KiB]
Downloaded 42 times

Author:  Auge_Ohr [ Sat Mar 21, 2020 2:21 am ]
Post subject:  Re: send CTRL-C to dchtmlviewer

skiman wrote:
Sending the key was working, the problem I had was setting focus to the PDF control in the htmlviewer. It seems as this isn't possible.

"where" do you send your Keystroke with SendInput API function to :?:

Author:  skiman [ Sat Mar 21, 2020 2:31 am ]
Post subject:  Re: send CTRL-C to dchtmlviewer

Hi Jimmy,

The keystroke is send to the component that has focus on that moment. In this case it is the goal to send it the pdfcontrol. Since a user has selected something in the pdf (some text, date or number) this control has the focus.Now the CTRL-C is automatically send to the pdfcontrol.

Meanwhile I changed my event handler, so I can simulate a drag/drop from the PDF control to the fields I need. This will avoid thousands of mouse clicks a day. :dance:

Page 3 of 3 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/