|
Why don't you want to draw it on your view ? The view is there for that reason, the mainframe is just the 'window' that will contain your view.
I think you need to review a little bit your program architecture. First, in a SDI application, all data should be contained in your document, not in your mainframe. Then, when the view is painted, it ask for data to the document and it draws this data. Normally, that is the standard way to proceed.
|
|
|
|
|
ok, I kinda know the answer, but maybe I overlooked something.
I have a C linked list collection ( old legacy C code that I don't want to change ).
The new items are added at the beginning of the list.
If I want to pass this pointer around to different classes :
class MainClass
{
MyList* pList;
};
class MyOtherClass
{
MyList* pList;
};
....
MainClass mainClass;
...
MyOtherClass otherClass;
otherClass.pList = mainClass.List;
now, if I add items to the list in MainClass , the other pointer in MyOtherClass will not point to the good item; it will point to the item that MainClass.pList was pointing at the time it was assigned.
is there an easy way to have the pointer pList in MyOtherClass always point to the same thing that the pointer pList in MainClass ?
One way to fix this would be to insert at the end; that will keep the head of the MainClass list.
One other way could be do something like : ( this seems to work in the small test I did )
class MyOtherClass
{
MyList** pList;
};
MyOtherClass.pList = &mainClass.pList;
but I can't do it in my application; the list belongs to a another class, and that implicate a lot of other problems.
Any other ideas ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
MyList is the calss that manages the linked list right ? So, on of the member in it should be the head of your list.
When you store the address of this class in another pointer, they will both point to the same linked list object. Thus, if the head changes, it will change for both pointers as they both point to the same class.
Or maybe I misunderstood your question. Maybe show us the code for the MyList class, it will help.
|
|
|
|
|
Actually, after reading your reply, I now believe that YOU understood him and I did not. Shame on me
Cedric is right: Just make the list-head accessible from your List-Class. If you need the most recent element, have your List-Class store a pointer to it as well.
Anyway, the List-Class should manage access to its contents, not the containing classes.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
no, sorry, my mistake, MyList ( maybe the wrong name here ) is the head of a link list; not the container of the list itself.
class MyList
{
MyList* pNext;
}
so, in standard ( beurk ) C ...
MyList* pList = NULL;
MyList* p = new MyList;
p->next = NULL;
pList = p;
p = new MyList;
p->next = pList;
pList = p;
...
on solution that we found was to keep a reference to the list in the MyOtherClass class.
class MyOtherClass
{
MyList*& pList;
};
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
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)
|
|
|
|