|
DavidCrow wrote: nm_114 wrote:
How?
By using SystemTimeToFileTime().
Well I knew that much! I was asking how you do the adding/subtracting...
DavidCrow wrote: That article is exactly what you need.
Well not really, as it doesn't handle months/years.
DavidCrow wrote: That's because a month does not have a constant value (i.e., 28, 29, 30, or 31 days) like the other items do.
I knew that too! But it's ok, I guess what I was looking for doesn't exist (a tested/bug-free exact replica of DateAdd() in C++). Oh well .
Thanks anyway.
|
|
|
|
|
nm_114 wrote: Well not really, as it doesn't handle months/years.
I already showed you how to add months to the SYSTEMTIME object. You would add years in the same fashion. What you have to account for when adding months is to make sure to increment years accordingly. For example, if it's September and you want to add four months, you would use:
wMonth = (wMonth + 4) % 12; But you would then have to add one to the year.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yep. I guess I was hesitant to write my own because I don't know how to account for leap years, but I guess it's not critical. I'll probably use that other article and write something similar to your example for months/years.
Thanks.
|
|
|
|
|
nm_114 wrote: ...I don't know how to account for leap years...
Are you kidding? Leap year algorithms/functions are plentiful here at CP, or even Googling for them.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
See if it helps you ...
int nDay;
int nMonth;
int nYear;
struct tm *when;
time_t now, result;
time( &now );
when = localtime( &now );//conversion from UTC to system time
if(when == NULL)//Error in the calculation of time
return -1;
when->tm_mday = when->tm_mday + nDays;
result = mktime( when );
if(result == (time_t)-1)//size of time_t = 0;result=-1--->error in calculation of result
{
return -1;
}
else
{
nDay = when->tm_mday;
nMonth = when->tm_mon+1;
nYear = when->tm_year+1900;
}
impossible to understand
|
|
|
|
|
Hi All,
I'm prototyping code, and can't seem to persist a hexadecimal base. The following does not perform as expected (it still outputs base 10):
std::cout.unsetf ( std::ios_base::dec );<br />
std::cout.setf ( std::ios_base::hex );<br />
std::cout.setf ( std::ios_base::uppercase );
The alternative (which I am now trying to avoid) is:
std::cout << std::hex << 0x1000 << std::endl;
Any ideas? I'm not sure if I am not using the stream correctly, missing a Microsoft feature, or making an incorrect assumption for flag manipulation.
Thanks,
Jeff
|
|
|
|
|
So out of morbid curiosity I thought I'd like to see this in action.
Borrowing from example code:
using namespace std;
int i = 10;
cout << i << endl;
cout.unsetf( ios_base::dec );
cout.setf( ios_base::hex | ios_base::uppercase );
cout << i << endl;
cout.setf( ios_base::dec );
cout << i << endl;
cout.setf( ios_base::hex, ios_base::dec | ios_base::uppercase );
cout << i << endl;
Output:
10
A
10
a
using namespace std;
int i = 10;
cout << i << endl;
cout.setf( ios_base::hex | ios_base::uppercase, ios_base::dec );
cout << i << endl;
cout.setf( ios_base::dec );
cout << i << endl;
cout.setf( ios_base::hex, ios_base::dec | ios_base::uppercase );
cout << i << endl;
Output:
10
10
10
10
*EDIT* And, in the "working" example, why on the 3rd cout does the hex flag not nead to be unset.<br />
In fact doing so causes it to fail
-- modified at 19:03 Sunday 4th February, 2007
|
|
|
|
|
Hi Mark,
Thanks. It appears it should fall into the 'Microsoft Features' category... I still like to presume it is me (in the past, it usually is me).
Jeff
|
|
|
|
|
Hi
I made an MDI application, created a dialog, that dialog has several controls on it;when I call DoModal,all controls on it appear fine, but when I minimize the dialog, then restore it, all controls disappears, what am I doing wrong?
|
|
|
|
|
Do you have any paint on your code?
|
|
|
|
|
LLewisLiu wrote: made an MDI application, created a dialog, that dialog has several controls on it;when I call DoModal,all controls on it appear fine, but when I minimize the dialog, then restore it, all controls disappears, what am I doing wrong?
are you creating control dynamically???
"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
Support CRY- Child Relief and you
|
|
|
|
|
I've attached to another window's input by calling AttachThreadInput(). I'm now trying to send text, as follows:
int size = strlen(text);
for(int i=0; i
|
|
|
|
|
strlen return the number of characters excluding the null character at the end. You are sending one less than the number with your 'i<size' . Change it to i<=size and it should work as you want.
|
|
|
|
|
Nope, look at the following string: "hello"
strlen returns 5, which means the following characters are sent:
0 - 'h'
1 - 'e'
2 - 'l'
3 - 'l'
4 - 'o'
Besides if I send 2 string in a row still only the last character of the last string is ommitted, not the last characters of both strings.
|
|
|
|
|
Do you have control over the code receiving the WM_CHAR message? If not then I'm not sure how
you could expect the receiver to handle system messages being forced to it without knowing what
message it could currently be processing or its state or anything. It seems to me posting (not
sending) WM_KEYDOWN and WM_KEYUP and letting the receiver translate the WM_KEYDOWNs to WM_CHAR
messages may be safer.
Mark
|
|
|
|
|
whenwood wrote:
SendMessage(inputHwnd, WM_CHAR, text[i], 0);
better use SendInput 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
Support CRY- Child Relief and you
|
|
|
|
|
|
WhiteSky wrote: See SendInput[^]
humm copying me
"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
Support CRY- Child Relief and you
|
|
|
|
|
I am initialising GUI components (in a CMDIFrameWnd) using the code below.
It works fine, except that the CMDIChildWnd child frames are blank at startup. If the user fiddles with the child windows (e.g. stretches them) then the splitter displays immediately appear. What have I missed in the initialisation ?
CMainFrame* pMainFrame = new CMainFrame;
if (! pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
CCreateContext context;
context.m_pCurrentDoc = NULL;
context.m_pCurrentFrame = NULL;
context.m_pLastView = NULL;
context.m_pNewDocTemplate = NULL;
context.m_pNewViewClass = NULL;
CMDIChildWnd* alertWnd = new CMDIChildWnd;
alertWnd->Create(NULL, "Alerts", WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, CFrameWnd::rectDefault, pMainFrame);
CSplitterWnd* alertSplitter = new CSplitterWnd;
alertSplitter->CreateStatic(alertWnd, 1, 2, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST);
alertSplitter->CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), &context);
alertSplitter->CreateView(0, 1, RUNTIME_CLASS(CSsfconView), CSize(100, 100), &context);
pMainWnd->ShowWindow(SW_SHOW);
pMainWnd->UpdateWindow();
cheers,
Neil
|
|
|
|
|
What happens if you pass NULL instead of &context to alertSplitter->CreateView()?
Also, this call shouldn't be necessary - pMainWnd->UpdateWindow();
Maybe try without it.
CSplitterWnd* alertSplitter should maybe be a member variable of the MDIChild class (or somewhere)
so it can be deleted, otherwise a memory leak.
|
|
|
|
|
Can anyone tell me a way to find out why a program just compiled crashes? And what i mean by crashes, not when its run. But when i try and execute the program i get a Windows error. I've heard of debugging but i have not quite figured it out fully. Or if there is another simplier way of doing this please let me know. Thanx in advance!
|
|
|
|
|
You need to place a breakpoint on or before the line where the crash is happening. In your case, you don't know where, so place a breakpoint on the first line in you main(). Hit F5 to start debugging, the program will stop at the breakpoint. Then you can use F11 to move into a function ( your own functions ), or F10 to go to the next line. Keep doing this until you find out where it is crashing then have a look at your variables ( just hover your mouse over them ), one of them will probably be wrong.
|
|
|
|
|
What errors? did you use of breakpoint on your code
|
|
|
|
|
hi
im new at C++ and im looking for some help in way that i could understand what un .EXE file loads in to memory and all kind of information i could get like this applications:
http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/ProcessExplorer.mspx
it would be great if someone could help to initiate this learning, if you know a good tuturial that could help me in this way would be great... thank you!!
|
|
|
|
|
An exe will load itself and any dll's it requires into memory. If a dll has already been loaded by another exe, it shares it. Depending on the exe, any resources it requires, images text files, will be loaded and unloaded by the exe, but these items will only stay in memory for a short period.
|
|
|
|