|
Hi all,
I am using date picker control in my dialog. I want to set an old date in that control. following is my code.
SYSTEMTIME sysTime;
memset(&sysTime, 0, sizeof(sysTime));
sysTime.wYear = 2008;
sysTime.wMonth = 8;
sysTime.wDay = 5;
sysTime.wHour = 2;
sysTime.wMinute = 20;
sysTime.wSecond = 20;
sysTime.wDayOfWeek = 1;
m_ctrlDate.SetFormat(_T("dd-MM-yyyy"));
m_ctrlDate.SetTime(&sysTime);
The date picker control is showing date 1/1/1970. How to set date in that control.
Thanks,
|
|
|
|
|
I tried the code that you wrote and it works perfectly.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Same here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi
When i passing the arguments through comment line arguments ..its running good ..and also i can able to see the output ,
my prob is when i use in debugging mode ..its thrown some exception
Unhandled exception at 0x7c81eb33 in Segmentation.exe: Microsoft C++ exception: pnm_error at memory location 0x0012fb6b..
why this kind of prob ..arise ..plz explain ..
Thanks
|
|
|
|
|
Have you the debugger? Use it! Have a look at the 'call stack' window.
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
[My articles]
|
|
|
|
|
Thanks for your response ...
|
|
|
|
|
raju_Code wrote: why this kind of prob ..arise
With what little information you've provided, it could be most anything. What command-line arguments are you sending? How are they being used? What are the compiler/linker differences in release vs. debug mode? Have you stepped through the code using the debugger to narrow down the problem to just a handful of statements?
The common practice these days seems to be to copy/paste some code (I prefer to type all of my code in, especially as a beginner, so I know exactly what is going on), compile it, then run the program. If it does not work, find nearest programming forum and ask for help.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
When I declare a LVFINDINFO object in the function body, EnumChildWindows fails to locate the control of SysListView32 type (a Windows class type). When I remove the LVFINDINFO object from the body, it works well.
The code snippet is as the below.
void CMainDlg::OnBnClickedGetDolby()
{
KillRunningApplet(_T("Sound"));
if(!LaunchCplApplet(_T("mmsys.cpl"), 0, 0)) {
OutputDebugString(_T("LaunchCplApplet fails. \n"));
return;
}
CWnd* pWnd = NULL;
int i = 0;
while(!pWnd) {
pWnd = FindWindow(NULL, _T("Sound"));
if(pWnd) {
OutputDebugString(_T("Found Sound window. \n"));
break;
}
Sleep(10);
i++;
if(i > 1000) {
OutputDebugString(_T("Sound window is not found. \n"));
return;
}
}
m_pListView = NULL;
EnumChildWindows(pWnd->m_hWnd, DoSomethingHelper, (LPARAM)this);
if(m_pListView) {
OutputDebugString(_T("Got SysListView32"));
}
else {
OutputDebugString(_T("SysListView32 is not found."));
return;
}
m_pListView->SendMessage(WM_KEYDOWN, VK_DOWN, 0);
CListView* pView = (CListView*)m_pListView;
CListCtrl& Ctrl = pView->GetListCtrl();
LVFINDINFO info;
int iIndex = 0;
info.flags = LVFI_PARTIAL | LVFI_STRING;
info.psz = _T("Speaker");
}
BOOL CALLBACK DoSomethingHelper(HWND hwnd, LPARAM lParam)
{
TCHAR sClassName[MAX_PATH] = {0};
GetClassName(hwnd, sClassName, MAX_PATH);
if(wcscmp(sClassName, _T("SysListView32")) == 0) {
CMainDlg* pMain = (CMainDlg*)lParam;
pMain->m_pListView = CWnd::FromHandle(hwnd);
}
OutputDebugString(sClassName);
return TRUE;
}
Maxwell Chen
|
|
|
|
|
Okay, never mind. Constructing the LVFINDINFO object takes some time so EnumChildWindows takes longer time to complete. So I added a Sleep(10) after EnumChildWindows call to make it happy.
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: pMain->m_pListView = CWnd::FromHandle(hwnd);
Since CWnd::FromHandle documentation [^] states:
The pointer may be temporary and should not be stored for later use.
I would use instead something like
pMain->m_hListView = hwnd;
and then obtain the CWnd pointer inside the CMainDlg::OnBnClickedGetDolby body.
Anyway I really don't know if it would help.
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
[My articles]
|
|
|
|
|
CPallini wrote: pMain->m_hListView = hwnd;
Thanks! It resolved the timing problem.
Maxwell Chen
|
|
|
|
|
Hello im trying to Detect when the Delete key is pressed it works also but it also works when i press . can someone tell me why this happens
|
|
|
|
|
Can at least someone tell me that this is not possible
|
|
|
|
|
The delete and period keys have different VK_XXX values, VK_DELETE and VK_DECIMAL .
Are you getting the same values on the numeric key pad with the Num Lock key set to ON and OFF?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
The Method is PreTranslateMessage
and im doing this
if(pMsg->wParam == VK_DELETE)
{
Clear Label
}
And it happens when i press the period Key meaning the button besides , and - second after m
and the num Lock is actiavated
|
|
|
|
|
Are you checking if (pMsg->message == WM_KEYDOWN) before checking for VK_DELETE ?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
yes im doing that also and its really weird i thought something like this can never happen
|
|
|
|
|
When the numlock is turned off, the . key becomes the delete key and 4, 6, 2 and 8 keys in the numpad becomes arrow keys. Turn numlock on and see what happens while pressing the . key.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
its not the numlock key that calls my Function its the . key [:] key the key besides m
meaning it comes like this
zxcvbnm, . - and the point key is the problem
|
|
|
|
|
Hi
As a rather novis VisualStudio CPP user, I have the need to change the text on a push button that was created using the Resource View editor. I imagine the text can be changed using SetWindowText or something similar, but then a handler to the button is needed. How can I obtain that handler, when I have not created the button myself in my program?
Lars
|
|
|
|
|
lmflho wrote: How can I obtain that handler, when I have not created the button myself in my program?
By using GetDlgItem()[^]
Nuri Ismail
|
|
|
|
|
Use GetDlgItem [^] function.
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
[My articles]
|
|
|
|
|
Hi,
two guys answering with the speed of light!
Thanks a lot, the code works nicely now!
Lars
|
|
|
|
|
lmflho wrote: I have the need to change the text on a push button...
At design time or run time?
lmflho wrote: How can I obtain that handler, when I have not created the button myself in my program?
You need to create a CButton member control variable. If you are using VS6, use ClassWizard (Ctrl+W). If you are using VS20xx, right-click the control and select Add Variable from the context menu. Now just use the SetWindowText() method of the member control variable.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi David,
and thanks for giving your attention to my little problem.
The problem is already solved (see other answers), I am now
able to change the button text in runtime
BR/Lars
|
|
|
|