#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Brisbane, Australia
    Posts
    50
    Rep Power
    12

    Howto skin C# apps?


    Is there anyone how might know how to skin C# or VB.NET forms?
    Is it possible? (I think nothing is impossible...)
    Is it going to be hard?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Bulgaria
    Posts
    22
    Rep Power
    0

    Re: Howto skin C# apps?


    Originally posted by oni9
    Is there anyone how might know how to skin C# or VB.NET forms?
    Is it possible? (I think nothing is impossible...)
    Is it going to be hard?
    Yes, it is possible. The only way in Windows to skin controls (or windows, it is the same) is to grab the WM_PAINT message from the original control's procedure and process it yourself. In the .NET framework the OnPaint function represents the OS WM_PAINT message. In .NET there is no need to replace manually the original procedure of the window with your own because the framework does it. With the overlapped or popup windows, like the form, you must handle yourself the WM_ERASEBKGND message. These are general principles of painting in Windows so they apply to any framework. In .NET find the function that represents the OS WM_ERASEBKGND message, get the DC (or graphics context) and paint whatever you want in the nonclient area of your form. Don't do it in the OnPaint handler. It draws on the client area of the window.
    It is not so hard once you know what you are doing.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Brisbane, Australia
    Posts
    50
    Rep Power
    12
    Thanks anatol

    I found the OnPaintBackground() function which I believe it represents WM_ERASEBKGND.

    I'm not sure what client area and non-client area really means.
    when I tried to draw a string by overriding OnPaintBackground(), the string drawn with a transparent background on the form, while with OnPaint(), it draws normally just like a label with solid form background.

    Is that transparent background area the non-client area I'm suppose to paint with?


    Abit confused, but I think I know how to skin apps with C#... thanks again
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Bulgaria
    Posts
    22
    Rep Power
    0
    Originally posted by oni9
    Thanks anatol

    I found the OnPaintBackground() function which I believe it represents WM_ERASEBKGND.

    I'm not sure what client area and non-client area really means.
    when I tried to draw a string by overriding OnPaintBackground(), the string drawn with a transparent background on the form, while with OnPaint(), it draws normally just like a label with solid form background.

    Is that transparent background area the non-client area I'm suppose to paint with?


    Abit confused, but I think I know how to skin apps with C#... thanks again
    I'm sorrry about the confusion. When you want, say, to paint the background of the app with some image you handle the WM_ERASEBKGND, but if you want to completely ignore the painting that windows does to forms (the window frame) you hande the WM_NCPAINT, NC comes from "non-client". There are also WM_NCLBUTTONDOWN,WM_NCMOUSEMOVE, etc. Now, what client and non-client means: this is a key concept of windows proramming so you must know it, especially if you do painting in Windows. Non-client area means the entire window, including the caption borders, close, minimize, maximize buttons. Client area is the area where you usually display things, excluding caption, borders, etc. Example: in Windows Explorer the client area is where you see the directories and files, without the caption, menus, toolbars and statusbar. Usually all the work is done in the client area of the window, but if you want to change the look of the entire window you should handle the nonclient area painting i.e WM_NCPAINT. There must be a function that represent the WM_NCPAINT in the .NET. Sorry that i can't remember the names of the functions but i've uninstalled Visual Studio .NET so try to find them yourself. When tou handle WM_PAINT, i.e , the painting in the client area, you get the client DC (or graphics context) to paint at. If you handle the WM_NCPAINT, you get the window DC to paint at. In Windows you get them with GetDC() (for the client area) and GetWindowDC() (for the nonclient area).

IMN logo majestic logo threadwatch logo seochat tools logo