|
I tried this, but it will not work. The time will get saved to the database even with no user interaction to the control. I don't want to save if no change.
-Elizabeth
Eilzabeth
|
|
|
|
|
Elizabeth Chang wrote:
The time will get saved to the database even with no user interaction to the control.
I don't understand. How is it that your date control is tied to a field in the database?
Without knowing anything about what you have there, I'll venture to say that the underlying code detects changes to the controls and sets the record's flag to "Modified" or "Dirty", or something like that.
There's gotta be a way for you to do something like this:
bool bModified = GetModified();
if (date field in database is Null)
dtCtrl.SetTime();
SetModified(bModified);
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I map the field to the control in DoDataExchange(). When an UpdateData(TRUE) is sent, the field is marked as dirty because of SetTime function. The value from the control is saved to the database.
-Elizabeth
Eilzabeth
|
|
|
|
|
In that case, you can do the same thing I explained, but use IsFieldDirty and SetFieldDirty instead of GetModified/SetModified.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I am not sure if I get it all. I created a class CDateTimeCtrlEx (drived from CDateTimeCtrl) and created a public member variable BOOL m_modified. I have Date fields in almost every form. Am I going to have to do this for each Date field?
--------------begin program code--------------------
void CDateTimeCtrlEx::OnDatetimechange(NMHDR* pNMHDR, LRESULT* pResult)
{
m_modified = TRUE;
*pResult = 0;
}
void CDateTimeCtrlEx::DisplayNullDate()
{
SetTime(&CTime::GetCurrentTime());
SetFormat("''");
}
void CDateTimeCtrlEx::ResetFormat()
{
SetFormat("M'/'dd'/'yyyy");
}
-----------------end program code-------------------
In my application OnDataExchange event:
--------------begin program code--------------------
void CTest_dateView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTest_dateView)
DDX_Control(pDX, IDC_DATETIMEPICKER_END, m_dtEnd);
DDX_Control(pDX, IDC_DATETIMEPICKER_BEGIN, m_dtBegin);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_END, m_pSet->m_DATE_END);
DDX_FieldText(pDX, IDC_EDIT_NAME_1, m_pSet->m_NAME_1, m_pSet);
DDX_FieldText(pDX, IDC_EDIT_NAME_2, m_pSet->m_NAME_2, m_pSet);
//}}AFX_DATA_MAP
m_dtBegin.ResetFormat();
if (!m_dtBegin.m_modified && m_pSet->m_DATE_BEGIN == 0)
{
m_dtBegin.DisplayNullDate();
}
else
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BEGIN, m_pSet->m_DATE_BEGIN);
m_dtBegin.m_modified = FALSE;
}
-----------------end program code-------------------
Eilzabeth
|
|
|
|
|
I am trying to write some code that will loop in a specified directory to check for some file extentions and then delete them. I Know how to open , delete and so on. But i do not know if there is a way to get the directory list of file names so that i can then Iterate through that.
Any help would be great!
|
|
|
|
|
Take a look at the CFileFind class in MFC - it is designed to do exactly that. Alternatively if you are just using the Windows API, you can use the FindFirstFile() and FindNextFile() API functions.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
|
Use the CFileFind object.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Look at the class CFileFind. And specifically the FindFile and FindNextFile member functions.
Good luck.
Always remember the building blocks of the universe:
Electrons, protons, neutrons, morons.
|
|
|
|
|
I've write a program that can build a decision tree model, so training
rules are made. But now, i dunno how to feedback the instances to the
model in order to calculate the training and testing errors. My
program is written in c++.
hkbeckham
|
|
|
|
|
I haven't got a clue what you're talking about ...
This is not a simple problem to diagnose without understanding the domain, the algo and the code
Can you be really more precise as to what is not working ? is it the code, is it the design, is it the specs, is it the algorithm ?
Thanks.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
I have two or more non-window objects (doesn't matter what kind...generic). The objects can be instances of different classes. I want one of the objects to signal the other objects when a change has occured in its state. (such as the change in one of the member variables...modified thru a Set function).
How is the best way to signal the other objects that a change event has occured?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
give each object a pointer to the other object, so that each can call a member function on the other when the 'event' occurs. maybe you could derive them both from a common "event handler" class with methods for singalling events.
(off the top of my head)
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
Chris Losinger wrote:
give each object a pointer to the other object
I wanted to avoid doing that.
Chris Losinger wrote:
maybe you could derive them both from a common "event handler" class with methods for singalling events.
That has posibilites...I'll have to think about it.
Thanks
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Have a look at the Observer Pattern.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Maximilien wrote:
Observer Pattern
Those are new to me...what are they? The only reference I find to Observer in msdn is Java related.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
|
Thanks...will give it a look
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Thanks for the links!
I decided to follow them, and whadayaknow, I learned about the Observer pattern. And they say you can't teach an old dog new tricks. I guess I do my best learning when I'm not forcing myself to learn something.
It's a nice pattern. I'm trying to remember if I've ever used it without being aware of its name, and no, I can't say I have. It's usually a lot simpler and more efficient to link classes directly. Still, I really liked that 1st implementation you gave. I'll keep it in mind for future projects.
Say, what other patterns do you readily use? I know there's lots of them, but what else besides Singleton and Observer do you use on a regular basis?
Thanks again,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
|
Thanks I will look it over.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
And don't forget http://sigslot.sourceforge.net[^]
It's a real easy implementation since it's only a single header file. I'm going to write an article about it sometime.
Joel Lucsy
|
|
|
|
|
Hi Joel,
Thanks for that. I hadn't heard of this before. I will read about it with interest. If you've used boost or libsigc++ I'd be interested in any comparisons you'd care to make. So far I've only used libsigc++
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Comparisons:
sigslot does not do return values (although I have a hacked version that does) while the others do.
sigslot (by default, can turn off) is multi-threaded aware, but I'm not sure about the others. My memory is telling me they aren't, but I could be mistaken.
sigslot is a single .h file, no .cpp's or libs involved. (Mmmm..., templates!)
siglslot does not allow connecting to a function that is not a method of a class. Some may think is a "good thing"tm
if you have a signal with 10 slot connected, all 10 will be called, you cannot abort the sequence early. I know boost allows this thru it's iterator interface, can't recall in libsig++ allows it.
The rest of differences are mostly syntactical.
Joel Lucsy
|
|
|
|