send CTRL-C to dchtmlviewer

This forum is for eXpress++ general support.
Message
Author
skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

send CTRL-C to dchtmlviewer

#1 Post by skiman »

Hi,

I would like to send a PAGE-DOWN to a dchtmlviewer.

Code: Select all

postappevent(xbeP_Keyboard,xbeK_PGDN,,oViewer)
The above isn't working, nothing happens. Would this be possible to accomplish?
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: send CTRL-C to dchtmlviewer

#2 Post by Auge_Ohr »

skiman wrote:I would like to send a PAGE-DOWN to a dchtmlviewer.

Code: Select all

postappevent(xbeP_Keyboard,xbeK_PGDN,,oViewer)
The above isn't working, nothing happens. Would this be possible to accomplish?
if you want to "send" Key they must be "virtual" -> VK_

Code: Select all

#define VK_PRIOR 0x21
#define VK_NEXT 0x22
#define VK_UP 0x26
#define VK_DOWN 0x28
and you can´t use PostAppEvent() while that is Xbase++ only.
greetings by OHR
Jimmy

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: send CTRL-C to dchtmlviewer

#3 Post by skiman »

Hi Jimmy,

Thanks for the answer, but I have no idea how to send a 'virtual key'.

I looked around and found samples in VB, which are using Sendkeys to send keys to another application. Do you have a sample?
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: send CTRL-C to dchtmlviewer

#4 Post by Tom »

Are you sure the dchtmlviewer knows keyboard-events? What about posting them to the scrollbar?
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: send CTRL-C to dchtmlviewer

#5 Post by rdonnay »

I looked at the docs for XbpHtmlViewer and XbpActiveXControl and there is nothing documented on how to send a key to an ActiveX object.

I also looked online and can find nothing.
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: send CTRL-C to dchtmlviewer

#6 Post by Auge_Ohr »

skiman wrote: Thanks for the answer, but I have no idea how to send a 'virtual key'.
I looked around and found samples in VB, which are using Sendkeys to send keys to another application. Do you have a sample?
have a look at c:\exp20\Samples\HtmlEdit_2\ from J.A. Diego Kerejeta.

it is a HTML Editor based on XbpHTMLViewer() and use "virtual Key"
INPUT Structure is used instead of keybd_event (), which is deprecated, so it need Ot4Xb

---

include "self made" Help File from ieFrame.DLL
look at "Webbrowser" which Event, Method or Property are available
shdocvw.zip
(131.8 KiB) Downloaded 658 times
greetings by OHR
Jimmy

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: send CTRL-C to dchtmlviewer

#7 Post by skiman »

Hi Jimmy,

Thanks, I will check that sample.
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: send CTRL-C to dchtmlviewer

#8 Post by skiman »

Hi,

Meanwhile I found the following C# code to send CTRL-C to an external application. It should put already selected text to the Windows clipboard.

Code: Select all

[DllImport("User32.dll")] 
private static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
.....

private void SendCtrlC(IntPtr hWnd)
    {
    uint KEYEVENTF_KEYUP = 2;
    byte VK_CONTROL = 0x11;
    SetForegroundWindow(hWnd);
    keybd_event(VK_CONTROL,0,0,0);
    keybd_event (0x43, 0, 0, 0 ); //Send the C key (43 is "C")
    keybd_event (0x43, 0, KEYEVENTF_KEYUP, 0);
    keybd_event (VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);// 'Left Control Up

}
I suppose this should be possible to convert to Xbase++.

Another possible solution I found was the following code:

The author wrote the following:
No idea for how long has this been possible but instead of fighting with Win32 programming (mostly user32.dll and various Windows messages like WM_GETTEXT, WM_COPY and various SendMessage(handle, WM_GETTEXT, maxLength, sb) calls) which is advised in most of SO threads on this topic, I easily managed to access selected text in any window in my C# code followingly:
And this is his code:

Code: Select all

static void fetchSelectionToClipboard()
{
  Thread.Sleep(400);
  SendKeys.SendWait("^c");   // magic line which copies selected text to clipboard
  Thread.Sleep(400);
}
I don't know how to simulate that sendkeys function.

If anyone have the knowledge to convert this to Xbase++, It would be a nice to have.

I would use it to send selected text in a dchtmlviewer to the clipboard, so I can import it, but I suppose it would be usefull for other situations also.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: send CTRL-C to dchtmlviewer

#9 Post by rdonnay »

I looked at that C# code a few weeks ago but could find nothing in the Xbase++ docs that shows how to send it to an XbpActiveXControl object or Automation Object.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: send CTRL-C to dchtmlviewer

#10 Post by skiman »

Hi,

In the htmleditor of J.A. Diego Kerejeta , I found the following. It is used to send a CTRL-C to the xbphtmlviewer.

Code: Select all

*****************************
PROCEDURE SendCtrlKey( xKey )
*****************************
LOCAL oInput := Input():New()
LOCAL nEvents:=  4
LOCAL nSize  := oInput:_sizeof_()
LOCAL pBuffer:= _xgrab( nSize * nEvents  )

oInput:_link_( pBuffer , .F.)
   oInput:type  := INPUT_KEYBOARD
   oInput:ki:wVk:= VK_CONTROL

GwstArrayNext(oInput)
   oInput:type  := INPUT_KEYBOARD
   oInput:ki:wVk:= xKey

GwstArrayNext(oInput)
   oInput:type      := INPUT_KEYBOARD
   oInput:ki:wVk    := VK_CONTROL
   oInput:ki:dwFlags:= KEYEVENTF_KEYUP

GwstArrayNext(oInput)
   oInput:type      := INPUT_KEYBOARD
   oInput:ki:wVk    := xKey
   oInput:ki:dwFlags:= KEYEVENTF_KEYUP

@user32:SendInput( nEvents, pBuffer, nSize )

oInput:_unlink_()
_xfree( pBuffer)
RETURN

*********************
BEGIN STRUCTURE INPUT
*********************
   MEMBER DWORD type
   BEGIN UNION
   MEMBER @ MOUSEINPUT mi
   MEMBER @ KEYBDINPUT ki
   MEMBER @ HARDWAREINPUT hi
   END UNION
END STRUCTURE // 28 // BYTES
Best regards,

Chris.
www.aboservice.be

Post Reply