|
I figured it out I was looping the call to the OnPaint() and inside I used a graphics object. I mistakenly Dispose()'ed of the PaintEvenArg instead of the graphics object.. I guess it doesn't like that because I took the call to Dispose() out and it works fine now
|
|
|
|
|
You have to do it like this:
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
Each successive call to SetStyle eleminates the previous setting and changes it to the new one. So, essentially, your just calling SetStyle(ControlStyles.DoubleBuffer). Because double buffering has to be used in conjunction with UserPaint and AllPaintingInWmPaint, you get the error Invalid Argument Used. Using a bitwise or, you combine the values of all three into one setting.
Hope this helps.
|
|
|
|
|
Hi!
I'm looking for some samples how to write an IRC client in C#.
Have someone any samples?
thx!
|
|
|
|
|
|
Hi,
I've have a tree view control that displays a scene graph (a collection of polygons, materials etc). I would like each type of object to have it's own context menu, for example, if the user right clicks on a node, it should check the 'Tag' property of the node, and if it is of a certain type it should show a certain context menu. Do I have to create a class derived from TreeView for this, or can I do it another way?
Dave Kerr
focus_business@hotmail.com
www.focus.esmartweb.com
|
|
|
|
|
|
Heck, I'm still trying to set up the djgpp thingy so I can do the "hello world " thing.
A lot of basic and a bit of pascal. None of which works in windows.
I need a plotter driver to run a home made plotter. It's a simple one run from the
printer port. Nothing fancy at all. A lot of other "hobby" folks would like to get it too.
I woulldn't mind trying to write it myself as a excuse to learn more about C.
Anybody interested in helping?
I made the interface boards and they work fine in dos mode with,yeck, basic.
Steppers are 400 steps per rotation 119 in.oz.
No, I don't realy expect anybody to come up for air on this.
Thanks anyway.
GaryR
|
|
|
|
|
I would start simpl (Hello World), then work your way up to the Plotter Driver. When you have questions, this is a good place to post your problems. Have fun!
Joan
|
|
|
|
|
Thanks Joan for the fast reply. Simple is the key word for sure.
It toke for ever to find the most basic starting level info on working with the printer and con ports.
For others that read this looking for the same. A lot of surplus electroics places have a book,
Controling the World with Your PC by Paul Burgsman. It costs like $35 and is well worth it. It has a disc
with excutables as well as hard copy in basic,pascal, and c. This is in dos mode not windows.
I want to take it into windows. No, I don't have VB, only wish I did.
Between the book and this forum, I don't expect many problems. The chore will be getting it into a GUI
so somebody other than myself can easly use it. I'm thinking cheap shareware or freeware.
At the moment the most popular method is to use the hp7475a driver and plott to file, them use a dos
program to print the plt file on the homemade plotter through the paralle (printer) port.
The mechanics and electronics were easy, that I have a degree in. Programing for windows
will be........interesting.
GaryR
|
|
|
|
|
How to create an image list from a resoruce biutmap.
It's along the lines Bitmap.FromResource, and Imagelist.Images.AddStrip, but I'm lacking some syntax here.
Also, I can add a "resource template" to the project, but the "Resource View" tab remains empty. What's that?
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
Here is one way to do it. First, make sure your image resource is marked as "Embedded Resource".
Assembly thisAssembly = Assembly.GetAssembly(Type.GetType("Sample.Namespace.SomeForm"));
Stream bmpStream = thisAssembly.GetManifestResourceStream(Sample.Namespace.ResourceName");
Bitmap bmp = new Bitmap(bmpStream);
ImageList.Images.AddString(bmp);
|
|
|
|
|
Hi,
I've been having loads of problems with collections in C#. Up to now, my main class in my program has stored large amounts of data (vertices, polygons etc) in ArrayList's. I'd like to be able to use the Collection Editor from the properties window though, and to do that I realise I need a specific collection for each object. However, I've tried deriving from CollectionBase, and half the function's I've used with ArrayList don't work, then I tried deriving from ArrayList and the program crashed.
I'd really like to just derive from ArrayList and make the collection type specific, can I do this? Or do I have to derive from CollectionBase, and if so, what code must I implement to make it work like ArrayList? I know where to go from there, using custom collection editors, but first I need my custom collection!
Any Ideas?
Dave Kerr
focus_business@hotmail.com
www.focus.esmartweb.com
|
|
|
|
|
Here's all you need (you can obvious add some more methods):
public class MyTypeCollection: System.Collections.CollectionBase
{
public MyTypeCollection(){}
public virtual void Add(MyType value)
{
this.List.Add(value);
}
public virtual MyType this[int index]
{
get {return (MyType) this.List[index];}
set {this.List[index] = value;}
}
public virtual void Remove(MyType value)
{
this.List.Remove(value);
}
}
Nice typed collection with Collection Editor support.
DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET
|
|
|
|
|
Cheers that worked great! I didn't have to change any of the code at all, just replaced 'ArrayList' with 'VertexCollection' and it worked fine.
Thanks very much!
Dave Kerr
focus_business@hotmail.com
www.focus.esmartweb.com
|
|
|
|
|
I am planning a ROM database in C# as hobby project. It may be usefull in retrieving big amounts of non transactional data from CD-ROM or disk file. I know Ms Access is an alternative but as I said it is a hobby project, more Access is not safe enough and brings a lot of overhead.
I may start with saving data into dataset objects, so that when I retrieve it , I can bind it into my win controls right away, anyway I would be retrieving them from database in datasets anyway.
I could save my data into dataset objects and serialize them but they become too big , and retrieving just one line of code would require loading a big file into memory.
Or I can split data and save chunks into numerous dataset objects and putting all these objects in a random access file, than building a hash table / index and saving it into the database. I assume this would minimize schema troubles and shift responsibility to ADO.NET in managing schema in Dataset.
I want your advise on this subject, may be totally different suggestions.
|
|
|
|
|
Is there a way to programmatically move a splitter control? I tried setting it's location, didn't work. I tried setting the size of one of the panels but that didn't work either.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Say you want the panels divided vertically with a splitter control in between.
Dock the panelLeft as Fill
Dock panelRight as Right
Dock the splitter as Right
Programmatically change the size of panelRight with panelRight.Width
This should work.
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
Thanks, but it doesn't work.
Form f=new Form();
Panel pf=new Panel();
pf.Dock=DockStyle.Fill;
f.Add(pf);
Splitter s=new Splitter();
s.Dock=DocStyle.Top;
f.Add(s);
Panel pt=new Panel();
pt.Dock=DockStyle.Top;
f.Add(pt);
I have a form with two panels and a splitter inbetween. I can click on the splitter and move it around ok. when I change the size of either or both of the panels, their size does change, but the splitter stays put. If any gap is created it just gets the background color of the Form.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
|
Bog wrote
Thanks, but it doesn't work.
Are you using the IDE? If not, editI think) you need to add event handlers to repaint the screen when a panel is resized. (
I used the IDE and it worked fine.
Using the toolbox, add two panels and a splitter. Make sure you add these components to the form and not to one of the other components
Name them pTop, pBottom and s
Set the properties (using the property window) of each as follows:
-----------Dock------BackColor
pTop-------Fill------White
s----------Bottom----Black
pBottom----Bottom----Yellow
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
Try this:
using System;
using System.Windows.Forms;
namespace TestSplitter4
{
///
/// Summary description for Splitter4.
///
public class Splitter4 :System.Windows.Forms.Form
{
public Splitter4()
{
Panel pTop = new Panel();
pTop.Dock = DockStyle.Fill;
pTop.BackColor = System.Drawing.Color.White;
Splitter s = new Splitter();
s.Dock = DockStyle.Bottom;
Panel pBottom = new Panel();
pBottom.Dock = DockStyle.Bottom;
pBottom.BackColor = System.Drawing.Color.Aqua;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
pTop,
s,
pBottom
});
}
public static void Main()
{
System.Windows.Forms.Application.Run( new Splitter4 ());
}
}
}
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
thank you Donald for all your attemps so far,
This works fine- but what I want to do is programmatically move the splitter.
Like, say the user clicks a button- the splitter changes it's location down 5 pixels, as if the user had clicked it and dragged. I've tried doing this by changing the height of either of the panels that the splitter is splitting- but what happens is, the panel sizes do change, but the splitter stays put.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
in an event, change the size of the panel that is not DockStyle.Fill
private void button2_Click(object sender, System.EventArgs e)
{
panel2.Height += 5;
}
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
I had a similar problem, and I posted my question to the newsgroup microsoft.public.dotnet.framework.windowsforms.controls on the news server news.microsoft.com
What worked was to change the SplitPostion of the splitter control.
Hope this helps,
Dominique
|
|
|
|
|
I'm writing an app that will do things like display entries from the event log and a few other things. It cycles through 3 event logs, showing errors and warnings in a datagrid.
I was testing out the main app when I happened to have taskmanager (seen end note) open and saw that it was using 40+ meg for a program that was doing nothing really. This got me chasing down why it was using so much memory. So I reduce my program into a smaller set of features, with no add-on dll's and made a small test harness to log memory usage. This showed that on my win2k development server the program ran fine for an hour (<20 meg usage) but in the second hour it hit 40+ meg 3 times. I also ran it on my rc1 .net server and it show memory usage of 180+ meg in 30 mins. I then added in a check call the GC when the memory usage was over a fixed value (~16 meg) and logged whether this was called or not.
The logs showed that on my Win2k server the memory usage continued to climb even though the GC was called every tick of the timer. On my WInXP machine, the GC was called more frequently as time went on, but it stayed around the 16 meg limit.
Has anyone else seen something similar to this? It has frankly driven me up the wall so much I’ve put this project on hold while I write another app and hopefully find a fix for it.
Any one interested in helping or looking at the source, please contact me here or email me ( omega501@hotmail.com ) with a subject of "Request Source" so I don't delete it out of hand
Note: Taskmanager reports memory usage of running apps very badly. It doesn't show how much memory they are currently using, it shows how much it thinks the program will need ( I think). To verify this, open an app (word or similar, something big) and then open taskmanager, select the process tab and find the app you have just run. Select it (so it's easier to find) and then with task manager still open, minimize the app - I did this to MS Word and the memory usage went from 15 meg to 400k instantly - now I make all my .net apps check their own memory
|
|
|
|