|
|
my date format is DD/MM/yyyy.can u help me?
shan
|
|
|
|
|
here is small code that compare current date with your stored date.
My date Format is YYYY-MM-DD , i Believe,you are smart Enough to modify the code according to your need.
BOOL <You Class>::FnCheckForValidDates(CString szEndDate)
{
<font color=#008000>
CTime TodayDate=CTime::GetCurrentTime();
int nYear,nMonth,nDay;
<font color=#008000>
<font color=#008000> nYear=_ttoi(szEndDate.Left(szEndDate.Find('-')));
<font color=#008000> szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),"");
<font color=#008000> szEndDate.TrimLeft('-');
<font color=#008000> nMonth=_ttoi(szEndDate.Left(szEndDate.Find('-')));
<font color=#008000> szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),"");
<font color=#008000> szEndDate.TrimLeft('-');
<font color=#008000> nDay=_ttoi(szEndDate);
<font color=#008000> <font color=#008000>
if(TodayDate.GetYear()>nYear)
return FALSE;
if(TodayDate.GetMonth()>nMonth)
return FALSE;
if(TodayDate.GetDay()>nDay)
return FALSE;
#ifdef MYDEBUG
AfxMessageBox("Returning True");
#endif
return TRUE;
}
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Hi!
How is it possible to limit my edit control (MFC) to only accept two digits. Now it is possible to type in how many as you want. To get it to accept only numbers were no problems, is there any properties that I can set to get it to only accept two digits as well?
|
|
|
|
|
No, you will need to subclass your edit control.
It is not really complicated: with class wizard create a new MFC class and make it inherits from CEdit. Then override the OnChar() member function (response to the WM_CHAR event). In this function, if you don't want to add a new char in the edit control, don't call OnChar from the CEdit class. If the character can be displayed, then call CEdit::OnChar().
Hope this help
|
|
|
|
|
CEdit::SetLimitText
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi there,
I fill a ListBox (AddString(str)) from a loop.
When ListBox become full the vertical scrollbar will be appeared.
But I want to do somthing to move the scroll to down in order to the last item become appeared always.
How can I do this?
This functionality is very simple when we use CListControl, because there is a method called Scroll(...) in CListControl class for this reason.
Thanks.
|
|
|
|
|
you have to do it manually:
something like:
void DlgFlexListSelectValue::SetHorizontalScrollBar(){<br />
CString str;<br />
CSize sz;<br />
int dx = 0;<br />
TEXTMETRIC tm;<br />
CDC* pDC = m_valueList.GetDC();<br />
CFont* pFont = m_valueList.GetFont();<br />
<br />
CFont* pOldFont = pDC->SelectObject(pFont);<br />
pDC->GetTextMetrics(&tm); <br />
<br />
for(int i = 0; i < m_valueList.GetCount(); i++){<br />
m_valueList.GetText(i, str);<br />
sz = pDC->GetTextExtent(str);<br />
<br />
sz.cx += tm.tmAveCharWidth;<br />
<br />
if(sz.cx > dx){<br />
dx = sz.cx;<br />
}
}
<br />
pDC->SelectObject(pOldFont);<br />
m_valueList.ReleaseDC(pDC);<br />
m_valueList.SetHorizontalExtent(dx);<br />
}
call the function when you have loaded the listbox.
it's on MSDN somewhere.
good luck.
No hurries, no worries.
|
|
|
|
|
Thank you.
but I don't have problem with horizontal scrolling
|
|
|
|
|
idd, I misread, my apologies .
good luck though.
PS: there should be a function like SetScrollPos or something.
No hurries, no worries.
|
|
|
|
|
m_list.SetCurSel( m_list.AddString(s) );
will work for u.
It will autimatically scroll to last item and will make is selected.
Jetli
Constant Thing In World Is Change.
|
|
|
|
|
i seem to have probz with my dialog based application.....my main dialog callz a modal dialog (which basically loadz some imagez into the screen) and then when i close thiz modal dialog....i see that the memory is not freed!!!!!(i came to view that from taskmanager)....each time i call this modal dialog,it increases by a definitive amount(520kb).....i have freed the dc memery and also even the pointer dynamically created for the modal dialog.....HELP....herez the code.....
THIZ IZ HOW I HAVE CALLED THE MODAL DIALOG FROM MY MAIN DIALOG!!!!!
CMyPresetViewer *PresetViewerDlg = new CMyPresetViewer;
if(PresetViewerDlg->DoModal()==IDOK)
{
}
delete PresetViewerDlg;
THIZ IZ THE CODE THAT IZ WRITTEN IN THE MODAL DIALOG
void CMyPresetViewer::OnStatic1()
{
ReleaseDC(m_dcPresetViewerDialog);
delete m_dcPresetViewerDialog;
AfxMessageBox("done");
CDialog::OnOK();
}
BOOL CMyPresetViewer::OnInitDialog()
{
CDialog::OnInitDialog();
m_DragOn=FALSE;
CClientDC dc(this);
m_dcPresetViewerDialog->CreateCompatibleDC( &dc );
m_hBmpNew = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDB_BITMAP59),
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Load Image Failed");
}
else {
m_st0.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width();
m_size.cy = rectStaticClient.Height();
m_st0.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(*m_dcPresetViewerDialog, m_hBmpNew ) );
offsetx= rectStaticClient.left;
offsety= rectStaticClient.top;
}
return TRUE;
}
void CMyPresetViewer::OnCancel()
{
CDialog::OnCancel();
}
void CMyPresetViewer::OnPaint()
{
CPaintDC dc(this);
dc.BitBlt(offsetx,offsety,m_size.cx,m_size.cy,m_dcPresetViewerDialog, 0, 0,SRCCOPY);
}
}
CAN ANYONE TELL ME WHERE I HAVE GONE WRONG!!!!!
I SEEM TO HAVE FREED AL THE RESOURCES.....
HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELP!!!!!
thankz in advance.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Let me guess, the bitmat is about 520 KB in size? I suggest the next time u use an API, you look at it in MSDN first, because that's what caused your memory leak! Take a look here[^] and see what you have to do...
I also got the blogging virus..[^]
|
|
|
|
|
READ IT A MILLON TIMEZ!!!!!if ur suggesring LR_SHARED!!!thatz not it.....and by the way.....itz not a cut paste code.....and moreover i didnt put it to be graded!!!!!
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
I don't see you releasing the old bitmap!
Take a closer look at: VERIFY(m_hBmpOld = (HBITMAP)SelectObject(*m_dcPresetViewerDialog, m_hBmpNew ) ); and wonder where you release the handle of the old bitmap.
I also got the blogging virus..[^]
|
|
|
|
|
u know what,,,,,i even did that!!!!!(i beleive u r talking abt DeleteObject() ) ....thatz not just it!!!!!
thanx anyway!!!!!
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Why are you creating PresetViewerDlg on the heap? From what you've shown, it is unnecessary.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How to get mouse cursor hot spot from handle to the cursor?
modified 11-Mar-21 21:01pm.
|
|
|
|
|
GetIconInfo()
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Message Closed
modified 11-Mar-21 21:01pm.
|
|
|
|
|
Maksim Goleta wrote:
It gives me the hot spot on the screen, how do I get the spot within the cursor so I can draw the cursor properly aligned?
No, it gives you the hotspot within the cursor. At least it always has for me.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
How to write script for compilation of VS.NET project. Languange of the script is not important, I just need working solution.
|
|
|
|
|
Is there a way to programmatically set XP's feature of hiding tray icons to always showing? My client wants to make sure their icon is always showing in the tray. I know you can manually set that, but they want it done automatically for the user.
Thanks
|
|
|
|
|
Suppose the item is selected,
how can i make it not be selected by function
Thanks
|
|
|
|
|
Look up SetItemState in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|