|
40 minutes ago! WTF! Have you developed insomnia?
led mike
|
|
|
|
|
led mike wrote: Have you developed insomnia?
Man, I hope not!
I'll be ready for a nap by 10am.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have an MDI application using the MFC feature pack which has several dockable views. A couple of these views really need their width keeping above a certain size or else they become a bit pointless because you can't see anything on them which could confuse the less mentally agile of users.
I've tried setting the m_sizeMin variable in the CDockablePane derived view class but that only works in certain circumstances. When you dock with tabs and certain other situations it seems to get overridden. Is there a blindingly obvious way to do this that I'm missing?
|
|
|
|
|
Dear Friends,
I need to display a date exact month before from current date.
For Ex: todays date is 14-OCt-08.. then i should display 14-Sep-08.
Can anybody please help me out with this?
Thank u so much in advance
Megha
|
|
|
|
|
megha_gharote wrote: Can anybody please help me out with this?
What *exactly* is that you need help with?
Tell what have you tried or thought of so far.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
This is what i did till now..
CTime currentTime=CTime::GetCurrentTime();
int nDay = currentTime.GetDay();
int nMonth = currentTime.GetMonth();
int nYear = currentTime.GetYear();
int nHour = currentTime.GetHour();
int nMin = currentTime.GetMinute();
int nSec = currentTime.GetSecond();
currentTime -= 2592000; ///30*24*60*60 (Seconds)
nDay = currentTime.GetDay();
nMonth = currentTime.GetMonth();
nYear = currentTime.GetYear();
nHour = currentTime.GetHour();
nMin = currentTime.GetMinute();
nSec = currentTime.GetSecond();
But i dont want to calculate it like this. Can anybody suggest me soem other method?
|
|
|
|
|
Try this instead:
SYSTEMTIME varTime;
GetSystemTime(&varTime);
varTime.wMonth--;
After the third statement, the month would be decremented by one. Kinda obvious, but you asked for it.
Add: Oops! I haven't taken account of the year January. But I think that you must be able to do it yourself now.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
What about if you are on 30th or 31st of march? Or any other 31st where the moth before only 30 has? Won't it crash? :P
EDIT: Question was already below, I should read all before posting
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
That was discussed two posts below here[^]. But that is an exercise that the OP must take care of.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Nelek wrote: What about if you are on 30th or 31st of march? Or any other 31st where the moth before only 30 has? Won't it crash?
BTW, I forgot to mention it won't *Crash* anyways.
SYSTEMTIME is just a structure and it can store the value you put into it. The trouble may come, only when a call to something like SetTime() is called with the new time structure after decrement has happened.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I think the below code will do the trick, anyway verifying it is up to you
CTime today = CTime::GetCurrentTime();
CTime aMonthAgo;
CTimeSpan ts(today.GetDay(),0,0,0);
aMonthAgo = today - ts;
aMonthAgo += CTimeSpan( - aMonthAgo.GetDay() + today.GetDay(), 0, 0, 0);
[added #1]
That was buggy, forget it . Anyway are you aware that your requirement cannot be satisfied when current day is for instance March 31th?
[/added #1]
[added #2]
Fixed code:
CTime today = CTime::GetCurrentTime();
CTime aMonthAgo;
CTimeSpan ts( today.GetDay(), 0, 0, 0 );
aMonthAgo = today - ts;
int iSpan = aMonthAgo.GetDay() - today.GetDay();
if (iSpan > 0)
aMonthAgo -= CTimeSpan( iSpan, 0, 0, 0);
This code sets aMonthAgo to:
(1) a date having the same day (of month) of current date, but month equal to previous month, whenever such requirement can be satisfied.
(2) Last day of previous month whenever the requirement (1) cannot be satisfied (for instance when input date is March 31th).
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]
modified on Tuesday, October 14, 2008 6:48 AM
|
|
|
|
|
SYSTEMTIME today, lastMonth;
GetLocalTime(&today);
memcpy(&lastMonth, &today, sizeof(SYSTEMTIME));
if (lastMonth.wMonth > 1)
lastMonth.wMonth--;
else
{
lastMonth.wMonth = 12;
lastMonth.wYear--;
}
|
|
|
|
|
enhzflep wrote: // as long as it's not january,
My 5 for your attention to detail. I missed out on the case where the month could be January!
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Oh gee Raj, thanks.
Quick question - do I lose thhose points for forgetting to consider the question:
What is the date 1 month prior to the 30th of march?
|
|
|
|
|
That's a flaw of OP's requirements.
The same applies to March 31th (and, for most years, 29th), May 31th,...
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]
|
|
|
|
|
As CPallini said.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
If the current date happens to be March 31st and the year is not a leap year, the most days you'd be off is 3. That said, once you subtract 1 from the current month (use the % operator so that it will wrap back around to December as needed), you may also need to subtract up to 3 days to have a valid date.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi guy,
does someone know some tricks to increase the time performance
of a VC++ application that need to write a large amount of data
into an Excel Sheet ?
Thanks
|
|
|
|
|
Yup!
Use a multidimensional safearray.
Once upon a time I was filling an Excel sheet with ~10Mb and it took about 40 minutes addressing one cell at a time. With a multidimensional safearray it took ~10 seconds.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks a lot !
I try immediately
|
|
|
|
|
That's a nice suggestion.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: That's a nice suggestion.
Well, actually it's all the out-of-process calls that are the culprits here. They are ~2000 times slower than ordinary function calls in comparison. Knowing that, it's no rocket science figuring out that making less calls of this type will improve performance.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Overclocking?
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 All, Good Morning.
I am facing compilation errors but I have declared everything properly. Something is missing Please help me. I declared a declared class having 3-4 member functions n variable in header file and defined its functions in source file. Everything was working fine. But Now if I add some #define statements in header file and use those in source file , It is giving error undeclared variable. also if I put the mouse on #define statement it showing the variable with _CURSOR_ appended with.
eg.
#define TRADE_TAG "trd"
if I put the mouse on TRADE_TAG then it will show like TRADE_TAG_CURSOR_ "trd".. dont know why.. also if I right click on TRADE_TAG n then look for declaration then msg box appears variable TRADE_TAG not declared ... can u guide me here.
Second issue.
If I add a member variable or member function to the class declaration n then define in source file , it again gives compilation errors. dont identify class member variables n function. strange thing is that in one function it is recongnising member variables n in the another it is not.. both functions are member of the class. putting mouse on member function defination shows it as member. but on compilation it is giving error then function is not a member of class see the declartion.I m pasting code here. Please help
Header file Kccdatabase.h
#ifndef __KCCDATABASE_INCLUDE__
#define __KCCDATABASE_INCLUDE__
#pragma once
#include "afxdb.h"
class CKccDatabase : public CDatabase
{
private:
char sTradeXML[500];
char sTradeKcc[150];
public:
CKccDatabase();
virtual ~CKccDatabase();
BOOL ConnectKccDatabase(CKccDatabase &;
void InsertTrade(CKccDatabase *);
void ConvertTrdToXML(long RowIndx , bool IsRegularTrade = 1);
void ConvertTrdToKccFormat(long RowIndx , bool IsRegularTrade = 1);
};
source file
#include "KccDatabase.h"
void CKccDatabase::ConvertTrdToXML(long RowIndx , bool IsRegularTrade)
{
sTradeXML="Hello";
}
void CKccDatabase::ConvertTrdToKccFormat(long RowIndx, bool IsRegularTrade)
{
sTradeXML = "Hello";
sTradeKcc= " yes";
}
when I compile this source file cntl+f7 then it gives these errors in
KccDatabase.cpp(126) : error C2039: 'ConvertTrdToKccFormat' : is not a member of 'CKccDatabase'
1> f:\kats_clients_local\kats32\kats32\KccDatabase.h(4) : see declaration of 'CKccDatabase'
1>.\KccDatabase.cpp(151) : error C2065: 'sTradeKcc' : undeclared identifier
1>.\KccDatabase.cpp(152) : error C2065: 'sTradeXML' : undeclared identifier
please note that it is recongnising variable xTradeXML in upper ConvertTrdToXML but not in ConvertTrdToKccFormat ... also when I put cursor on the ConverTrdToKccFormat function defination then It shows this as member of CKccDatabase class ..
the only difference is that i have defind ConvertTrdToXML 4-5 days ago .. and otherone today.. :-9
Can anybody help
thx
|
|
|
|
|
I cannot spot any error in your code. Did you copy pasted this code or typed it yourself in the browser?
-Saurabh
|
|
|
|