|
I have an application that populates a PictureBox control with an Image and then dynamically adds controls to the form on the top of the PictureBox . The PictureBox is the Container of all the dynamic controls. The problem I have is disposing of these dynamic controls. When I run the following code it dosposes of some of the dynamic controls but not all of them:
foreach (Control control in this.pictureBox1.Controls)<br />
{<br />
this.pictureBox1.Controls.Remove (control);<br />
control.Dispose ();<br />
}
Any ideas why it doesn't get rid of them all?
When they were created they were all added to the pictureBox1.Cotrols collection.
|
|
|
|
|
Hello,
How do you remove Remove text selection in an RTB, (i.e. So you can't select the text in the RTB) RTB = RichTextBox
regards,
Gobbatroll.
|
|
|
|
|
can media player develop in VC change in C#?
OR
can develop media player in C#?
sdfsdfsdfhsdfh
|
|
|
|
|
you can find C# sample programs to play audio and video files in the Managed Directx 9 SDK
|
|
|
|
|
Hi,
I would like to dynamically list all bitmaps of one folder (with thumbnail) on listView control.
The idea is that when user select/change the folder, the program will auto search every existing bitmaps from the folder, and try to list them on listview control.
Now, I got 2 question,
1. How can I tell ListView to draw item from customerDraw, but I couldn't find this property.
2. Or I need to create ImageList dynamically, and then list them.
Could anyone give me some ideas , and better provide me some examples
Thousand thanks
|
|
|
|
|
It would be easier to inherit from ListBox and do your own custom drawing there.
You set DrawMode to DrawMode.OwnerDrawVariable (if you want to draw the bitmaps in different sizes). Then you override OnMeasureItem and OnDrawItem to do the painting.
You should create a property for your new listbox called Directory. When value is set for this property you populate private arraylist with all bitmaps in that directory. To do that you can use: System.IO.Directory.GetFiles(myDirectory, "*.bmp")
During measure item and drawitem you just draw those bitmaps.
|
|
|
|
|
string[] sA;
How to change sA size (Length)
Thank You.
|
|
|
|
|
You set the array length when you "new" the type. As is the array has no size yet.
|
|
|
|
|
The initial size is set at creation time:
sA = new string[5];
If you want to change the size later, you have to create a new array and copy the content of the old one:
string[] sB = new string[8];<br />
Array.Copy( sA, 0, sB, 0, sA.Length );<br />
sA = sB;
|
|
|
|
|
You can alsow store your data in System.Collections.ArrayList
that how you don0t need to specify a size, and size can be chaneg during runtime without copying the contents to another array.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
The answer is, you cannot change the size of an initialized array.
The amount of storage space designated at initialization time is not changeable without destroying the original Array object. For example, the String type (basically a Char[]) is considered immutable; that is, you cannot truly change a String variable, you can only destroy it and assign a new value to the same variable name (that's why StringBuilder is such an efficiency improvement over string concatenation...under the covers it uses a collection type that's sizable until you ask for the ToString() representation).
That said, I saw someone posted a method to copy one Array into another (presumably larger) Array, and someone else has suggested the ArrayList class. There are numerous other classes available (StringCollection to name one), or you can make your own. A good place to start is CollectionBase or DictionaryBase, depending on whether you want straight values or key-value pairs.
Hope this helps.
|
|
|
|
|
Hi, I had a problem with socket permission.
I have created a server that has leaves its port opened to clients and telnet applications.
Clients can run succesfully if they stay in the same machine (localhost). Telnet on local host to the server port can be connected too.
However, if I tried to connect to the server port from another machine in the intranet, I won't be able to connect.
I've tried many ways, I've set the trust region of intranet to full trust, I've made instances of SocketPermission:
SocketPermission mySocketPermission1 = new SocketPermission(PermissionState.Unrestricted);
SocketPermission mySocketPermission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, "192.168.*.*", SocketPermission.AllPorts);
But, why can't remote clients (hyperterminals / telnet) connect?
For your information, I'm using asynchronous sockets for my server application. Is the problem related with the socket permission, or is there any other possible problems, i.e. wrong class library usage. Thanks.
|
|
|
|
|
You are given tow rectangles each defined by an upper left(UL) corner and a lower right(LR) corner.Both rectangles' edges will always be parallel to the x or y axis as shown in Figure 7.2.Write a window program that use mouse to draw the rectangle add the program will determines wether the two rectangles overlap.For convenience.You may use the following structs:
Struct point{
Int x;
Int y;
}
Struct rect{
struct point UL;
struct point LR;
}
The function prototype is As following:
Int overlap(struct rect A,struct rect B):
Please help me to finlish the question,thanks.
|
|
|
|
|
(struct rect A,struct rect B):
Remember that this is the C# forum
Let .NET do it for you...
bool overlap(Rectangle a, Rectangle b){
return a.IntersectsWith(b);
}
|
|
|
|
|
In the Component Services Administrative Tool,we can see the satatus of components activation. Like this,I wonder if i can implement this kind of functionality as using C# Language.
Please,help me.....Any idea will be helpful...
|
|
|
|
|
programmatically of course.
is there anyone here who has used multiple backbuffers in ddraw ?
|
|
|
|
|
fd97207 wrote:
how to find out how much graphics card memory and how much RAM I have?
I think you can find it here:
http://www.codeproject.com/csharp/wmi.asp[^]
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Hej
Is it posible to have a Windows Control Library(controller) in a listview like an item?
ex
I whant to make a ListView that can show all the tabels that you could play the boardgame at. So if i make a controller that shows whos playing on this board(table) and what game thay are playing(by icons) and then i whant this controller to be in the ListView.
I will need about 50 controls in the ListView, do i have to make my own ListView control or do the original ListView control be abled to contain this controllers?? and if so, where can i find information about this?
//Jimmy
|
|
|
|
|
Hello,
I'm trying to program a "clone" of civilization III, using only C# and GDI+ (kind of exercice to learn).
I've manage to make a functional map and map editor, and I'm trying to animate the sprites.
It works, except for two things : shadows and player color.
My animation are 256 colors storyboard. I know that the last 20 indexes are used for shadows.
Question 1: how can I know with C# and GDI+ what is the index in the palette of a pixel?
The GetPixel function gives the color, not the index.
Question 2 : How can I use an alphablending effect, but only on some indexes of the palette? Is it possible?
Question 3 : for player color, how can I replace the 10th index color in the palette by another color? Supposing player color is the 10th index of course.
Thanks
|
|
|
|
|
If you want alpha blending, you'll need to use 32-bit color where the high 8 bits is the alpha channel. These are per-pixel.
If you want to get the palette index for a color, first get the Color as you're doing. Then you'll need iterate through the ColorPalette .Entries for the Image.Palette :
Color pixel = bmp.GetPixel(0, 0);
ColorPalette palette = bmp.Palette;
for (int i=0; i<palette.Entries.Length; i++)
if (palette.Entries[i].Equals(pixel)) return i;
return -1;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the answer, but it won't work.
I know that in the palette the last index is the transparency color, whatever the actual color. It is usually magenta, but it could be something else. And if it is Magenta, but the first color is also magenta, then only some pixels (last index) must be transparent, the other one (first index) must remain magenta.
That's why I'd like to get the actual index, and not only the color
|
|
|
|
|
I've found a solution to one of my problem.
Bitmap.Palette return a copy of the palette.
So I need to do
ColroPalette palette = bmp.Palette;
palette.Entries[0] = Color.FromArgb(150,255,255,255);
bmp.Palette = palette;
And then it works, even for the alphablending, and the picture is 8bpp indexed, it doesn't need to the 32-bit color.
However, your solution to get the index of a pixel will not work, as I can have several indexes in the palette with the same color, but they must be processed differently.
For instance, the last index is the background color and must be 100% transparent. But if it is magenta, and the 76th index is also magenta, then only the background must become transparent, and the 76th inndex must remain magenta
|
|
|
|
|
Sorry, but in most cases it will work. Palettes don't usually contain the same color more than once. Sure, I suppose they could - but it's atypical. All the graphics programs I've worked with - and quite a bit - like Photoshop (last 4 versions), GiMP, and a handful of lesser-known programs consolidate the palette for space and because it's usually pointless to have more of the same color in a palette. So, just because it doesn't work for your atypical example, don't say it doesn't work.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry if I was a bit offensive. Your solution works, but not in my particular case, because it is quite likely that the palette contains several identical colors, and there should be used as different color by the software.
|
|
|
|
|
Hi!
I'm looking for a method which i can use to eject my DVD-drive. If C# doesn't provide this functionality, maybe someone knows an API-call.
THX
|
|
|
|