|
Hi novachen,
I dont know why this is happening, but to explicitly break at some point, instead of using a breakpoint, try using System.Diagnostics.Debugger.Break();
Do let me know if it helps..
Cheers,
Rahul
I do not understand what I do. For what I want to do I do not do, but what I hate I do. - Romans 7:15
|
|
|
|
|
Hi,
Is there any way I can make panel corners rouhd, whithout using any kind of image?
Thanks
|
|
|
|
|
Derive from Panel and override OnPaint using various methods from the Graphics object that is passed to you in the PaintEventArgs . Depending on how you do it (and how much you want to paint), you may need to set various control styles in your constructor. See Control.SetStyle and ControlStyles for information about what each style is used for.
Specifically, see Graphics.DrawArc .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I found it does not work when I wrote a mybutton inherited from Button class and use mybutton.Click += new System.EventHandler(functionname), and nothing respond.
So who can tell me how to deal with it.
|
|
|
|
|
chq12 wrote:
So who can tell me how to deal with it.
See the reply below!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
|
Did you override any ControlStyles with Control.SetStyle ? If not, you overwrote some other functionality and caused the button control to not get notification of click events. What else did you do to it?
And, yes, everything inherited is still callable from derivitive classes unless overridden or hidden (through the new modifier for non-virtual methods / properties). That why you should look to see what else you did the derivitive button class. For instance, if you used SetStyle(ControlStyles.Selectable, false) , the click even shouldn't fire anymore. Overridding WndProc is especially dangerous if you don't forward non-handled messages back to the base (with base.WndProc ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I override some method, such as OnMouseUp, OnMouseLeave, OnMouseEnter and OnMouseDown, following is the code. Someone told me I should call base method, But how can i call it? or it is from other problem.
myButton testbutton = new myButton("test", new Rectangle(0,0, 45, 45));
this.testbutton.Click += new System.EventHandler(testbutton_click);
class myButton : System.Windows.Forms.Button{
int ShowType;
Brush backBrush;
Brush textBrush;
Font myFont;
public myButton(String title, Rectangle rect){
backBrush = System.Drawing.Brushes.Violet;
textBrush = System.Drawing.Brushes.Green;
myFont = new Font(FontFamily.GenericSerif, 18, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Pixel);
this.Bounds = rect;
this.Text = title;
GraphicsPath myPath = new GraphicsPath();
Rectangle rect1 = new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height);
myPath.StartFigure();
myPath.AddArc(rect1, 0, 360);
myPath.CloseFigure();
this.Region = new Region(myPath);
ShowType = 0;
}
protected override void OnMouseEnter(EventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Green;
ShowType = 0;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e){
backBrush = System.Drawing.Brushes.Violet;
textBrush = System.Drawing.Brushes.Blue;
ShowType = 0;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Blue;
ShowType = 1;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Red;
ShowType = 0;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
SizeF mySizeF = e.Graphics.MeasureString(this.Text, myFont);
e.Graphics.FillRectangle(backBrush, new Rectangle(0, 0, this.Width, this.Height));
if(ShowType==1)
e.Graphics.DrawEllipse(System.Drawing.Pens.Red, new Rectangle(0, 0, this.Width, this.Height));
int offwidth = (int) ((this.Width - mySizeF.Width)/2);
int offheight = (int) ((this.Height-mySizeF.Height)/2);
e.Graphics.DrawString(this.Text, myFont, textBrush, offwidth, offheight);
}
}
|
|
|
|
|
If you're overriding those and not calling the base class's implementation, there's your problem. Unless you have a VERY good reason to not call the base class (such as handling EVERYTHING in your override), always call the base class's implementation, either before or after your code (depending on what's important, but usually doesn't matter).
To do so, just use the base reference:
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
} . See? Not hard at all.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
yes, it worked, thanks very much
|
|
|
|
|
Hi,
I have searched here and google but cannot find what I am looking for. I have a status bar,richtextbox and menu control in my application. The rtb is set to fill the form, which docks it between the bottom of the form and the bottom of the menu. When the status bar is active it appears at the bottom of the form.
Now my problem is when the status bar is active(visable) it goes over my rtb covering up a the hscrollbar. I am wondering if there is anyway i can get the rtb to dock to the top of the status bar like it does to the bottom of the menu.
Thanks alot in advance.
ps. if anyone is wondering its a notepad clone, so i can gain skill with C#.
|
|
|
|
|
Try right clicking on the object that is covering up your object and click "Send to Back". It sounds like a simple layering issue.
|
|
|
|
|
Thanks a ton, This helped me solve the problem. Which was I was loading the status bar before the rtb. Your Layering suggestion solved it. Thanks alot.
|
|
|
|
|
I wrote a inherit button, myButton, when I used click event for myButton, I found it did not work, no event response. if I changed it to button, it work very well, then what's wrong is it? should i override onclick method or anything else I need to do?
myButton testbutton = new myButton("test", new Rectangle(0,0, 45, 45));
this.testbutton.Click += new System.EventHandler(testbutton_click);
class myButton : System.Windows.Forms.Button{
int ShowType;
Brush backBrush;
Brush textBrush;
Font myFont;
public myButton(String title, Rectangle rect){
backBrush = System.Drawing.Brushes.Violet;
textBrush = System.Drawing.Brushes.Green;
myFont = new Font(FontFamily.GenericSerif, 18, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Pixel);
this.Bounds = rect;
this.Text = title;
GraphicsPath myPath = new GraphicsPath();
Rectangle rect1 = new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height);
myPath.StartFigure();
myPath.AddArc(rect1, 0, 360);
myPath.CloseFigure();
this.Region = new Region(myPath);
ShowType = 0;
}
protected override void OnMouseEnter(EventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Green;
ShowType = 0;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e){
backBrush = System.Drawing.Brushes.Violet;
textBrush = System.Drawing.Brushes.Blue;
ShowType = 0;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Blue;
ShowType = 1;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Red;
ShowType = 0;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
SizeF mySizeF = e.Graphics.MeasureString(this.Text, myFont);
e.Graphics.FillRectangle(backBrush, new Rectangle(0, 0, this.Width, this.Height));
if(ShowType==1)
e.Graphics.DrawEllipse(System.Drawing.Pens.Red, new Rectangle(0, 0, this.Width, this.Height));
int offwidth = (int) ((this.Width - mySizeF.Width)/2);
int offheight = (int) ((this.Height-mySizeF.Height)/2);
e.Graphics.DrawString(this.Text, myFont, textBrush, offwidth, offheight);
}
}
|
|
|
|
|
when you did the override on the mouse actions you forgot to call the base - my guess
|
|
|
|
|
But I did not override Onclick method.
I just used myButton like myButton.Click += new -----like a normal button, and I thought it should work because it inherit from button. However it did not respond to this click event. I do not know why? and should I override OnClick method?
|
|
|
|
|
By not calling the base class method for other mouse messages, you are suppressing the normal behaviour of the object. It doesn't "see" mouse-up or mouse-down events, so cannot generate a click event.
Steve S
|
|
|
|
|
What happens in this situation...
I have
class A
{
public static DataType variable;
public static DataType MyFunction()
{
}
}
and I read the variable from 2 threads at the same time or eventually call the function from two thread at simulatenously. Will the program crash?
If so, how do I synchronize it in C#?
Thanx
--------
Dave
|
|
|
|
|
Right now it won't even compile, because MyFunction doesn't return a value.
The program won't crash, but you will have the normal synchronization issues: possible 'dirty read', etc. If those are to be avoided, use synchronization. If not, don't use it.
Synchronization in C# is done mainly through the use of the lock keyword and the calls Monitor.Enter(object) and Monitor.Exit(object) . Unless you specifically need to use interlocking synchronized sections or span methods with a synchronized context, my advice is to just use the lock . Its use is the same as that of the synchronized keyword in Java.
I recommend checking out all the classes in the System.Threading namespace and making sure that you understand their uses before continuing on. Also, I recommend that you buy a good book or two on C# and .NET basics at the first opportunity.
Regards,
Jeff Varszegi
|
|
|
|
|
I know it wouldn't compile
I have solved it using lock and property, but what was I looking for was something like an attribute or so. Nevermind.
Thanx
--------
Dave
|
|
|
|
|
|
I'm writing an IMAP client program to read and display content of e-mails from IMAP servers. I use the command FETCH to read the headers and bodies of these mails and displays them in a text box. But when emails includes
MIME parts, it cannot work correctly. For example when e-mail includes images, the textbox shows only Base64 code. Is there any component other than text box to display MIME parts without writing many codes? Help me, please.
Thanx in advance
|
|
|
|
|
Instead of using a TextBox, why not use the WebBrowser control in cases of HTML mail? If you just want to handle plain-text, you'll have to search for the MIME part using the Content-Type "text/plain", if any. Some readers (mostly based on user preferences) send messages in both plain text and HTML, but other still send only plain text or only HTML. The Content-Type of the message will tell you what it contains. If it is "multipart/alternative" (there's other "multipart" types, see MSDN for details) then search for "text/plain".
If you choose to use MSHTML or the WebBrowser control, it's not a walk in the park. For each image and the like, you have to base64-decode the data and save it as a file. In the HTML, each request to the file has to be mapped correctly so it appears in text. There's other ways to do this, too (IE supports MHTML, which is a manifest format, which is just multipart MIME with the proper MIME type associated with the file).
It just all depends on what you want to do and how much you want to support.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanx but I dont know how to extract body parts of e-mails. In the header the boundary can be xxx but in the body the boundaries can be yyy, zzz ... and xxx. How can I resolve this problem?
|
|
|
|
|