Click here to Skip to main content
Licence 
First Posted 12 Jun 2001
Views 94,806
Bookmarked 30 times

Davide Calabro's CButtonST class port to WTL

By | 26 Jun 2001 | Article
A fully featured owner-draw button class

CButtonST

CButtonST

CButtonST

CButtonST

Introduction

Now you can use Davide Calabro's excellent CButtonSt class in your ATL/WTL projects. The Class is still called CButtonSt and it retains a majority of the original code. Just follow these simple instructions:

  1. Create a WTL Project
  2. Design the dialog and add the button controls
  3. Add the ButtonST.h header file to your project
  4. Assign a CButtonSt to each button.
  5. In OnInitDialog,
    • Subclass each member controls (CButtonST) to each ID using the SubclassWindow method.
    • uses the CButtonSt methods to change the appearance of the control.
  6. In your dialog, don't forget to add the macro REFLECT_NOTIFICATIONS which allows the buttons to get messages like WM_DRAWITEM.
  
class MyDialog : public CDialogImpl<MyDialog>
{
  BEGIN_MSG_MAP(MyDialog)
    ...
    MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
    REFLECT_NOTIFICATIONS()
  END_MSG_MAP()
  ...
  LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, 
    LPARAM /*lParam*/, BOOL& /*bHandled*/);
  ...
  CButtonST m_btn;
  ...
};

LRESULT MyDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/,
  LPARAM /*lParam*/, BOOL& /*bHandled*/) 
{
  ...
  m_btn.SubclassWindow(GetDlgItem(IDC_BTN));
  m_btn.SetIcon(IDI_EOAPP);
  m_btn.SetFlat(false);
  ...
}

See Davide Calabro's original CButtonSt article for more details.

Latest Updates

  • 26 June 2001
    • Updated to Davide Calabro's version 3.2
    • Added support for defining the icons from an image list
    • Added support for creating dynamically the buttons
  • 14 June 2001 - Fixed a bug in the autorepeat feature

Serge Thank you.

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 here

About the Author

Serge Weinstock

Web Developer

United Kingdom United Kingdom

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralTHANK YOU! Pinmemberlzhishen20:28 17 Sep '10  
GeneralSelectObject(pbmpOldBk) Bug Pinmemberfreesindbad20:59 17 Feb '10  
GeneralThank you ! Pinmemberflg6187300:51 24 Nov '09  
Generalloading in dialog bar Pinmemberanubis_ex10:37 21 Jun '05  
GeneralSome bugs. Pinmembert2di4u22:45 24 Nov '04  
GeneralAnother resource leak when using icons PinsussMarkus Steinlein0:05 11 Aug '04  
GeneralPort STButton 3.9! PinmemberRodger5:23 12 May '03  
GeneralBug, resource leak PinsussJohn Gijs0:03 23 Apr '03  
Generalm_bIsFlat - classic appearance and cool behavior PinmemberPablo Aliskevicius3:57 23 Apr '02  
GeneralKeyboard Input PinmemberRob Melchione8:12 25 Jan '02  
Hey, Does this class support keyboard input(TAB, SPACE, ENTER, etc...)??? If it does, I must be doing something wrong. I assume that it is not working as a result of the messages being reflected to the button, but I could be wrong.
 
Any help would be apprecitated.
 
Rob Melchione
Generalterrific article, ... one suggestion :) Pinmemberpartnerinflight8:50 14 Aug '01  
Generalerror C2065: ImageList_Read and ImageList_Write PinmemberOdissey19:23 20 Jun '01  
GeneralRe: error C2065: ImageList_Read and ImageList_Write PinmemberSerge Weinstock7:23 21 Jun '01  
GeneralRe: error C2065: ImageList_Read and ImageList_Write PinmemberAnonymous22:26 12 Jul '01  
GeneralRe: error C2065: ImageList_Read and ImageList_Write PinmemberJohn E23:51 20 Mar '02  
GeneralLockup PinmemberTodd Smith12:50 13 Jun '01  
GeneralRe: Lockup PinmemberMaximilian Hänel14:11 13 Jun '01  
GeneralRe: Lockup PinmemberSerge Weinstock22:23 13 Jun '01  
GeneralGreat! PinmemberMaximilian Hänel2:07 13 Jun '01  
GeneralThanks! PinmemberDavide Calabro23:06 12 Jun '01  

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
Web04 | 2.5.120528.1 | Last Updated 27 Jun 2001
Article Copyright 2001 by Serge Weinstock
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid