Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Querying Date and Time in Symbian C++

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: symbianyucca (09 Apr 2007)
Last edited: hamishwillee (26 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg

The CAknTimeQueryDialog API is designed for querying time and date values from the user. The following function shows how you can use it:

TInt ShowQueryDialogL(const TDesC& aTitle, TTime& aTime)
{
CAknTimeQueryDialog* Dialog =
CAknTimeQueryDialog::NewL(aTime,CAknQueryDialog::ENoTone);
Dialog->PrepareLC(R_TIME_QUERY);
Dialog->SetPromptL(aTitle);
return Dialog->RunLD();
}

Like all dialogs the CAknTimeQueryDialog also requires resource definition. In this example function you could use one of the following resource definition. The R_DATE_QUERY can be used to query date values and R_TIME_QUERY can be used to query time values.

RESOURCE DIALOG r_date_query 
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY
{
layout = EDateLayout;
label = "";
control = DATE_EDITOR
{
minDate = DATE
{
year = 1973;
month = 2;
day = 17;
};
maxDate = DATE
{
year = 2973;
month = 2;
day = 17;
};
flags = 0;
};
};
}
};
}
 
RESOURCE DIALOG r_time_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY
{
layout = ETimeLayout;
label = "Alarm Time";
control = TIME_EDITOR
{
minTime = TIME
{
second = 0;
minute = 0;
hour = 0;
};
maxTime = TIME
{
second = 59;
minute = 59;
hour = 23;
};
flags = EEikTimeWithoutSecondsField;
};
};
}
};
}

To query both date and time same time, you could utilize CAknMultiLineDataQueryDialog API. The following sample code shows how it is used:

TInt ShowQueryDialogL(TTime& aDate,TTime& aTime)
{
CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(aDate,aTime);
return dlg->ExecuteLD(R_DATE_TIME_QUERY);
}

The resource definitions for this sample code:

RESOURCE DIALOG r_date_time_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineFirstLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataFirstDateEd;
label = "Date";
control = DATE_EDITOR
{
minDate = DATE
{
year = 2006;
};
maxDate = DATE
{
year = 2599;
};
flags = 0;
};
};
},
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineSecondLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataSecondTimeEd;
label = "Time";
control = TIME_EDITOR
{
minTime = TIME
{
second = 0;
minute = 0;
hour = 0;
};
maxTime = TIME
{
second = 59;
minute = 59;
hour = 23;
};
flags = EEikTimeWithoutSecondsField |
EEikTimeForce24HourFormat;
};
};
}
};
}
This page was last modified on 26 July 2012, at 05:02.
40 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×