|
Maybe VC++ keeps the window open until you, the user or programmer, close it.
Try right-clicking on your built .exe and chose to edit the properties. Make
sure that on the program tab "Close at end of execution" (or sth. like that... I don't know the real English expression -- I've got a German Win version) is NOT checked. You can also test your program in the console. If it works properly in there, this should just be one of Win's .. well... failures.
|
|
|
|
|
pf7 is correct. if a program is complete, if you just run the executable, the program will close itself. however, VS.net forces the progeram window to remain open until you close it (press any key to continue...)
you can add
_getch();
to your program, i beleive you need #include <conio.h> to use it. put _getch() at the end of the program to force a key press before th window closes.
|
|
|
|
|
Well my answer may be stupid. Excuse me because I am a beginner but try putting this at the end of your code before the "return":
int a;
cin >> a;
Your program wont close until the user presses "enter".
|
|
|
|
|
CString strFileDirs = "dirs.data";<br />
char szBuf[_MAX_PATH];<br />
<br />
TRY {<br />
CStdioFile fileDirs(strFileDirs, CFile::modeRead);<br />
while(fileDirs.ReadString(szBuf, _MAX_PATH)){<br />
ULONGLONG dwSavedPos = 0;<br />
dwSavedPos = fileDirs.GetPosition();<br />
<br />
TRACE("seek: %u\n", dwSavedPos);
fileDirs.SeekToBegin();<br />
fileDirs.Seek(dwSavedPos, CFile::begin);
}<br />
fileDirs.Close();<br />
}<br />
CATCH (CFileException, pE) {<br />
pE->ReportError(MB_ICONSTOP, IDS_FILE_ERROR);<br />
}<br />
END_CATCH<br />
What I'm doing wrong?
|
|
|
|
|
Use TRACE("seek: %I64u\n", dwSavedPos) instead.
|
|
|
|
|
|
What about:
DWORD dwSavedPos = fileDirs.GetPosition();<br />
TRACE("seek: %lu\n", dwSavedPos);
|
|
|
|
|
and compiler warns about bad type conversion.
My system is default Win2000 and VS .NET installation.
And I dont use any external include dirs all is just from default install.
|
|
|
|
|
Ok, my bad. It wasn't until I read the VS .NET documentation that I see that CFile::GetPosition() indeed returns a ULONGLONG. I'm at a loss for what to try next as I do not use VS .NET and am not familar with all the differences between VS v6.
|
|
|
|
|
could somebody explain why the nPos parameter wraps at 32767
void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
olle
|
|
|
|
|
|
See if MSDN article Q152252 is of any help.
|
|
|
|
|
it works, thanks
olle
|
|
|
|
|
(more of a curiousity question than anything)
I've seen both this:
SHELLEXECUTEINFO sei = {0};
and this:
SHELLEXECUTEINFO sei;
memset(&sei, 0, sizeof(sei));
and even: (but this is Win32 specific I think)
SHELLEXECUTEINFO sei;
::ZeroMemory(&sei, sizeof(sei));
Which is "better"? Is there *really* any difference?
Personally, I've always used the first one, but I've seen many people using the second one, and was wondering if I should switch over.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
[Rich Cook]
|
|
|
|
|
I would have thought the first two would be the same and they nearly are. Under VS.NET 2003, however, with the first, the compiler first stores a 0 at the first DWORD then does a stosd for the remaining while memset does a stosd for the entire structure. The result is a very slight, but measurable, performance penalty for the first. Don't know why it's being so dumb but there you are.
ZeroMemory just uses memset. (I believe it's a macro.) It was for use when NT actually ran on non-Intel processors.
|
|
|
|
|
Thanks!
I figured ZeroMemory and memset were basically the same.
Weird that = {0} works different on VS.NET. I'm still using VC6, so that doesn't affect me now.
Joe Woodbury wrote:
stosd
wtf?
I prefer to wear gloves when using it, but that's merely a matter of personal hygiene
[Roger Wright on VB]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
[Rich Cook]
|
|
|
|
|
|
Well (as I found out the hard way) the
MY_STRUCT foo = {0};
is only usable (in terms of zeroing out the whole structure) on MS compilers. So if you want to write correct, portable code you should use memset (AFAIK).
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
What sort of error does this produce on non-Microsoft compilers?
|
|
|
|
|
MY_STRUCT foo = {0};
Jim Crafton wrote:
is only usable (in terms of zeroing out the whole structure) on MS compilers
Was the compiler(s) compliant with the C or C++ standard?
I have not read the standard for C in years but if I remember it right then the above initialization should work on all compliant compilers. If you are sure I am wrong about this then send a reply and I'll go look it up to verify what the standard has to say on the subject of initializing Aggregate Types.
Trust in the code Luke. Yea right!
|
|
|
|
|
Thanks!
So far, I've only done dev work in Windows, using DevStudio, so I haven't run into anything like that.
I prefer to wear gloves when using it, but that's merely a matter of personal hygiene
[Roger Wright on VB]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
[Rich Cook]
|
|
|
|
|
Jim Crafton wrote:
s only usable (in terms of zeroing out the whole structure) on MS compi
No, that syntax for initializing a struct is inherited from C. It sets the first member to 0, then by definition sets all remaining members to 0. So if you write = {1} that sets the first member to 1, and all remaining members to 0.
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Crap!! I swear to god I ran into this, using GCC (I think it was the 2.9x series) but I just tried it (using GCC 3.2) and it works perfectly!
My apologies to all! Sorry
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Ok, i have an annoying problem. I'm writing an MFC program that has a ton of edit controls and droplist combos. all data enteres/selected in these controls needs to be saved in a text file. I've taken care of all the edit controls and radio buttons, but i'm baffled as to how to do it with a droplist combo.
So far, (in my 2 weeks of MFC experience), the only way i've found to enter data in a droplist combo or a list combo is to enter it in the property window of the individual combo. i need to be able to enter the data somewhere in the code.
Basically, what i want to do is:
- input strings from a text file (which i can handle no problem)
- store those strings into the contents of the droplist combo (this is where i have troubyle)
- and eventually display all the necessary strings in the droplist box.
If anyone can give some insight, i'd greatly appreciate it. If its not possible to do, ie the only way to enter data is to manually enter it when creating the listbox, well, i'm just screwed.
|
|
|
|
|
(droplistbox == combobox )
CCombobox::AddString ( ... ) should do the work to add a string into the combobox
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|