tag:blogger.com,1999:blog-21376270.post-71227180766294107442007-11-02T15:17:00.000+06:002007-11-02T15:39:50.020+06:00When do we need custom skins?<strong><span style="font-size:130%;">The Question.</span><br /></strong><br />I have been asked about custom skins a great number of times.<br />When are they really needed and how do they function?<br /><br />Let's have this short article describing the topic.<br /><br />First of all, we need to accept that <a href="http://www.skincrafter.com/skincrafter.html"><strong>SkinCrafter</strong> </a>skins are <em>skins for applications</em> based on <strong>Windows Common Controls </strong>types<strong>.</strong><br /><br />When skin is applied, all controls are skinned with a particular graphics. I.e. all buttons look similar and all textboxes look similar.<br /><br />It's not a rare case that developer needs to make some controls looking <strong>differently</strong>.<br /><br />For example, he needs a<strong> greed button</strong> among the <strong>blue ones</strong>.<br />Or he wants to highlight the textbox with wrong input <strong>in red</strong>.<br />Or ...<br />I can list such cases endlessly.<br /><br />Well, that's what the custom skins are meant for. You need them to make controls of one type <strong>look deferently</strong> than other skinned controls of this type.<br /><br /><strong><span style="font-size:130%;">Implementation.</span></strong><br /><strong></strong><br />In <strong><a href="http://www.skincrafter.com/skbuilder.html">SkinBuilder</a></strong>, you should go to <strong>Custom Controls</strong> pane, and add the custom control you need.<br />For example, a textbox.<br />It will result in a new textbox item appeared in the controls tree. Which is completely the same as in <strong>Default Controls</strong>, but is here for you to put different <em>images</em> and <em>colors</em> settings.<br /><br />When fulfilled, name this items according to your taste (let's say something like "<em>redCustomTextBox</em>" will do) and save the skin.<br /><br />Now you will have <strong>two skins</strong> for textbox within a <strong>single skin file</strong>.<br /><br /><em>That's a half of the job.</em><br /><br />If you now apply this skin to your application, all textboxes still will be skinned with default textbox skin.<br />That's because you need to specify in code, which control should use our custom skin .<br /><br />There is an interface method - <strong>SetCustomSkinWnd</strong> - which should be used.<br />This method assigns<em> a custom skin</em> to <em>a particular control or window</em>.<br /><br />In our case, a sample code snippet will look like this:<br /><br /><span style="font-size:85%;">SkinOb.SetCustomSkinWnd(myTextBox.Handle.ToInt32(), "redCustomTextBox", false);</span> <em>//that's C# sample</em><br /><br />The above code should be called after the textbox is created. And when compiled <em>myTextBox</em> should be skinned with <strong>custom skin </strong>and look different.<br /><br />See more info about <em>SetCustomSkinWnd</em> method in <strong><a href="http://www.skincrafter.com/downloads/skincrafter_net.chm">SkinCrafter Help File</a></strong>.Paul GreatSkinhttp://www.blogger.com/profile/07083313196194548540noreply@blogger.com