Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Embedded MapPoint ActiveX control never gets the focus
Embedded MapPoint ActiveX control never gets the focus [message #458162] Mon, 11 July 2005 12:56
Eclipse UserFriend
Originally posted by: marcello.atzeni.akhela.com

This is a multi-part message in MIME format.
--------------040608010509060700060406
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,
I'm trying to embed the Microsoft MapPoint 2004 ActiveX control into a
SWT application.
I modified the sample application that comes with the introductory
article by IBM about SWT support of ActiveX/OLE controls in order to use
tha MapPoint 2004 control in place of the PDF reader.
I was able to instanciate the control, have it load a map and display
itself in the application frame.
However, unlike the other controls I've tested, it looks like the
control fails to get the focus, and, as a result, it does not receive
any mouse events.
Just to add more information, I've also tested this ActiveX control by
writing a MFC and a VB application, both of which work fine.
In order to make things clearer , I've written a simpler application
that basically loads and displays the control, and prints the focus
status to standard output (please see attached file, SWTSample.java).
As you can see the control site object never gets the focus, while the
OLE frame does. The source file also contains a few lines of
commented-out code that use the Internet Explorer control, which you can
uncomment to check the overall application and see the expected
behaviour (in this case both the frame and the site object get the focus).
I'm using Eclipse 3.1 RC2, Microsoft MapPoint 2004 European edition on
MS Windows 2000 and Sun's JDK 1.5.0_02 for Windows.
I have checked the forums and bugzilla, and looked for a hint on the Web
but I could not find any solution.
Is it a common problem, or a bug? How can I solve it? Is the test
application OK or should I change/add anything to make it work?
Thank you in advance.
Best regards,
Marcello Atzeni



--------------040608010509060700060406
Content-Type: java/*;
name="SWTSample.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="SWTSample.java"

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SWTSample {

/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("MapPoint Control test");
shell.setSize(500, 450);

OleClientSite site;
OleAutomation auto;
OleFrame frame = new OleFrame(shell, SWT.CENTER);
frame.setVisible(true);
//Uncomment the following line to use Microsoft MapPoint Control
site = new OleClientSite(frame, SWT.CENTER, "MapPoint.Control");

//Uncomment the following line to use Internet Explorer Control
// site = new OleClientSite(frame, SWT.CENTER, "Shell.Explorer");

auto = new OleAutomation(site);
shell.setLayout(new FillLayout());
shell.layout();
shell.open();
site.doVerb(OLE.OLEIVERB_SHOW);

doSomething(auto);

System.out.println("controlSite focusControl property is "+site.isFocusControl());
System.out.println("Frame focusControl property is "+frame.isFocusControl());

boolean focused=false;
boolean focused2=false;
while(!shell.isDisposed())
if(!display.readAndDispatch()) {
if(focused != site.isFocusControl()) {
focused = site.isFocusControl();
System.out.println("controlSite "+(focused?"got focus":"lost focus"));
}
if(focused2 != frame.isFocusControl()) {
focused2 = frame.isFocusControl();
System.out.println("frame "+(focused2?"got focus":"lost focus"));
}
display.sleep();
}

display.dispose();
}

private static void doSomething(OleAutomation auto) {
//-->Uncomment the following lines to use Microsoft MapPoint Control
int[] rgdispid = auto.getIDsOfNames(new String[] { "NewMap" });
int dispIdMember = rgdispid[0];
Variant[] rgvarg = new Variant[1];
rgvarg[0] = new Variant(2); //Map of Europe <-- change this value if required!

//-->Uncomment the following lines to use Internet Explorer Control
// int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate2" });
// int dispIdMember = rgdispid[0];
// Variant[] rgvarg = new Variant[1];
// rgvarg[0] = new Variant("http://www.google.com");

Variant pVarResult = auto.invoke(dispIdMember, rgvarg);
}
}

--------------040608010509060700060406--
Previous Topic:Reset perspective move my toolbar group from the end to the middle of the Workbench Window Tool bar
Next Topic:[ANN] v4.1 - SWT Designer, Swing Designer & WindowBuilder
Goto Forum:
  


Current Time: Tue May 07 04:59:23 GMT 2024

Powered by FUDForum. Page generated in 5.03520 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top