|
I've created an MDI application, and I'm doing graphics drawing in the child window using OpenGL. For some reason, whenever I draw something and then open a new window, the exact same scene is in the new window also. Also, if I have a few child windows open and I create or alter a scene in one of them, all other windows end up displaying the altered screen. This kind of defeats the purpose of an MDI application if every single child window is displaying the same thing. Why does this happen and how can I fix it?
|
|
|
|
|
We had a similar problem in one of our OpenGL apps. Are you using call lists in the OpenGL rendering process? If you are make sure you are rendering to a unique call list number and playing back the correct one for the MDI window in question.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
I have DLL that hold pointer to class that allocated in other DLL, this class has virtual functions so the DLL can use it with no need to Export & Import this class.
In these situation, I can add virtual functions to the class interface and the other DLL does no effected from it (backward compatibility...) in one condition: the new functions should be declared after the last original function, so the Virtual Table order is kept.
so far so good, but here is my problem:
this class is derived from base class that also has virtual functions, and if I want to add functionality to the base class the Virtual Table order is changed and I don't have backward compatibility.
So, how can I add virtual function to base class without changing the virtual table order ???
Thanks in advance
Didi Gurfinkel
|
|
|
|
|
I'm not sure whether this will work, but it's simple to give it a try: derive virtually from your base class:
class Derived: virtual public Base
{
...
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Wow, that was quick !
Its seemed that it works.
Thanx
DD
|
|
|
|
|
Do you know what is the overhead of using virtual public ?
DD
|
|
|
|
|
Hmmm... I think it is about an extra pointer per virtual base class (with respect to space) and an extra offset when accessing data in a virtual base class (with respect to execution). But I'm far from 100% about this. Plus, implementations vary wildly between compilers, and I don't have much info about VC++ class layout.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
If my component is supporting any standard interfaces
IPersistStream or IErrorInfo
do I need to specify these interfaces in the
coclass section ?
|
|
|
|
|
Yes.
Also, make sure you have a COM_INTERFACE_ENTRY(IWhatever) in the COM_MAP in your CoClass's .h file.
|
|
|
|
|
Is it possible have a function pointer to a member function of a class?
Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
This is question #1 here at the forum. Please consult Mike Dunn's C++ FAQ.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: Oops, I mistook your question for the related (though not identical) problem of having a callback invoke a member function.
Please follow the wise answers of the other folks.
|
|
|
|
|
Joaquín M López Muñoz wrote:
PS: Oops, I mistook your question for the related (though not identical) problem of having a callback invoke a member function.
Please follow the wise answers of the other folks.
LOL
Gosh! I am havin a good time at 2 AM
Nish
[Signature temporarily down]
|
|
|
|
|
What's so funny? (I'm not offended, just clueless)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Oh well, maybe it's cause it past 2 AM. I somehow found that misunderstanding kinda humorous. Actually more than the misunderstanding, your update of the post was hilarious. You have a great sense of humor Joaquin I appreciate it highly Thanks for making me feel nice. Was a bit pissed about something....Now I feel much better!
Nish
[Signature temporarily down]
|
|
|
|
|
Was a bit pissed about something....Now I feel much better!
Oh, glad to be helpful in such a weird way
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
yes. but it's not nice.
http://www.codeproject.com/lounge.asp?forumid=1159&app=50&fr=101&select=126729#xx126729xx
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
Here is a code snippet :
class CTest
{
public:
void test1(CString t)
{
AfxMessageBox( _T("test1: ") + t);
}
void test2(CString t)
{
AfxMessageBox( _T("test2: ") +t);
}
};
//test
............
typedef void (CTest::*method_ptr)(CString);
CTest x;
method_ptr fn;
fn = &CTest::test1;
(x.*fn)("xyz");
fn = &CTest::test2;
(x.*fn)("xyz");
...........
|
|
|
|
|
#include <stdio.h>
class A
{
public:
void abc()
{
printf("hello world");
}
};
int main(int argc, char* argv[])
{
void (A::*pf)()=&A::abc;
A a;
(a.*pf)();
return 0;
}
Nish
[Signature temporarily down]
|
|
|
|
|
So basicly there is not a way to have an indpendant type of function pointer that can work for any function in any class?
I am trying to implement a command list where when the user type in a command it searches through its list, finds it and then executes the appropriate function.
Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
Steve Severance wrote:
So basicly there is not a way to have an indpendant type of function pointer that can work for any function in any class?
I am trying to implement a command list where when the user type in a command it searches through its list, finds it and then executes the appropriate function
Actually you can point the same function pointer to any number of functions as long as they all have the same prototype [means same argument types and return value]
Nish
[Signature temporarily down]
|
|
|
|
|
would it be possible to use a base class like
class CRoot
{
//root class
};
class MyClass : public CRoot
{
void MyFunc();
};
and then
void (CRoot::*pf)()=&CMyClass::MyFunc;
MyClass a;
(a.*pf)();
Steve
Not all who wander are lost...
|
|
|
|
|
I open a window A and from this, another window B for which the window A is the parent window. In window B there is a button with a label "Start" that starts the execution of the thread "Train". This thread must get data from the parent window and perform some calculations, and finally, update some controls in window A. I use AfxBeginThread (Train, this) from B window and inside the thread function I get a pointer to the parent window by means of GetParent function. However this does not work. Can anyone help me?
|
|
|
|
|
Can you show some code snippets?
Nish
[Signature temporarily down]
|
|
|
|
|
In the lack of more info, I'd venture to say the problem is that you are trying to call some member function (or use some member variable) of the CWnd * returned by GetParent (possibly cast to CAWnd * or whatever your class is named). Is this right? If so, then the problem is that that CWnd * is not actually the original object; this is due to inherent limitations of MFC with respect to multithreading. To solve the problem, pass the thread a pointer to A instead of a pointer to B (and have A store somehow a pointer to B so that you have access to both windows).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
All threads in MFC has own CWnd-HWND map and it don't initialize while you create new thread due to perfomance reason. A common solution is to put HWND in thread-parameters and in child thread should construct CWnd by means CWnd::FromHandle function.
Good luck
|
|
|
|