Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Platform/API C++
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 07-21-2005, 03:22 PM   #1 (permalink)
DIY_Gamer
Registered User
 
Join Date: Jul 2005
Posts: 2
DIY_Gamer is on a distinguished road
Question Help with C++ & Win32 in a class

Hello to all! I am a newbie to Windows programming. I have succesfully created windows in a standard .cpp file. I have even added some DX9 code. No problem...but, now I want to go modular. I have tried creatin a class which will open and maintain a window for me. I am using (*function) pointers which I can pass in to the class to be called with each msg cycle. I figured that out from the MSDN help included with VC++ 6.0 (the IDE I'm using).

My problem is actually the lpfnWndProc member of WNDCLASSEX that is giving me fits. I call my class "nuWin" and the lpfnWndProc is called "WndProc"(see below)


Code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
. Now, in the implementation (.cpp file), it must be called nuWin::WndProc. The error I get attacks this:

Code:
C:\downloads\Learning\C++\Game Delelopment\WinCode\magWin\magWin\devWin.cpp(68) : error C2440: '=' : cannot convert from 'long (__stdcall nuWin::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int, unsigned int,long)'
I think that Win32 is having a problem making a call to a class member, even though I made sure the function was public. I just don't know how to fix the problem. Is there a way to get the address to a function in an instantiated class that can be called without the class specifier/scope resolution? Or am I going at this the wrong way, entirely? Any and all suggestions are welcome.

Thank you for your time.
DIY_Gamer
__________________
DIY_Gamer is offline   Reply With Quote
Old 07-29-2005, 07:45 AM   #2 (permalink)
DIY_Gamer
Registered User
 
Join Date: Jul 2005
Posts: 2
DIY_Gamer is on a distinguished road
Finally found the answer on GoogleGroups: The member function must be declared as a Static Member Function, and therefore requires no class instantiation and, more importantly, no differentiation between instantiated objects.
__________________
DIY_Gamer is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class using a specific instance of another class? is this possible? abs Standard C, C++ 5 02-08-2005 03:12 PM
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:36 AM
Java Class Basics: Static Methods bdl Java 0 02-29-2004 02:25 PM
What is OOP and Java? srt42 Java 0 04-07-2003 01:21 AM
Starting out with C anon C 0 02-24-2003 01:06 PM


All times are GMT -8. The time now is 09:38 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle