August 21st, 2003, 04:54 PM
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?
August 21st, 2003, 08:01 PM
Re: Howto skin C# apps?
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.
August 21st, 2003, 10:32 PM
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
August 23rd, 2003, 08:13 PM
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).