|
You have to have code to handle the command generated by a click on the button. If there is no code in your program to handle the click, the button will be disabled.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
|
In my application I have the following which opens a SHOUTcast stream and plays it.
In order to use the function OpenURL(LPVOID pParam) it has to be static or not a member of my class. The problem is that I want to have the OpenURL function set values that are members of my class.
For example my class has a variable called:
CString StreamName;
So I call the following line of code.
AfxBeginThread( OpenURL, _param );
I want OpenURL to set the value of StreamName.
If OpenURL is not a member of the class it doesn't know StreamName.
If OpenURL is a static member of the class then StreamName has to be static ( not sure how to deal with that)
I can't make OpenURL a friend of the class because I would have to pass in the class object and the threadproc must have a param list of ( LPVOID pParam )
How do I get around this problem?
|
|
|
|
|
There's many ways to do this. One is to pass the pointer to the object and another is to have a global pointer to the object.
|
|
|
|
|
You could also encapsulate your thread function in a class whose constructor takes the instance of the object. Anyway, as you can see there's all kinds of ways and which you choose really depends on a lot of specifics about your code.
|
|
|
|
|
Thanks I will try these ideas
|
|
|
|
|
See here and here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Overwhelming response many thanks.
|
|
|
|
|
Hello,
This[^] very nice class should fit all your needs..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
|
there is not open mode in fstream(ios) for creating a new file if the given file doesnt exist. how could I do that?
thanks
|
|
|
|
|
Doesn't that happen by default? Check out the fstream constructor's documentation.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I dont think so, since I have tried , it donesnt work. and little information on fstream in msdn.
you have any idea?
thanks
|
|
|
|
|
heng0987 wrote:
I dont think so, since I have tried , it donesnt work.
What does your code look like? This works fine for me:
fstream ff("c:\\david.txt", ios::out);
ff << 123;
ff.close(); heng0987 wrote:
...and little information on fstream in msdn.
Really?[^]
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
could you plz tell me in complete details how can i call matlab functions from a c++ program .
NOTE: ( i've already tried using engine.h but i got an error telling me" unresolved external symbol _engopen")
gobar
|
|
|
|
|
Did you include the lib that contains engopen?
Check this directory for some of the libraries that you need to link.
<matlab path="">\extern\lib\win32\microsoft\msvc60
|
|
|
|
|
i have created an SDI MFC app. How do i get it to check its own location on the hard-drive and spit back the path? IS there a path property for the executable?
thanks
|
|
|
|
|
GetModuleFileName(NULL, ...)
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
TCHAR buff[MAX_PATH];
GetModuleFileName(NULL, buff, MAX_PATH);
char drive[3];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
_splitpath(buff, drive, dir, fname, ext);
|
|
|
|
|
You may find this code intresting
CString strTmp,strDirectory;
GetModuleHandle(NULL,strTmp.GetBuffer(MAX_PATH),MAX_PATH);
strTmp.ReleaseBuffer();
strDirectory=strTmp.Left(strTmp.ReverseFind('\\'));
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Does anyone know what needs done to get the project built in Release mode.
Debug build is OK.
SSIC_Example error LNK2005: "class _AFX_THREAD_STATE * __stdcall AfxGetThreadState(void)" (?AfxGetThreadState@@YGPAV_AFX_THREAD_STATE@@XZ) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "class AFX_MODULE_STATE * __stdcall AfxGetModuleState(void)" (?AfxGetModuleState@@YGPAVAFX_MODULE_STATE@@XZ) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "class CWinThread * __stdcall AfxBeginThread(unsigned int (__cdecl*)(void *),void *,int,unsigned int,unsigned long,struct _SECURITY_ATTRIBUTES *)" (?AfxBeginThread@@YGPAVCWinThread@@P6AIPAX@Z0HIKPAU_SECURITY_ATTRIBUTES@@@Z) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "class CWinThread * __stdcall AfxGetThread(void)" (?AfxGetThread@@YGPAVCWinThread@@XZ) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "int __stdcall AfxMessageBox(char const *,unsigned int,unsigned int)" (?AfxMessageBox@@YGHPBDII@Z) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "protected: class CFrameWnd * __thiscall CCmdTarget::GetRoutingFrame(void)" (?GetRoutingFrame@CCmdTarget@@IAEPAVCFrameWnd@@XZ) already defined in mfc71.lib(MFC71.DLL)
i.e. what setting have I forgot to change in Release mode.
|
|
|
|
|
Somehow it seems to be trying to link both the MFC DLL and the static MFC library. If you changed the setting 'Use of MFC' in Project Properties for the Debug build, change the Release build to match. Otherwise, it could be that some other static library you're trying to link with was linked with the static MFC library.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for your post. I did ensure that all project link to MFC in shared DLL, but now get the following errors:
Example error LNK2005: ___xc_a already defined in msvcrt.lib(cinitexe.obj)
Example error LNK2005: ___xc_z already defined in msvcrt.lib(cinitexe.obj)
Example error LNK2005: ___xi_a already defined in msvcrt.lib(cinitexe.obj)
Example error LNK2005: ___xi_z already defined in msvcrt.lib(cinitexe.obj)
Example error LNK2005: __amsg_exit already defined in msvcrt.lib(MSVCR71.dll)
Have you any futher suggestions for the above?
|
|
|
|
|
It's pretty much the same problem, only this time the library at issue is the C/C++ run-time. The setting you're looking for is C/C++ > Code Generation > Runtime Library.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Is there a simple way of making the Exe for my program get a different icon depending on whether it's a debug or release build?
I can change the icon the main dialog uses at run time without problem, but not the icon that the exe has in explorer
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|