|
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
|
|
|
|
|
myform frm = new myfrm();
if(frm.Showdialog()==DialogResult.OK)
{
}
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
Looks like you beat me to it this time Mazy.
- Nick Parker My Blog
|
|
|
|
|
Nick Parker wrote:
Looks like you beat me to it this time Mazy.
Yah, I exercise a lot to beat competitor.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
spindar wrote:
Please let me know if there is an easy way of doing this. Hopefully without sitting in a while loop waiting for a flag.
Have you looked into the DialogResult enum? You can do things like this (similar to how the MessageBox works):
Form2 fr = new Form2();
if(fr.ShowDialog().Equals(DialogResult.OK))
{
MessageBox.Show("Hey");
}
- Nick Parker My Blog
|
|
|
|
|
Thanks for the help and the fast response
Matt
|
|
|
|
|
Sorry for the basic post, but I have looked everywhere and I can't figure out if this is possible or not. I am wondering if it is possible to check and variable to see if it is between certain ranges of numbers using a switch statement.
Ex:
switch (int){
case (between 1 and 10):
case (between 11 and 20:
and so on. Let me know if know.
Jason
|
|
|
|
|
you can preprocess the number a bit beforehand like switch(int/10)
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Another way is to combine (encode) 2 numbers into 1 eg:
Required range: 22-63
int range = (22 << 16) + (63 & 0xFFFF);
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|