Click here to Skip to main content
Licence CPOL
First Posted 19 Oct 2008
Views 15,651
Bookmarked 59 times

Use the free DSkinLite Library to skin your Application UI

By | 19 Oct 2008 | Article
DSkinLite is a powerful library to help you develop the user interface program.
   Download DSkinLiteDemo.zip - 1.06 MB
   Download DSkinLiteDemoSrc.zip - 1.08 MB

codeProject.jpg

Introduction  

DSkinLite is a powerful library to help you develop the user interface program. It uses the xml to configure the appearance of user interface, it is suitable for ui developer. Please feel free to contact us with any questions you may have. You can also discuss anything about dskinlite or report bug, or suggest new feature at the forum http://forum.uieasy.com  

Background

We have worked at UI development for several years, so we always want  a library to release us from the bored paint. We have a lot of experience of ui development in projects, so we think dskinlite is more suitable for developer. And we also use dskinlite in our project currently,  we will optimize it continually.   We also hope it will be a useful library for you. 

The key features:    

  • It is a "lite" library, because it doesn't use the hook and just replace the window procedure like the SubclassWindow in MFC. So it has less influence to your application. And It will keep "lite" .    

  • DSkinLite has own optimized image library to process image. And the image library is more suitable for drawing, transparent and alpha blend. At the same time, DSkinLite focus on the speed and the method of drawing, this also improves the efficiency. It also supports the png image format, you can use it make more fancy interface.  

  • DSkinLite uses the xml file to define the gdi resource and describe how to skin a window, so you can construct more ui styles of control very easy. So it separates the interface from the program logic, you can change the skin of application easily. The elements in  painting are abstracted to line, text, rectangle, and image. You can use those items to"configure" a window's appearance in the xml.  

  • The DSkinLite is writen by C++, and  bases on win 32 APIs, so it doesn't depend on any framework. You can use it in MFC, ATL, WTL or Win32 application conveniently. Once there is a window handle, you can use DSkinLite to skin it, even it is not a standard control.  

  • The adjustment of the hue and saturation. The You can adjust the skin's color smoothly.

  • Support change skin at runtime, you can also use different style to skin the control at runtime.

  • Support Unicode.  

  • Support the transparent control fully, it support all control include a child dialog to be transparent.

Using the code

    Using dskinlite in your application is very simple. Recommend you to read the sample code before using dskinlite in your application. The following tutorial sample is a mfc application. 

Step1: Load the .dll file.

    You can use the dskinlite dll by linking the import library, and also you can use the Win32 API LoadLibrary to load the .dll dynamically.In the following description, Use the first method to load the dll.

Step2: Include the dskinlite.h

    Suggest you to include the file dskin.h and dskindef.h in the stdafx.h, so the whole workspace can see the definition of dskinlite.

   #include "dskindll.h"
   #define DSKINDLL_API extern "C" __declspec(dllimport)
   #include "..\include\dskindll.h"
   #include "..\include\dskindef.h"

Step3: Init the dskinlite

    You can write the initial code in CxxApp::InitInstance(), and write the exit code in the CXXApp::ExitInstance().

  
      BOOL CDskinliteTestApp::InitInstance() 
       { 
          .......
          dsLoadskin(_T("skin"));
          .........
       }

      int CDskinliteTestApp::ExitInstance() 
      {
        dsExitSkin(); 
        return CWinApp::ExitInstance();
      } 

   The parameter is the skin directory , It is a relative path to the application exe module.

Step5: Write the XML file.

   You can refer to the xml file in the sample directory, or review the help document about How to Write the xml file ?

   For example:  

  
 <window name="MailButton" type="button">
    <property  bclipwindow="true" tooltips="#default"   clipcolor="RGB(255,0,255)"/>
    <buttoninfo  subtype="push" width="69" height="21"/>
    <image  state = "normal" picfile="#stardard.button.nor" />
    <image state = "over"  picfile="#stardard.button.hot"  />
    <image state = "down"  picfile="#stardard.button.down"  /> 
    <image state = "disable" picfile="#stardard.button.dis" />
    <text state="all" font="#default" horzalign="center" vertalign="" textcolor="RGB(0,0,0)"/>
  </window>         

   The label named "MailButton" describes one way to skin the control button.

Step6: Use the dskinlite to skin your window 

   You must call the function dsSkinWindow to skin your window.

  BOOL CDlgTest::OnInitDialog() 
  { 
    CDialog::OnInitDialog(); 
    dsSkinWindow( GetSafeHwnd(), SKIN_TYPE_DIALOG, NULL, TRUE);
    return TRUE; // return TRUE unless you set the focus to a control
  } 

   This program will use the default label to skin the dialog, and also enumerates the child control of the dialog, then skin the child.

  BOOL CDlgButton::OnInitDialog()
  { 
    CDialog::OnInitDialog(); 
    SET_NOSKIN( 0, GetDlgItem( IDC_BUTTON6)); 
    dsSkinWindow( GetSafeHwnd(), SKIN_TYPE_DIALOG, NULL, TRUE); 
    dsSkinWindow( GetDlgItem( IDC_BUTTON6)->GetSafeHwnd(), 
    SKIN_TYPE_BUTTON,_T("MailButton"), FALSE);
    return TRUE;
  } <a href="DSkinLite/DSkinLiteDemo.zip"></a>

   This program will skin the dialog and all of its children use the default label except the button which id is IDC_BUTTON6. The program will use the label "MailButton" to skin the button IDC_BUTTON6. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

galexding

Software Developer (Senior)

United States United States

Member

Software architect and developer with over 8 years of experience, specializing in window development using C++. Welcome to my home page:http://www.uieasy.com/

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionhow can I solve the unicode/mcb isue of strange ending characters displayed on labels etc? Pinmembersfasdjkfh9:23 2 Nov '08  
AnswerRe: how can I solve the unicode/mcb isue of strange ending characters displayed on labels etc? Pinmembergalexding13:28 2 Nov '08  
GeneralSomething strange in text out Pinmembercqwerty2:09 27 Oct '08  
GeneralRe: Something strange in text out Pinmembergalexding6:04 27 Oct '08  
GeneralQT support Pinmembershabyb4:02 25 Oct '08  
GeneralRe: QT support Pinmembergalexding18:00 25 Oct '08  
GeneralCFileDialog issue Pinmemberrobot_chou2:36 24 Oct '08  
GeneralTabCtrl Skin PinmemberBui Tan Duoc22:34 22 Oct '08  
GeneralRe: TabCtrl Skin Pinmembergalexding5:20 23 Oct '08  
Generalwhy the dll not open ,so it is not complete source code!!! Pinmemberxiayingang3:09 22 Oct '08  
GeneralRe: why the dll not open ,so it is not complete source code!!! Pinmembergalexding4:27 22 Oct '08  
GeneralMENNU BAr not showing PinmemberAlexEvans21:03 21 Oct '08  
GeneralRe: MENNU BAr not showing Pinmembergalexding5:19 23 Oct '08  
GeneralWindows CE support Pinmemberalexquisi3:49 21 Oct '08  
GeneralRe: Windows CE support Pinmembergalexding4:28 21 Oct '08  
Generalgood Pinmemberzhangjingfei21:20 20 Oct '08  
QuestionSource code? PinmemberSteve Weeks20:42 20 Oct '08  
AnswerRe: Source code? Pinmembergalexding23:58 20 Oct '08  
GeneralRe: Source code? PinmemberSteve Weeks3:07 21 Oct '08  
GeneralRe: Source code? Pinmembergalexding4:28 22 Oct '08  
GeneralAdd more keyboard support!!! [modified] Pinmemberamtf2217:59 20 Oct '08  
GeneralRe: Add more keyboard support!!! Pinmembergalexding0:02 21 Oct '08  
QuestionCan we use it in a .NET WinForms application? Pinmemberldyc5:49 20 Oct '08  
AnswerRe: Can we use it in a .NET WinForms application? Pinmembergalexding6:17 20 Oct '08  
Generalawesome!!! Pinmember_Nal_Ra19:51 19 Oct '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 19 Oct 2008
Article Copyright 2008 by galexding
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid