Click here to Skip to main content
Click here to Skip to main content
Go to top

Week hours planning control

, 6 Aug 2002
Rate this:
Please Sign up or sign in to vote.
An article on making a week hours planning control

Introduction

Last week I saw a Windows 2000 server user's management.  I have seen in the session planning a control. I think that this control is very important for applications which use planning tasks. And the best use of this control is in Internet/Network applications. This article demonstrate using of window messages to create controls. This article uses WM_LBUTTONUP, WM_LBUTTONDOWN, WM_MOUSEMOVE. And demonstrate how to have a good method of drawing by repainting only the area which is modified. This is my first article for Code Project.

Usage

Simply include the header file.

#include "WeekHours.h"

Then you insert in the dialog a static control and enable the notify property (window styles). And modify the control ID, for e.g. IDC_SESSIONS_PLANNING (if you don't modify the IDC_STATIC, class wizard won't let you create variable). Then create a variable for this control (the type will be CStatic) change the type to CWeekHours .

//{{AFX_DATA(CTimeTestDlg)
enum { IDD = IDD_TIMETEST_DIALOG };
CWeekHours m_WeekHours;
...
...
...
//}}AFX_DATA

To initialize the control

The initialization of the control will be in OnInitDialog or constructor of the dialog. The set state order is important.

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

    ...
    ...
    ...

    // TODO: Add extra initialization here

    // select a language for the week days
    m_WeekHours.m_Language = LNG_ENGLISH;       

    // Selection button text
    m_WeekHours.m_SelBtnText = "Autorised connection";  
    
    // Deselection button text
    m_WeekHours.m_DeSelBtnText = "Refused connection";  


    // Select the 8 hour in all week days
    m_WeekHours.SetHourDaysState(8, HST_SELECTED);  

    // Select the 9 hour in all week days
    m_WeekHours.SetHourDaysState(9, HST_SELECTED);  

    // Select the 10 hour in all week days  
    m_WeekHours.SetHourDaysState(10, HST_SELECTED); 

    // Select the 11 hour in all week days
    m_WeekHours.SetHourDaysState(11, HST_SELECTED); 

    // Disible the Thursday hours
    m_WeekHours.SetDayHoursState(5, HST_DESIBLED);  

    // Disible the Friday hours
    m_WeekHours.SetDayHoursState(6, HST_DESIBLED);  
}

To get state of hour

Use the function GetHourState(int iDay, int iHour) to get the state of the hour. The class provide different functions to manipulate the state of a hour and block of hours.

// Get state of a hour
int GetHourState(int iDay, int iHour);		

// Set the state of a hour
void SetHourState(int iDay, int iHour, int State);	

// Set the state of the day hours
void SetDayHoursState(int iDay, int State);	

// Set the state of the hour in all week days
void SetHourDaysState(int iHours, int State);	

Conclusion

This article can show how to create own control from basic MFC window class. And demonstrates how to exploit a simple window message to create controls. If you use this control or you fixed bugs, sending mail for me will be a nice idea. Thanks.

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

Share

About the Author

Mourad DEBBAH
Web Developer
Algeria Algeria
ASM, C/C++, JAVA, PERL, PHP, PASCAL, data base, and victorial drawing Programmer. Live in Algeria.
Now i work in a company with VB 6 and SQl Server. I am interested by OOP using UML.

Comments and Discussions

 
GeneralIn C# Pinmembercanozurdo7-Mar-07 9:21 
GeneralRe: In C# Pinmemberpita200024-Mar-07 10:21 
GeneralIt's a great control... PinmemberJung Jinhyuck2-Jun-04 19:32 
GeneralRe: It's a great control... PinsussMourad DEBBAH16-Sep-04 2:02 
Generalhelp me Pinmemberhongge13-Jul-03 15:39 
GeneralSpelling PinmemberColin Davies12-Feb-03 22:12 
GeneralRe: Spelling PinmemberThe Computer Whisperer18-Feb-03 8:44 
GeneralRe: Spelling PinmemberColin Davies18-Feb-03 9:04 
GeneralRe: Spelling PinmemberThomas West7-Jul-03 5:49 
GeneralRedrawing problems Pinmemberfjosesen12-Aug-02 2:29 
GeneralRe: Redrawing problems PinmemberMourad DEBBAH12-Aug-02 21:55 

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.

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 7 Aug 2002
Article Copyright 2002 by Mourad DEBBAH
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid