|
Thanks for the help! I getting a better grasp on c++ every day...
I ment to ask this in the last post, but forgot... what does
Inline do... and how does it do it...
Thanks!
|
|
|
|
|
inline is a *suggestion* to the compiler that it write the function in place when it writes the code, so that the overhead of a function call is no longer present. The compiler is free to ignore it, and will ignore anything but the simplest of functions, which it may inline without the suggestion.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
So, using the inline function:
inline int name
is that how i would use it?
Thanks!
|
|
|
|
|
inline int GetScore()
{
return score;
}
every where you call GetScore() in your program, it will place the code inside of the brackets where you call the function instead of calling the function. This will save you the time of all of the setup work that is required when you call a function. Typically you only use inline for very simple functions.
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!
|
|
|
|
|
Hello!
Has anyone used OleSavePictureFile? Any sample code about this function?
Thanks!
marcela bovio
|
|
|
|
|
I am looking for some good examples showing how to handle the MS Mediaplayer events( buffering, playing, etc) using VC6 and ATL. All the examples I can find concentrate on handling the events from HTML. Any help is appreciated. thanks in advance
|
|
|
|
|
Hey...say I want to make a window be hidden, as I show another window...
I figure I have to SendMEssage to the window's handle...what's the parameter I have to send using SendMessage to make the window hide or disappear? Thanks =) - Dave
|
|
|
|
|
If this is a window you have access to in code you can do..
Wnd.ShowWindow(SW_HIDE);
otherwise you could try sending a WM_SHOWWINDOW message with the right params.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
I'd use ShowWindow(SW_HIDE);
bryce
|
|
|
|
|
I was originally hesitant to post this question, mainly out of concern that it has been answered before; however, I have been unsuccessful in finding any form of answer to this question, so here goes ...
Why ATL over MFC for application development?
It was my understanding that MS conceived the ATL as the ActiveX Template Library for use by developers to design and implement ActiveX controls; not for full blown application development. Yet, I find case after case of developers using the ATL just for that; Why? What advantages are gained by using ATL as your primary frame work for application development over the MFC? What makes it so much better than the MFC? It appears that as a developer, you loose more than you gain, but then, that's what I'm asking (perhaps I'm not seeing the forest through the trees?).
Thank you enlightening me on this subject,
D.
|
|
|
|
|
Youa re right about ATL, it was conceived to create COM and ActiveX controls. However there are a few classes that help with windows development.
WTL (Windows Template Library) is a small framework that builds upon ATL, and this is what most developers use to develop full blown applications with an ATL style.
The advantages of WTL over MFC are that every thing is template based, so your framework gets compiled right into your application. There is not need for large bloated DLLs like MFC requires, to run your application. I also believe that WTL is a cleaner design, and easier to expand than MFC. A lot of what WTL provides are simple wrappers, which makes it efficient and easy to extend.
Many of the constructs that are available in MFC are also available in WTL as well. One of the things that is missing is the Document / View architecture. This can be easily over come though with a good design. Another disadvantage to using WTL at this point is that there is no documentation for it. So you have to rely on your ability to read and understand the source code, and talking to other developers that use WTL.
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!
|
|
|
|
|
Thank you for responding, what you've said makes sense to me, and I can understand now why WTL/ATL would be appealing. Coming from a background in Delphi, I am used to having the ability to include the base framework code or provide it as an additional "DLL"; guess I've been spoiled?
Thank you again,
D.
|
|
|
|
|
I have developed a search program..where it searches only in C:\ and other drives if specified. But it doesnt support C:\,A:\ or Mycomputer or all the hard drives at the same time to perform a search. I have to type C:\ once and then A:\ once seperately for a search.
|
|
|
|
|
What is your question?
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!
|
|
|
|
|
rofl
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
i think you want to enumerate through all the drives attached to your computer before starting the search on each drive or putting them in a selection listbox or whatever
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
erhh..I reckon I didnt comprehend my situation well in my previous post. See, I wanna perform a search on all the hard disks at the same TIME.But my program searches only one hdd at a time.Is there any API function to comb the all the hdd's ?
Lauren you need not roll on the floor and laugh...lol well, i dont mind..Insults are invited
|
|
|
|
|
I wasn't trying to insult you, I am sorry if you do feel insulted.
I think from your post, there is a possibility of at least two or three different questions. I just wanted to make sure that I answered the correct question.
To answer your question, why don't you search through one hard drive at a time, but do not return the results, or do not quit searching until all of the harddrives have been searched. You will not gain any performance on searching multiple drives simultaneously unless you have a dual processor machine.
Like Mike Dunn posted, use the GetLogicalDrives functions in order to know which drives are available.
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!
|
|
|
|
|
I beleive there would be a performance increase if a thread was created for each ide channel regardless of the processor count.
|
|
|
|
|
erhh..I reckon I didnt comprehend my situation well in my previous post. See, I wanna perform a search on all the hard disks at the same TIME.But my program searches only one hdd at a time.Is there any API function to comb the all the hdd's ?
Lauren you need not roll on the floor and laugh...lol well, i dont mind..Insults are invited but dont forget give a solution.
|
|
|
|
|
|
Here is some code.. it doesn't accually do anything with the drive info once it gets it but it should be easy for you to modify to your liking.
int drivenum;
CString Drive;
for (drivenum = 'A'; drivenum <= 'Z'; drivenum++) {
Drive.Format("%c:\\", drivenum);
switch (GetDriveType(Drive)) {
case DRIVE_UNKNOWN: break;
case DRIVE_NO_ROOT_DIR: break;
case DRIVE_REMOVABLE break;
case DRIVE_FIXED: break;
case DRIVE_REMOTE: break;
case DRIVE_CDROM: break;
case DRIVE_RAMDISK: break;
}
}
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
When the object of my class (see below) have done its work my app crashes!
And the debuger says there is in operator 'delete' an expression error: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). I have allocated memory in both my constructors and deleting it corectly... haven't I?
My class:
class CScoreData
{
// Public member functions
public:
CScoreData(char* player, int score);
CScoreData();
~CScoreData();
void FillData(char* player, int score);
char* GetPlayer(){ return m_chPlayer; }
int GetScore(){ return m_nScore; }
// Operator overloading
public:
CScoreData& operator=(CScoreData& sd);
// Member data
private:
char* m_chPlayer; // Player name
int m_nScore; // Player score
};
CScoreData::CScoreData()
{
m_chPlayer = new char[MAX_SD_BUFFER];
m_nScore = 0;
}
CScoreData::CScoreData(char* player, int score)
{
m_chPlayer = new char[MAX_SD_BUFFER];
FillData(player,score);
}
CScoreData::~CScoreData()
{
delete [] m_chPlayer;
}
void CScoreData::FillData(char* player, int score)
{
strcpy(m_chPlayer, player);
m_nScore = score;
}
CScoreData& CScoreData::operator=(CScoreData& sd)
{
if(this == &sd)
return *this;
strcpy(m_chPlayer, sd.GetPlayer());
m_nScore = sd.GetScore();
return *this;
}
int main()
{
CScoreData sd;
sd.FillData("Testar att vara cool",120000);
ofstream fout("file.osh",ios::binary);
if(!fout)
return 1;
fout.write((char*)&sd, sizeof(sd));
fout.close();
/////////////////////////////////////////////
/////////////////////////////////////////////
CScoreData sd2;
ifstream fin("file.osh", ios::binary);
if(!fin)
return 1;
fin.read((char*)&sd2, sizeof(sd2));
fin.close();
cout << sd2.GetPlayer() << "\n" << sd2.GetScore() << endl;
return 0;
}
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
I believe the problem is because of the way that you are reading and writing your data out to the file. You are doing this:
Rickard Andersson wrote:
fout.write((char*)&sd, sizeof(sd));
Which will not write out the data to the character array like you expect, but the pointer that you have allocated. Then when you read in SD2 with this:
Rickard Andersson wrote:
fin.read((char*)&sd2, sizeof(sd2));
The pointer is still actually valid because sd was not yet destroyed. So when you access the data it succeeds for sd2.
Finally, when the objects delete themselves because they go off of the stack, the first object to be deleted will succeed because the pointer is valid, the second deletion will fail.
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!
|
|
|
|
|
So, a new allocation won't cause when creating more then one object of the same class?
Okay, then I have to put those into separeted functions and read in one and write in another...
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|