Click here to Skip to main content
13,667,388 members
Click here to Skip to main content
Add your own
alternative version


32 bookmarked
Posted 6 Aug 2002

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


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.


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 .

CWeekHours m_WeekHours;

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()


    // 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);	


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.


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

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.

You may also be interested in...


Comments and Discussions

GeneralIn C# Pin
canozurdo7-Mar-07 9:21
membercanozurdo7-Mar-07 9:21 
GeneralRe: In C# Pin
pita200024-Mar-07 10:21
memberpita200024-Mar-07 10:21 
GeneralIt's a great control... Pin
Jung Jinhyuck2-Jun-04 19:32
memberJung Jinhyuck2-Jun-04 19:32 
GeneralRe: It's a great control... Pin
Mourad DEBBAH16-Sep-04 2:02
sussMourad DEBBAH16-Sep-04 2:02 
Generalhelp me Pin
hongge13-Jul-03 15:39
memberhongge13-Jul-03 15:39 
GeneralSpelling Pin
Colin Davies12-Feb-03 22:12
memberColin Davies12-Feb-03 22:12 
GeneralRe: Spelling Pin
The Computer Whisperer18-Feb-03 8:44
memberThe Computer Whisperer18-Feb-03 8:44 
GeneralRe: Spelling Pin
Colin Davies18-Feb-03 9:04
memberColin Davies18-Feb-03 9:04 
GeneralRe: Spelling Pin
Thomas West7-Jul-03 5:49
memberThomas West7-Jul-03 5:49 
GeneralRedrawing problems Pin
fjosesen12-Aug-02 2:29
memberfjosesen12-Aug-02 2:29 
GeneralRe: Redrawing problems Pin
Mourad DEBBAH12-Aug-02 21:55
memberMourad DEBBAH12-Aug-02 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180820.1 | Last Updated 7 Aug 2002
Article Copyright 2002 by Mourad DEBBAH
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid