I install applications everyday and see them run everywhere that use their own "forms", closing buttons, text fields, etc. I am somewhat of a beginner in C# (I know about event driven programming, OOP and have a bit of experience) and would like to know how this is achieved, in other words, how do I make my own buttons, form, etc without using the .Net form objects for this?
An example is Windows Sticky Notes app. How did they make and load that "form"? How did they customize/made the closing button? How can you make your own text field to grab data from? How do I make my own? Your help is really appreciated and you are thanked in advance.
Maybe Fanatic2012 is just interested in how it's done, just for the sake of understanding the internals?
While it's true that many of existing controls can be customized (especially WPF), this is a perfectly legitimate question.
Entirely custom UI systems are made for games all the time. They are usually less sophisticated than what's available for desktop applications, but they do the work and are based on the same or similar principles.
Also, it is possible to create an independent UI system to be run within a standard window (maybe for a GDI or a GDI+ based game.)
Essentially, you need two things: a graphics system to draw the controls (DirectX, OpenGL, GDI, GDI+), and a way to get user input.
Then you can create a bunch of classes, the exact design of which would be influenced by the previously mentioned two factors.
You would need to develop code to figure out over which control the mouse is, then code to detect mouse enter/exit events, clicks, double clicks, and so on. You would have to develop a class to represent the UI on the application level, that would keep track of current focus, interactions and such. There is usually some sort of application loop involved (the render loop in games, the event loop in windows applications).
Once you've figured out the low level stuff, you would then probably abstract it away in your controls, in a way similar to what Windows Forms system does - under the hood, the user input data is obtained "raw", but window and control classes process it, so eventually the controls only get notifications when the user action is related to them, and the windows event loop is hidden behind the .NET event system, where events appear to fire only when something actually happens.
To create composite controls, like panels, group boxes, tab pages and similar, you'd use the Composite design pattern (an OOP design pattern that enables a group of objects and a single object to be treated in the same way). You would probably make use of the Decorator pattern as well, to provide things like scroll bars, borders, or other effects.
The whole UI system would be based on one of the architectural pattens like MVC or MVP, which would enable the controls to respond to user actions, and the application to operate as a whole. You could also accomplish the response implementation using the Observer pattern, which is really what the C# event system is all about, but on a more user-friendly level.
TheGreat, sir, you are great. I want to know what happens under the hood all the time, why reinvent the wheel? Maybe to understand how they came to it in the first place. Now I have a better knowledge of how those things were made, I really appreciate your response, I will be sure to research those concepts to have a better understanding. Again, really appreciated.
Yeah, especially because the complexity of a UI system can be mind-blowing, and there are time-tested solutions already available. But, I don't think the OP had commercial use in mind - I think he just wanted to know what's going on under the hood, on a conceptual level.
As the number of abstraction layers grow with time, certain low-level things become almost mystical to people learning how to program. It almost seems like magic - it's easy to think that there's something terribly special going on under there. So it's good to have some idea about that stuff.