|
thanks Mr P. I knew that (what inline was) - I didnt know that making it inline would get around that particular 'multiple define' issue
'g'
|
|
|
|
|
#pragma once just causes the compiler to process an include file only once per build... that has nothing to do with the linker.
Don't try it, just do it!
|
|
|
|
|
Hi
I get from an application a UTC time value in the following variables : nyear, nmonth, nday, nhour, nminute, nsecond.
I need to convert this UTC time value in a time_t format (also UTC), whatever the time zone and the DST of the computer.
I've tried with a CTime object, but CTime::GetTime() considers that it contains a local time, and take into account the time zone. (I can only remove the DST effect)
Thank you for any idea ?
Jérôme
|
|
|
|
|
I think if you first fill a SYSTEMTIME structure with the nyear, nmonth, nday... values then use it in your CTime constructor your times will work.
ie.
<br />
<br />
SYSTEMTIME st;<br />
st.wYear=nyear;<br />
st.wMonth=nmonth;<br />
st.wDay=nday;<br />
st.wHour=nhour;<br />
st.wMinute=nmin;<br />
st.wSecond=nsec;<br />
CTime mytime(&st);
<br />
Regardless if that particular method works or not. If you use SYSTEMTIME object there's a bunch of functions available to go back and forth between time zones that may make your life easier.
|
|
|
|
|
Thank you for your answer.
When creating "CTime mytime(&st);" with the SYSTEMTIME st value I assume that the CTime constructor takes into accout that the given time is UTC time, and it must apply the local time conversion ?
So when I execute time_t t_utc = mytime.GetTime(), I get a UTC time in t_utc ?
Is it the way it works ?
|
|
|
|
|
Well, like I said before, it's been a while since I've used time structures and objects, but I have used them extensively in the past.
If you Do just a little playing around and debugging the SYSTEMTIME variable (it's easiest because all the members are .hour, .min, .sec and you can watch the values directly) I'm fairly sure will reveal that it always works in UTC timezone. The companion functions Format() etc. all add in timezone offsets.
This means you're thinking a little backwards as to when the timezones come into play, but it depends on which actual Structure or object you are talking about.
Just do a little debugging, it will become clear very quickly.
Oh and do yourself a favor, leave yourself lots of comments so you remember later. I looked through my old source and I forgot that part which is why I can't answer your question directly
|
|
|
|
|
I've finaly found a solution :
time_t system_time, time_tloc, time_tgmt;
struct tm loctime, gmttime;
time(&system_time);
loctime = *localtime(&system_time);
gmttime = *gmtime(&system_time);
time_tloc = mktime(&loctime);
time_tgmt = mktime(&gmttime);
long offset = time_tloc - time_tgmt;
CTime t(nAnnee,nMois,nJour,nHeure,nMinute,nSeconde, -1);
time_t lRetValue = t.GetTime() + offset;
Thank you for your help.
Jérôme
|
|
|
|
|
try GetLocalTime and GetSystemTime Api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
how do i clear the keyboard buffer? i tried fflush(stdin) , _flushall(), nothing's working what could be the problem??
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|
|
This looks like it will only purge one keyboard message. Shoudn't it be:
MSG msg;
while ( PeekMessage(&msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE|PM_NOYIELD) );
Steve
|
|
|
|
|
|
oops! sorry hehe, i'm talking about console mode . in C.
for example, you get the input through scanf , after getting the inputs, it does some process (may it be a while-do),during the process if you make strokes in your keyboard, its gets accumulated in the Kb buffer, so after the process is over, it automatically types in the input for the next scanf , you get me now?.. i want to clear the buffer everytime before "scanningf!"
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|
VivekuniQ wrote: ForumVisual C++
Subject:Re: keyboard buffer
Sender:VivekuniQ
Date:11:06 12 Jan '06
how do i clear the keyboard buffer?
what specific problem are you facing
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
please look at my reply to owner drawn
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|
Holla,
I just migrated some code from VC6 to VC7. It compiled without any warnings or errors, with no changes made.
However, the size of the debug- and release-versions increased by a factor of 10. The release version, for example, was 2 MiB and is 20 MiB now.
I suspect that this is due to the templates in the source (I did not write it, so I cannot be sure) which supposedly were inflated during compilation.
Is there a way (compiler option or pragma) do prevent this code inflation from happening in VC7?
It works and all, but sending 20 Megs via E-Mail is quite a pain.
Thanks in advance.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
This is highly unusual. What libraries do you use? MFC, ATL, WTL, STL etc.
Regards,
Nish
|
|
|
|
|
Are you really sure that you had compiled in release ?!?
20mb gees, it is like all libs that microsoft has made has linked with your application.
-Prakash
|
|
|
|
|
are these static libs ? if so, it's not a bug. it's intended.
i had a discussion[^] (scroll down to the last msg from J. Caves) with an MS tech about this a couple of years ago, and it seems the increase is due to the STL - MS changed something in the STL implementation that causes tons and tons of additonal code to get sucked in.
see his sample program and note the size of the libraries he gets.
it sucks. sucks. sucks.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
IMO, that discussion (the google group thingy ) should be bumped up!!!
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
For a largish lib I once did the following (mainly to reduce compile time):
make one .cpp that #includes all the other .cpp's, and let the compiler only see th "includer" cpp
It doesn't work always of course (overlapping #defines or other local symbols) but maybe it's worth a try.
Did you already try the same code on VC8?
We say "get a life" to each other, disappointed or jokingly. What we forget, though, is that this is possibly the most destructive advice you can give to a geek.
boost your code || Fold With Us! || sighist
|
|
|
|
|
peterchen wrote: maybe it's worth a try
i'll see what happens. there are 200+ files, though.
peterchen wrote: Did you already try the same code on VC8?
don't have it yet.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks for the help everyone.
There has to be SOME way to get this right again
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Hello Friends
I have a MFC application and in which I want to show some message when user tries to close the lid of the laptop. Is there a way or event through which i can get when used closed lid of laptop.
Also I want to get notification when user presses Ctr+Alt+Del and logs into Laptop after he closed the lid of the laptop.
Is there any way to do this ?
Regards
Mahesh
|
|
|
|
|
For Ctr+Alt+Del , you have to write GINA. There is a sample in platform sdk.
Alternatively you can create a registry value DisableCAD under Winlogon key
to disable the ctrl-alt-del.
Vipin - MVP
|
|
|
|