|
Well, I encourage you to read Chapter 9 : "Source Files and Programs" of the book "The C++ Programming Language, 3rd Edition" by Stroustrup.
Maxwell Chen
|
|
|
|
|
Good advice,
I will get the book. thanks
|
|
|
|
|
Hello,
I figured out the problem I was having, but I still don't know a good solution.
If you take the code posted above... and add the following line to Class2.h:
#include "Class1.h"
So there seems to be a problem at the posted comments when I add this include. Why can't I link in this way, and what suggestions can anybody give me to avoid this sort of thing.
Thank You
|
|
|
|
|
Originally Class2 has been included by Class1 in file "Class1.H". Now you added #include "Class1.h" in file Class2.h, you got cross inclusion! ... like your bowels getting knotted.
#include "some_file" means to embed the entire texts of the file "some_file" into where the #include directive being invoked.
Foe example, "MyHeader.H":
class Foo { };
And another file, FooBar.h, includes MyHeader:
#include "MyHeader.h"
class Bar {
public:
Bar() { }
};
You can now imagine file "FooBar.h" as the below:
class Foo { };
class Bar {
public:
Bar() { }
};
And to the view of compiler, it is!
Maxwell Chen
|
|
|
|
|
Thanks,
No more cross-inclusion.
|
|
|
|
|
I want to write a voice chat program in LAN using Visual C++, but don't know where to begin. Please give me some hints and documentations . Thanks.!
|
|
|
|
|
You could use Microsoft Speech (if both comptuers will be using XP (and NT/2000?), or DirectX DirectPlay (I think, or DirectSound) for the voice part.
I would get the DirectX and/or Speech SDK from microsoft and look around there.
Speech: http://www.microsoft.com/speech/download/sdk51/
DirectX: http://www.microsoft.com/downloads/details.aspx?FamilyId=124552FF-8363-47FD-8F3B-36C226E04C85&displaylang=en
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
|
I want to make a program like some of the installers I've seen, if the directory does not exist it asks if you would like to create it. This is my only idea:
<br />
if(CreateDirectory("C:\\Something",0) == TRUE)<br />
{<br />
RemoveDirectory(C:\\Something");<br />
if(MessageBox(0,"Directory exists, would you like me to create it?","?",0) == IDYES)<br />
CreateDirectory(C:\\Something",0);<br />
}<br />
<br />
<br />
if(CreateDirectory("C:\\Something",0) == TRUE)<br />
{<br />
if(MessageBox(0,"Directory exists, would you like me to create it?","?",0) == IDNO)<br />
RemoveDirectory(C:\\Something");<br />
}<br />
Either way they don't seem to be very good, is there another way?
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
KingKruncher wrote:
is there another way
Yes there is (actually more than one). One of them is to use GetFileAttributes to check for the existence of a file or directory. Take a look:
if (GetFileAttributes(TEXT("c:\\some_directory")) == (DWORD)-1)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
{
if (MessageBox(NULL, TEXT("Directory c:\\some_directory does not exists. Would you like to create it?"), TEXT("Please Confirm"), 0) == IDYES)
{
}
}
}
Hope this helps.
Gurmeet S. Kochar If you believe in God, it's because of the Devil
My CodeProject Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
Thank you alot Gurmeet S. Kochar. That still doesn't seem right, but it's better than what I had. Thanks again.
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
|
Well, I was just thinking there would be a function called "DoesDirectoryOrFileExist" or something like that, but I just couldn't find any thing.
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
I am trying to open a popup menu from a menubar without progmatically, without the mouse necesarily being near the menu and without SendInput.
SendMessage( targetWindow, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
The documentation for SC_MOUSEMENU says "Retrieves the window menu as a
result of a mouse click.". Now I know the parameters I send are correct, but it does nothing. Can someone explain why it doesnt work? Or possibly explain how I could get it to work?
lParam = MAKELPARAM( screenIntersect.x, screenIntersect.y );
I have matched my screenIntersect to the values I got from Spy++ just to ensure they were correct compared to normal ( not gernerated by me )
messages.
I know I can send ALT+downarrow key command to open the first menu.. only problem with that is if the menu is already in tht "ALT" state sending another ALT will turn that state off. Also its not really the same since the ALT state will wait for a hotkey, not what normall happens when you open a menu with a mouse click.
Thanks,
|
|
|
|
|
I need to develope a text editor that can also display bmp images. I need to perform clipboard functions on bitmaps as well as text.
I m inheriting a new class from CEdit and having a CBitmap member variable. I want to override the CEdit paste (infact clipboard methods) method so taht I can display bitmaps alongwith the text since CEdit allows only CF_TEXT format.
I cant find any way at the moment to do this.
A lot of thanks for the suggestions.
|
|
|
|
|
|
OK. I try to see whether CRichEdit provides this functionality and how to use it. but isnt there anyway to override CEdit::paste??
|
|
|
|
|
|
I am testing on Windows XP with Fast User Switching.
Our drawng code goes through our own DrawRect function which is a wrapper for Rectangle().
Our function checks the return value from Rectangle, which is a bool. Microsoft says to check GetLastError when Rectangle fails. I did and it rturns '5' - access denied after switching away from the current user, to another user, and then coming back to the original user.
Anyone else ever seen this error come back for the Rectangle call?
I have stepped through the program, and if I let the drawing continue everything --appears-- to be fine
|
|
|
|
|
Hello,
I'd like to retrieve blob fields (which contains jpeg file) from MySQL queries without file access.
My current solution is w/ file access : fwrite(row[1],1,lengths[1],pOutFile); (like examples from MySQL.org) + Bitmap image(path to saved file) and I'm not satisfied ...
TIA
lbe
|
|
|
|
|
If I remember correctly this can be accomplished using streams. Allocate global memory of the correct size using GlobalAlloc(), read your blob data into that memory, use CreateStreamOnHGlobal() to make an IStream object containing your data, then use Bitmap::FromStream() to read the data into a bitmap object.
and no, I do not have code that does this
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Assume row[1] comes from "mysql_fetch_row" and is a BLOB. The code below works for me :
LPVOID pvData = NULL;
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, lengths[1]);
pvData = GlobalLock(hGlobal);
CopyMemory(pvData, row[1], lengths[1]);
GlobalUnlock(hGlobal);
IStream * pStream = NULL;
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
Bitmap * image;
image = Bitmap::FromStream(pStream);
pStream->Release();
|
|
|
|
|
sorry for repost
i have an edit box and a button add on a tab (i have 3 tabs on a dialog..each tab is a seperate dialog using property page)...im trying to have it where if a user press enter in the edit box it will execute the button add (call on the add function which the button is mapped to)..how can i do this? this is a single line edit box
i've tried onchar event for that dialog and it's not detecting when i type in that edit box...
i've also tried default push button property for that button and it's also not working
any suggestions? thanks
|
|
|
|
|
You need to process WM_GETDLGCODE message and return DLGC_WANTALLKEYS + whatever edit control returns (don't remember if DLGC_WANTCHARS would be enough), in order to receive this keyboard message message. Or you can make it a multiline edit contrl (ES_MULTILINE) with ES_WANTRETURN style.
Edward
|
|
|
|
|