|
-
February 13th, 2009, 12:09 AM
#1
Changing Address of Variable in Class
I'm incorporating a Dialog Bar into my application. I'm getting some very weird behavior for one of the member variables.
I have a boolean called m_bBarEnabled. The constructor for the class initializes it to FALSE. At that point, the address of m_bBarEnabled is 0x3d62d0. I have &m_bBarEnabled set as a watch. After the program's documents have loaded in OnNewDocument, I want to enable the bar so some further initializing can happen (which need the loaded data from the Doc). So OnNewDocument calls the Dialog Bar's member function EnableBar() before quitting. All EnableBar does is set m_bBarEnabled to TRUE. When I put a break point in EnableBar, the address of m_bBarEnabled is 0x88ce50! It sets that address to TRUE and returns.
Next I put a break in the OnUpdateCmdUI of the Dialog Bar and when that is called, the address of m_bBarEnabled is back to 0x3d62d0 and is set to FALSE (because when EnableBar was called, it was at a different address).
What's going on? There is only one instance of the Dialog Bar in the program. I double checked that before writing. Why is this variable moving in memory? I've never seen this behavoir before.
More Information: I put in some more breakpoints. The constructor for the dialog bar was being called before the Create in the MainFrame. I moved the initialization to OnCreate and the address for m_bBarEnabled changed to 0x88ce50. However, when OnUpdateCmdUI is called after initialization, the address of m_bBarEnabled is still 0x3d62d0 and it's not set correctly.
There seems to be a second instance of the dialog bar created. This is mostly code ported from VC 6 to VC 2005. I found some other changes that I had to make to get the thing to compile. This mechanism worked fine in VC 6.
Is there anyone who has a clue what's I'm missing here?
Bill
Last edited by wdolson; February 13th, 2009 at 12:51 AM.
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
|