|
You are a wealth of information, knock on wood!
Heath Stewart wrote:
be sure to install the Office primary interop assemblies
I did. How can I use them? Should they be added to that folder where the mshtml interop assembly is?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Just run the batch script in the PIA folder if you haven't already. This installs them into the Global Assembly Cache (GAC), which makes them available to all .NET applications without having duplicate assemblies in your application folder. For that matter, the Microsoft.mshtml.dll assembly should be in the the GAC as well if you installed VS.NET. The GAC is a far better place to put assemblies that multiple applications could use because it fosters assembly versioning and is non-specific to any one application. You only need to add a reference to these assemblies in VS.NET for your project, then.
IIRC, the Office XP PIAs do not install a registry key that VS.NET uses to find assemblies in folders (the references dialog does not scan the GAC). To do this, open the registry editor (regedit.exe), go to HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders and add a new key with the default value set to the folder in which your PIAs are located. See the other keys there for examples. Restart VS.NET and when you open the Add Reference dialog, you'll them listed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I must be exceptionally dense today. I have a class derived from ListView and I am trying to handle the notification event when the user resizes a column in the header. I tried to capture it in WndProc as follows:
protected override void WndProc(ref Message m)
{
NMHEADER header;
if(m.Msg == 0x004E)
{
header = (NMHEADER) Marshal.PtrToStructure(m.LParam, typeof(NMHEADER));
int code = (int)header.hdr.code;
if(code == -308)
{
}
}
base.WndProc(ref m);
}
What am I doing wrong?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Which line is failing exactly? Is the first conditional block being entered? Is the NMHDR.code not what you expect?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry, I guess I should have been more specific...I put a break in the inner if test like this
<br />
if(code == -308) <br />
{<br />
int i = 0;
}
It never got there, turns out I have two problems...I couldn't trap any header notification message. One problem was that I needed to call the base class WndProc first like this.
<br />
.<br />
.<br />
.<br />
base.WndProc(ref m);<br />
header = (NMHEADER) Marshal.PtrToStructure(m.LParam, typeof(NMHEADER));<br />
.<br />
.<br />
.
Now I can catch every header notification message except the one I want: HDN_TRACK.
I catch the HDN_BEGINTRACK and HDN_ENDTRACK just fine...I'm thinking there is some kind of bug
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
That's odd. I've handled a lot of ListView messages in a couple different classes and have called base.WndProc last in most cases. Even many of the controls in System.Windows.Forms do that. This gives you a chance to handle messages before the base class does, which may void anything you want to do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've built a custom control that displays some objects as text (each text entry is NOT a System.Windows.Forms.Control).
So, after the OnPaint override is called, my control might look like this:
------------
| someText |
| hello |
| blah |
------------
All is well. However, when I write text past the client area of the control, like so:
------------
| someText |
| hello |
| blah |
------------
more text
even more
The last two lines of text that I've drawn are obviously not visible. So, in order to see the last 2 lines of text I've drawn on my control, I need to put in a scrollbar. Using a scrollbar, I can get the last two lines of text to display...however, only if I repaint the whole control, which means that every time I scroll, I need to repaint the control (which results in "flashing").
So, is there a better way to do this? I guess my real question is, what is the normal way to implement custom scrolling?
The graveyards are filled with indispensible men.
|
|
|
|
|
You could just inherit from ScrollableControl , otherwise you're going to have to read-up on the Windows Common Controls[^], primarily the Scroll[^] control. This start getting into the need for Window Handles (the Handle property of a control), the need to override WndProc and more. So, if you don't want to derive from ScrollableControl and override the necessary behavior, you're going to have to learn about Windows programming, messages, and the Common Controls.
BTW, most controls in System.Windows.Forms encapsulate their respective common controls, like the TextBox encapsulates the Edit control. Some controls encapsulate functionality of several common controls. These are complete .NET native solutions like with Java AWT and Swing (which provides a more consistent interface with the window manager, ex. Windows).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I would love to be able to just inherit my control from ScrollableControl and let Windows deal with it. However, since the objects I'm drawing on my control are not System.Windows.Forms.Controls (indeed, I'm just drawing text, not adding controls), the scrollbars never show up, even if I turn on .AutoScroll property. It seems ScrollableControl is used only for a control in which you have actual controls being added to your control...unfortunately I only have text. So, please correct me if I'm wrong, but I don't think ScrollableControl will work in this particular situation unless I'm overlooking something.
I am familiar with Windows programming and the message pump (I've done MFC and ATL development in the past), I was just hoping for an easy solution to the problem. I'll look into the double buffering, though, before jumping into the WinProc override.
As always Heath, thanks for the informative reply.
The graveyards are filled with indispensible men.
|
|
|
|
|
By inheritting from ScrollableControl , you at least get some of the functionality you need, but by no means all of it.
Also, double-buffering is not an alternative to overriding WndProc . Control.SetStyle is something you'd call in your constructor or some other initialization code to enable the three styles that cause .NET to call your painting routines in a separate thread to paint in the back buffer, then to paint that on the screen.
Overriding WndProc is necessary to implement the scrolling. These two things have nothing to do with each other (although you could enabled double-buffering in WndProc yourself, but then you have to handle the back and screen buffers yourself - I'd recommend the latter method).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Oh, and do avoid the flickering, you should use double-buffer painting. See Control.SetStyle and the ControlStyles enumeration for more information. In most cases, the .NET Framework can give this functionality to you for (almost) free so that you don't have to maintain your own back and front buffers (it calls your painting methods in a separate thread and posts them to the screen when available).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm using a web page to send an email to an unknown person online. This email is saved to my local database, and given an offer/order number.
When this person replies, I want to be able to tell that this is the same person.
Currently, I can only think of parsing the subject of the email. So say, my original subject would be "08293: This is the subject". So if the person replies, the subject should naturally be "Re: 08293: This...".
But what if the person does not reply this way? How can I possible track the email?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Most bots stick an extra header in the message, such as a tracking number. NNTP (newsgroups) also do something similar for tracking purposes. You could use the subject, but your parsing algorithm will have to take many different things into account (such as the language of the reply, whether "Re:" is used or another string). So, you'd add a header and your email message would look something like this:
Subject: Welcome. Please Reply.
Content-Type: text/plain
X-TrackingID: 0123456789
Welcome. Please reply to this message so we may verify your email address. Typically, you should prefix your custom SMTP headers with "X", to signify that this is an extended header. You'll see this a lot with things like X-Mailer , X-Priority , etc.
You could further create this tracking ID and store that in the database. When you get an email back, check for the header and update the record in your database using the tracking ID in your WHERE clause or something.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can I circulate through all controls on the form, know which one has a dynamic property, and save all changes to app.config?
In fact, how do I write to app.config in code in the first place?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
There is no support for writing to a .config file like you can read from it in .NET. Being that it is just an XML file, you can use the classes in System.Xml to write to it.
I recommend you DO NOT save your controls to a .config file, though. This is meant for application settings, not necessary serialized content. In order to use the ConfigurationSettings mechanism in .NET effectively, you should also implement the IConfigurationSectionHandler interface so that you can get the configuration object easily using ConfigurationSettings.GetConfig . For a good article on extending this type of behavior, see Nick's article, An extension for a Configuration Settings class in .NET[^].
If you want to do what you need, you'd be better off using serialization. See the System.Xml.Serialization namespace for simple XML serialization, or the System.Runtime.Serialization for more advanced serialization, which probably wouldn't be necessary in your case. For more information on serialization in .NET, see Serializing Objects[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
See the System.Xml.Serialization namespace for simple XML serialization...
Thank you very much, that was so helpful.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Hi,
We have all strings that were not auto-generated stored in special resource files.
I notticed that if the code refers to a non-existent resource string the compiler will not let you know about it, and you will find out things are not right until run time.
Do you know of a way to make the compiler tell me about the resource problems?
Thanks,
Elena
|
|
|
|
|
elena12345 wrote:
Do you know of a way to make the compiler tell me about the resource problems?
Code better
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Yeah, thanks a lot
I am just moving a bunch of code.
And a bunch of resource strings have to move from one file to another.
So I want to make sure I didn't leave anything out.
Don't tell me to architect better. I didn't architect this thing
Elena
|
|
|
|
|
You could have an external application use reflection on your assembly to check for completeness.
You could do something like create string contants in a certain namespace and have this program use reflection on that namespace to get each string constant. It could then use reflection to make sure the resources contain something named the same thing.
You could then make this "check" part of your build.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
The compiler (csc.exe in this case) doesn't care about resource files, just like the resource compiler (resgen.exe) doesn't care about source code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to add a control in a panel from another thread than the on who created the panel.
So in this case I have to use the invoke method on the panel control to do that : this.Controls.Add(...).
My code is working very well on the framework, but with the same code, I have an Argument exception on the Compact Framework.
If Smbd has an id.
Thanks
|
|
|
|
|
MobileLover wrote:
If Smbd has an id.
Make sure the method you are calling via invoke is infact available on the compact framwork.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Yes it is a method written by me !
|
|
|
|
|
I wrote a Form that acts as a slightly more sophisicated MessageBox. The only thing I cant do is make my application wait for the user to make his selection and hit OK before continuing (sp?).
Please let me know if there is an easy way of doing this. Hopefully without sitting in a while loop waiting for a flag.
Thanks,
Matt
|
|
|
|
|