
aewarnick
Avatar/Signature-
Posts
1052 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by aewarnick
-
It is a waste to create a graphics object when one is sent to OnPaint.
-
C++ speed is not consistant and C# is. Why?
aewarnick replied to aewarnick's topic in Interoperation / Office Integration
Let me explain better. I used Dev-C++ to create the C++ app and it has no runtimes. I am not using debug and Dev doesn't even have to be open for this weird thing to happen. I posted the same question here: http://www.vbforums.com/showthread.php?s=&threadid=271594 -
This is actually, in my opinion, a very weird happening. I have a c++ program that stretches an image in the entire window and then draws that same image at normal size whereever the mouse moves. It works great and fast if I have another large program open like VS. But if I just have dev and the program running the drawing is slower than C# is. But C# remains the same. Is there something that .net does that my little c++ app does not that could cause that wierdness?
-
I was surprised when no build errors were shown when using << and even more surprised when the code worked correctly! What is << in C#?
-
Inheritance with a constructor that takes arguments problem
aewarnick replied to aewarnick's topic in Visual C# .NET
Thanks. Never saw that before. I'll try it out. -
Stream s= System.Reflection.Assembly.GetCallingAssembly().GetManifestResourceStream("YourNamespace.Treasure.jpg"); Bitmap b= (Bitmap)Bitmap.FromStream(s); Also, Stream is located in the System.IO namespace.
-
That was actually part of a whole method sub or function. All you need is Stream s= System.Reflection.Assembly.GetCallingAssembly().GetManifestResourceStream(name); Bitmap b= (Bitmap)Bitmap.FromStream(s);
-
If you are going to do that though, make sure you use a compressed image format because they will be embedded exactly as they are with the same size and bytes. Then you can get the images like this: Stream s= System.Reflection.Assembly.GetCallingAssembly().GetManifestResourceStream(name); if(s==null) return null; return (Bitmap)Bitmap.FromStream(s); name is the namespace of your project followed by a dot, then the exact name of the file including the extention. Mine would be AW.embeddedImage.png
-
Ok, I'll explain exactly what I am doing. I have a Form that I use to test my code, I create it initially, then keep a pointer to the hwnd. From then on, I use the handle to access the Form's TextBox where I display variables values of the Form that I am testing. The problem is that when I change the text on the text box, it steals the focus from the form I am testing.
-
Is there a way to remove focus from a control or window with code?
-
Pen object Width property does not seem to be in pixels
aewarnick replied to aewarnick's topic in Graphics and Multimedia
Yes, I found that it was not the Pen it was how DrawRectangle draws the lines!!!! It is very annoying!!!!!!! Here is the rectangle I have to use to draw a border: this.BorderRect=new Rectangle(this.borderWidth/2, this.borderWidth/2, this.Size.Width-this.borderWidth, this.Size.Height-this.borderWidth); The top and left edges start the line in the middle and move out half and half. The right and bottom edges start on the inside and draw out!! Why? -
The problem you are facing is the difference between .net and C++. I did a drawing test on this topic myself. You can download these programs and see for yourself. Here are the links: You can trust each program. I did nothing wierd or nasty. You must unzip all three, put them in the same folder and then use the merge file located in the 3rd Chunk to put the file together again. There are directions in the download on how to use the drawing tests. 1st Chunk 2nd Chunk 3rd Chunk If you have problems and are interested, let me know. I can e-mail the programs too.
-
The Items property. foreach(string s in this.ListBox1.Items) { MessageBox.Show(s); } or for(int i=0; i<this.ListBox1.Items.Count; i++) { MessageBox.Show(this.ListBox1.Items+""); }
-
Inheritance with a constructor that takes arguments problem
aewarnick replied to aewarnick's topic in Visual C# .NET
Yes, that will solve my problem. Thanks. -
class Inherit : c1 { Inherit(){} // calls c1() constructor but not c1(string argument) //which messes things up. //How would I call the constructor with an argument in the base class? } class c1 : UserControl { public c1(){} public c1(string argument) { // argument is used here and is important! } }
-
Does anyone know how to disable the feature of AutoScroll that causes a control to be automatically scrolled into veiw when it is focused? I declared this in my class, overriding the base class method but the control still scrolls down when the focused control is out of view. void ScrollControlIntoView(Control c) { //did nothing here hoping to fix the problem. } That is my FIRST question. The second is this: I have a feeling, disabling that feature is impossible. So I have created my own scolling panel derived from Panel. Everything works greate except when I resize a control within the panel with the mouse movement. I really get issues then even if I only move the mouse one pixel down, making the control one pixel bigger. But when I resize the control any other way everything works great! What is going on!? Here is the Panel class: public class aPanel : Panel { bool causedByScroll=false; ArrayList controlList=new ArrayList(2); ArrayList pointsList=new ArrayList(2); Rectangle controlsRect= Rectangle.Empty; VScrollBar vScrollBar=new VScrollBar(); HScrollBar hScrollBar=new HScrollBar(); bool autoScroll=true; public bool AutoScroll { get{return this.autoScroll;} set{this.autoScroll=value; this.SetBars();} } //----------------- public aPanel() { this.Controls.Add(this.vScrollBar); this.Controls.Add(this.hScrollBar); this.vScrollBar.Scroll += new ScrollEventHandler(this.vScrollBar_Scroll); this.hScrollBar.Scroll += new ScrollEventHandler(this.hScrollBar_Scroll); this.MouseUp += new MouseEventHandler(this.mouseUp); } //----------------- void SetBars() { if(causedByScroll) return; if(this.controlsRect.Height > this.Height) { this.vScrollBar.SetBounds(this.Width-this.vScrollBar.Width, 0, this.vScrollBar.Width, this.Height); //this.vScrollBar.Minimum= this.hScrollBar.Height*2-this.ClientRectangle.Height; //this.vScrollBar.Maximum= this.controlsRect.Height; this.vScrollBar.Maximum= this.controlsRect.Height+this.hScrollBar.Height*2-this.ClientRectangle.Height; this.vScrollBar.Visible=true; } else { this.vScrollBar.Value=0; this.vScroll(0); this.vScrollBar.Visible=false; } if(this.controlsRect.Width > this.Width) { this.hScrollBar.SetBounds(0, this.Height-this.hScrollBar.Height, this.Width-this.vScrollBar.Width, this.hScrollBar.Height); this.hScrollBar.Visible=true; } else { this.hScrollBar.Value=0; this.hScroll(0); this.hScrollBar.Visible=false; } } //----------------- void vScrollBar_Scroll(object s, ScrollEventArgs e) { this.vScroll(e.NewValue); } //----------------- void hScrollBar_Scroll(object s, ScrollEventArgs e) { } //----------------- void vScroll(int v) { this.causedByScroll=true; for(int i=0; i<this.controlList.Count; i++) { ((Control)this.controlList[i]).Location=new Point(((Control)this.controlList[i]).Location.X, ((Point)this.pointsList[i]).Y-v); } this.causedByScroll=false; } //----------------- void hScroll(int v) { } //----------------- protected override void OnMouseWheel(MouseEventArgs e) { if(!this.vScrollBar.Visible) return; base.OnMouseWheel(e); int v= this.vScrollBar.Value+-e.Delta; if(v > this.vScrollBar.Maximum) v= this.vScrollBar.Maximum; else if(v < this.vScrollBar.Minimum) v= this.vScrollBar.Minimum; this.vScrollBar.Value= v; this.vScroll(this.vScrollBar.Value); } //----------------- protected override void OnLayout(LayoutEventArgs e) { base.OnLayout(e); if(e.AffectedControl==null || this.causedByScroll || e.AffectedControl is ScrollBar || e.AffectedControl==this || e.AffectedProperty != "Bounds") return; if(!this.AutoScroll) { this.vScrollBar.Visible=false; this.hScrollBar.Visible=false; return; } int index= this.controlList.IndexOf(e.AffectedControl); if(index > -1) //location may have changed { //this.vScrollBar.Value=0; //this.vScroll(0); if(((Point)this.pointsList[index]).Y != e.AffectedControl.Location.Y+this.vScrollBar.Value) { //a.MB.Show(e.AffectedControl.Location.Y+" val="+this.vScrollBar.Value+" max="+this.vScrollBar.Maximum+" pt="+((Point)this.pointsList[index]).Y); this.pointsList[index]=new Point(e.AffectedControl.Location.X, e.AffectedControl.Location.Y); } } else { this.controlList.Add(e.AffectedControl); this.pointsList.Add(new Point(e.AffectedControl.Location.X, e.AffectedControl.Location.Y)); } this.controlsRect= Rectangle.Empty; for(int i=0; i<this.controlList.Count; i++) { Control c= (Control)this.controlList[i]; Point p= (Point)this.pointsList[i]; if(p.Y < this.controlsRect.Y) this.controlsRect.Y= p.Y; if(p.X < this.controlsRect.X) this.controlsRect.X= p.X; if(p.Y+c.Height+this.AutoScrollMargin.Height > this.controlsRect.Bottom) this.controlsRect.Height= p.Y+c.Height+this.AutoScrollMargin.Height; if(p.X+c.Width+this.AutoScrollMargin.Width > this.controlsRect.Right) this.controlsRect.Width= p.X+c.Width+this.AutoScrollMargin.Width; } this.SetBars(); } //----------------- void mouseUp(object s, MouseEventArgs e) { if(this.vScrollBar.Visible) this.vScrollBar.Focus(); } } I think Microsoft came accross the same problem because when I use AutoScroll and resize a control with the mouse, the Value of the ScrollBar is set to 0 thus eliminating the problem. I would think that ms would have come up with better scrolling features than that. Does anyone know how to fix this problem or know of any better scrolling controls or how to make the mouse wait?
-
My processor is a celeron 533 mghz. Ram 128 mb. Not much compared to today's standards. I though about using regions. I guess I'll try it.
-
The code is 8500 lines long. For simplicity of coding is why I have not split it up. I just type a. and the whole list of everything pops up.
-
Ok, got somewhere but don't really understand why the above does not work. Here is what I had to do: I created a method in Class WrappedBmp called Assign. When I call that and send wb to it, it works. Why doesn't the above code work?
-
I got it to work but found that I cannot pass pointers to managed types, which makes sense. The reason I was trying to use pointers was that I cannot assign a class to a class. Here is the edit method: void Edit() { if(this.surface.selWB==null) return; a.graphics.WrappedBmp wb=new a.graphics.WrappedBmp(this.surface.selWB); EditForm f=new EditForm(this.surface, ref wb); if(DialogResult.Yes==f.ShowDialog()) { this.surface.selWB= wb; this.surface.Invalidate(); this.needsSaved=true; } f.Dispose(); } In EditForm f, wb is directly modified and IS actually changed, HOWEVER, when I assign this.surface.selWB= wb; selWB does NOT change. There are no errors, just nothing! But if when I initialize wb like this: a.graphics.WrappedBmp wb= this.surface.selWB; this.surface.selWB IS changed from the EditForm. And is what I don't want. I want a new instance of WrappedBitmap to be directly changed and then assign that to this.surface.selWB only if EditForm returns Yes. Why doesn't wb when it is a new instance and modified by EditForm change selWB when it is assigned to it?? ie.. the full code above.
-
How do I make an unsafe constructor??
-
C# windows project. Class code, form code...