|
Not Sure, But I don't have reason to dislike it.
|
|
|
|
|
Did you search on the Net?
|
|
|
|
|
Good Luck!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi all...
How can i change only day of week on button click??
I'm using DateTimePicker and in long date format i'm printing day with the help of "dddd"... How can i change day on button click??
i.e Increment by one day...
SendMessage(GetDlgItem(hdlg,IDC_DATETIMEPICKER6),DTM_SETFORMAT,(WPARAM) wParam,(LPARAM) (LPCTSTR) lpszFormat3);
and in "lpszFormat3" i'm writing this..
CHAR lpszFormat3[MAX_PATH] = "HH':'mm 'every'dddd";
I need to change "dddd" on button click...
How can i do this??
Thanks..
Ash..
|
|
|
|
|
Hi there,
Ashish Chauhan wrote: IDC_DATETIMEPICKER6),DTM_SETFORMAT,(WPARAM
Why are you sending a SetFormat() message to set the date/time? Have you tried something as simple as having a member variable to the control and then calling SetTime() ?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I need to show custom format of date and time..
Date and time with some string..That's why using DTM_SETFORMAT..
Is their any other way to do that??
Ash..
|
|
|
|
|
In your previous message, you stated that you need to just increment the day by one. You didn't say about date/time format. Are you having a trouble setting the format or changing the date/time?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I successfully managed to setting the format.. Actually i took 5 to 6 DateTimePicker..All for different purpose..
This one is printing "02:36 Every Tuesday"
The first one is time and last one is Day and "Every" is string.. On button click i need to change Tuesday to Wednesday then if i click one more time then Wednesday to thursday and so on...
Ash..
|
|
|
|
|
Can you try SetTime()[^]?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
BTW it's Non MFC Application.
Ash..
|
|
|
|
|
Ashish Chauhan wrote: BTW it's Non MFC Application.
OK. I get it now. Have you tried the DateTime_SetSystemtime macro?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks Rajesh..
SystemTime Works... Manage to manipulate day of week...
But how to print the changed day in DateTimePicker??
I mean if today is tuesday i can change it to wednesday with the help of
SYSTEMTIME st;
GetSystemTime(&st);
st.wDayofWeek += 1;
After that it increment the day. But when i try to print the result on DateTimePicker using DTM_SETFORMAT it doesn't reflect...
What could be the problem??
Ash..
|
|
|
|
|
And when i apply the code below on button click it changes time only not day of week. Also i'm not doing manipulating time as well..
Case IDC_BUTTON1:
{
st.wDayOfWeek += 1;
BOOL a =DateTime_SetSystemtime(GetDlgItem(hdlg,IDC_DATETIMEPICKER6),GDT_VALID, &st);
TCHAR lpszFormat3[MAX_PATH] = "hh':'mm 'every' dddd";
SendMessage(GetDlgItem(hdlg,IDC_DATETIMEPICKER6),DTM_SETFORMAT,(WPARAM) wParam,(LPARAM) (LPCTSTR) lpszFormat3);
}
Ash..
modified on Tuesday, March 11, 2008 9:00 AM
|
|
|
|
|
Please try this code and tell me if it helped.
void NextDayOfWeek(const SYSTEMTIME& st, SYSTEMTIME *calculatedTime)
{
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
ULARGE_INTEGER nenoSeconds, nenoseconds_in_a_day;;
nenoseconds_in_a_day.QuadPart = 24*60*60*1000;
nenoseconds_in_a_day.QuadPart *= 10000;
nenoSeconds.HighPart= ft.dwHighDateTime;
nenoSeconds.LowPart= ft.dwLowDateTime;
nenoSeconds.QuadPart += nenoseconds_in_a_day.QuadPart;
ft.dwHighDateTime = nenoSeconds.HighPart;
ft.dwLowDateTime = nenoSeconds.LowPart;
FileTimeToSystemTime(&ft, calculatedTime);
}
case IDC_BUTTON1:
{
SYSTEMTIME myTime, ans;
HWND hdt;
GetDlgItem(IDC_DATETIMEPICKER6, &hdt);
if(DateTime_GetSystemtime(hdt, &myTime) == GDT_VALID)
{
NextDayOfWeek(myTime, &ans);
::SendMessage(hdt, (UINT)DTM_SETSYSTEMTIME, (WPARAM)(DWORD)GDT_VALID, (LPARAM)(LPSYSTEMTIME)&ans);
}
}
I'd also suggest you read a little bit about FILETIME on MSDN.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi..
Thanks Rajesh...Code works..
Thanks a ton...
I'm actually new in this...Anyways you mind telling me the calculation?
I mean i'm bit confused in quadpart, Lowpart, Highpart..
Gone through MSDN but still confused...
How did you calculate the next day.
Thanks Again..
Ash..
|
|
|
|
|
To manipulate time as a long integer, we need to convert it to FILETIME . ULARGE_INTEGER[^] is an union, defined in Winnt.h . This data structure can store a 64 bit unsigned integer. This data structure has a Low part (the low order 32 bits) and a High part (the high order 32 bits), whereas the Quadpart will be the unsigned 64 bit integer itself. I take up the high and low order bits from the SYSTEMTIME variable passed on to this function and assign it to the ULARGE_INTEGER variable. And then I calculate the no. of nano seconds in a day (24 hours, 60 minutes, 60 seconds, 1000 milliseconds, 10000 nanoseconds). Then, I add it up to the Quadpart of the ULARGE_INTEGER variable, nenoSeconds. This way, we've incremented one day of the week. Assign it back to SYSTEMTIME variable, and convert it back to SYSTEMTIME from FILETIME . Look at the code simultaneously and you will understand it.
Original idea - Credits to Rehan Nadeem[^]
MSDN - FILETIME[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Alright Cool...
Got it..
One more problem..I'm using property sheet for tab control..There are 3 tabs(Property pages) in my property sheet..
How can position my property sheet at the center of the screen. I tried with SetWindowPos but couldn't succeed..Cause i'm not sure about the handle of propertysheet.
Can you help me in that??
Ash..
|
|
|
|
|
Ashish Chauhan wrote: I tried with SetWindowPos but couldn't succeed..Cause i'm not sure about the handle of propertysheet.
Can you show me the code? What do you mean you aren't sure about the handle?
Also, have you tried enabling the "Center" property of the dialog (at design time) which contains the property sheet? Also look at CWnd::CenterWindow()
In the future, if you have a new problem, please start a new thread.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I'm not creating any dialog for property page..What i'm doing is that i am creating 3 pages (Property pages) and adding those pages in property sheet.
Also it's Non-MFC..
Here's my code for creating the sheet..
Should i start new thread??
HWND CreatePropSheet()
{
PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
memset(psp, 0, sizeof(PROPSHEETPAGE) * 4);
memset(&psh, 0, sizeof(PROPSHEETHEADER));
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = NULL;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = (DLGPROC)Page1DlgProc;
psp[0].pszTitle = TEXT("Job");
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = NULL;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM2);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = (DLGPROC)Page3DlgProc;
psp[1].pszTitle = TEXT("Schedule");
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = NULL;
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM3);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = (DLGPROC)Page4DlgProc;
psp[2].pszTitle = TEXT("Scan Options");
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE |PSH_USECALLBACK | PSH_MODELESS;
psh.hwndParent = NULL;
psh.hInstance = g_hInst;
psh.pszIcon = NULL;
psh.pszCaption = "Automatic Virus Check";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = (PFNPROPSHEETCALLBACK)PSheetCallback;
return (HWND)PropertySheet(&psh);
}
Ash..
|
|
|
|
|
I set the "Center" Property for pages also. As there is property page dialog box for tabs(Pages)...
There is no dialog for Propertysheet..Creating programmatically..
Ash..
|
|
|
|
|
Ashish Chauhan wrote: Should i start new thread??
I said, in the "future". The reason why I asked you to create a new thread is, your query will get more visibility and more people may give you valuable inputs. This thread is kind of buried now and I'll try helping you out, but I may or may not be able to solve it. If I fail to solve your query, then start a new thread.
Now, please show me what you tried with SetWindwoPos().
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Please try this code and tell me if it worked:
HWND hPWnd = CreatePropSheet();
RECT rc;
GetWindowRect(hPWnd, &rc);
SetWindowPos(hPWnd, NULL,
((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
[ADD] BTW, Thanks for painting my messages red by voting. I appreciate it. [/ADD]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Yeah..Thanks Rajesh
This code works...
Initially i was doing something like that
g_hwndPropSheet = CreatePropSheet();
RECT rect;
GetWindowRect(g_hwndPropSheet, &rect);
int xL = LOWORD(dwSize) / 2 - (rect.right - rect.left) / 2;
int yT = HIWORD(dwSize) / 2 - (rect.bottom - rect.top) / 2;
SetWindowPos(g_hwndPropSheet, NULL, xL, yT, -1, -1,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
g_hwndPropSheet is type of HWND.
Thanks again..
Ash..
|
|
|
|
|
Ashish Chauhan wrote: DateTimePicker??
Why do you repeatedly say DateTimePicker ? It belongs to the .NET framework class library. I believe that we're talking about CDateTimeCtrl .
Ashish Chauhan wrote: GetSystemTime(&st);
What are you doing using GetSystemTime() ? This would get the computer's time and not the time that's being shown in your DateTimeControl() ! Please use the DateTime_SetSystemtime Macro to set the value into your control. Also, check the return value of this macro. It should return a non zero value if it didn't fail. Try that and let me know the result.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi All,
I Create some thread by using the function _beginthreadex.
I hold some handle to this thread
(ThreadHandle = (HANDLE) _beginthreadex(...))
And now i want to kill the running thread and i don't know how to do it.
thanks for any help...
|
|
|
|