Changing look and feel of WinForms application
Hi there,I have a question that I can't solve for a long period of time. I love custom interfaces against standard ones but can't find the way to customize my Windows Forms application. Lets take a look into msn for example.
1. In the conversation dialog the RichEdit with messages has overridden scroll bar. How to change look and feel of scroll bars of each control using Windows Forms? Maybe by using User32 and GDI32 functions?
2. Send button looks good, but I didn't find the way to implement button like this using standard properties.
3. There is no ComboBox in msn I liked but I would like to change typical button on the right of ComboBox with my button.
4. I would like to have textboxes with my background (gradient for example)
I'm sure this is all possible because there are lot of expensive WinForms control libraries with such features.
Thanks a lot.
Sasha.
1. Changing look and feel... do you mean by feel also changing its behaviour? Anyway, I think that controls that enable or disable scrollbars are hard to customize. Internally they use an override of the CreateParams method to enable scrollbars by using the WS_HSCROLL and WS_VSCROLL style bits. Here is a thread of someone who actually did override the scrollbars, which is kinda ugly, but still:
http://www.dotnet247.com/247reference/msgs/55/277466.aspx
Microsoft generally uses more sophisticated control sets than the standard control set that is used by Visual Studio, so I wonder if they used RichTextBox at all for the MSN app, or are you confident that this is a RichTextBox class? I mean, they do all sorts of special things in that control with downloading and all.
2: I don't think that the MSN send button is a default button. It is imho often quite easy to build these sort of controls from the ground up by yourself. The visual styles from .NET 2.0 can help out there, or the ControlPaint class.
3: I don't really know what the best way is to accomplish this. The only thing I can tell you is that the combobox is 'just' a collection of a textbox, a button and a listbox, when pressed. So if you have these components, you can build your own.
4: I have had a terribly hard time customizing the default windows textbox. I eventually gave up and soon I'll be building my own from scratch. Things like doing your own text painting (with anti-aliasing, like I tried), or drawing a custom background will get you into a lot of trouble. Most of TextBox's functionality is still ancient Windows code and you cannot modify its behaviour. In my case sometimes the text was just printed over my text, using the default font. In my search I found many other people complaining about this issue. I would recommended not even trying, and if somebody has any good ideas about this issue, I would love to hear about it.
Thank you for reply and suggestions, but please take a look at this linkhttp://www.dotnetskin.net/By placing "Skin" component on form and specifying the path to skin file it applies described in xml file look and feel to all controls in form. I'm wondering how they did this.
I guess they used User32 and Gdi32 exported functions. Any suppositions?
Ok, that's a pretty cool piece of work! (Other then that it crashes now and that it shows some glitches :/).
I am a bit puzzled how he did this, just like you are. Note that it hasn't got skin support for textboxes :). I can't run it anymore at this point, but I'd like to investigate this more at work tomorrow.
Still, I doubt whether he is really customizing controls. I think he will use something like a windows hook to intercept messages and customize them (check SetWindowsHookEx). I'm not very experienced in customizing controls in this way, but I really think that he is taking over *all* of the painting. And since the internal states of the controls are usually not exposed, you often need to take over most of the logic too. This equals making a control from scratch. My idea is that he uses the controls as placeholders for his own logic and painting. But I could be terribly wrong :).
The professional GUI frameworks that I evaluated all had controls that were build from scratch.
In the meantime I am just as curious if someone can tell me otherwise.
Ok, a few more things that I'd like to point out about DotNetSkin:
-Did you know that you can download a few simple controls from the site for your use for free? I wonder whether these controls are similar controls as the one used in the distributed app. They look the same. Anyway, these controls are simply derived from CheckBox, Button etc... essentially they are completely custom build, no special tricks.
-I previously mentioned that I think that the entire controls, including its logic, are rebuild. Well, take a look at how the buttons/checkboxes/radiobuttons behave compared to original ones: if you press one of them and keep them pressed, and if you then move away from the control, the controls remain pressed. A Windows original button will go back to unpushed state when left during press. This indicates to me that the logic is custom made. This behaviour is shown in both the free controls and the distributed controls.
Very interesting, but i didn't find anything like that. Could you please give me a link to source code of those controls?
I tried to review source code using reflector, but they encrypted all function names and varialbes.
Thank you for examples, i'll review it.
Another tip:
You can also see what p/invokes are imported in Reflector by right-clicking an assembly and selecting 'Analyze'. This will even work for the obfuscated redistributable version.
Then you can see exactly what GDI and User imports have been made.