home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
msj
/
v10n04
/
multilin.exe
/
TIMEFORM.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-01
|
5KB
|
169 lines
// timeform.cpp : implementation file
//
#include "stdafx.h"
#include "global.h"
#include "timeform.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTimeFormat dialog
CTimeFormat::CTimeFormat(CWnd* pParent /*=NULL*/)
: CDialog(CTimeFormat::IDD, pParent)
{
//{{AFX_DATA_INIT(CTimeFormat)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CTimeFormat::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTimeFormat)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTimeFormat, CDialog)
//{{AFX_MSG_MAP(CTimeFormat)
ON_LBN_DBLCLK(IDC_TIMEFORMATS, OnDblclkTimeformats)
ON_EN_CHANGE(IDC_CUSTOM, OnChangeCustom)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTimeFormat message handlers
BOOL CTimeFormat::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
AppendTimeFormat( LOCALE_STIMEFORMAT | LOCALE_NOUSEROVERRIDE);
AppendTimeFormat( LOCALE_STIMEFORMAT);
SendDlgItemMessage( IDC_TIMEFORMATS, LB_SETCURSEL, 0, 0);
SendMessage( WM_COMMAND, IDC_TIMEFORMATS, 0);
// Format a sample date
OnDblclkTimeformats();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
#define STRINGLEN 128
/////////////////////////////////////////////////////
// EnumTimeFormatsProc
//
// Add the given date format string to the list box and
// set that item's data to TIME_SHORTFORM or TIME_LONGFORM
#define MAXSAMPLELEN 128
#define MAXTIMEFORMAT 50
////////////////////////////////
// ShowSampleTime
//
void CTimeFormat::ShowSampleTime( CString& szTimeFormat, DWORD dwTimeFlags)
{
static TCHAR szSampleTime[ MAXSAMPLELEN];
GetTimeFormat( GetThreadLocale(), // use this thread's locale
dwTimeFlags, // flags passed into this function
NULL, // use current system time
szTimeFormat, // format seleted by user
szSampleTime, // for formatted date
MAXSAMPLELEN); // date buffer length
SetDlgItemText( IDC_FORMATTED, szSampleTime);
}
BOOL CTimeFormat::AppendTimeFormat(
DWORD dwFlags) // pointer to date format string
{
static TCHAR szFmt[STRINGLEN] = TEXT("");
static TCHAR szTmp[STRINGLEN] = TEXT("");
LONG lTmp;
LONG lIndex = SendDlgItemMessage( IDC_TIMEFORMATS,
LB_GETCOUNT,
0, 0);
int nBufLen = GetLocaleInfo( GetThreadLocale(), dwFlags, szFmt, STRINGLEN);
if ( nBufLen == 0 )
{
LONG lRC = GetLastError();
}
// Is this format string already in the list?
for ( lTmp = 0; lTmp < lIndex; ++lTmp )
{
SendDlgItemMessage( IDC_TIMEFORMATS,
LB_GETTEXT,
lTmp,
(LPARAM)szTmp);
if ( lstrcmp( szFmt, szTmp) == 0 )
return( TRUE); // Already in list
}
lIndex = SendDlgItemMessage( IDC_TIMEFORMATS,
LB_ADDSTRING,
0,
(LPARAM)szFmt);
if ( ! (lIndex = LB_ERR || lIndex == LB_ERRSPACE) )
{
return( SendDlgItemMessage( IDC_TIMEFORMATS,
LB_SETITEMDATA,
lIndex,
(LPARAM)dwFlags) == LB_ERR ? FALSE : TRUE);
}
return( FALSE);
}
void CTimeFormat::OnChangeCustom()
{
// TODO: Add your control notification handler code here
CString szTimeFormat;
SendDlgItemMessage( IDC_CUSTOM,
WM_GETTEXT,
MAXTIMEFORMAT,
(LPARAM)(szTimeFormat.GetBufferSetLength(MAXTIMEFORMAT)));
DWORD dwTimeFlags = 0;
ShowSampleTime( szTimeFormat, dwTimeFlags);
}
void CTimeFormat::OnDblclkTimeformats()
{
// TODO: Add your control notification handler code here
LONG lIndex = SendDlgItemMessage( IDC_TIMEFORMATS,
LB_GETCURSEL, 0, 0);
CString szTimeFormat;
SendDlgItemMessage( IDC_TIMEFORMATS,
LB_GETTEXT,
(WPARAM)lIndex,
(LPARAM)(szTimeFormat.GetBufferSetLength(MAXTIMEFORMAT)));
DWORD dwTimeFlags = SendDlgItemMessage( IDC_TIMEFORMATS,
LB_GETITEMDATA,
(WPARAM)lIndex, 0);
ShowSampleTime( szTimeFormat, dwTimeFlags);
}