|
The docs on this are sparse, to say the least...
My problem: I'm trying to embed a WebBrowser object in a Windows Mobile application. I can create it and query its size and window handle, but IWebBrowser2::Navigate2 fails with E_FAIL .
Can anyone give me any hints to why it fails?
Code (yes, C++):
My host control is declared like this:
class HtmlControl : public Window
{
public:
HtmlControl(HWND window)
: Window(window)
, iOleObject_(NULL)
{
iOleSite_.host = this;
iOleFrame_.host = this;
CreateWebControl();
}
Site iOleSite_;
Frame iOleFrame_;
IOleObject* iOleObject_;
private:
void CreateWebControl();
}; Where Site and Frame are declared like this:
struct Site : public IOleClientSite,
public IOleInPlaceSite
{
HtmlControl* host;
STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
IMoniker** ppmk);
STDMETHODIMP GetContainer(LPOLECONTAINER FAR* ppContainer);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL fShow);
STDMETHODIMP RequestNewObjectLayout();
STDMETHODIMP GetWindow(HWND FAR* lphwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME FAR* lplpFrame,
LPOLEINPLACEUIWINDOW FAR* lplpDoc,
LPRECT lprcPosRect,
LPRECT lprcClipRect,
LPOLEINPLACEFRAMEINFO lpFrameInfo);
STDMETHODIMP Scroll(SIZE scrollExtent);
STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
};
struct Frame : public IOleInPlaceFrame
{
HtmlControl* host;
STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP GetWindow(HWND FAR* lphwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
STDMETHODIMP GetBorder(LPRECT lprectBorder);
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS pborderwidths);
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS pborderwidths);
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject* pActiveObject,
LPCOLESTR pszObjName);
STDMETHODIMP InsertMenus(HMENU hmenuShared,
LPOLEMENUGROUPWIDTHS lpMenuWidths);
STDMETHODIMP SetMenu(HMENU hmenuShared, HOLEMENU holemenu,
HWND hwndActiveObject);
STDMETHODIMP RemoveMenus(HMENU hmenuShared);
STDMETHODIMP SetStatusText(LPCOLESTR pszStatusText);
STDMETHODIMP EnableModeless(BOOL fEnable);
STDMETHODIMP TranslateAccelerator(LPMSG lpmsg, WORD wID);
}; The implementations of Site and Frame will be provided if needed, so that this space isn't cluttered too much.
So, the interesting function here is HtmlControl::CreateWebControl() . Let's walk it through, so that the possible strangeness of the IWebBrowser2::Navigate2 failure can be better seen.
First, an instance of the WebBrowser COM object is created and its associated IOleObject is retrieved:
IUnknown* iUnknown = NULL;
HRESULT hr = ::CoCreateInstance(CLSID_WebBrowser,
NULL,
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
IID_IUnknown,
(void*)(&iUnknown));
VERIFY(SUCCEEDED(hr));
hr = iUnknown->QueryInterface(IID_IOleObject, (void*)(&iOleObject_));
VERIFY(SUCCEEDED(hr)); These operations were all successful in the sense that hr == S_OK .
After getting the WebControl object, I want to show/activate it using our IOleClientSite implementation:
hr = iOleObject_->SetClientSite(&iOleSite_);
VERIFY(SUCCEEDED(hr));
const RECT rect = GetClientRect();
hr = iOleObject_->DoVerb(OLEIVERB_SHOW, NULL, &iOleSite_, 0, GetHwnd(), &rect);
VERIFY(SUCCEEDED(hr)); These operations were also successful in the sense that hr == S_OK . However, the end result (the IWebBrowser2::Navigate2 failure) occurs also if OLEIVERB_SHOW is changed to OLEIVERB_UIACTIVATE or OLEIVERB_INPLACEACTIVATE .
Next, I dig the IWebBrowser2 out of the WebControl object and checks if the browser HWND is sane:
IWebBrowser2* iWebBrowser = NULL;
hr = iOleObject_->QueryInterface(IID_IWebBrowser2, (void**)&iWebBrowser);
VERIFY(SUCCEEDED(hr));
HWND hwndBrowser = NULL;
hr = iWebBrowser->get_HWND((long*)&hwndBrowser);
VERIFY(SUCCEEDED(hr));
VERIFY(hwndBrowser != NULL);
VERIFY(::GetParent(hwndBrowser) == GetHwnd());
IOleWindow* iOleWindow = NULL;
hr = iOleObject_->QueryInterface(IID_IOleWindow, (void*)(&iOleWindow));
VERIFY(SUCCEEDED(hr));
hwndBrowser = NULL;
hr = iOleWindow->GetWindow(&hwndBrowser);
VERIFY(hwndBrowser != NULL);
VERIFY(::GetParent(hwndBrowser) == GetHwnd()); Again, these operations were successful in the sense that hr == S_OK . Also, the browser HWND is equal in both method 1 and 2 and its parent is indeed our host control. I see this as some kind of indication that something works.
But... the thing I need doesn't work; the precious IWebBrowser2::Navigate2 :
VARIANT vURL;
vURL.vt = VT_BSTR;
vURL.bstrVal = ::SysAllocString(L"about:blank");
VARIANT vEmpty;
vEmpty.vt = VT_EMPTY;
hr = iWebBrowser->Navigate2(&vURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
VERIFY(SUCCEEDED(hr)); Now I get hr == E_FAIL .
I cannot really see the problem, since everything up to this point worked successfully, and the last call seems trivial.
Is anyone still around all the way down here with some guess as to what might be going on?
Thanks for any input!
--
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
How to make the form floating in ppc?
And how can we drag the form?
??????,??????!
|
|
|
|
|
Hi,
I'm writing a program on the .NET compact framework to connect to the MPD musicplayer via a wifi connection. When I run the program from the simulator it runs fine. However when I deploy the software on the real device, I see the strange fenomenom, that I get the same data back from the the Networkstream object twice (even when connected through the active sync app). I checked the network traffic and I can see no errors there, the messages are correctly in sync. The stream.read method however returns the same data twice, when I do a re-read the correct message is received and the software runs smoothly furtheron. I disabled the optimizer, played around with the socket options, without any result. Adding delays between send and receive doesn't help either, however I do see a difference in debug and release versions. Stepping through the code does not show the problem anymore.
// The code i use to send and receive
protected void sendCommand(string command)
{
if (stream != null)
{
mLock.WaitOne();
OnLog(">>" + command + "\r\n");
byte[] sendBytes = System.Text.Encoding.ASCII.GetBytes(command + "\r\n");
connection.GetStream().Write(sendBytes, 0, sendBytes.Length);
}
}
protected string readResponse(bool check)
{
if (stream != null)
{
byte[] myReadBuffer = new byte[connection.ReceiveBufferSize];
NetworkStream myStream = connection.GetStream();
StringBuilder response = new StringBuilder();
int numberOfBytesRead = 0;
if (stream.CanRead)
{
do
{
numberOfBytesRead = myStream.Read(myReadBuffer, 0, myReadBuffer.Length);
response.Append(Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
commander.addDatatrafic(numberOfBytesRead);
}
while (myStream.DataAvailable && numberOfBytesRead > 0);
OnLog("<<" + Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead) + "\r\n");
response.Replace("\n", "\r\n");
if (check)
{
if (!checkOK(response.ToString()) && !checkFailed(response.ToString()))
{
response.Append(readResponse());
}
}
mLock.ReleaseMutex();
//lastresponse = response.ToString();
return response.ToString();
}
return "";
}
else
{
return "";
}
}
Anybody any ideas?
Regrards,
eric
modified on Monday, April 14, 2008 4:43 PM
|
|
|
|
|
Eric,
My best guess here is that the function for reading the data is being called twice for the first time. You may try adding a counter and increment its value every time data is being read and check its value at the end.
You may also use any sniffer to check for the data being transferred to and fro. Searching over the google, you may find few tools for the same.
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Hi there.
Is there any way I can catch an event, when i plug a cable from my device to a computer?
When there is an active connection between the two devices I want to show a dialog box in my mobile application.
Haolan
|
|
|
|
|
Please check Windows Mobile API
there is lot of system states.
|
|
|
|
|
Can you tell me more specific where I can find these system states?
|
|
|
|
|
Hi
Please search in msdn2.microsoft.com
There are you can find get all system sattes.
|
|
|
|
|
I found this:
http://msdn2.microsoft.com/en-us/library/microsoft.windowsmobile.status.systemstate.activesyncstatus.aspx[^]
With this I have written the following code:
void activeSyncState_Changed(object sender, ChangeEventArgs args)
{
ActiveSyncStatus status = (ActiveSyncStatus)args.NewValue;
try
{
if (status == ActiveSyncStatus.Synchronizing)
{
MessageBox.Show("Hello world!");
}
}
catch (Exception ex)
{
// Handle Exception
}
}
SystemState activeSyncState = new SystemState(SystemProperty.ActiveSyncStatus);
activeSyncState.Changed += new ChangeEventHandler(activeSyncState_Changed);
But when I plug in my cable nothing happens. But I guess I dont use the right api, because I need to fire my event when a connection is established and not when activesync is synchronizing. Is there any way to do that?
|
|
|
|
|
Hi
i tried same code it's work for me
it's wok please double checok u registrated dll in ur enumaltor
Thank you
|
|
|
|
|
code :
Imports Microsoft.WindowsMobile.Telephony
Dim phone As New Phone
phone.Talk("+1.....", True)
=============================================
That code to dial number using Visual Basic for Pocker PC devices
How can I hangUp that connection from My application And How to monitoring the connection to Know it's status whether
Dialing , connected or No connection
|
|
|
|
|
Hello,
I am trying to launch pword.exe using CreateProcess but its failing.
I have used following code : -
BOOL a = CreateProcessW(L"pword.exe", L"", NULL, NULL, TRUE, 0, NULL, NULL, 0, 0);
a = CreateProcessW(L"\\windows\\pword.exe", L"", NULL, NULL, TRUE, 0, NULL, NULL, 0, 0);
Can anybody of you tell me why is it failing?
Thanks in advance!
|
|
|
|
|
Try the following which worked for me:
Process myProcess = new Process();
myProcess.StartInfo.FileName = "\\Windows\\pword.exe";
myProcess.StartInfo.Verb = "Open";
myProcess.Start();
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Hi,
I'm trying to create a program that interacts with a bunch of wireless sensors, but I'm not sure where to begin since I have no experience in this and had trouble finding information about it. Here are a few questions that will hopefully help me on my way:
1) What language should I program in? And what framework do I need? I am planning on having this application on a mobile device (i.e. cellphone, PDA).
2) How does the sensor send data to the program? What is needed in order for it to communicate with the program? What hardware as well as software frameworks and APIs?
Here's what I'm thinking: I will write my mobile app in C# and have some event handlers. The sensors will be calling the event handlers of that app. Do I need to do some socket programming, such as creating sockets and taking in packets in order for the sensors to communicate with the application? Also, do I need to account for the fact that the transmission is wireless and if so, how?
Any help will be greatly appreciated.
Thanks!
|
|
|
|
|
Hi all,
After it seems that I'm finding the way to resolve my previous problem,
now I found another problem.
Please read this simple line of code:
Imports System
Imports System.IO
Imports System.Drawing.Graphics
Imports System.Drawing.Color
----------------------------------------
TextBox1.BackColor = RGB(255, 255, 0)
It generate the following error:
Error 1 Value of type 'Integer' cannot be converted to 'System.Drawing.Color'. E:\Documents and Settings\MI\Documenti\Visual Studio 2005\Projects\TrackPlotter\TrackPlotter\Form1.vb 555 30 TrackPlotter
I tryed the same line code in VB 5 with the expected result to colorize the Box yellow.
Is my C.F. 2.0 crazy?.....Or not?
Marco
|
|
|
|
|
I think the code that you would need to use is:
TextBox1.BackColor = Color.FromArgb(255, 255, 0)
Or:
TextBox1.BackColor = Color.Yellow
Also, make sure that you have the .Net CF Service Packs installed on your mobile device. (I had a few problems with coloring on my PPC before I installed the .Net CF SP2 on it)
I hope this helps
|
|
|
|
|
Hi Mitch,
Thanks for reply.
I have .Net CF SP2 installed on both device and emulator (Windows Mobile 2003 SE).
I know that the code that I would need to use is:
TextBox1.BackColor = Color.FromArgb(255, 255, 0)
The problem I described in the post is born while I was trying to resolve another previous and primary problem (actually unresolved).
This is the main problem:
1)- I need to get an RGB vatue from a txt file (I.E. 65535 for Yellow).
2)- Convert it in Integer or Color (Result is the identical: Appl. retuns a color like Aquamarine instead of Yellow.
3)- Use this value as BackColor property for a TextBox.
But........
TextBox1.BackColor = Color.FromArgb(255, 255, 0)
work correctly (Colorize TextBox Yellow), but it's not good for my application.
------------------------------------------------------
TextBox1.BackColor = Color.FromArgb (65535)
'Color.FromArgb can accept also an RGB Value as single argument.
'65535 is the RGB value of Yellow
Don't work correctly (Colorize TextBox like Aquamarine instead of Yellow).
--------------------------------------------------------
Are 3 days I'm working around....... But Nothing!
modified on Thursday, April 10, 2008 10:54 AM
|
|
|
|
|
Hi all,
After 3 days I resolved problem explained above.
I discovered that in .Net CF 2.0 (may be also others versions), statement Color.FromArgb(Red, Green, Blue) works as expected (correctly)if it's used to reproduce a color structure from a triade of the three R-G-B components values(one value for each component in the order R-G-B),
but if it's used to reproduce a color structure from a color value (I.E. 65535 for yellow), it works with colors components values inverted.
More exactely, it reproduce colors like statement:
Color.FromArgb(Blue, Green, Red)
And then, I resolved problem estracting each single component values from the single color value, and recombined them in Color.FromArgb(Red, Green, Blue), following the normal R-G-B sequence.
Thanks
Marco
modified on Thursday, April 10, 2008 1:41 PM
|
|
|
|
|
hi
how can i get x,y from GPS using PPC in C# code ?
thanks
|
|
|
|
|
Take a look at the article entitled "Writing your first GPS application" that's on this site. Regarding X and Y I presume you mean Latitude & Longitude.
|
|
|
|
|
hi anyone
I'm a computer science student. Now I'd like to upload the picture in my Pocket PC to network
(web application (PHP)).
You have any guildline for me about the above application.
|
|
|
|
|
Webservice would be really easy
Create a webservice that acceps a bytearray and a name
Then save the bytearray with the name
I dont know php, but i guess there must be something like bytearray in ASP
If not, witch to ASP.NET
Alexei Rodriguez
|
|
|
|
|
I am writing an installer for my Windows Mobile Application. My application requires CF2 SP2. As that is not included in Windows Mobile 5, I presume I need to distribute it. I don't know what files to include and where to get them. I know how to (and have already of course) install it on my Windows PC, and how to set Visual Studio to automatically deploy it when I debug my projekt, but doesn't help my customers...
Anyone?
/ackabacka
|
|
|
|
|
Hello everybody.
I have an application for pocked PC for windows mobile 5.0 and I want to run it on a laptop computer running windows XP, without visual studio.
In order to run the application, I've installed the following:
The stand alone emulator.
Install the virtual network driver.
Install the images for windows mobile.
Install ActiveSync.
I need the internet connection to download the application files, but i can not establish an internet connection. Can anyone tell me what should I do to realize the connection?
Thank you
modified on Tuesday, April 8, 2008 8:16 AM
|
|
|
|
|
|