|
werfel wrote: i'm putting a class definition in the header. isn't that where they're supposed to be?
You can do that, but then you'd have to tag the methods with inline, or put the method bodies within the class. It's easiest to do the latter. Kind of like C#:
class X {
void method() {
}
}; werfel wrote: i would then have to #include the .cpp in the .h, which i understand to be a big no-no.
Indeed! What you need to investigate is how to create static (.lib ) or dynamic libraries (.dll ). A good start is learning how to use and create static libraries, since there are less details to keep in mind.
Basically, a library consists of two things: header files and a .lib -file. The header files instructs the compiler at compile time that the classes and functions are available for linking. The .lib file provides the actual code and data for the linker, so that the names referenced in the header file will be bound to the corresponding code and/or data.
One could say that the linker is the part of the compiler toolkit that puts all the pieces together. The pieces are typically .lib and .obj files. The .obj files are produced by the compiler for each compilation unit. In a C++ project, the .cpp files are compilation units. If you have #include d code bodies (such as functions, not prototypes) into several .cpp files, the linker will find duplicates of the code. Since the preprocessor is basically a cut'n'paster (#include basically pastes whatever is in the inluded file), the linker can't know that the found duplicates are the same. It will have to refuse linking. This is the linker error you got.
--
Pictures[^] from my Japan trip.
-- modified at 14:59 Sunday 18th December, 2005
|
|
|
|
|
I have created a simple media player for .wav files and want to add a scroll bar to speed up or slow down audio as it is being played. (By up to max +5% and -5% only). Any ideas on how I can achieve this in c++ or vb.net? Any help would be much appreciated.
Hedphoniks
|
|
|
|
|
Hello All, I am working in C++ (6.0) for the first time. I am a C#/VB.NET web developer so I feel well over my head.
I got the sample Hello World sample windows app to work, but I need to basically do the same thing only I am writing a DLL instead of an executable. Essentially, I am trying to write a plug-in for another application.
Any sample code, good starting urls would be greatly appreciated. If you evern need help in the ASP.NET world, I will kindly return the favor.
-James
___________________________
J A M E S C O L E M A N
Practice Director, Microsoft
AGENCY.COM
jcoleman@agency.com
http://www.agency.com
|
|
|
|
|
Is it just me, or does this seem like overkill to detect an empty string...
if( strcmp( szPossiblyEmptyString, "" ) == 0 )
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Yes, I usually do
if (!(*szPossiblyEmptyString) )
But this maybe not very readable.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
if (szPossiblyEmptyString [0] == 0)
That works fine for testing for an empty string. If you also want to test for a NULL pointer
if (pszString == NULL || pszString [0] == 0)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote: if (pszString == NULL || pszString [0] == 0)
That's a good habit, in case one has to work with BSTR strings.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Definitely superfluous.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Good Habit to inculcate.
|
|
|
|
|
How do you change the value of CStatic variable dynamically/runtime? Using Visual C++ .NET.
Thanks,
Pat
|
|
|
|
|
|
I'm not sure if I understand. I have the following code:
CStatic m_text;
m_text.SetWindowText(_T("hello there"));
I get a "Debug Assertion Failed" error and the program dies.
Did I do something wrong?
Thanks,
Pat
|
|
|
|
|
PatP07 wrote: CStatic m_text;
That's not enough, that just creates an instance of the MFC class. To create the underlying Win32 window, you need to call Create on it.
|
|
|
|
|
Here's an example copied from MSDN.
CStatic myStatic;
myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), pParentWnd);
myStatic should not be a short lived local variable, so it may be a good idea to make it a member of the container class.
|
|
|
|
|
Ok, got it to work...thanks a lot!
P.
|
|
|
|
|
In addition to Nishant's answer:
The C++ objects are just simple wrappers around the Windows API. When you do "raw" windows programming, you deal with window handles. You've probably seen them in code - HWND is their C/C++ type. When you program without MFC or any other toolkit, you either use the builtin functions such as SetWindowText() , or manipulate the windows by sending different messages to them.
What MFC does for the common control windows, such as labels (CStatic ), is that it wraps the window handle, and provides C++ methods for manipulating the windows. The methods then call the corresponding Windows API function or sends the appropriate message with parameters.
What this wrapping business means is that you actually have two objects to maintain in your code! In the case of m_text , there's the actual C++ object, and the actual window. These two object's lifetimes are not synchronized. When the m_text object's constructor has executed, the window object is not yet created. It is created in a successful call to Create() . When DestroyWindow() is called later on, the window object is destroyed, but the C++ object remains. Whenever the window object is not alive, most methods on any CWnd derived class are not available.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Hi
I want to know how i can extract an exe into memory and then execute it directly from memory. Any idea or ref . Pl. help me.
thanks
|
|
|
|
|
|
He wrote: into memory
he wants to do it "on the fly" not wanting to land on disk !!
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
VivekuniQ wrote: he wants to do it "on the fly" not wanting to land on disk !!
there no way AFAIK... but maybe he can write a temporary exe on the disk, ShellExecute() it, and when it exits, delete the file...?!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
I want to execute exe directly from memory. I am writing a binder that will bind my project files and execute them to the memoty.I am doing this to make single exe out of several. Any idea or ref.
|
|
|
|
|
is it ok for you, instead of creating an exe "in memory" an launch it as is, to create threads and processes instead ?
as i am understanding your last comment, you're trying to make several independant units that are running separatedly (but maybe synchronized). this way, threads may be what you're looking for...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Well that sounds great.
should i load exe that is at the end of main exe file and create a process with the address of second exe.
well i have joined (appended) 2 exe files. now i want to load 2nd exe (which is at end of 1st exe) to the memory.
|
|
|
|
|
You can embed binary files as "binary" resources inside your exe, easy as embeding an icon.
Then you can save the binary contents as a "temporary" .exe, and execute it.
I hope it helps
Guimasun
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
Hi
Thanks a lot for help.
I think there is no way to execute exe file from memory.
So i am going to use ShellExecute().
well if i find out any way i'll ley you know.
thanks
|
|
|
|