|
Hi,
Just a quickie. I have created a flashy interface using Picture Boxes as buttons and want to have them make a 'click' sound when pressed for user feedback. Is there a simple call which I can use? Or any piece of code to do the job,
Regards,
John
|
|
|
|
|
See http://www.codeproject.com/cs/media/windowssoundevents.asp[^]. Just find the key for the navigation sound in the registry (the article mentions where in the registry to find these events) and call PlaySound (as documented in the article) with that key.
Support for system sounds will be added to the FCL in .NET 2.0 due out in early 2005.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How I can show the contents of the control PC to other clients in the LAN?
|
|
|
|
|
If you're using Windows XP, click on Start-<Help and Support. There is functionality to view existing Windows sessions already built into Windows XP, along with an invitation system. You could also install VNC (free download from the web - just google to find it) which allows you to connect to existing sessions, IIRC, but the Windows Remote Desktop Client won't work because it starts a different terminal session with each connection so they won't see your desktop session.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'd like to create a form that contains a number of controls that can be moved, and behave like forms. Similar to the Access relationship view. I've figured out that I need to do the following:
* External Form style border
* Move function upon mouse down on header (thick title bar in forms).
* Resize function upon mouse down on sides or base.
* Lock mouse pointer internal to form when moving object.
I was looking to set the border style to form, and then hoping that the header and side parts of the border could be used to fire events.
As for the mouse, i was looking at tying the mouse handle to the inside of the form, but i'm not sure how to do it, and the thought alone makes me wonder what could go wrong.
So i'm not sure how to go about this, does anyone know where to begin?
Cheers
Cata
|
|
|
|
|
One way is to implement .NET's drag and drop features for controls. I've mentioned this several times in the forum, so try a search. Just use some custom clipboard format (like ".NETControl" or something) and you can reposition controls that way.
You could also handle the MouseDown event and mark a flag. In the MouseMove event update the control's Location as you move if that flag is set. In MouseUp , reset the flag so that just simply moving the mouse doesn't move a control when your mouse passes over it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
[EDIT: Ah, did a google search for drag drop controls, and got a working example. It's perfect. Only problem I have now is figuring out how to implement a Form style border on a control. If you can offer any help into that, i would be grateful]
Ah, thanks for the ideas Heath.
The second one would cause problems with moving the mouse outside the area, and while i could lock the box to the perimiter, it would still look unproffsional.
How does this work with object borders?
I've tried a bunch of searches, but still haven't found anything. Sorry to be a pain, but i've done a whole bunch of permutations of Move, Control, Controls, Drag, Drop, but come up empty handed.
Cheers
Cata
|
|
|
|
|
Ok, I have the Drag Drop working, but i'm interested in a couple of other things.
How can i stop the mouse pointer from leaving the form / control / container while in the process of dragging?
How would i configure a form type border on a control? I know they are sperate objects, but i've no idea where to start to set them up. Not sure what i'm looking for in google tbh.
Cata
|
|
|
|
|
See the Capture property. It won't stop the mouse from going outside the bounds of the container, but you can always stop the control from moving further through various means. I'm sure stopping the mouse is possible and, IIRC, have seen it done but I'm really not sure how and am sure it requires a lot of low-level notification message handling, perhaps even app or sys hooks.
You could, through quite a bit of work most likely, detect when the mouse is over a border (within a certain threshold) of a control and change the mouse cursor appropriately. The Mouse* events could be handled the same way as I mentioned in my previous post, only you would change the Size property (remember, you must create a new Size object since its a value type, or just change the corresponding properties of the control).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, i'll look into that.
What about borders?
I've made something that looks like a 12 year old could do better. But it can detect when you select the header part, and the 4 side bits when the mouse is over them, change to resize arrows and can be re-sized.
The centre has a filled panel that is the content. It's really a sloppy job that isn't fully working yet. How would I make a windows type form with smooth corners?
|
|
|
|
|
See the ControlPaint class, which has several helper methods for drawing borders given a certain Rectangle (bounds).
As far as actually showing the control while dragging, you'll have to do what I mentioned before with the mouse events. This is pretty much what designers like VS.NET and SharpDevelop do, at least to some degree. Designers are also not magic - the controls themselves are instantiated and painted at runtime with various design-time decorators.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I found this article if you are interested. I'm going to go and try and implement it in C#, but it's something for you to add to your knowledge base:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q179/1/92.asp&NoWebContent=1
(What's the tag to set it up as a link?)
|
|
|
|
|
Don't bother. After I noticed that all but one function that was declared in VB already exists in the .NET FCL (like Control.PointToClient ), I thought I'd look at the Cursor class and sure enough, there's a Clip property that takes a Rectangle that defines the clipping rectangle, in screen coordinates (so use Control.RectangleToScreen from your Control to get it's bounds in screen coordinates).
Ahh, the power of cheese research.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ARG! I was so proud of finding that :P
Oh well, to bad.
Just the Form border thing to figure out now. Is there any Control that represents a forms border?
(hmmm... cheese...)
|
|
|
|
|
A form border is not a control, it's just colored pixels (i.e., painted). Use the ControlPaint like I mentioned earlier and handle the mouse events appropriately. That's all window managers like Windows basically do. Everything currently comes down to painting a 2D image into a device context and handling various events when the cursor is in a certain position.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, can do all the moving and re-shaping. I've created a set of panels around the edge of the control that can be used to re-size or move it.
But i really need the final touches.
Where can i find the windows graphics for top, bottom, and sides of a window to insert into the bordering panels? I was looking at the ShellStyle.dll. Am I going the long winded way around?
|
|
|
|
|
Hi!
Does anyone knows if there's an object to handle events, like the Api's functions CreateEvent() or SetEvent().
I need to set events to check some objects state, and using WaitForSingleObject() to wait for the event. In C++ I would do:
SetEvent(hEvent1);
dwerror=WaitForSingleObject(hEvent2, timeout);
ResetEvent(hEvent1);
How could I do something like that in C#?.
Thank you.
Demian.
|
|
|
|
|
You could start by searching Code Project. Here you will find a number of articles on Event Handling. Here is a promising looking article:
http://www.codeproject.com/csharp/csevents01.asp[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Some more information on events from the Microsoft web site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriEventHandlers.asp[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
See the System.Threading namespace as well. There's a lot of objects that can be signaled, like those deriving from WaitHandle . These classes and their members actually use the native APIs like WaitForSingleObject and encapsulate them in easy-to-use classes.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to create a class iheriting from Hashtable. My aim is, it has to save (serialize) itself when a key/value pair is assigned to it. Also, it has to deserialize in the constructor.
I could make it work by haing the Hashtable as a member of my class, it couldn't do it when I tried to inherit my class from hashtable. Can any one help?
TOJO
|
|
|
|
|
It won't work when you deserialze (by default) since a new object is created from deserialization. What you probably could do is deserialize to a new object (a your Hashtable derivative) then enumerate through the DictionaryEntry objects (using the IDictionaryEnumerator from Hashtable.GetEnumerator ) and add them back into your current instance. When the deserialized Hashtable falls out of scope, it will eventually be garbage collected.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, thanks for reading my post.
I am trying to produce a custom control based on a textbox. This is to be distiguished from a regular text box by a small red triangle at the bottom right of the control.
I have managed to get the triangle to display correctly.
My problem is that when I enter text, it displays correctly but when the delete key is pressed, it does not remove the characters, it just moves the cursor back one space.
I have tried Invalidating the control every time a key is pressed (and in a few other events) but when this is done, the keypresses are registered (the cursor moves) but the text is not displayed.
I have even tried to make my event handler draw the text but that has given me a whole raft of other problems and I don't think that the background event should be drawing the foreground anyway.
The code for my OnPaintBackground event is as follows:
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground (pevent);<br />
<br />
Rectangle r = pevent.ClipRectangle;<br />
PointF[] pts = new PointF[3];<br />
<br />
int sideLength = 5;<br />
<br />
pts[0] = new PointF(r.Right, r.Bottom - sideLength);<br />
pts[1] = new PointF(r.Right - sideLength, r.Bottom);<br />
pts[2] = new PointF(r.Right, r.Bottom);<br />
<br />
pevent.Graphics.FillPolygon(Brushes.Red, pts);<br />
}<br />
Please help point me in the right direction (or if you prefer, you could always give me a finished example )
Thanks in advance
Stephen
|
|
|
|
|
DataSet ds = new DataSet();
ds.ReadXml(filePath);
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "database";
dataGrid2.DataMember = "package";
Now dataGrid1 is on tabPage1 and dataGrid2 on tabPage2. He fills dataGrid1 correctly but how can i fill tabPage2? Because he doesn't do it like this.
thx in advance
|
|
|
|
|
bertcox wrote:
Now dataGrid1 is on tabPage1 and dataGrid2 on tabPage2. He fills dataGrid1 correctly but how can i fill tabPage2? Because he doesn't do it like this.
Uhhhh....You didn't supply near enough information to answer this. What is stopping you from filling dataGrid2?
RageInTheMachine9532
|
|
|
|