It seems using the following scheme would cause problem while building in MS Visual Studio 2005. Can someone give any suggestion on HOW TO ACCESS MEMBER VARIABLE OF b IN a.cpp? Some preprocessor instructions would be appreciated. Thanks a lot. // a.h class b; class a : public A { public: // Constructor, Destructor, and other members and functions. (Omitted) //... // void SomeFunction(); b* m_pb; }; // a.cpp #include "a.h" #include "b.h" void a::SomeFunction() { MEMBERVARIABLEDATATYPE Member_Variable_of_b = m_pb->MemberVariable; // This would cause compiler error } // b.h class a; class b : public B { public: // Constructor, Destructor, and other members and functions. (Omitted) //... // a* m_pa; MEMBERVARIABLEDATATYPE MemberVariable; // MEMBERVARIABLEDATATYPE is well defined, for example, int, double, etc. };
ytod
Posts
-
Mutual Include -
some problem regarding inheritance of and debuggerI found some runtime error in my solution with the IDE: Visual Studio .Net 2003. 1st problem: I inherited the STL class complex<_Ty>, and add some members to the class. However,I found the operator overloading didn't work well. I follow the way did in the overloading function:
return complex(x,y);
but the left side of the = lost many members. and the builder would inevitably warn:warning C4172: returning address of local variable or temporary 'Complex.h(382) : while compiling class-template member function 'Complex<_Ty>::_Myt &Complex<_Ty>::operator *(const Complex<_Ty>::_Myt &)' with [ _Ty=double ]
Is there any suggestion? thanks! 2nd problem: While debugging the code, I found SOME of the member functions cannot be broke! but others CAN! and some breakpoints would jump to the other functions while debugging. These break points would be marked with INFAMOUS white question marks which said:The breakpoint would not currently be hit. Invalid file line:353
I'd checked the configuration, it's set on debug mode. Searching on the web but found no proper way. Is there any suggestion? Thanks! -
MFC v.s. valarrayIt seems that is incompatible with the MFC, by searching the google I found it may work to #undefine min(), max(). Is there any alternative to solve this problem? Thanks!
-
What shuld I do to grab any audio data from sound card?Is it possible to grab audio data from sound car? For instance, if I open a game emulator, the music in the game would be played through the sound card. ( Does it? Actually I'm not very sure! ) What should I do to grab the audio data that played by my sound card? I'll appreciate your help, thanks!
-
How to support multi-languageI had written an application in a language version. All displaying strings in my application were written in this language in the string table. Now, How could I add support for other languages without modifying the existed resources? Is it possible to be done by adding resources such as string table in other languages? What should I do to use resources of the specified language and let the IDE build an application of specified language? I'll appreciate your help, thanks~~!
-
How to get all file name in a folderCan somebody tell me how to get all file path name in a specified folder? Thanks.
-
Pass paramters to an application while openning a fileBut that would only execute Nero Express but not open the .nrv file if
lpFile
is passed with the path of nero.exe andlpParameters
is passed with/w
. On the other hand, iflpFile
is passed with the path of the .nrv file, the parameter/w
is ignored since it views .nrv file as a document file, as MSDN said. Actually it didn't work...:sigh: But thanks for your reply anyway...:) My code is like this: // csFilePath is a CString object which is equal to the path of the nero.exe // or the path of the .nrv file.ShellExecute(GetSafeHwnd(), NULL, csFilePath, "/w", NULL, SW_SHOWNORMAL);
-
A simple client to serverTry to read some MSDN documents about Windows Sockets API or MFC class CSocket or CAsyncSocket. You should understand the the mechanism of TCP first. If you wanna use a simple way to realize your program, use MFC CSocket would be your choice. But Windows Sockets API would be better for developer. Good luck.
-
Need some helpYou may need to check if m_Video is a valid MCIWnd handle... If so, use this function to check the error code: MCIWndGetError( ). Good luck!
-
Pass paramters to an application while openning a fileHi, everyone: I have a problem about how to open a document file with a specific application or pass some parameters into the application while opening the document file. For example: I need to open a .nrv file, a Nero file. But using ShellExecute() would always open Nero in traditional mode. I wanna open the .nrv file by Nero Express. I examine the shortcut of the Nero Express is like this: "C:\Program Files\Ahead\Nero\nero.exe" /w It looks like passing a parameter into the nero.exe, how can I do that through programming? Thanks!
-
How to verify if an application exsist in the system?How to verify if an application exsist in the system? For example, I want to make sure if Nero exsist in this computer. Can some one help? Thanks!
-
Problem about finding memory leakPJ Arends wrote: #undef THIS_FILE static char THIS_FILE[] = __FILE__; That's of great help, thanks!:-D
-
Problem about finding memory leakWhile running debug mode on an application written by me, the debug would complain that it has memory leak:
Detected memory leaks!
Dumping objects ->
{118957} normal block at 0x04D89230, 22960 bytes long.
Data: < > 00 00 00 00 CD CD CD CD 00 00 00 00 00 00 00 00
...Is there any tool to trace the memory usage? It may be hard to find where the error is by simply trace the code( too long to examine X| ) Thanks!
-
color the text in MFC DialogIt didn't work.... But if the condition in if() changed to this form could work:
if( pWnd->GetDlgCtrlID() == IDC_STATIC_MY_STATIC ) { pDC->SetTextColor(RGB(255, 0, 0)); }
Anyway, thnks for your help. -
color the text in MFC DialogDavidCrow wrote: ytod wrote: To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text? ;P Miss one word "color": And what should I do to change the reulting text "color"? But I need to try what the previous post described first, thanks!
-
Write a .ini file of the application in MFCCould someone tell me how to write a .ini file of an application to store some states of all controls in an application? Simply using CFile to write or there are some special classes to handle this? Thanks!
-
How to add a lineat the beginnig of a file?I think allocating a buffer that's long enough to store previous data could also work.
-
color the text in MFC DialogHi, everyone: Can someone provide a EZ way to change an individual text in a dialog? I knew that I can use CDC functions to realize that, but can I do this on a Static Control? To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text? Or don't think about that, simply use CDC functions? Thanks!
-
How to get WM_VCSROLL ?WinProc? You program in WIN32? :confused: Did you mean DefWindowProc()? Anyway, that's not important. I guess this problem is because your message is sent to another window. Under the MFC framework, all messages would be sent to DefWindowProc( ) if their message handler are not defined (Ex: user defiend messages ). So your problem sounds quite strange...;P ( In Win32, you need to define all message handlers if you want to do something when these messages are sent. Otherwise, DefWindowProc( ) would be called. ) In addition, in Visual Studio you can use a tool Spy++ to "SPY" any message in your window. I hope that will help. Good luck!;)
-
Any Suggestin about shrink/ stretch a BMP?I knew that...;P Maybe need to talk in more detail... Some function would provide the BITMAPINFOHEADER and Bitmap buffer data. I wanna change the size of the resulting BMP. The step I thought was that: 1. call CreateCompatibleDC( ) to create a memory DC. 2. call CreateCompatibleBitmap( ), get the handle of a bitmap and use last-created memory DC to select it. 3. call memcpy( ) to copy the data to the last-created compatible bitmap. 4. call StretchBlt( ) from the memory DC to the dialog DC( or memory DC number 2 ). For I need to save time, the data of the BMP after stretch need to be saved. So...the following work may required to be done only once. 5. call GetCurrentBitmap for the dialog DC( or memory DC number 2 ). 6. call CBitmap::GetBitmapBits( ), get the data( upset-down, need to flip. ) 7. CreateDIBSection( ) for the new data in new size. 8. OK, next time when repaint is required, simply use a memory DC to select these bitmap handles and call BitBlt from a memory DC to dialog DC. ( The steps concerning with the deleting of some temp GDI objects are omitted. ) OMG! Too many steps... Is there a simpler way than that? Thanks!