|
If you invalidate the pointer in your main class, you will have to update it in the other class.
One other thing you could try: Have a function "getCurrentPointer" or whatever you want to call it, and store a MainClass* myMainClass in your "OtherClass". Then use "myMainClass->getCurrentPointer" to retrieve the actual object.
e.g. (c-like pseudocode):
class MainClass
{
private List myList
public List* getCurrentList()
}
class OtherClass
{
private MainClass* pMainClass
public void setMainClass(*MainClass)
}
and somewhere:
OtherClass myOtherClass
MainClass myMainClass
OtherClass.setMainClass(&myMainClass)
// Now, when you change your List, you always use
myOtherClass.pMainClass->getCurrentList()
Since you are not pointing to a data member of a MainClass object, but to the object itself, you can do about everything you want with the MainClass-List (except deleting it, of course) and still have a way to access the List from your other class.
Thats just an idea
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Thanks,
also, have a look at my other answer.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I konw: in pure C / C++ program I can get the path from arguments passaed to main function.
int main(int argc, char* argv[])
argv[0] - path to program.
but how to get path to executable file in MFC application ??
miQel
-- modified at 9:22 Wednesday 22nd February, 2006
|
|
|
|
|
Look at GetModuleFileName.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
thx
I still have a problem, I have made simple Dialog app. Under OK button have put some code:
LPTSTR lpFilenamem;
int retval;
retval = GetModuleFileName(NULL, lpFilenamem, 100); //*
if (retval >0 )
MessageBox(lpFilenamem);
the program crashed on line signet by //* with communicate: Unhalded exception
miQel - always learning
|
|
|
|
|
Try...
TCHAR caFilenamem[ _MAX_PATH ];
int retval;
retval = GetModuleFileName(NULL, caFilenamem, _MAX_PATH); You were passing in an uninitialized pointer.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
miqel wrote: but how to get path to executable file in MFC application ??
The same way, actually, you'll just use __argv[0] instead. You also have access to the app's m_lpCmdLine member.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
To the O.P., I do not think that you can use CWinApp::m_lpCmdLine for that - I think it only contains true arguments, excluding the executable and its path.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
True. Sorry for the mis-post.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
Hi All,
Can anyone tell me how to add an icon to Windows Namespace? One way to do this is to add a key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace, but for this one needs to have admin privileges on the system. Is there a different way by which a non admin user can do the same?
Thanks and Regards,
Anil
|
|
|
|
|
If there is no similar key under HKEY_CURRENT_USER there is no different way.
Don't try it, just do it!
|
|
|
|
|
|
Anil_vvs wrote: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace
but for accessing same key in user account you need ADMIN Priviledge there too.. have a try
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi All
I am using SHFormatDrive () to format any drive but the problem is that this function gives a windows dialog, I want to make this dialog silent so that if user press any button then irectly it format the drive.
Please guide me.
Thanks
|
|
|
|
|
|
Thats exactly what I thought.
BUT, there are some cases in which an automatted format might be desirable. If you inserted a floppy in an unknown format into my MIDI-Keyboard, it would automatically begin formatting it, if you had pressed the "Save Song X" button.
They would state that in the manual, but the first time it happened, it did cost me disk 22 of Monkey Island....
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Sebastian Schneider wrote: but the first time it happened, it did cost me disk 22 of Monkey Island....
That's too bad...
|
|
|
|
|
toxcct wrote: virus like ?
So you start Teaching Virus Making here
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
oh no...
simply seeing that his software would behave like a virus...
this way, it was more an alarm signal for beeing careful for the ones who'd like to answer...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
Have a look at the function FormatEx in fmifs.dll
I think there is (or at least, was) some article/sample at Systems Internals (http://www.sysinternals.com)
|
|
|
|
|
rajeevktripathi wrote: I want to make this dialog silent...
The format is controlled by the dialog interface. That is, the user must click the OK button to actually begin the format—the format cannot be started programmatically.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
Well, actually, it can. See my post. I have been using this func for ages in a program of mine. It even supports callbaks to a progress funtion (optional).
|
|
|
|
|
kakan wrote: Well, actually, it can.
SHFormatDrive() will always present a UI.
kakan wrote: See my post. I have been using this func for ages in a program of mine. It even supports callbaks to a progress funtion (optional).
The question, as well as my response, was regarding SHFormatDrive() , not FormatEx() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
Sorry, I misunderstood your post.
|
|
|
|
|
hi, im a mechanical engineering student and i've been given the task of calculating the second moment of area of three beams with different cross-sectional areas using the trapezium rule on c++ . i need the program to ask the user which cross-sectional area they want to calculate the SMOA for and use the corresponding data. the problem for me arises with the data for the heights and widths to be used as these are stored in txt files. the txt files contain a list of numbers: a single floating pt for the width, an integer, n, for the number of steps taken...which corresponds to the set of floating points which follow describing the height of the beam at these n points. i think i have to use an array to open and use the values, but one of the files has 20 values where the other two only have 10,(i.e.n=10 for two and n=20 for one) does anyone have any helpful hints for me? it would be very much appreciated!
thanks again
jo
-- modified at 11:14 Wednesday 22nd February, 2006
|
|
|
|