Jump to content
  • Advertisement
Sign in to follow this  
Aidamina

[SOLVED]WndProc

This topic is 4810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a program that uses opengl but i got a problem: I got a class which initialises the opengl window and i got the WndProc in another class. I use this:
wc.lpfnWndProc = (WNDPROC )p_trendering->p_tengine->WndProc;
To point to:
 LRESULT CALLBACK  engine::WndProc(HWND hwnd, UINT msg, WPARAM  wParam, LPARAM lParam)
which is declared static in the class. But in the WndProc function i can't call any member of the engine class. Like:
tengine->myfunction();
where tengine is an instance of the class and myfunction a function. Any suggestions? [Edited by - Aidamina on September 12, 2005 6:03:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
Thx for the link but that doesnt solve my issue, because i don't know a good way to implement this whole new class in my engine.

I tried google but i don't really know where to look for....

Anyone else got some suggestions?

Share this post


Link to post
Share on other sites
If i understand you correctly, you cant access the parts of the class from the static member.

Well if this is the case this is a solution which is a little messy but good enough. Firstly make another static member call m_pThis or something and in the constructors initialisation list give it the value 'this'. So now u have a static pointer to this. Don't forget to give this value some substance by putting myclass::m_pThis in the CPP file.

Now in the static file you can do:

m_pThis->Member();

or whatever.

Hope you understand, if not reply and i will try again [smile].

ace

Share this post


Link to post
Share on other sites
I understand and i thought it would work but it throws this:

Unhandled exception at 0x00421f68 in engine.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1.

when i do:

m_pThis->AnotherClass->myfunction();

and yes i did this:

engine * engine::m_pThis=NULL;

and this:

engine::engine(void)
{
m_pThis=this;



}

Share this post


Link to post
Share on other sites
Quote:
Original post by Aidamina
Unhandled exception at 0x00421f68 in engine.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1.

0xcdcdcdcd is a special value that Visual Studio uses to indicate uninitialized data. 0xcdcdcdd1 is 0xcdcdcdcd + 4 -- you are using an uninitialized pointer.

Share this post


Link to post
Share on other sites
Ok this might be help full and i got it working partially

I can now acces private members of the class, but i can't acces public pointer members:

Unhandled exception at 0x0042200b in engine.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1.

CAN DO:

engine* p_engine=NULL;
p_engine = (engine*)GetWindowLong(hwnd, GWL_USERDATA);
p_engine->keys[0]=true; //privat member

CAN NOT DO:

engine* p_engine=NULL;
p_engine = (engine*)GetWindowLong(hwnd, GWL_USERDATA);
p_engine->trendering->topengl->setstate(true); //trendering is pointer to class

ALSO TRIED:

engine* p_engine=NULL;
p_engine = (engine*)GetWindowLong(hwnd, GWL_USERDATA);
if (p_engine)
p_engine->trendering->topengl->setstate(true); //trendering is pointer to class

Any suggestions?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!