Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4604783
  • 博文数量: 671
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 7310
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-14 09:56
文章分类

全部博文(671)

文章存档

2011年(1)

2010年(2)

2009年(24)

2008年(271)

2007年(319)

2006年(54)

我的朋友

分类: C/C++

2008-09-14 20:43:31

  • Sample Image - swing.jpg

    Introduction

    This library presents a set of MFC classes that replicate the Java Swing style controls.

    I sat down for two whole months to write this library. I was inspired from the cool GUI which Java Swing components offer. Although I tried to create the simulation as the same, in some places it was not possible. Win32 API does not have support to redraw a scrollbar. I also tried to make the combo box as good as possible. The progress bar looks even cooler, as does the slider. I hope you like these components - but email me if you have any bug fixes or suggestions.

    Note:The release version of this MFC extension dll will only work with with release versions of your application, and the debug version with the debug version of your application. Take care to avoid errors.

    To use the library

    First you need to compile the Swing libary. Unpack the downloaded zip and compile the project in the Swing/ directory. This will give you a swing.lib file for linking, and a swing.dll file that you application will use.

    In your project, be sure to include the "swing.h" header file, and also link to the swing.lib library file.

    To get the swing look and feel, set your dialog's background color in your application's InitInstance()

    SetDialogBkColor(RGB(204, 204, 204), RGB(0, 0, 0));

    Using class wizard create control variables for the controls. Then replace the variable types with those given below

    CButton (button) CSwingButton
    CButton (checkbox) CSwingCheckBox
    CButton (radio) CSwingRadio
    CEdit CSwingEdit
    CRichEditCtrl CSwingRichEditCtrl
    CProgressCtrl CSwingProgressCtrl
    CComboBox CSwingComboBox
    CSliderCtrl CSwingSliderCtrl
    CWnd CSwingBorderWnd

    To set the caption for a button use the function

    void SetButtonText (CString pstr)
    CString GetButtonText ()
    

    Simillarly for a checkbox and radio use:

    void SetRadioText (CString pstr)
    CString GetRadioText ()
    
    void SetCheckboxText (CString pstr)
    CString GetCheckboxText()

    For a progress bar use:

    void SetCaption (CString pstr)
    CString GetCaption ()
    

    You can also use following methods for check boxes and radios:

    void SetCheck (BOOL check)
    BOOL GetCheck ()
    

    As all the windows are derived classes, all the other member functions will work.

    There is a problem with radio buttons. You will have to set the control which comes after the last radio button of the last group also with the group property.

    I have also given the facilit where if there is a window which needs only a swing border, you can use the class wizard to create its variable and set its type to CSwingBorderWnd

  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found

    阅读(770) | 评论(0) | 转发(0) |
    0

    上一篇:Advanced Checkers Control

    下一篇:Ruler Control

    给主人留下些什么吧!~~