Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » OLE: how to set a (OLECHAR **ppchURLOut) parameter?
OLE: how to set a (OLECHAR **ppchURLOut) parameter? [message #462620] Sat, 15 October 2005 03:58 Go to next message
Michael Sizaki is currently offline Michael SizakiFriend
Messages: 1
Registered: July 2009
Junior Member
Hi,

I want to implement the IDocHostUIHandler::TranslateUrl Method
http://msdn.microsoft.com/workshop/browser/hosting/reference /ifaces/idochostuihandler/translateurl.asp

As a test I tool WebSite and modified the TranslateUrl method

How do I assign a pointer to a **OLECHAR?


int TranslateUrl(int dwTranslate, int pchURLIn, int ppchURLOut) {
if (pchURLIn != 0) {
int length = OS.IsUnicode ? OS.wcslen (pchURLIn) : OS.strlen (pchURLIn);
TCHAR buffer = new TCHAR (0, length);
int byteCount = buffer.length () * TCHAR.sizeof;
OS.MoveMemory (buffer, pchURLIn, byteCount);
String url = buffer.toString (0, length);

// translate the URL
String newURL=url;

int ptr=COM.CoTaskMemAlloc(newURL.length()* TCHAR.sizeof);
buffer=new TCHAR (ptr, newURL, true);
byteCount = buffer.length () * TCHAR.sizeof;
OS.MoveMemory (ptr, buffer, byteCount);
OS.MoveMemory (ppchURLOut, new int[]{ptr}, 1);


}
return COM.S_OK;
}

Unfortunately, this crashed the VM :-(

Michael
Re: OLE: how to set a (OLECHAR **ppchURLOut) parameter? [message #462630 is a reply to message #462620] Sat, 15 October 2005 08:46 Go to previous message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
OLECHAR is the Unicode.

if (pchURLIn != 0) {
int length = OS.wcslen(pchURLIn);
char[] buffer = new char[length];
OS.MoveMemory(buffer, pchURLIn, length * 2);
String url = new String(buffer);
//...translate the url...
length = url.length();
int ptr = COM.CoTaskMemAlloc(length * 2);
OS.MoveMemory(ptr, url.getBytes(), length * 2);
OS.MoveMemory(new int[] {ppchURLOut}, ptr, 4);
}
return OS.S_OK;

Hope this helps.
Previous Topic:Setting selection in JFace ComboViewer
Next Topic:Browser - Javascript Error Masking
Goto Forum:
  


Current Time: Fri Apr 19 07:42:51 GMT 2024

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

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

Back to the top