|
Trying to create and access a WebBrowser control behind the scenes in a win32 console app:
::CoInitialize(NULL);
SHDocVw::IWebBrowser2Ptr brwsr = NULL;
HRESULT hResult;
hResult = brwsr.CreateInstance(__uuidof(SHDocVw::WebBrowser));
I can then call brwsr->get_Name, brwsr->get_FullName etc. with no problem.
brwsr->Navigate(...) is causing a runtime crash (with CoCreateInstance or CreateInstance.)
Here's the current method I'm using:
BSTR oURL;
oURL = SysAllocString(L"http://www.google.com");
VARIANT var;
var.vt = VT_EMPTY;
brwsr->Navigate((BSTR)oURL, &var, &var,
&var,&var);
SysFreeString(oURL); (which I copied and pasted from somewhere).
Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.
|
|
|
|
|
Force Code wrote: Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.
Nope. Nobody uses COM nowdays. But a long time ago (I was just a child), a wise COM guru told me: "Check always HRESULT s, my son!"
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
The fact that its crashing on the brwsr->Navigate call sort of rules out checking the return value.
What would you be using to access the web in a trivial win32 console app.
|
|
|
|
|
OK, but why do you call the method without filling parameters with meaningful values?
I read a bit the documentation and it seems you cannot simply supply empty variants.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hello Force Code,
I'm not familiar with the IWebBrowser2 interface but after looking up the documentation for Navigate(), my gut feel is that the 2nd to the 5th parameters should be filled with VARIANT parameters that actually contain some information (rather than just being VT_EMPTY). Passing "NULL" might even be a better choice (I really don't know).
My suggestion is to look up the documentation for Navigate() for proper guidance and then pass in appropriate values for the 2nd to 5th parameters.
- Bio.
|
|
|
|
|
I've created a function to load a bitmap file. Load the BITMAPFILEHEADER, load the BITMAPINFOHEADER and then I get the data. If it needs to be flipped, I flip it.
My problem is that not all images can be loaded. I have created 3 images in Paint, all 64x64, 24-bit bitmaps. Two of them load just file, but the third one is warped - like it has been in a storm or something! No matter if I try to copy and paste it to a new bmp, it's still warped!
Anyone happens to know what may be the cause?
|
|
|
|
|
Gadjuka wrote: Anyone happens to know what may be the cause?
Probably. Seeing the loader code would make it much simpler
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Gadjuka wrote: Anyone happens to know what may be the cause?
A mistake in your code (i.e. my CPMRU is out of order tonight ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Is your pixel buffer DWORD aligned?
You may already know this, but there may be extra bytes at the end of each row of the image, so that the number of bytes in each row is divisible by 4 (i.e. DWORD aligned). The actual number of bytes per row is not the width (in pixels) multiplied by the number of bytes per pixel. Instead, it is the next higher number which is divisible by 4. The actual width in bytes is called the stride.
You can compute the stride using:
int s = ((w * bpp+31) / 32) * 4;
where s is the stride (number of bytes per row), w is the width of the image (in pixels, not in bytes), and bpp is the number of bits per pixel, in your case 24.
So then the size of the buffer into which you copy your pixels will be the stride times the height (number of rows) in the image.
This seems likely to be your problem, since your pixels are 3 bytes each, rather than 4 bytes each.
Hope this helps.
|
|
|
|
|
Actually - I didn't know!
As you say, it seems likely this is the cause of my problem. I'm gonna try this as soon as I get home!
If this doesn't help, I'll do as Mark said and post the code...
|
|
|
|
|
I thought my image was 64x64 and hence this that you have to have a width that is dividable by 4 shouldn't be a problem. But the image was really 65x64!
But with the information I got from you Californian2 I was able to fix so that my function now can load bitmaps of any size. Thank you very much!
|
|
|
|
|
Hi,
How can I use these menu notifications on MFC:
WM_COMMAND
WM_CONTEXTMENU
WM_ENTERMENULOOP
WM_EXITMENULOOP
WM_GETTITLEBARINFOEX
WM_MENUCOMMAND
WM_MENUDRAG
WM_MENUGETOBJECT
WM_MENURBUTTONUP
WM_NEXTMENU
WM_UNINITMENUPOPUP
I didn't find anything on the MSDN Library. Can anybody explain me the messaging routing of the menu object?
Thx
|
|
|
|
|
|
I know that, but I didn't find the wrapper (command-handler member function) for these messages in the CMenu class, e.g the command-handler member function for WM_CREATE is OnCreate etc. My idea is to inherit a class from CMenu and add the message handler-functions for these messages, is that correct?
|
|
|
|
|
Have you tried via ClassWizard (Ctrl+W)?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What do you mean with "via ClassWizard"? Creating a class inherited from CMenu?
When I tried to adding an event handler to the menu resource via the Event Handler Wizard I only found the messages COMMAND and UPDATE_COMMAND_UI
|
|
|
|
|
blackbondi wrote:
What do you mean with "via ClassWizard"?
Via means by way of.
blackbondi wrote: Creating a class inherited from CMenu?
Among other things, like adding member/control variables, and creating event handlers.
blackbondi wrote: When I tried to adding an event handler to the menu resource via the Event Handler Wizard I only found the messages COMMAND and UPDATE_COMMAND_UI
The list of messages will depend on what object you currently have selected. For you to only be seeing COMMAND and UPDATE_COMMAND_UI, you probably have a menu item selected.
What version of Visual Studio are you using?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes but like so I can't add the event handler for the two messages I want. The version is Visual Studio 2008.
|
|
|
|
|
I even can't inherit a class from CMenu via ClassWizard, because it isn't listed in the "Base class" combobox
|
|
|
|
|
It depends to your work,what do you need?
|
|
|
|
|
I want to implement the messages.
WM_MENURBUTTONUP
WM_MENUDRAG
thx
|
|
|
|
|
|
Hi,
For static menus built during compile time we have to use this macro to map a contiguous range of command IDs to a single message handler function:
ON_COMMAND_RANGE(id1, id2, memberFxn)
But I have a dynamic menu based on database, I use for the item's ID the primary key of the corresponding record. The problem is: I don't know the range of these command IDs, because it's dynamic as I said. Please help me.
Thx
bondi
|
|
|
|
|
I need help with following problem:
I created new project with two Windows Forms called Form1 and Form2. Now, I put on each Form one Button and one Text Box.
The main Form is Form1 which I start the program. When I click Button1, Form2 shows and into Textbox1 in Form2 it puts some text. To do this in Form1 I added code:
#include "Form2.h"
...
private: Form2^ form2;
...
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
form2 = gcnew Form2();
forma2->textBox1->Text="sometext";
forma2->Show();
}
Everything works fine, but..... Now I want do the same in opposite direction. I want to click on Button1 on Form2 and put some text into textbox1 on Form1. How to do this????
I cannot add in Form2 #include "Form1" because it will not compile(There are some errors)
Please help me with this "simple" problem.
Best regards
Szymon
|
|
|
|
|
szymon79 wrote: I cannot add in Form2 #include "Form1" because it will not compile(There are some errors)
Please help me with this "simple" problem.
Your problem is not specific to forms or buttons. You simply do not understand how to include files and design code for inter operation of classes. You should refer to some beginner tutorials or books as a means of learning about fundamental issues such as this. Using text messaging will prove extremely inefficient for this purpose.
In the future, if you have questions about C++ .NET development use the Managed C++/CLI forum
Also take the time to read posting guidelines for CodeProject
|
|
|
|