CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    10

    How to Make Custom Applications

    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.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to Make Custom Applications

    For client side development, I would recommend using WPF (Windows Presentation Foundation) which allows you to 'skin' the buttons and controls to whatever look you like.

  3. #3
    Join Date
    Sep 2012
    Posts
    10

    Re: How to Make Custom Applications

    Yes I know WPF allows for more customization, but, can I just make my own without the help of predefined classes for that.

  4. #4
    Join Date
    May 2011
    Posts
    41

    Re: How to Make Custom Applications

    Why would you? One of the tenants of OOP is code re-use. There is no need to re-invent the wheel. Now if you want to make a better wheel.....you can extend the original wheel.

  5. #5
    Join Date
    Jan 2010
    Posts
    1,133

    Re: How to Make Custom Applications

    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.

  6. #6
    Join Date
    Sep 2012
    Posts
    10

    Re: How to Make Custom Applications

    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.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to Make Custom Applications

    Learning is one thing, but rolling your own for commercial use is harder to justify.

  8. #8
    Join Date
    Jan 2010
    Posts
    1,133

    Re: How to Make Custom Applications

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured