Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / C#

Use the Free USkin Toolkit to Skin your Application

Rate me:
Please Sign up or sign in to vote.
3.39/5 (51 votes)
10 Nov 2008CPOL4 min read 1.7M   43.2K   208  
USkin provides a free library and tools to developers for easily adding skins to their software UI.
// DialogDlg.cpp : ʵ���ļ�
//

#include "stdafx.h"
#include "Dialog.h"
#include "DialogDlg.h"
#include ".\dialogdlg.h"
#include "..\..\..\Include\uskin.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// ����Ӧ�ó��򡰹��ڡ��˵���� CAboutDlg �Ի���

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// �Ի�������
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧��

// ʵ��
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CDialogDlg �Ի���



CDialogDlg::CDialogDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDialogDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_lstView);
	DDX_Control(pDX, IDC_TAB1, m_tabCtrl);
	DDX_Control(pDX, IDC_BUTTON6, m_btn);
}

BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
	ON_WM_NCDESTROY()
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_WM_SIZE()
	ON_COMMAND(ID_COLORTHEME, OnColortheme)
	ON_COMMAND(ID_ABOUTSKINFILE, OnAboutskinfile)
END_MESSAGE_MAP()


// CDialogDlg ��Ϣ�������

BOOL CDialogDlg::OnInitDialog()
{
	
	CDialog::OnInitDialog();

	// ��\������...\���˵�����ӵ�ϵͳ�˵��С�

	// IDM_ABOUTBOX ������ϵͳ���Χ�ڡ�
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// ���ô˶Ի����ͼ�ꡣ��Ӧ�ó��������ڲ��ǶԻ���ʱ����ܽ��Զ�
	//  ִ�д˲���
	SetIcon(m_hIcon, TRUE);			// ���ô�ͼ��
	SetIcon(m_hIcon, FALSE);		// ����Сͼ��

	//ShowWindow(SW_MAXIMIZE);

	// TODO: �ڴ���Ӷ���ij�ʼ������
	m_tabCtrl.InsertItem(0,"��ͨ1");
	m_tabCtrl.InsertItem(1,"��ͨ2");
	m_tabCtrl.InsertItem(2,"��ͨ3");
	m_tabCtrl.InsertItem(3,"��ͨ4");
	CString str;
	for(int i=0;i<4;i++)
	{
		str.Format("col%d",i);
		m_lstView.InsertColumn(i,str,0,80);
	}
	for(i=0;i<20;i++)
	{
		str.Format("col%d",i);	
		m_lstView.InsertItem(i,str,0);
	}
	time_t t;
	t=time(&t);
	srand(t); 
	return TRUE;  // ���������˿ؼ��Ľ��㣬���򷵻� TRUE
}

void CDialogDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// �����Ի��������С����ť������Ҫ����Ĵ���
//  �����Ƹ�ͼ�ꡣ����ʹ���ĵ�/��ͼģ�͵� MFC Ӧ�ó���
//  �⽫�ɿ���Զ���ɡ�

void CDialogDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // ���ڻ��Ƶ��豸������

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// ʹͼ���ڹ��������о���
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// ����ͼ��
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

//���û��϶���С������ʱϵͳ���ô˺���ȡ�ù����ʾ��
HCURSOR CDialogDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CDialogDlg::OnBnClickedButton1()
{
	// TODO: �ڴ���ӿؼ�֪ͨ����������
	CFileDialog dlg(TRUE);
	dlg.DoModal();
}

void CDialogDlg::OnBnClickedButton4()
{
	// TODO: �ڴ���ӿؼ�֪ͨ����������
	CColorDialog dlg;
	dlg.DoModal();
}

void CDialogDlg::OnBnClickedButton3()
{
	// TODO: �ڴ���ӿؼ�֪ͨ����������
	CFontDialog dlg;
	dlg.DoModal();
}

void CDialogDlg::OnBnClickedButton5()
{

	// TODO: �ڴ���ӿؼ�֪ͨ����������
	CPrintDialog dlg(TRUE);
	dlg.DoModal();
}

void CDialogDlg::OnBnClickedButton6()
{
	// TODO: �ڴ���ӿؼ�֪ͨ����������
	//USkin_ExitUSkin();
	//USkinRemoveSkin();
	//USkin_LoadUSkin(_T("qq2004.uskn"));
	CAboutDlg dlgAbout;
		dlgAbout.DoModal();
}

void CDialogDlg::OnNcDestroy()
{
	CDialog::OnNcDestroy();
	
	// TODO: �ڴ˴������Ϣ����������
}


void CDialogDlg::OnFileOpen()
{
	// TODO: �ڴ���������������
	//AfxMessageBox("��\n");
	MessageBox("");
}

void CDialogDlg::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);
	TRACE("ONSIZE\n");
	// TODO: �ڴ˴������Ϣ����������
}

void CDialogDlg::OnColortheme()
{
	// TODO: �ڴ���������������
	
	int n=rand();
	float h=n%360;
	USkinApplyColorTheme(h,1.0f);
}

void CDialogDlg::OnAboutskinfile()
{
	// TODO: �ڴ���������������
	::USkinAboutSkin();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions