|
Works fine when I use braces.
Using VC++ 6.0 SP5.
J
"I am the Lorax. I speak for the trees."
|
|
|
|
|
Rage wrote:
But inserting brackets is still a good idea !
I always insert the braces. It makes the code easier to read and avoids me forgetting to add them when I add another statement to the for loop. As for the error I can not see why...
John
|
|
|
|
|
To me, the code is "cleaner" without the braces, but I understand it's just a style thing.
J
"I am the Lorax. I speak for the trees."
|
|
|
|
|
"just a style thing"?
Read a good book on defensive programming - "Code Complete" comes to mind. Your "style" is prone to errors.
|
|
|
|
|
John M. Drescher wrote:
I always insert the braces
I'll to 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]
|
|
|
|
|
I sounds like you are single steping through the code with the debugger.
1. for(int i = 0; i < 20; ++i)
2. if(!m_aSoftwareGains[i].Load(pFile))
3. return false;
4. m_bSoftwareGainsLoaded = true;
<pre\>
When single stepping it will appear to go 1,2,4,1,2,4,...,1,2,3.
<pre>
1. for(int i = 0; i < 20; ++i)
2. {
3. if(!m_aSoftwareGains[i].Load(pFile))
4. return false;
5. }
6. m_bSoftwareGainsLoaded = true;
<pre\>
Now It should appear to be 1,3,5,1,3,5,...,1,3,4.
INTP
|
|
|
|
|
Yes, I discovered this after digging through the assembly. Oops.
J
"I am the Lorax. I speak for the trees."
|
|
|
|
|
Are you sure you don't have a ";" at the end of line one?
I've tried to reproduce the difference in behaviour, but with no success. When you look at the disassembly, it seems to be identical with or without braces.
Haakon.
'Problems worthy
of attack
prove their worth
by hitting back.'
Piet Hein
|
|
|
|
|
It was a user problem. I assumed the problem was there, and that biased my testing.
I stepped through, and when the code returns from the call (line 2), the little yellow arrowhead points to line 4. THAT DOESN'T MEAN THAT IT IS THE NEXT INSTRUCTION TO RUN! I must have seen that in my testing, wondered what the hell was going on, and stopped the debug.
I too traced through the assembly, but made the same mistake - didn't trace through far enough.
Oh well.
J
"I am the Lorax. I speak for the trees."
|
|
|
|
|
No problem.
If we didn't learn anything, you certainly have.
H.
'Problems worthy
of attack
prove their worth
by hitting back.'
Piet Hein
|
|
|
|
|
code:
#define _CRTDBG_MAP_ALLOC
#include<cstdlib>
#include<crtdbg.h>
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrefInst, LPSTR cmdLine, int cmdShow)
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
int* i = new int;
i = NULL;
_CrtDumpMemoryLeaks();
return 0;
}
debug output:
==========================================================
'Game.exe': Loaded 'C:\work\StreetsOfDusk\Binaries\Debug\Game.exe', Symbols loaded.
'Game.exe': Loaded 'C:\WINNT\system32\ntdll.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\d3d9.dll', No symbols loaded.
'Game.exe': Loaded 'C:\WINNT\system32\d3d8thk.dll', No symbols loaded.
'Game.exe': Loaded 'C:\WINNT\system32\msvcrt.dll', No symbols loaded.
'Game.exe': Loaded 'C:\WINNT\system32\kernel32.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\user32.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\gdi32.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\advapi32.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\rpcrt4.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\version.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\lz32.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\winmm.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\mmdrv.dll', Cannot find or open a required DBG file.
'Game.exe': Unloaded 'C:\WINNT\system32\mmdrv.dll'
'Game.exe': Loaded 'C:\WINNT\system32\indicdll.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\imm32.dll', Cannot find or open a required DBG file.
'Game.exe': Loaded 'C:\WINNT\system32\TDispVol.dll', No symbols loaded.
'Game.exe': Loaded 'C:\WINNT\system32\d3d9d.dll', No symbols loaded.
Direct3D9: (INFO) :======================= Hal HWVP device selected
The program '[696] Game.exe: Native' has exited with code 0 (0x0).
==========================================================
What means "Cannot find or open a required DBG file."? Where can I get those DBG files?? The msdn didn't help me
|
|
|
|
|
i have no idea what your problem, but i searched google, and i found this site, where at the bottom, bumps you to this microsoft site about downloading new symbols.
it might help...
*.*
|
|
|
|
|
|
It's nothing to do with CRTDBG.H - that's the debugger telling you that it couldn't find debugging symbols for the DLLs being loaded.
Download a symbol set for your operating system from the Microsoft Debugging Tools site[^], and/or use the Symbol Server described at that site.
If you go the Symbol Server route, you'll need a permanent internet connection of at least DSL grade. 512Kbps DSL only just about cuts it - there's a hefty delay the first time you debug a project.
--
Mike Dimmick
|
|
|
|
|
Ok, i have yet another refreshing problem. I have a lsitbox on a dialogpage (actually, its page1 of a propertysheet dialog, if it makes any difference) that has x number of strings. The user has the option to delete, add to, or edit a current string. If the user selects, say, to add a new string, a new window pops up asking for the name of the string.
WHen the user hits ok, the stringname is stored and added to the contents of the lisbox. However, when the user hits ok, the main page (with the listbox) is now in focus, and the contents of the listbox have not been updated. The only way to see the new string is to change focus to another page in the dialog box, or close the dialogbox and reopen it.
I've tried UpdateData() in OnSetActive, which i put in the page1 class of my propertysheet. It didint work. (i admit i dont fully understand it, but it was a shot in the dark).
Is there some way i can refresh the page (or the whole dialog for that matter) When focus is set to it? Or, is there a way to refresh only the listbox?
*.*
|
|
|
|
|
keegan wrote:
WHen the user hits ok, the stringname is stored and added to the contents of the lisbox. However, when the user hits ok, the main page (with the listbox) is now in focus, and the contents of the listbox have not been updated.
These two seem contradictory.
You have a property page (which is derived from a dialog) that has a listbox and an Add button on it. When the Add button is clicked, a (modal) dialog is displayed where text can be entered. When that dialog is dismissed, the text that was entered is added to the listbox. Yes? You should have code something like:
void CMyPropertyPage::OnClickAdd()
{
CMyDialog dlg;
if (dlg.DoModal() == IDOK)
m_listbox.AddString(dlg.m_strText);
}
Otherwise, I'm not understanding your question.
|
|
|
|
|
Heh, i was putting my AddString in my DoDataExchange. It's worked there on other pages, but i see why it should go where you suggested.
Once again, thanks
*.*
|
|
|
|
|
DoDataExchange() is only called during a call to UpdateData().
As a side note, you should rarely, if ever, have a need to explicitly call UpdateData().
|
|
|
|
|
I have a dialog app that I've written. I want to put our company logo on it but it's in jpg format. I could resave it to a bitmap but it takes away from it's colors. So how can I display this jpg on my dialog app?
I've looked at some of the examples in the bitmaps section of codeproject but these are way too much more than I need. Any suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You could transform it into a 24 bit bitmap but it will be a large file... I would use CxImage but I agree it is a lot of code for a simple thing like that. I think there are ways using ActiveX but I am not sure how to do this.
John
|
|
|
|
|
Try using GDI+. Displays JPEGs beautifully
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
I would like to read files greater than 32G. I think ReadFile can only handle 4 Gig files. Any suggestion? Would Mapped file work:?
Rdh
|
|
|
|
|
|
Assuming you are not wanting to read the entire file at once, there is still a maximum of 3GB of address space available. Just a guess, but I'd say that you'll need to read the file in chunks.
|
|
|
|
|