|
Do not use DoModal. Hiding modal dialog is not going to help, since main app window is disabled.
Use modeless dialog and toggle visibility as you need.
JohnCz
MS C++ MVP
|
|
|
|
|
Hello,
Which design pattern would you recommend to use, if i want to separeate data from the Business logic in c++ ?
Thanks,
Berlus
|
|
|
|
|
Have a look into MVC architecture[^] to check if this fits your needs.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
If you are interested in design pattern than go through this link
->[^]
Sometimes I create a COM component for Business logic in C++.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
Hey guys. I am trying to figure out how i can create totally custom Edit control (something like CEdit, but i do all the painting). Something like this one in Vista's explorer, beautiful semitransparent search entry control. I have started with MFC (myEdit : CEdit) and overriding a different stuff, but the effect is actually miserable. For example it paints in OnChar its ugly white background color and there seems no way to get rid of it. Another question, this blinking cursor which indicates that a control has focus and user can enter some chars into Edit control - how windows paints it? Can you point me to a place where i can find complete information regarding implementation of Edit / Entry controls, or maybe share some knowledge with which window messages should i mess, should i go with MFC or plain Win32 API, etc.
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
there are a number of completely custom edit controls/text editors here on CP that you could look at. it's a lot of work to write your own editor, but that's the best way to get the exact features you want. CEdit can only do so much...
csrss wrote: this blinking cursor which indicates that a control has focus and user can enter some chars into Edit control
see SetCaretPos.
see this, too[^].
|
|
|
|
|
Thanks very much, this Caret thing info helped a lot
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
hi friends i am trying to find the contacts who have a birthday in the next 7 days in my list. i managed get the current time as a string but i am stucked here. i know i must compare only number of the month and day. so use subtraction and if the result is <=7 i will show the contact. but i don't know how to do this. i appreciated if you can help me. and here is the my example code.
#include <stdio.h>
#include <time.h>
#include <string.h>
int main( )
{
char buff[11];
char birth[11]="2011-05-15";
int res;
time_t now = time(NULL);
strftime(buff, 20, "%Y-%m-%d\n", localtime(&now));
res = difftime(mktime(birth), now);
printf("%d", res);
return 0;
}
|
|
|
|
|
quartaela wrote: i know i must compare only number of the month and day.
what if today is the second day of January ?
in any case: Google knows how to do this[^]
|
|
|
|
|
well yes you are right . on the other hand this is C++. i forgot to say that i am working with C.
|
|
|
|
|
the diff between C and C++ will be minimal. basically, get rid of the "std::" scope operators. it's still 2 mktimes and a difftime()/secsPerDay.
|
|
|
|
|
mktime() does not take a string; see here[^] for information on date and time routines. You will need to convert the string to a time_t via the strtod() or similar functions. Note also that your strftime() call has the potential to crash your program since you are telling it that there are 20 elements in buff but you have only reserved 11.
The best things in life are not things.
|
|
|
|
|
but if i give size of 20 to string "buff" how can i manage to make unused fields to 0. and i only read the strings with "YYYY-MM-DD" from a file not including minutes and second etc._?
|
|
|
|
|
strftime() is not any use for what you are trying to do. Go to the link I provided and study the features of the Time & Date routines. You should also spend some time learning the C sizeof operator and how it can help you.
The best things in life are not things.
|
|
|
|
|
well i search all the fields of time.h in the link which you gave me but i can't find any solutions. i guess i will use difftime to compare two dates which are time_t variables. but the problem is i read the birthday string from the file and need to convert this string to time_h variable and then i can compare current time and her/his birthday. i will search another ways.
|
|
|
|
|
quartaela wrote: but the problem is i read the birthday string
As I said before you will need to convert the string to its constituent numbers using strtoi() (sorry not strtod() ) and then use those numbers to populate a tm structure from which you can get the time_t value via mktime() . The documentation for all these functions is available on MSDN starting here[^]. This may all sound long and involved but I'm afraid that is the reality of programming.
The best things in life are not things.
|
|
|
|
|
well i almost near the solution. i use atoi() (i can't use strtoi() cause i guess compiler or O/S doesn't compatible with this function). so this the example code
int main(void) {
char c[11] = "2000/10/15";
printf("the number is %d", atoi(c));
return 0;
}
and the output is 2000. the problem is how can i take other numbers "10" and "15". i guess when i take this numbers i can able to solve the problem.
|
|
|
|
|
You need to split the string into its constituent parts using strtok() .
I would suggest you spend some more time learning some of the more common library functions before going further with your project. Go back to the link[^] I gave you and read through all the alphabetic list so you know (more or less) what functions are available, then you know where to look when you have specific requirements.
The best things in life are not things.
|
|
|
|
|
well finally i managed it . thanks for your help mates .
|
|
|
|
|
What about:
int y, m, d;
sscanf(c, "%d/%d/%d", &y, &m, &d); It's not the best solution, but it does give you something to explore.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Date/times held in strings are no good for doing calculations, they are only good at interfacing to humans.
Use the time_t type, it basically is the number of seconds since 01-JAN-1970.
Once you have two time_t values, you can simply subtract them and compare to some constant, such as 7*24*60*60.
[ADDED]
POSIX has a nice strptime() function to turn a datetime string into a number; Windows itself hasn't (MFC has, boost has); so your best option may well be:
- use sscanf to turn the string into struct tm; here[^] is an example that should work, provided the month is by number, not by name.
- use mktime to turn that into a time_t
- then either use difftime or simply subtract.
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, May 10, 2011 6:27 PM
|
|
|
|
|
MFC have CTimeSpan Class, add your date and time int one object and
bithday time in other
CTimeSpan objBithday(dd,mm,yy,hr,mm,ss);
CTimeSpan objToday(dd,mm,yy,hr,mm,ss);
CTimeSpan TimeDIff = objToday - objBithday;
Try This............ :
laugh:
|
|
|
|
|
chk this;
CString today_date_str,birth_date_str;
GetDlgItemText(IDC_DATETIMEPICKER1, today_date_str);
GetDlgItemText(IDC_DATETIMEPICKER2, birth_date_str);
m_today_dt_ole.ParseDateTime(today_date_str,0,LANG_USER_DEFAULT);
m_birth_dt_ole.ParseDateTime(birth_date_str,0,LANG_USER_DEFAULT);
CString chk_dt1=m_today_dt_ole.Format(_T("%d/%m/%Y"));
CString chk_dt2=m_birth_dt_ole.Format(_T("%d/%m/%Y"));
m_today_dt_ole.ParseDateTime(chk_dt1,0,LANG_USER_DEFAULT);
m_birth_dt_ole.ParseDateTime(chk_dt2,0,LANG_USER_DEFAULT);
COleDateTimeSpan daydiff=(m_today_dt_ole-m_birth_dt_ole);
int noofday=0;
noofday=(int)daydiff.GetTotalDays();
if(noofday<=0)
{
noofday=-(noofday);
}
noofday++;
CString Value ;
Value.Format(_T("%d"),noofday);
|
|
|
|
|
well mate i guess this is C++ or C#_? cause i can't understand the codes. i am working with C . but thanks for your help
|
|
|
|
|
I'm not the one having a problem with datetimes, I merely try to help out the OP.
And I don't think he is using or willing to use MFC.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|