|
I have global variables
float xtrans, ytrans; defined in my file TestGLView.cpp
and I have this function for handling keyboard events in my file ChildFrm.cpp
void CChildFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CMDIChildWnd::OnKeyDown(nChar, nRepCnt, nFlags);
char keypressed = char(nChar);
if(keypressed == 'I')
ytrans += 0.2;
if(keypressed == 'K')
ytrans -= 0.2;
}
this function uses the global variables from TestGLView.cpp
so I need to #include "TestGLView.cpp" in the file ChildFrm.cpp
but when I do that, I get this error:
C:\WINDOWS\Desktop\QE2 heart program\ChildFrm.cpp(14) : error C2370: 'THIS_FILE' : redefinition; different storage class
c:\windows\desktop\qe2 heart program\testglview.cpp(22) : see declaration of 'THIS_FILE'
so I comment out this line from ChildFrm.cpp since its present at the top of both files:
static char THIS_FILE[] = __FILE__;
but then I get tons of other errors, here are some:
TestGLView.obj : error LNK2005: "public: static class CObject * __stdcall CTestGLView::CreateObject(void)" (?CreateObject@CTestGLView@@SGPAVCObject@@XZ) already defined in ChildFrm.obj
TestGLView.obj : error LNK2005: "protected: static struct CRuntimeClass * __stdcall CTestGLView::_GetBaseClass(void)" (?_GetBaseClass@CTestGLView@@KGPAUCRuntimeClass@@XZ) already defined in ChildFrm.obj
TestGLView.obj : error LNK2005: "public: virtual struct CRuntimeClass * __thiscall CTestGLView::GetRuntimeClass(void)const " (?GetRuntimeClass@CTestGLView@@UBEPAUCRuntimeClass@@XZ) already defined in ChildFrm.obj
So how can I alter the global variables from another file without having to deal with all this? There must be an easier way???
|
|
|
|
|
This is what the 'extern' keyword is used for. In your ChildFrm.cpp file, JUST use the following (no need for #include "TestGLView.cpp"):
extern float xtrans, ytrans;
Cheers,
Free
|
|
|
|
|
Instead of including TestGLView.cpp , add
extern float xtrans, ytrans; to ChildFrm.cpp , so the compiler knows, that they're implemented in another file of this project.
Regards
Thomas
Finally with Sonork id: 100.10453 Thömmi
Disclaimer: Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.
|
|
|
|
|
How do I check to see if the key being pressed is the up, down, left or right arrow key? i.e. to check if "I" is pressed, I do this:
void CChildFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CMDIChildWnd::OnKeyDown(nChar, nRepCnt, nFlags);
char keypressed = char(nChar);
if(keypressed == 'I')
//Do stuff
}
but what do I write in the if statement to check for an arrow key?
|
|
|
|
|
You can use VK_LEFT, VK_UP, VK_RIGHT and VK_DOWN
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
You can find all of the other lookup codes in MSDN by looking up Virtual Key Codes.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
You may need to handle the arrow keys in the PreTranslateMessage function which you can override.
if (pMsg->message == WM_KEYDOWN)
{
switch (pMsg->wParam)
{
case VK_UP :
case VK_DOWN :
case ...
}
}
you should return TRUE if you dont want te message to be processed further, or pass the message through to the base class to allow it to be processed by controls as normal.
Roger Allen
Sonork 100.10016
yet to be identified being from the planet Paltinmoriumbanfrettybooter
|
|
|
|
|
Hi,
I have one project which is using DAO with an access97 database, now we want to change the database to Access 2K. But, of course, we have some problems:
steps.
Database migration to Access 2K. (No problems)
Test the Application with new database (Format not recognize), I was investigating it but I only found that my project is using DAO35 with MFC42 (version 6.0) and it seems that it needs DAO36 and MFC version >= 6.01.
I not sure, and I hope that somebody could be in the same trouble that I am now.
Thanks!!
---------------------
Pere Llibre
Software Engeneering
|
|
|
|
|
Have you installed MDAC 2.7?
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Yes I have MDAC 2.7 installed, but nothing happens.
I have VC6 with sp5 -> mfc version 6.0 and I found that MFC load DA035 with this msvc.dll (access2k not supported), If you have mfc version >= 6.01 it will use DAO36 (access2k supported).
Do you know something about it? or anything else? Thanks for your prompt repply.
---------------------
Pere Llibre
Software Engeneering
|
|
|
|
|
Your problem is very common. Is no problem with librarys, neither MDAC, is a problem in the class of dao, this classes are usin the incorrect version.
For that you need to find, an article that wrote paul dilascia in MSJ, in the the first or second mounth of 2000 year. In that Article Paul explain the solution for your problem...
I will try to find that article.
Give me a couple of hours...
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I found the article
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
You can find a solution Here
The MSJ issue is January 2000
Best Reagards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Thank you very much!!
Best Regards,
---------------------
Pere Llibre
Software Engeneering
|
|
|
|
|
Don't mention it..
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
You can find a solution Here
The MSJ issue is January 2000
Best Reagards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I have a logon dialog with a username and password fields implemented as edit boxes. I need to trap the window handles for the two edit boxes at dialog initialization. How do I do this?
Thanks in advance,
Bob
|
|
|
|
|
GetDlgItem (IDC_USERNAME)->GetSafeHwnd()
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks!
|
|
|
|
|
I need to rename a registry key, but am not sure how to do this in VC++. Any suggestions?
|
|
|
|
|
Andrew Stampor wrote:
I need to rename a registry key, but am not sure how to do this in VC++. Any suggestions?
There is no direct way to rename a key. Create the new key. Enumerate all the subkeys and their values from the old key and add them under the new key. Now delete the old key.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Thanks.
Do you know if this code exists somewhere on CodeProject? I've done a couple of searches, but haven't found anything about it. Do you have this code somewhere? If it doesn't exist here, I'll be sure to post the class I create when I am done.
|
|
|
|
|
How can I create some custom controls using only the win32 API???
Is there any tutorial about this subject??
ps: I kinda want to do something that looks like RealOne.
|
|
|
|
|
Can anyone point me to a good learing book with lots of samples for programming in windows? I have programmed in C/C++ for some time, self taught, but in the Dos environment and need to get to the Windows environment.
|
|
|
|
|
Can't go wrong with Jeff Prosise's Programming Windows with MFC. Charles Petzold's books are also very good.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|