Click here to Skip to main content
15,886,795 members
Articles / Desktop Programming / WTL

Gradient Bar Control

Rate me:
Please Sign up or sign in to vote.
4.69/5 (7 votes)
4 Nov 2012Zlib6 min read 38.2K   3.9K   39  
A WTL control to display quality rate
#pragma once

#include "GradientBarCtrl.h"

// CUserDlg dialog

class CUserDlg
	: public CDialogImpl<CUserDlg>
	, public CWinDataExchange<CUserDlg>
{
public:
	enum { IDD = IDD_USERNAME_PASSWORD };

	BEGIN_MSG_MAP(CUserDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_CLOSE, OnClose)
		COMMAND_HANDLER(IDOK, BN_CLICKED, OnBnClickedOk)
		COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnBnClickedCancel)
		COMMAND_HANDLER(IDC_PASSWORD, EN_CHANGE, OnEnChangePassword)
		COMMAND_HANDLER(IDC_PASSWORD, EN_SETFOCUS, OnEnSetfocusPassword)
		COMMAND_HANDLER(IDC_PASSWORD, EN_KILLFOCUS, OnEnKillfocusPassword)
		COMMAND_HANDLER(IDC_USERNAME, EN_CHANGE, OnEnChangeUsername)
		COMMAND_HANDLER(IDC_PASSWORD_RETYPE, EN_CHANGE, OnEnChangePasswordRetype)
	END_MSG_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnBnClickedOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnBnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	LRESULT OnEnChangePassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnEnSetfocusPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnEnKillfocusPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	LRESULT OnEnChangeUsername(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnEnChangePasswordRetype(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	BEGIN_DDX_MAP(CUserDlg)
        DDX_CONTROL_HANDLE(IDC_USERNAME, m_ctlUsername)
        DDX_CONTROL_HANDLE(IDC_PASSWORD, m_ctlPassword)
        DDX_CONTROL_HANDLE(IDC_PASSWORD_RETYPE, m_ctlRetypePassword)
        DDX_CONTROL_HANDLE(IDOK, m_btnOk)
        DDX_CONTROL(IDC_PASSWORD_STRENGTH, m_ctlPasswordStrength)
    END_DDX_MAP()

private:
	CEdit m_ctlUsername;
	CEdit m_ctlPassword;
	CEdit m_ctlRetypePassword;
	CGradientBarCtrl m_ctlPasswordStrength;
	CButton m_btnOk;

	void UpdateControls();
	bool ShouldEnableOkButton();
};

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 zlib/libpng License


Written By
Software Developer (Senior)
Croatia Croatia
Graduated at the Faculty of Electrical Engineering and Computing, University of Zagreb (Croatia) and received M.Sc. degree in electronics. For several years he was research and lecturing assistant in the fields of solid state electronics and electronic circuits, published several scientific and professional papers, as well as a book "Physics of Semiconductor Devices - Solved Problems with Theory" (in Croatian).
During that work he gained interest in C++ programming language and have co-written "C++ Demystified" (in Croatian), 1st edition published in 1997, 2nd in 2001, 3rd in 2010, 4th in 2014.
After book publication, completely switched to software development, programming mostly in C++ and in C#.
In 2016 coauthored the book "Python for Curious" (in Croatian).

Comments and Discussions