The native pointer can point to any address. Please explain why you want to use native pointer to managed resource? It is very incorrect way. I think you should change your architecture instead of making such a thing. If you want to call managed code (method of managed object) from unmanaged context you should use callback.
Handle can not point to native heap, but IntPtr can.
I have an ActiveX dll compiled in visual studio 2003. and it was working fine with the IE .Recently i have build the activex with VS2005. The same activex works fine now also. But it is showing ATL 8.0 on the center of IE.
Note: this activeX dose not have UI.
Can any one know whats went wrong with VS2005? I know VS2005 has ATL 8.0 version.
The ATL version # is painted by the default OnDraw of CComControlBase (see OnDraw in atlctl.h). So whether you know it or not, you've created a visual control. So you should either override OnDraw yourself and simply return S_OK or change your object derivation to truly be a non-visual control.
I have a series of “Do This” buttons on the main form.
I want to be able to clear the web browser window as each button is clicked so the browser control only displays the result of the last button that was pressed.
As a test, I am calling this Html Line method 5 times. Each call should clear the box and display only the last html line. I’ve tried multiple ways to clear the box, nothing works. At the end of the process all 5 lines are displayed.
What is the proper way to define a web browser box so I can clear it and refill it at will?
System::Void Feedback::HtmlLine ( String ^ showLine )
if ( webBox == nullptr)
webBox->DocumentText = ""; // Does nothing!
webBox->Navigate("about::empty"); // Does nothing!
String ^ fullDisplay = webBox->DocumentText; // Content just keeps growing
int count = 1;
in your first snippet, it is all about webBrowser1.
in your second snippet, it is all about webBox.
If those are distinct, then you're probably looking at one while modifying the other; and if they aren't distinct, you should not have two variable names for the same thing. Cleaner code yields fewer problems.
My suspicion is that you need to wait for the Navigate to finish before doing the Document->Write since Navigate is an asynch operation as I recall. Try moving the code after ->Navigate into a handler for webBox->Navigated event.
First note that it should be "about:blank" not "about::empty". There is just one colon, not two, and use blank instead of empty. You can try all those out in a browser window and if you do I think you will see that you need to use "about:blank".
Next, yes; you must wait for the navigation to complete. The common way to do that is to handle the DocumentComplete event. That event is used so much that it is the default event for the WebBrowser control. In other words, if you double-click on the WebBrowser control in the designer, then a handler for the DocumentComplete event will be automatically added.
I am not sure how to clear the page when you use Write to write HTML. What I would do in my DocumentComplete event handler is to use:
webBrowser1->Document.Body.InnerHtml = showLine;
I have been using C# more than I have been using C++ lately so that syntax might be incorrect but I assume you can fix it if needed.
Note however that you need to wait for the document to be complete only once; after that, you can change the HTML without waiting, but you might need to wait for DocumentComplete event if you need to immediately use the document.
You are trying to declare and implement a variable without any context for it to exist within. Firstly the declaration needs to be inside a class, and secondly the implementation needs to be inside a constructor or other class function.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
I’m creating a window’s form application that will have a series of “do it” buttons and a large scrollable text area for feedback.
The feedback might be something like:
Item 1 completed
Item 2 completed
Warning: I had problems
Item 3 completed
Error: That was a serious problem
Item 4 failed
Item 5 completed
During the feedback I’d want to highlight words like Warning and Error so they pop out.
I tried using a RichTextBox, but it really only allows one selection at a time. I can highlight “Warning” on the fly, but when I try to then highlight “error” I change the selected area and “Warning” goes back to standard text.
My thought was to create a WebBrowser object instead of a RichTextBox object, then format it with HTML. But I can’t seem to find the right syntax to create the browser object, not give it a URL, then be able to build the HTML code on the fly from within my program.
Anyone know of the proper way to create a scrollable text box where I can format the text on the fly as my process runs?
There are many ways to achieve something like that, from simple to very complex:
use a ListBox in OwnerDrawn mode; that will easily allow you to have a homogeneous style for each line of text, meaning you could simply have a line in red, or in a bold font, or ... . An example can be found here[^].
Use a RichTextBox, and make sure to use it correctly. Which means:
- add text, select text, set properties for selected text, unselect;
- rinse and repeat.
Use a WebBrowser; build an HTML document in memory, and assign it to the browser's DocumentText property.
Create your own control, from scratch (based on UserControl or, my preference, Panel); paint everything yourself, and teach it any trick you want.
1. many times I want words in the line to be different, not entire lines.
2. I've looked for ways to "unselect" and the only thing I've found is to select from the end, size 0.
The problem I get is ever time I select a new area to highlight, it un-highlights the previous area.
3. I've tried the WebBrowser approach, it is the most promising. I can create anythign I like with it.
I used the WebBrowser->Document->Write( HtmlCode ) to add lines to the control and all is great -- almost.
My problem is I can't find a way to clear the control for the next "do it" run of the process.
It just keeps appending to the end of what is alreay there.
4. This might be my only answer, but I'd like to avoid it.
RTB coloring is by applying ForeColor/BackColor to text while it is selected; it is NOT the highlighting you get while one piece of text is selected, that merely indicates what is selected, it isn't permanent.
I suggest you search and read some CP articles on text editing in RTBs.
WebBrowser.DocumentText is what is needed in a WB.
Have you overlooked the Multiline property of the RichTextBox? I don't know what the default is but if the RichTextBox is the same as a TextBox then you need to set it to true.
The WebBrowser control and HTML are a little confusing to use initially but they are very useful and worth learning. I wrote the article Introduction to Web Site Scraping[^]. It mostly goes the other direction in the sense of getting from HTML not putting it but it is probably useful for you too.
Actually its my first project in VC++2010. Right now Iam converting my project from C# to VC++2010. In VB.Net I used Modules to use my Public variables and functions to my whole project. And in C# samething I used classes to declare the same accessed in every forms.
Similarly Now I want to use it in VC++2010.. For that any Samples & Codes will be useful for me..
Now Ichanged it as
= static_cast<Microsoft::Office::Interop::Excel::Worksheet^>( MyXLWorkBook->Worksheets->Item);