|
Hi leppie,
Yes, I know that, my mistake...
What about the main question in my topic?
Do you know how to do that?
Thanks
|
|
|
|
|
Declare the field as an IntPtr and use the Marshal.StructureToPtr method to get the IntPtr value to assign to that field. If you expect changes to be saved to that structure, since it's a value type you must use Marshal.PtrToStructure when you get it back to get the new structure with the different values.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
is there a way i can add controls to a panel and make the panel resizable
chad
|
|
|
|
|
Of course you can add controls to your panel.
Example: this.control1.Parent = this.panel1;
(Control1's parent is set to panel1)
To resize your panel just set the Size property.
Example: this.panel1.Size = new Size([width],[heigth]);
or set the panel's Height and Width property.
Good luck!
|
|
|
|
|
will i be able to resize the panel at runtime
chad
|
|
|
|
|
Yes. That code he posted gets compiled and executed at runtime. You can change it's size and position all you want in response to events like mouse movement or clicks, etc.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok you must forgive me i'm new to csharp i changes the size of my panenl how do i make it where my users can change it when there useing my form because right now they can't change the size of it when i compile it
chad
|
|
|
|
|
Of course they can't change it unless you provide a way. It's compiled using a certain size and position. If you want the Panel to resize in relation to its container, look at the Anchor and Dock properties. With Anchor , if you anchor the control to opposite sides, it will be resized in relation the margin between its borders and that of the corresponding borders of the container control.
If you want your users to be able to resize it like you can in the designer, you'll have to provide a mechanism to do so, like handling the MouseDown to set a flag, the MouseMove event to resize or move the ocntrol if that flag is set, and the MouseUp event to reset the flag.
When you compile an application, it's runs according to how you program it. Application don't general allow for design-like changes to it. Part of the reason you compile an application is that people can't change it (easily).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey
we ar working on a game project thats have a form in 1024x712, we will have one picture as a skin in the background, but we have notice that this will course alot of flickering when moving the form around, and if we have a picture box abouv it that got transparent corners it will flckering alot when its moves.
Is there any way to make this flickering to go away? it siems like the systemcontrollers grafik dont take much CPU but the big Form background takes alot ??
//Jimmy
|
|
|
|
|
You could enable double-buffering and paint it yourself in the OnPaint handler:
public class MyForm : Form
{
public MyForm()
{
SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer | ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
if (BackgroundImage != null)
e.Graphics.DrawImage(BackgroundImage, new Point(0, 0));
base.OnPaint(e);
}
} Something like that should do the trick.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey thanks
I will loog in to this, but i dont realy understand what SetStyle is? maby there is som information about this in the MSDN =)
//Jimmy
|
|
|
|
|
I have experienced the same effect.
It seems that Windows needs much time to redraw the .NET controls. If you remove the background skin, the flickering should decrease. But the best effect is to cut out transparency. After that, the flickering should be gone.
|
|
|
|
|
Yes, if i remove the BackGround picture it stopt to flickering, the System controls grafic dont simes to take much preformanc at al, but the singel 1024*712 Form.backgroundpicture is.
I have test the fomrats
png
jpg in al diffrent compressions
gif
It simes like jpg in middle compression is the best.
//Jimmy
|
|
|
|
|
Is it possible to get "handel" and "bedrijf" into a combobox?
And when i add an new school in the xml-file, i want that name also in the combobox
Thanks in advance!
<?xml version="1.0" standalone="yes"?>
<test nr="1">
<school naam="handel">
<direc> guy</direc>
<teur> qui</teur>
</school>
<school naam="bedrijf">
<direc> louis</direc>
<teur> qyu</teur>
</school>
</test>
|
|
|
|
|
The DataSet treats attributes as either tables or fields, depending on where you are. For example, this schema would also produce a table called "1". The "naam" will be just another field in your "school" table, so you can use it just like any other field.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi gurus,
in MFC and GDI+ I could easily randomize brushes, colors, GDI+ enumerations and so on... My question is simple.
How can I do the same things in C#?
I would like to randomize the following C# elements:
- Color (RGB values. Alhpa remains the same)
- Brushes (LinearGradientBrush, SolidBrush and HatchBrush)
- Brushes styles (LinearGradientMode and HatchStyle)
For example, in C++ I could do the following:
<br />
m_pRandom->SetBounds(HatchStyleHorizontal, HatchStyleTotal);<br />
m_hs=(HatchStyle) m_pRandom->GetRandom();<br />
while m_hs is HatchStyle and m_pRandom is a random object.
I could easily randomize in C++ between different enumerations. How can I do the same in C#?
Thanks for the help.
Best regrads.
|
|
|
|
|
At least one way of handling this would be to create an ArrayList, which would hold the objects you want to access randomly. Then, your random number could simply index the array, returning the object you want.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
If you mean you just want to pick random colors, hatches, or brushes, then just pack them into an array or list and select a random number over that range. For colors, you could do something like this:
Random rand = new Random();
Color c = new Color();
c.R = rand.Next(256);
c.G = rand.Next(256);
c.B = rand.Next(256); If you're getting a pixel from somewhere else, just don't touch the A property (the alpha channel). Note that since Color is a value type, you cannot change these propeties on a Color that is referenced by another class or struct. You'd have to copy it or create a new one then reassign that color property.
For selecting anything else, just put them in a an array and select a random index like so:
Brush[] brushes = new Brush[] {
new LinearGradientBrush(...),
new HatchBrush(...),
...};
Random rand = new Random();
Brush brush = brushes[rand.Next(brushes.Length)]; You could do the same with hatch styles, although you can make this easier by using the Enum class:
HatchStyle[] styles = (HatchStyle[])Enum.GetValues(typeof(HatchStyle));
Random rand = new Random();
HatchStyle style = styles[rand.Next(styles.Length)];
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I understand now that everything happens in the Next method.
but when I want to assign a new radomize value to a Color object, the compiler says that A, R, G and B are read-only properties
|
|
|
|
|
Oops, that's right. Do the same thing only use the Color.FromArgb(int, int, int) method.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yeap, it works that way
Thanks.
For, the brushes, is it possible to create only 1 brush instead of an array that contains all brushes? I want to create the brush at run time to do something similar to the following C++ code:
<br />
void CBlock::InitializeBrush()<br />
{<br />
SAFE_DELETE(m_pBrush);<br />
<br />
switch (m_bt)<br />
{<br />
case BrushTypeSolidColor:<br />
m_pBrush=new SolidBrush(m_clrForeground);<br />
break;<br />
<br />
case BrushTypeLinearGradient:<br />
m_pBrush=new LinearGradientBrush(m_rect, m_clrForeground, m_clrBackground, m_lgm);<br />
break;<br />
<br />
case BrushTypeHatchFill:<br />
m_pBrush=new HatchBrush(m_hs, m_clrForeground, m_clrBackground);<br />
break;<br />
}<br />
}<br />
while m_bt is a BrushType, m_lgm is a LinearGradientMode.
I guess I have to create an array with all the "BrushType" in a similar way to
what you show me with the LinearGradientMode?
|
|
|
|
|
You mean something using the same concepts like the following?
public Brush GetRandom()
{
Random rand = new Random();
switch (rand.Next(3))
{
case 1: return new LinearGradientBrush(Bounds, ForeColor, BackColor,
LinearGradientMode.Horizontal);
case 2: return new HatchBrush(HatchStyle.Wave, ForeColor);
default: return new SolidBrush(ForeColor);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok, it works that way
Thanks a lot!
One more thing about randoms in C#.
How can I get a new value each time I instanciate a Random class?
It seems that when I trace the values, in my array, I have identical series of values. I guess it's like for C++, these series correspond to one second. How can I generate a completely different value each time I instanciate a Random class? Is there somewhere a kind of GetTickCount in C#?
|
|
|
|
|
oops,
I posted the message as anonymous... that message was mine
|
|
|
|
|
I reply to this one, then, to make sure you get a notification email (if configured in your settings for CP).
Yes, just use DateTime.Millisecond or some other int or long like Environment.TickCount .
If you always use the same seed, you'll always get the same sequence of "random" numbers, but it isn't - nor can it be without peripherals based on chaos principals or something similar - truly random.
Microsoft MVP, Visual C#
My Articles
|
|
|
|