|
Jason Hihn wrote:
while (Array.GetSize()){
delete Array[0];
Array.RemoveAt(0);
}
That's a pretty inefficient way of doing it since every time you remove at 0 the upper data has to be shifted down. I would just keep it simple e.g.
for(int i=0; i
|
|
|
|
|
Jason Hihn wrote:
while (Array.GetSize()){
delete Array[0];
Array.RemoveAt(0);
}
Let's try again.
That's a pretty inefficient way of doing it since every time you remove at 0 the upper data has to be shifted down. I would just keep it simple e.g.
for(int i=0; i < Array.GetSize(); i++)
{
delete Array[i];
}
Array.RemoveAll();
Joel
|
|
|
|
|
Joel Matthias wrote:
for(int i=0; i < Array.GetSize(); i++)
{
delete Array[i];
}
Array.RemoveAll();
I prefer to write this as follows, personally:
while (Array.GetSize())
{
delete Array[0];
}
Array.RemoveAll();
I don't like using for() loops when clearing out arrays - but I guess that's just me being picky about coding style.
: Dean 'Karnatos' Michaud
|
|
|
|
|
That's fine but the code doesn't work and infact it produces an infinite loop since you never actually remove the pointer from the array.
Also you imply that 'while loops' are somehow more correct or are a better coding style than 'for loops' how do you justify that. People have been using 'for loops' to iterate through arrays for years.
Joel
|
|
|
|
|
Dean `Karnatos` Michaud wrote:
I prefer to write this as follows, personally:
while (Array.GetSize())
{
delete Array[0];
}
Array.RemoveAll();
Imho, that's bad, for 2 reasons: (1) it's inefficient to repeatedly make a function call to GetSize() and (2) it's dangerous to treat integers as boolean expressions. Better to write while (Arrary.GetSize() > 0) .
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Do you know how to exclude a MFC dialog-based application from the taskbar?
rechi
|
|
|
|
|
Remove the WS_EX_APPWINDOW style from the window, and that should do the trick.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
My application is having some major errors due to an issue relating to the variables defined in my app. As I step through the code using the debugger to check up on some bugs, I notice that upon declaration of my variables, they are immediately populated with junk data. This junk data is the source of many of my issues. Has anyone ever seen this before? I dont' understand why when a CString is declared it is being initially populated with junk instead of being an empty string.
Thoughts?
|
|
|
|
|
no real advice. but when things stop making sense, a Rebuild All is usually my first action.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Stew wrote:
I notice that upon declaration of my variables, they are immediately populated with junk data.
This is what a debug build does to tell you "You forgot to initialize this data".
|
|
|
|
|
Variables (intrinsic types and pointers) are not initialized for you. When you istantiate a class object the constructor is called and the constructor is responsible for initializing it's internal variables.
If you have a CString which you are declaring like:
CString strMyString;
and it has junk in it, the most likely problem is that you have overwritten your stack somewhere. If you are doing:
CString* pstrMyString;
then it should be set to junk since the constructor hasn't been called and all you've done is allocate apointer.
|
|
|
|
|
hi,
how can i import or use *.jpg images with the picture control (static) with microsoft visual c++ 6.
- thanks.
|
|
|
|
|
you can't. you need code to translate the JPG to a format windows understands. there are many ways to do this on this site.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Hello,
I am trying hard to show tooltips for controls that are enclosed by a group box using standard stuff of Windows.
I have noticed that if the group box is visible I get no tooltip whatsoever, if I make it invisible I get the tooltip.
Has anyone a good solution to this problem ?? I know that the group box is technically a camouflaged push button, but there must be a way to have both the group box and the tooltip visible.
PLS HELP ME !!!!!!!!!!!
Riccardo
|
|
|
|
|
Check the Z_order of your controls, and make sure that your controls come after the group box, that way they will appear to be on top of the group box, and hopefully the group box won't still the mouse messages.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
yes, but how can I control the Z-order of my controls ??
|
|
|
|
|
Did you ever find a solution for this problem? The Z-Order does not seem to make a difference.
Thanks,
John
|
|
|
|
|
What method would my fellow CPians recommend I use to interface with an SQL server. I don't need anything too complicated... just a basic way to connect and send and recieve data from the DB. There won't be any mad SQL statements [like the ones I had in my good damn DB exam!!]
Any help appreciated
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
ADO is OK. there are probably wrapper classes around, if you're not fond of playing with COM.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Chris Losinger wrote:
ADO is OK. there are probably wrapper classes around, if you're not fond of playing with COM.
Not fond of COM at all.. hence I asked. Must have a look at ADO in more detail... it's been a while since I looked at it. No doubt they'll be loads of articals on it here
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
Brian Delahunty wrote:
just a basic way to connect and send and recieve data from the DB.
I don't know if I got your question correct.Anyway,If it is very very simple operation I do it with CRecordset class in MFC.But for most case I use COM.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
I'd prefer not be be using COM. I think ADO is probably the best way to go
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
Brian Delahunty wrote:
I'd prefer not be be using COM. I think ADO is probably the best way to go
ADO is a COM Api library !!! You could try to arrange a MFC wrapper classes ...
If not, the MFC class CRecordset as Mazy had posted works fine , it uses ODBC , contrary to ADO that uses OLEDB (COM low-level api)
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
I apologise for my stupidity... I've never looked into it much. I relying on people to inform me at the moment as I'm too lazy to go researching...
Thanks for the help
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
Brian Delahunty wrote:
I apologise for my stupidity
Hey,man, you don't need to apologise for a thing that you didn't know .
Brian Delahunty wrote:
Thanks for the help
Your Welcome
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|