|
Have you looked at the MinimumSize/MaximumSize properties?
You can also check for the WM_GETMINMAXINFO message.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
set the maximumsize.Height and minimumsize.Height Form properties to 400.
The user will not be able to resize the form vertically (less than 400).
|
|
|
|
|
Thanks Jim Stewart and peenu for the help! I see there are a lot of properties I overlooked. The MaximumSize and MinimumSize properties did the trick:
this.MinimumSize = new Size (400,400);
this.MaximumSize = new Size (1280,400);
-- James --
|
|
|
|
|
This will help you manage all those brushes and pens you so relentlessly create without disposing of them correctly. YES YOU!!!
public class GDIBuffer
{
static Hashtable pens = new Hashtable();
static Hashtable brushes = new Hashtable();
public static Brush GetBrush(Color color)
{
if (!brushes.Contains(color))
brushes.Add(color, new SolidBrush(color));
return brushes[color] as Brush;
}
public static Pen GetPen(Color color)
{
if (!pens.Contains(color))
pens.Add(color, new Pen(color));
return pens[color] as Pen;
}
public static Pen GetPen(Brush brush)
{
if (!pens.Contains(brush))
pens.Add( brush, new Pen(brush));
return pens[brush] as Pen;
}
public static Pen GetPen(Brush brush, int width)
{
Tuple t = new Tuple();
t.left = brush;
t.right = width;
if (!pens.Contains(t))
pens.Add( t, new Pen(brush, width));
return pens[t] as Pen;
}
struct Tuple
{
public object left;
public object right;
}
}
Now instead of calling new Pen/SolidBrush , just call the buffer.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Wrong! but can be used.
in net we have such classes: SystemPens, SystemBrushes and etc.
Your class does not check is requiered Pen or Brush can be replaced by System version, which are exist as singleton instance for hole application and does not use additional GDI Objects.
Good Luck
Alex Kucherenko
|
|
|
|
|
I have a question about these System Objects. What if the user changes his/her properties in Display Settings while the app is running? Do these colors change?
Quote from MSDN:
"Public Properties:
ActiveBorder: Gets a SolidBrush object that is the color of the active window's border.
ActiveCaption: Gets a SolidBrush object that is the color of the background of the active window's title bar.
ActiveCaptionText: Gets a SolidBrush object that is the color of the text in the active window's title bar. "
To me this would imply that the colors are changing. But then again I have been known to be wrong at times.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Try to search more in MSDN.
look into Brushes.Black
Good Luck
Alex Kucherenko
|
|
|
|
|
Ahhh, ok... That makes sense.
Thanks,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
|
Alex Kucherenko wrote:
Wrong!
Why?
Alex Kucherenko wrote:
in net we have such classes: SystemPens, SystemBrushes and etc.
Your class does not check is requiered Pen or Brush can be replaced by System version, which are exist as singleton instance for hole application and does not use additional GDI Objects.
Thats exactly what I am simulating...and those singletons DONT exist unless they are used.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Shouldn't this class implement IDisposable? I mean the objective of this class is to create and maintain pens and brushes; these need to be destroyed, right?
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
|
Hi,;)
When a webbrowser is embeded in a child window,the browser can not respond to user.What can I do to make the browser work correctly as it is embeded in a single form?
Many Thanks.
|
|
|
|
|
Hi guys...
does anyone know of a way to have the columns in a list view auto adjust to the width of the data in a column?
Right now, i have to manually adjust the column header to see the entire data.
Thanks,
.gonad.
.gonad.
|
|
|
|
|
Hi There !
I am trying to develop a control which will be added to web pages and will allow to make "friendly print".
I have tried to look for something similar and couldn't find anything.
I have found some answers dealing with css, which includes the lines:
img{ visible:none}
It allows me to print only some of the elements.
I want to create header and footer of my own.
I have read this article, which is aproposal of standard for css, which I'm afraid wasn't carried out.
(http://www.pwg.org/xhtml-print/HTML-Version/CSS-Print.html)
@page {
counter-increment: pages;
@bottom{ font-family: Times, Palatino, serif;
font-size: 80%;
font-weight: normal;
text-align: center;
content: "Page " counter(pages);
}
}
Does anyone has any idea what to do ? (without handling the registry...)
|
|
|
|
|
Hey All,
Im looking for some advice. I have written a little thread that will check to see wether a text file has been updated. It compares the time for example. I as wondering, whats the best way to have a thread execute a method every few seconds without completely bogging down my main thread?
Thanks,
Ryan
|
|
|
|
|
Have that thread manage the timer (start it, stop it, etc.). If the file has changed, you can Invoke() a method so that it will run on the main thread.
You might want to check into the FileSystemWatcher. It doesn't work in Win9x/ME, though.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
|
zhyluo2003 wrote:
where is a's memory allocated? in the stack or heap?
Memory is allocated for all objects (primitives too). GC cleans it up. Note: That unlike C, everything goes onto the managed heap, so one can "dynamically" create a valuetype array. MS recommends using classes above structs for performance reasons.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Structs and other valuetypes such as ints and the like are created on the stack, not on the heap.
Thus, the syntax
int x = new int();
is confusing, because it appears the integer is allocated on the heap when it isn't.
To allocate on the heap, it is necessary to use (object) new int(), to box the valuetype as a heap object. It really is just syntactical sugar.
Valuetype arrays are allocated on the heap, but that's because arrays themselves are objects. But unlike object arrays, valuetype arrays contain the values as inlined elements rather than references.
Managed C++ makes it clear by exposing 2 pointers int __box * and int * to differentiate between boxed valuetypes and the stack-based equivalents.
Valuetypes are faster to operate than objects, but passing valuetypes around can involve an expensive copy operation if the valuetype is large, and are not passed by reference.
You can make your program an order of magnitude using valuetypes, but only if the data type truly exhibits value semantics. On the down side, you do lose a lot of flexibility.
Thanks,
Wes
|
|
|
|
|
leppie wrote:
MS recommends using classes above structs for performance reasons.
Any links?
|
|
|
|
|
Boxing is very expensive. Everytime you add a valuetype to an ArrayList for example it gets boxed (and making a typed collection doesnt get rid of it AFAIK). With a class you dont get that. Unfortunately the only place I could find something now, is in the EMCA 335 spec Partition 5
D.3. Type Usage Guidelines
D.3.1. Class Usage Guidelines
• Do favor using classes over any other type (i.e. interfaces or value types)
On the MSDN/C# homepage there is only a very informative article on performance.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
struct is a value type, so it should be in the stack.
- Kannan
|
|
|
|
|
here is the code:
struct SA
{
//definition of the struct
}
...
SA a = new SA();
...
where is a's memory allocated? in the stack or heap?
Thanks.
|
|
|
|
|
Can anyone help me in using matlab applications inside c#?
how to access matlab ?
i have tried to add a reference to matlab application COM object , and i found a class MlApp , i used it and found all functions , but when i run the program i have the following exception
"QueryInterface for DIMapp failed"
how can i deal with that?
|
|
|
|