|
Make sure you call Dispose() on any Graphics objects you create. A great way to make sure of this is to use a using{} statement:
using(Control.CreateGraphics())
{
...
}
|
|
|
|
|
First of all thanks for your replies...
Well I found the source of my problem.
I just wasn't thinking strait....
It actullay din't have anything to do with the program running out of (free) memory, instead it the problem was, that (due to a programming error) it tried to read memory which I hadn't allocated....
|
|
|
|
|
which (kind of) functions actually create graphics objects?
any font/brush/rect created with new?
:wq
|
|
|
|
|
I'm not really sure waht you mean when you say graphics objects...
Of course a font and brush etc., are graphics objects, but they are (I think) only tools. The graphics object (the actual one, which does the drawing and stuff) can be obtained from the OnPaintArg's
Graphics gr = new e.graphics (though still i'm not sure, if this is all correct)
|
|
|
|
|
exactly my problem - i thought the garbage collection is doing things for me.
hmm. i will search my code for 'possible' real graphics objects i need to dispose...
:wq
|
|
|
|
|
I meet the same problem when I want to write a ownerdraw menuitem, I find the steps to cause "Out of memory":
1.Override the "OnDrawItem", you can write nothing but "base.OnDrawItem(e)" clause;
2.Set a break point at the clause;
3.Start to run with debug (F5);
4.When the program runs to the break point, just wait for a moment (1~3minutes)to go to next step;
5.Now you can try to open a desktop's popmenu by right-clicking mouse, maybe you will see nothing because the system has no memory to draw it, when you move mouse to the place you think the popmenu will display, the system will try to draw it.
The classic phenomenon of gdi resource insufficient now appears.
6.Try the above steps for several times, "Out of memory" will occur
But I have nothing to do in "OnDrawItem"!!!!!
I'm amumu, and you?
|
|
|
|
|
Greetings!!!
I was thinking, isn't it possible to change the coordinate system of the form, like in vb, so that (0,0) is in the bottom left corner???
|
|
|
|
|
I doubt it, but it would be a trivial thing to do on your own.
What do you want to do this for anyway?
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
Sounds like your making a graph. Well, whatever it is, you could easily write a translation function. I don't know what the properties and function names are, but the following pseudo-code should give you the idea
Point TranslatePoint(Point p)
{
Point q;
q.x = p.x;
q.y = Window.Height - p.y;
return q;
}
|
|
|
|
|
Look at Graphics.Transform property. This will help you specify a tranformation matrix that you can use.
I have never wasted time worrying about such insignificant things. Keep your eye upon the donut and NOT upon the hole. - Bill Sergio about posting in the right forum. The Lounge - June 23, 2002
|
|
|
|
|
Well what i'm gonna use it for is just to play around with some basic game physics (very basic).
I'm quite new at C# so I din't know if there was a funktion that could alter the coordinate system of the form, like in vb...
I just figuered that it would be the easist approch.....
Well thanks again....
|
|
|
|
|
Hallo everybody...
Is there anyone who knows a place where I can find out something about the conventions, such a variable naming....
|
|
|
|
|
There are two convention style for vb / c#
camelCase: <- justLikeThis
and
PascalCase: <- JustLikeThis
in vb & c# we dont use strange names. just use long names if it make sourcecode easy to understand. dont use ALL_CAPS_WITH_UNDERSCORES. in mfc people use the m_ prefix with all vars buts its m_difficult m_tootype m_like m_this.
|
|
|
|
|
yes, in/on MSDN
|
|
|
|
|
Hi all,
Can I put a ComboBox into ListView? If possible, please let me know the way to do it.
Thanks very much.
|
|
|
|
|
I dont quite get what you are trying to do.
But i think your trying to do something like the properties window in visual studio.
There is a control called PropertySheet, you can try it out.
|
|
|
|
|
On a form I have a treeView control on the left and an empty panel at the right.
An ArrayList holds 100 instances of a control I've made in another class.
On every "AfterSelect" event fired from the treeView, a control from the ArrayList is added to the panel,according to the index of the selected node. When the user selects another node, the previous control is hiden via "this.panel1.Controls.Clear()" and the new one is added via "this.panel1.Controls.Add(control)".
These controls I add and clear have a button on them. Now here is the problem:
If the user selects node 1, then node 2, then clicks the x button of the form, the form disposes normally.
If the user selects node 1, then click the button on control 1, then selects node 2, then clicks the clicks the x button of the form, the form does not dispose (the event is never fired.)
If the same scenario as above is followed, but before clicking the x button the user selects node 1 again, (then click x button) the form disposes.
The button click from the controls do nothing! (there's no code there).
Has anyone any ideas?
If you need the project to have a look at it, tell me so.
Thank you in advance for your time,
SM
|
|
|
|
|
Hello world..... Well close enough....
Well my problem is that I can't figure out how to take a piece of a bitmap (stored in a picturebox... or whereever), and copy this to another picturebox, or event better: Directly to the screen.
also I would like to be able to flip this image....
Hope you can / will help
>
|
|
|
|
|
|
Hi, perhaps someone can help me...
I run a query like this:
string str = "SELECT LOG.Type, LOG.Time, LOG.Nick, LOG.Message FROM LOG WHERE (((LOG.Type) Like 'SAY') OR ((LOG.Type) Like 'ACTION') ) AND ((LOG.Message) Like '*text*') ORDER BY LOG.Time DESC";
OleDbDataAdapter sda = new OleDbDataAdapter(str, accessConn);
sda.Fill(dt);
DataRow[] rows = dt.Select();
For simplicity, str equals the string i copied from a stringbuilder object while debugging. The Message field is of memo type. dt is a DataTable object.
Now the problems is, rows.Length = 0 after last statement, while sending the exact query via Access produces the correct results.
After some more debugging, it seems the problem is with the wildcards at Message Like '*text*' . Changing the query to Message Like 'text' produces the correct results.
Can anyone try this or help
|
|
|
|
|
OK i sorted this, maybe a bug
Resolution:
converted access db to access 2002 format and made db ANSI-92 complaint.
i then search using ANSI-92 standards IOW % instead of * for wildcard.
|
|
|
|
|
|
From MSDN:
Initializes a new instance of the String class to the value indicated by a specified pointer to an array of 8-bit signed integers, a starting character position within that array, a length, and an Encoding object. This constructor is not CLS-compliant.
[C#] unsafe public String(sbyte*, int, int, Encoding);
I assume this is what you need.
Read MSDN
|
|
|
|
|
I have a DLL which was made in Delphi 6.0
Its source code looks like this:
===========================================
library TestDLL;
uses
SysUtils,
Classes,
Windows;
procedure GetInteger(var N : integer);
begin
N:= 115;
end;
exports
GetInteger;
begin
end.
======================================
As i thought this function after calling it in C# by:
======================================
[DllImport ("C:/MyTest.dll")]
static unsafe extern void GetInteger(int* i);
int N = 0;
GetInteger(&N);
Console.WriteLine("N value after calling GetInteger: " + N);
=========================================
Have to write string "N value after calling GetInteger: 115" in console, but i saw "N value after calling GetInteger: 0"...
So my anser is: where is my mistake?
|
|
|
|
|
koenig wrote:
[DllImport ("C:/MyTest.dll")]
static unsafe extern void GetInteger(int* i);
int N = 0;
GetInteger(&N);
change to:
[DllImport ("C:/MyTest.dll")]
static unsafe extern void GetInteger(ref int i);
int N = 0;
GetInteger( ref N);
|
|
|
|