|
whoa.... that was quick ... and harsh... forgive me for not knowing basic knowledge... that's why I'm not a Microsoft MVP maybe?...
thanks for the reply though..
|
|
|
|
|
I have a borderless form with a background color/transparent setting so that the form background is sucsesfully transparent. When I place a .png (or gif) in a picturebox on top of this transparent form, the transparent bits of the png show as white and not as transparent. I don't see a specific picturebox color transparent setting - anything else I should try?
|
|
|
|
|
I had the same problem with a label. I ended up writing the text out manually with the graphics object. You might have to do the same.
My goal is to look at code like a chessmaster looks at a chessboard to see positions and possibilites beyond lines and characters.
|
|
|
|
|
I was afraid of that. It's a fairly complex photoshop image and I doubt I could recreate it easly with graphics.
Still looking for some help here...
|
|
|
|
|
Only forms have transparency support through layered window support. A PictureBox is a separate control, not a layered window, so the container window - while still being layered - is not what's showing up again.
A good way to solve this is to either set your picture as the form's BackgroundImage or paint it on yourself, and then set the color in the image you want transparent as the TransparencyKey for the Form . See the documentation for the TransparencyKey property for more information.
EDIT: Oh yeah, and that's only supported in Windows 2000, XP, 2003 and newer. For older Windows OS's you'll have to resort to clipping regions, which won't give you great quality and is typically a pain since you have to code all the splines.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath, another excellent answer!
|
|
|
|
|
I have a VC dialog that hosts a FlexGrid control. The contol has two columns with data. The first column has read only data and is fixed. So it has a 3D edge for each cell that looks like a button. The second column is editable.
I'm porting this to C#. In the form I place a DataGrid to display the data. Two things I cannot do with DataGrid. First, I cannot get the 3D edge for the cells in column 1 and second, I cannot stop DataGrid from adding new rows. I just need to edit the contents of column 2 and not add more rows.
Can somebody help ?
« Superman »
|
|
|
|
|
To create custom columns, extend the DataGridColumnStyle and override the necessary methods. You could then paint whatever borders you want. There are many examples here on CodeProject, MSDN[^], and elsewhere (just google).
To disallow new rows, you either need to bind to an IList or IListSource implementation that is fixed in size (like an array of objects), or bind to a DataView instead of a DataSet or DataTable . Set the DataView.AllowNew property to true when doing so. See the documentation for the DataView class for more information and example code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath for you earlier reply. I could get what I wanted done.
But I have another problem and thought maybe you could shed some light.
The grid has 2 columns and 5 rows out of which one column is editable. I'm implementing an observer pattern where the grid is one of the views. When the user changes the text in the grid column I need to update the model. For this I register for the LostFocus event of the TextBox hosted in the DataGridTextBoxColumn. This is done in my derived class.
Everything is allright if the user enters text and changes focus using the mouse. But using the arrow keys, the focus does change to the next grid cell, but there is no LostFocus event generated.
« Superman »
|
|
|
|
|
When deriving your own classes, you can fire all the events you want. The Commit method is still called on the derived class so add an event to your class and fire it inside the Commit implementation. It's your class - you have control of what happens.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I am using drag and drop in my app. I have this code for the DragEnter event:
<br />
private void tabPage1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)<br />
{<br />
if( e.Data.GetDataPresent(DataFormats.FileDrop, false) == true )<br />
e.Effect = DragDropEffects.All;<br />
else<br />
e.Effect = DragDropEffects.None;<br />
}<br />
Now, how can I tell if a file or folder was dropped? What I am using now in DragDrop is:
<br />
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);<br />
<br />
foreach( string file in files )<br />
{<br />
DirectoryInfo di = new DirectoryInfo(file);<br />
if (di.Exists)<br />
MessageBox.Show("DIR: "+file);<br />
else<br />
MessageBox.Show("FILE: "+file);<br />
}<br />
Is this the proper way to do the check?
Thanx for the help,
-Flack
|
|
|
|
|
You handle the DragDrop event and use the DragEventArgs.Data.GetDate to get a string[] array (in your case). Then just copy the files or whatever.
In your DragEnter event handler, don't use DragDropEffects.All unless you intend to support all effects (some of which aren't often relevant). Just set the ones you actually support, like Move or Copy , which are the two most common ones.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanx for the reply.
After I do:
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
in DragDrop, how can I differentiate between strings that represent file names and strings that represent folder names? Is the way I did it in my original post the correct way?
Thanx
-Flack
|
|
|
|
|
Flack wrote:
Is the way I did it in my original post the correct way?
Yes, that is one way of doing it. It works, doesn't it?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I find it much easier if a class is going to have an empty constructor to make the class's properties and methods static. But I haven't read or seen anything on the "ramifications" of using static a bunch. One one hand it seems as though it would help the system's performance since static methods and properties are loaded on system startup - but does this dramatically affect the system's "startup" time; and memory usage - or enough to worry about it anyway? And is calling static methods etc. offer any significant performance increase over intializing a class with an empty constructor and then utilizing its methods etc.? Has anyone discovered some good "rules of thumb" for determining when to make a method or property static? I typically create static sql connection strings, color properties, etc... based on the above questions, is this a good idea or not?
|
|
|
|
|
If a method does not rely on state within the class ( i.e. member variables of a specific instance of a class ), then it should be static, or possibly part of a fascade class.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
As Christian implied, you should use instance members when the class requires state for each instantiation. Statics are also executed synchronously within a single AppDomain so forget multi-threaded applications.
Finally, this makes for a terrible object-oriented design and throws polymorphism out the window since you can neither mark a static member as abstract nor override an inheritted static member. You're basically turning the .NET Framework into a procedural construct. If that's what you're after, you don't want object-oriented runtimes like the .NET CLR or Java Runtime Environment.
Static members are best reserved for class factories, non-instance operations (like binary operators, non-class specific methods like Control.MousePosition , and the like). Everything else should be an instance member. In a good OO design, you'll end up using mostly instance members.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I have a form that is shaped with a GraphicsPath object. After setting the form's region, my form's border looks bad (jagged edges). I would like a nice solid border around the form. Is there something I can do?
I have tried using the TransparencyKey property to fill my form with a color. This works fine, except it doesn't work at 32 bits (a bug in TransparencyKey) and I can't use AntiAliasing for my border.
Is there any way I can get smooth, soft edges on my custom shaped form using a GraphicsPath?
Thanx for the help,
-Flack
|
|
|
|
|
use a bitmap as a region, graphics software can draw stuff better than we can do in code usually
|
|
|
|
|
What's your target platform? If it's Windows 2000 and later, you can use layered windows (of which TransparencyKey partly encapsulates, and is - as you've experienced/read - buggy). You can perform the layered windows yourself, though, and get a nice smooth edge like you see with Windows Media Player 9 or the splash screens for newer Adobe applications.
See the SetLayeredWindowAttributes native API documentation in the Platform SDK. You can P/Invoke this. Also see the "Using Layered Windows" link at the bottom. Also, override CreateParams , get base.CreateParams , and OR the WS_EX_LAYERED (0x00080000) extended style, returning the modified CreateParams from your override. You can achieve all this through managed code, but there's a bug in there somewhere and I honestly can't remember where. I do know that doing the work mentioned above has worked for me in .NET applications previously.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've got an object that i am writing a re-sizing method for. The resize begins upon mouse down when over a certain area of a component. This works fine, i can create an increasing side, but only on a per click basis.
The element that activates the re-size is part of the component, and not tied to the parent form. What I need to do is detect the movement of the mouse as an event, either inwards or out of the component, and use the difference in the X coordinates for horizontal re-sizing, and the difference in the Y coordinates for vertical re-sizing.
I thought i had this figured, but guess I was wrong.
Cata
|
|
|
|
|
Without any code example, we can only guess at what you doing wrong, but...
Are you doing your resize in the MouseMove handler or MouseDown. Use MouseMove and check for the position of the mouse, then if your in the resize area, check the status of the MouseButtons in the MouseEventsArgs, then you can use that to determine if you should resize or not.
RageInTheMachine9532
|
|
|
|
|
...or like I said originally today, set a flat in the MouseDown handler and reset it in the MouseUp handler. Dave's method would work, but you end up having to check the same condition (which makes several calls) with each execution of the handler, which is slightly less efficient than using a simple flag.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi.
How could I implement a pointer to an array of bytes, (bytes[]) in C#?
Thank you.
|
|
|
|
|
You can use something like
unsafe
{
byte* bytes = stackalloc byte[50];
}
The stackalloc keyword puts the bytes on the stack as opposed to the heap, and therefore not subject to garbage collection. If you don't use stackalloc, be sure to use the fixed keyword to pin the bytes to the heap (so that the GC won't clean them up).
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|