先发一个KWinGUI Framework的一个Demo程序。主要是展示一个圆形的Slider组件,可以做播放器之类的音量按钮。
截图:
主程序代码如下:
1 #define IDC_SLIDER1 1001
2 #define IDC_SLIDER2 1002
3
4 #define IDD_ROUNDSLIDERCTRLDEMO_DIALOG 10000
5
6 #define _WIN32_WINNT 0x0400
7
8 #include "kxcmnctrls.h"
9 #include "kapp.h"
10 #include "resource.h"
11
12 class KRndSliderDemoDlg : public KDialogBase<KRndSliderDemoDlg>{
13 public:
14 BEGIN_MSG_MAP
15 MSG_HANDLER(WM_INITDIALOG,OnInitDialog)
16 COMMAND_ID_HANDLER(IDOK,OnOK)
17 COMMAND_ID_HANDLER(IDCANCEL,OnOK)
18 END_MSG_MAP(KDialogBase<KRndSliderDemoDlg>)
19
20 enum{IDD=IDD_ROUNDSLIDERCTRLDEMO_DIALOG};
21
22 LRESULT OnInitDialog(WPARAM wParam,LPARAM lParam,bool& bHandled){
23 m_rscSlider1.SubclassDlgItem(IDC_SLIDER1,*this);
24 m_rscSlider2.SubclassDlgItem(IDC_SLIDER2,*this);
25
26 m_rscSlider1.SetRange(-179, 180, FALSE);
27 m_rscSlider1.SetPos(42);
28 m_rscSlider1.SetZero(90);
29 m_rscSlider1.SetInverted();
30
31 m_rscSlider1.SetDialColor(RGB(255, 255, 0));
32 m_rscSlider1.SetKnobColor(RGB(0, 0, 255));
33
34 m_rscSlider2.SetRange(875, 1080, FALSE);
35 m_rscSlider2.SetPos(948);
36 m_rscSlider2.SetZero(180);
37 m_rscSlider2.SetRadioButtonStyle();
38
39
40 m_rscSlider2.SetFontName(_T("Comic Sans MS"));
41 m_rscSlider2.SetFontSize(14);
42 m_rscSlider2.SetFontItalic();
43 m_rscSlider2.SetTextColor(RGB(0, 0, 255));
44
45 CentralizeWindow();
46 return TRUE;
47 }
48 LRESULT OnOK(WORD wID,WORD wNotifyCode,HWND hWndCtrl,bool& bHandled){
49 EndDialog(wID);
50 return 0;
51 }
52 private:
53 KRoundSlider m_rscSlider1,m_rscSlider2;
54 };
55
56 class KRndSliderDemo : public KWinApp{
57 public:
58 bool InitInstance(){
59 KRndSliderDemoDlg dlg;
60 dlg.DoModal();
61 return false;
62 }
63 };
64
65 KRndSliderDemo theApp;
KRoundSlider类实在过于有些冗长,这里就不贴出来了。
通过此Demo简单展示一下KWinGUI的使用。我仍然在使用宏来做消息映射,目前这是这个框架最丑陋的地方,下一步准备做大的改动。cexer的消息派发模型我还是比较感兴趣的,还望cexer多多指导,善莫大焉,呵呵。
程序静态链接未压缩状态下大小108K,
在此提供下载。