To access 'g_m' from another cpp file you need to declare 'g_m' as an extern in that file - see my first post. In my first post I suggested that you have dedicated files for this purpose, Globals.h and Externs.h. If you do this each time a cpp file needs to access a global you can just include the 'Externs.h' so it makes life easier. Also it anables you to quickly see all your globals at one time, you could add the extern declaration to each file that needs to access the global but as your project grows it will probably get messy very quickly.
The problem here is that you have a terminology issue.
You declare the variable in HEADER file (something.h) that can be freely included in SOURCE files (*.c / *.cpp)
Where you and other have an issue is that you implement the variable in another .h file, that you actually treat like a source file.
So, your compiler builds some cpp file, that is the only file including this special header.
As long as you are disciplined about this, you'll be fine.
But anyone else coming along will be puzzled.
Some day you'll make a mistake...
If you put the actual implementation
int g_MyVariable = 0;
in a source file, then you can't make this mistake.
Could any one help me how I can get all drives along with the hidden drives in windows. I am searching in msdn. I am not getting any good clue how to do it. Please help me if you know showing hidden drives using mfc / c++ to get the hidden drives info. If I got solution i will share the same.
[I mean Hidden drive is, if I remove drive letter in device manager then the drive will be disappear for user. The actual drive & content will be existed in windows. If i go to Disk manager, I can again assign drive letter back and can see the drive.]
Thanks in advance for help.
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
I am writing a plugin for an existing application, which allows me to create a tool window and provides standard controls from their own SDK to use on the tool window.
The problem is thier sdk is inssuficient and lacks many standard things such as a main menu and context menu etc,so I like to use Windows API controls on this tool, but I dont have access to this window's WndProc function. All the callbacks are handled internally by the main application which is seemingly hidden.
I am able to find the Hwnd for this tool window using a spy tool. How would I go about adding my own Winapi controls on this window and how would I catch the messages sent by the controls without having access to the WndProc() or the Main() function of the application?
If I initiate a seperate WndProc function, it will conflict with the main application and crashes it.
There are several overload function for the tool window which the application provides. These inculde the OnPaint() and OnIdle() functions.
I was able to do some basic things like painting a rect onto this window so I know I am accessing it correctly.
Any help would be much appreciated.