|
|
Dtp = new LboxDTPicker(
hDlg,
GetDlgItem( hDlg, IDC_EDIT1 ),
true
);
| |
|
|
// *********************************************************
// 拡張コンストラクタ
// *********************************************************
LboxDTPicker::LboxDTPicker( HWND hOwner, HWND hBase, BOOL bNoData )
{
BaseEdit = new LboxEdit( hBase );
this->bNoData = bNoData;
BaseEdit->Hide( );
BaseEdit->Disable();
RECT rt;
POINT pt;
GetWindowRect( hBase, &rt );
pt.x = rt.left;
pt.y = rt.top;
ScreenToClient( hOwner, &pt );
int nW,nH;
nW = BaseEdit->Width();
nH = BaseEdit->Height();
if ( bNoData ) {
this->hWnd =
CreateWindowEx(
0,
DATETIMEPICK_CLASS,
"DateTime",
WS_BORDER |
WS_CHILD |
WS_VISIBLE | WS_TABSTOP |
DTS_SHOWNONE,
pt.x, pt.y, nW, nH,
hOwner,
NULL,
LboxGetInstance( hOwner ),
NULL
);
}
else {
this->hWnd =
CreateWindowEx(
0,
DATETIMEPICK_CLASS,
"DateTime",
WS_BORDER |
WS_CHILD |
WS_VISIBLE | WS_TABSTOP,
pt.x, pt.y, nW, nH,
hOwner,
NULL,
LboxGetInstance( hOwner ),
NULL
);
}
if ( this->hWnd != NULL ) {
SetWindowPos(
this->hWnd,
hBase,
0,0,0,0,
SWP_NOMOVE | SWP_NOSIZE
);
}
}
LboxDTPicker::LboxDTPicker()
{
}
LboxDTPicker::~LboxDTPicker()
{
delete BaseEdit;
}
| |
|
|
|
|
// *********************************************************
// 選択された日付文字列の取得
// 戻り値 : 無し
// *********************************************************
BOOL LboxDTPicker::GetDateString( LboxString *LString )
{
SYSTEMTIME st;
if ( GDT_NONE != DateTime_GetSystemtime( this->hWnd, &st ) ) {
LString->Printf( "%04d/%02d/%02d", st.wYear, st.wMonth, st.wDay );
return true;
}
else {
LString->SetChar( 0, 0 );
return false;
}
}
| |
|
|
|
|
// *********************************************************
// 選択された日付の SYSTEMTIME の取得
// 戻り値 : 無し
// *********************************************************
BOOL LboxDTPicker::GetDateSystemtime( SYSTEMTIME *st )
{
if ( GDT_NONE == DateTime_GetSystemtime( this->hWnd, st ) ) {
ZeroMemory( st, sizeof( SYSTEMTIME ) );
return false;
}
else {
return true;
}
}
| |
|
|
|
|
// *********************************************************
// 文字列日付を設定
// 戻り値 : 設定できない日付を指定すると false
// *********************************************************
BOOL LboxDTPicker::SetDateString( LboxString *LString, LPTSTR lpDelim )
{
return SetDateString( LString->szLboxString, lpDelim );
}
BOOL LboxDTPicker::SetDateString( LPTSTR lpDate, LPTSTR lpDelim )
{
SYSTEMTIME st;
BOOL bRet;
LboxToken *Token;
Token = new LboxToken();
Token->CreateToken( lpDate, lpDelim );
if ( this->bNoData ) {
if ( Token->nCount != 3 ) {
ZeroMemory( &st, sizeof( SYSTEMTIME ) );
DateTime_SetSystemtime( this->hWnd, GDT_NONE, &st );
}
else {
ZeroMemory( &st, sizeof( SYSTEMTIME ) );
st.wYear = atoi( Token->Token[0] );
st.wMonth = atoi( Token->Token[1] );
st.wDay = atoi( Token->Token[2] );
bRet = DateTime_SetSystemtime( this->hWnd, GDT_VALID, &st );
if ( !bRet ) {
DateTime_SetSystemtime( this->hWnd, GDT_NONE, &st );
}
}
bRet = true;
}
else {
if ( Token->nCount != 3 ) {
bRet = false;
}
else {
ZeroMemory( &st, sizeof( SYSTEMTIME ) );
st.wYear = atoi( Token->Token[0] );
st.wMonth = atoi( Token->Token[1] );
st.wDay = atoi( Token->Token[2] );
bRet = DateTime_SetSystemtime( this->hWnd, GDT_VALID, &st );
}
}
delete Token;
return bRet;
}
| |
|
|
|
|
// *********************************************************
// 日付の SYSTEMTIME の設定
// 戻り値 : 設定できない日付を指定すると false
// *********************************************************
BOOL LboxDTPicker::SetDateSystemtime( SYSTEMTIME *st )
{
BOOL bRet;
if ( this->bNoData ) {
if ( st->wYear == 0 && st->wMonth == 0 && st->wDay == 0 ) {
DateTime_SetSystemtime( this->hWnd, GDT_NONE, st );
}
else {
bRet = DateTime_SetSystemtime( this->hWnd, GDT_VALID, st );
if ( !bRet ) {
DateTime_SetSystemtime( this->hWnd, GDT_NONE, st );
}
}
return true;
}
else {
bRet = DateTime_SetSystemtime( this->hWnd, GDT_VALID, st );
return bRet;
}
}
| |
|
|
|
|
case WM_NOTIFY:
if ( Dtp != NULL ) {
Dtp->Notify( hDlg, lParam );
}
break;
case LBOX_DTP_CHANGE:
Dtp->GetDateString( Buff );
Dlg->StatusSetText( Buff );
break;
case LBOX_DTP_KILLFOCUS:
Dlg->StatusSetText( "KillFocus" );
break;
case LBOX_DTP_SETFOCUS:
Dlg->StatusSetText( "SetFocus" );
break;
| |
|
|
// *********************************************************
// WM_NOTIFYメッセージを取得してユーザメッセージを送る
// 戻り値 : メッセージ( 0 の時は対象外 )
// *********************************************************
UINT LboxDTPicker::Notify( HWND hTarget, LPARAM lParam )
{
HWND hCur;
LPNMHDR lpNmhdr;
lpNmhdr = (LPNMHDR)lParam;
hCur = lpNmhdr->hwndFrom;
// メッセ−ジがこのオブジェクトである場合
if ( hCur == this->hWnd ) {
if ( lpNmhdr->code == DTN_DATETIMECHANGE ) {
SendMessage( hTarget, LBOX_DTP_CHANGE, (WPARAM)hCur, 0 );
}
if ( lpNmhdr->code == NM_KILLFOCUS ) {
SendMessage( hTarget, LBOX_DTP_KILLFOCUS, (WPARAM)hCur, 0 );
}
if ( lpNmhdr->code == NM_SETFOCUS ) {
SendMessage( hTarget, LBOX_DTP_SETFOCUS, (WPARAM)hCur, 0 );
}
return lpNmhdr->code;
}
return 0;
}
| |
|
|
|