Click here to Skip to main content
15,900,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: Special Keyboard keys Pin
Heath Stewart4-Jan-05 13:29
protectorHeath Stewart4-Jan-05 13:29 
Generalstopping service via WMI Pin
thespiff4-Jan-05 8:36
thespiff4-Jan-05 8:36 
GeneralRe: stopping service via WMI Pin
Heath Stewart4-Jan-05 10:51
protectorHeath Stewart4-Jan-05 10:51 
GeneralRe: stopping service via WMI Pin
thespiff5-Jan-05 1:03
thespiff5-Jan-05 1:03 
GeneralRe: stopping service via WMI Pin
Heath Stewart5-Jan-05 4:50
protectorHeath Stewart5-Jan-05 4:50 
GeneralRe: stopping service via WMI Pin
thespiff6-Jan-05 2:19
thespiff6-Jan-05 2:19 
GeneralImplementing mouse panning functionality Pin
Andres Coder4-Jan-05 7:55
Andres Coder4-Jan-05 7:55 
GeneralRe: Implementing mouse panning functionality Pin
Heath Stewart4-Jan-05 11:30
protectorHeath Stewart4-Jan-05 11:30 
desmond5 wrote:
The base of this toolbar is a Control (or UserControl if you will).

That would be incredibly inefficient with too much overhead. A UserControl is a container control, used for hosting other controls like a Form hosts controls. This should not be used for single objects.

Even more advanced toolbars that seem to host other controls like a combo box are not container controls. They typically "site" (position) those controls at a particular location and move them when the control itself is moved.

desmond5 wrote:
Any ideas how is the mouse handling done in the Control class ?

Much of the mouse interaction is not handled by the Control class at all. Almost every Windows Forms control in the BCL encapsulates the related Windows Common Control - the very same native controls you see throughout Windows and Windows applications. This gives a consistent user interface whether your application is writtin in C/C++ using the Win32 APIs, MFC (C++), VB, or .NET (or a slew of others, excluding Java that wrote it's controls from the ground up for consistency across platforms, which is arguably less important that a single platform where most users spend their days).

If you want to see the implementation for yourself, learn to read Intermediate Language (IL) and use the ildasm.exe (IL Disassembler) application that ships with the .NET Framework SDK and is located in the Bin directory of the .NET Framework SDK installation. This is installed by default with VS.NET under the VS.NET installation root.

You could also use a decompiler like the .NET Reflector[^].

For your approach where you're defining everything in managed code, a more common approach is to have each UIElement implement a Click handler like so:
public class UIElement : IDisposable
{
  // ...
  public abstract void OnClick(MouseEventArgs e);
}
Override OnMouseDown, for example, on your toolbar control and pass the MouseEventArgs passed to you to the UIElement at those client coordinates (i.e., 0,0 corresponds to the upper-left corner of the control that was clicked - not the screen). That will allow you to get any relative mouse click point for the element as well as any modifier keys.

A better design would be to encapsulate only the properties of the MouseEventArgs you want, which makes this easily callable for key events (like pressing the [Space] key when the UIElement has the focus, if you implement focus within the toolbar itself).

Regarding your naming conventions you should really read Naming Guidelines[^] in the .NET Framework SDK. Methods (not functions, mind you) should never be lower case, nor should properties. Fields may be, as it really doesn't matter how you name private fields (no one should see them anyway, but take into account how they're serialized, implementing ISerializable for custom serialization if needs be).

It's important to follow the guidelines as it makes developing applications using your library easier when it's consistent with the other libraries a developer would be using. Just think of all the classes, members, etc. that you use from the BCL? Have you ever seen a method that begins with a lower-case letter? A property, or a class? Not in the BCL (base class library) you won't.

It's good to run your assemblies through FxCop[^], which will not only catch naming violations (not typically bad violations, but following the guidelines is helpful for your clients) but many other errors as well.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralIs this acceptable practice Pin
Wayne Phipps4-Jan-05 7:54
Wayne Phipps4-Jan-05 7:54 
GeneralRe: Is this acceptable practice Pin
perlmunger4-Jan-05 8:41
perlmunger4-Jan-05 8:41 
QuestionHow To Serialize Multiples Refereces to The Same Object? Pin
fmarcos4-Jan-05 7:18
fmarcos4-Jan-05 7:18 
AnswerRe: How To Serialize Multiples Refereces to The Same Object? Pin
Matt Gerrans4-Jan-05 8:03
Matt Gerrans4-Jan-05 8:03 
GeneralLaunching Forms Dynamically Pin
SignMan3594-Jan-05 6:14
SignMan3594-Jan-05 6:14 
GeneralRe: Launching Forms Dynamically Pin
Nick Parker4-Jan-05 7:23
protectorNick Parker4-Jan-05 7:23 
GeneralRe: Launching Forms Dynamically Pin
SignMan3594-Jan-05 14:28
SignMan3594-Jan-05 14:28 
GeneralRe: Launching Forms Dynamically Pin
Anonymous5-Jan-05 4:01
Anonymous5-Jan-05 4:01 
GeneralRe: Launching Forms Dynamically Pin
SignMan3595-Jan-05 8:34
SignMan3595-Jan-05 8:34 
GeneralRe: Launching Forms Dynamically Pin
Skynyrd6-Jan-05 3:30
Skynyrd6-Jan-05 3:30 
GeneralControlling Scroll bars Pin
Wjousts4-Jan-05 5:32
Wjousts4-Jan-05 5:32 
GeneralDeclaring inherited class objects Pin
MarkBremmer4-Jan-05 5:32
MarkBremmer4-Jan-05 5:32 
GeneralRe: Declaring inherited class objects Pin
Bahadir Cambel4-Jan-05 6:57
Bahadir Cambel4-Jan-05 6:57 
GeneralRe: Declaring inherited class objects Pin
Steven Campbell4-Jan-05 16:52
Steven Campbell4-Jan-05 16:52 
GeneralRe: Declaring inherited class objects Pin
Anonymous5-Jan-05 4:20
Anonymous5-Jan-05 4:20 
Generalmulit-client server programming question Pin
ppp0014-Jan-05 0:22
ppp0014-Jan-05 0:22 
GeneralRe: mulit-client server programming question Pin
perlmunger4-Jan-05 8:30
perlmunger4-Jan-05 8:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.