|
-
July 28th, 1999, 03:43 PM
#1
Globals
Hi,
I have a modeless dialog which according to the utility Spy++ has no parent. I need to be able to set focus to this dialog across files. What I mean is if I'm in another code file I may need to access this dialog's members. I can't seem to find a way to gain access outside of the file that creates the dialog. Everything is "0".
Could someone show me how to make a global varialble that has a pointer to the dialog?
Thanks
Steve
-
July 28th, 1999, 04:02 PM
#2
Re: Globals
Put it in your App class so you will have to access it through it.
For example
class CMyApp : public CWinApp
{
...
public:
CMyDialog * m_MyDialog;
...
};
Make sure you set it to NULL in the constructor and when it is destroyed. If you do that then now you can do the following in any project file.
if ( AfxGetApp()->m_MyDialog != NULL )
{
// Get my data
}
else
{
// I don't know maybe create it
}
Is this what you are talking about?
Wayne
-
July 28th, 1999, 05:07 PM
#3
Re: Globals
Wayne,
does it make a difference if my app is a Dll and another third party app is running and using my dll?
Steve
-
July 28th, 1999, 05:42 PM
#4
Re: Globals
If it is a non COM DLL then no it does not matter, because your code is loaded in the same memory space as the exe. If it is a COM Dll, then ?. When I answered your question, I thought it was in a regular EXE. If it is in a DLL then you would not call AfxGetApp(). What I would do is just declare a global pointer to it in the DLL and manipulate it that way. Just make sure you manage it the same way with setting it to NULL if it is not used.
Wayne
-
July 28th, 1999, 05:48 PM
#5
Re: Globals
Wayne,
I get a m_MyDialog not a member of CWinApp error.
Steve
-
July 28th, 1999, 05:54 PM
#6
Re: Globals
Wayne,
My dll is part of the same memory space. You need to explain how to make a global pointer. I don't understand where to put the declaration or the assignment. Everywhere I've tried the variable isn't seen by my other files.
Steve
-
July 29th, 1999, 07:49 AM
#7
Re: Globals
First of all, by your other files, you do mean in the same project, right?
Let me know,
Wayne
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|