|
Mmmm, is the word extern what you are looking for?
Globals.cpp
int globalInt = 0;
CString globalStr = "";
CMyDoc* myDoc = NULL;
other1.cpp
extern int globalInt;
globalInt = 3;
other2.cpp
extern int globalInt;
if (globalInt == 3)
AfxMessageBox ("GloballyModified");
else
AfxMessageBox ("not working");
Of course, other1.cpp should be executed before than other2.cpp
ADD:
I would use the Global.h to declare constants, all the includes that are going to be needed in all other modules, and things like that, but for variables I prefer it like above
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
thanks for the reply. I found my mistake. In one of my header files, I had included the #include "Globals.h" by mistake. So when that header file was used in my .cpp files I inadvertantly included Globals.h twice which gave me the redefinition errors. Thanks again for the reply
|
|
|
|
|
How to make variables to be global inside the whole application. he had declared the variables in a "Global.h" as public but he had problems to acces them from other places although the include Globals.h was made.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Why did you delete your message?
|
|
|
|
|
F*CK, are you stupid to delete your questions once you get the answers ?
this is a forum man, not a chat. that means that other newbies - yeah, like you - can search the forum if someone else already asked the same question.
but if you delete, how can one find back what the question was ?
moreover it's not that first time you do this, and I've already notified you about this.
so, please, never do that again !
modified on Friday, May 16, 2008 8:17 AM
|
|
|
|
|
Well, now you really need the rant icon, don't you?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I really don't understand why people are doing this. Am I missing something?
|
|
|
|
|
Michael Schubert wrote: Am I missing something?
morons brother... you can't fight against.
|
|
|
|
|
It seems that you got your answer and then delete your question,right!?
|
|
|
|
|
Hamid. wrote: It seems that you got your answer and then delete your question,right!?
Right :-#)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Alok how are you you back to the codeproject but it seems you are front of time how did you accde to these replies?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I want to read Japanese string from string table. Means string is stored in Japanese language in MFC.
Can any body help me out. I try with ::LoadString(hModule, IDS_STRING1002 , szTemp, sizeof(szTemp))
but it is giving ??????? ?????? .
|
|
|
|
|
|
|
Do you want to use of multilangues on your program?
|
|
|
|
|
Hamid. wrote: multilangues
What's one of those?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: What's one of those
New version of multilanguages.
|
|
|
|
|
yes, it can be a mutilingual program.
means String Table is going to contain japanese, Chines etc. that i have to load and print in message box.
|
|
|
|
|
I think this[^] article is helpfuls for you.
|
|
|
|
|
If you want to display the text in a MessageBox you have to use MessageBoxEx where you can (and have to) specify the language ID.
|
|
|
|
|
Does your program compile without a hiccup, but it displays question marks in place of Unicode characters? In that case, you just need to install the appropriate language in your computer. Go to Control panel -> Regional and language options -> "Check" Install files for East Asian languages. Restart your machine. That should be it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
That i have done.
I have done the setting in control panel.
String Table is going to contain japanese, Chines etc. that i have to load and print in message box.
|
|
|
|
|
Cool. Is your string table ready? Is your app compiling without errors after adding Japanese text entries into the string table?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
yes, program is compiling.
But string which is stored in japanese is coming like ??? ????
|
|
|
|
|
You should answer all the questions that I asked.
1. Have you added the Unicode text to string table and have you verified that the program is actually reading it?
2. Are you type or paste Japanese text (Unicode) into notepad?
3. If yes, are you able to paste this text into your application?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|