Wrapping Win32 in classes

This is a discussion on Wrapping Win32 in classes within the Windows Programming forums, part of the Platform Specific Boards category; Ok, im trying to make my own wrapper class for my win32 programs. Code: //basic structure of my win32 wrapper ...

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    Wrapping Win32 in classes

    Ok, im trying to make my own wrapper class for my win32 programs.

    Code:
    //basic structure of my win32 wrapper class
    class Myclass
    {
       LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    ...
    }
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
    {
        WNDCLASSEX wc;
        ...
        wc.lpfnWndProc = WindProc; //I get an error when i try to compile
    //Error	1	error C3867: 'MyClass::WndProc': function call missing argument list; use '&MyClass::WndProc' to create a pointer to member	c:\documents and settings\martinb\my documents\visual studio 2005\projects\calculator parser\calculator parser\main.cpp	31
    //Error	2	error C2440: '=' : cannot convert from 'LRESULT (__stdcall MyClass::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'	c:\documents and settings\martinb\my documents\visual studio 2005\projects\calculator parser\calculator parser\main.cpp	31	
    
    
    //Everything else is fine. Just that.
    
        ...
    }
    ...
    };
    My Website
    010000110010101100101011
    Add Color To Your Code!

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    A callback cannot be a non-static member function.

  3. #3
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Thank you.

    I made it static, but now i get this error:

    Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup MSVCRTD.lib

    how can I fix that one?
    My Website
    010000110010101100101011
    Add Color To Your Code!

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Do you have a WinMain function?

  5. #5
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    yes, look above.

    its in the class.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    It can't be in the class. I think you need to spend some time learning regular C++ before you jump into Windows API programming.

  7. #7
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    >> It can't be in the class.

    mrafcho001, the reason for this is because now you have the member "Myclass.WinMain", but you have no "WinMain" which it what the compiler is looking for.

  8. #8
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Yeah.

    I though it might work because it does C#. But that was just a retarded assumption :-\
    My Website
    010000110010101100101011
    Add Color To Your Code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 03:26 PM
  2. Classes and Win32 API, and another Question
    By philvaira in forum Windows Programming
    Replies: 10
    Last Post: 04-10-2004, 07:21 PM
  3. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  4. win32 and user defined classes
    By paulf in forum Windows Programming
    Replies: 4
    Last Post: 04-16-2002, 06:12 PM
  5. Programming Win32 using Classes
    By xds4lx in forum Windows Programming
    Replies: 9
    Last Post: 11-03-2001, 12:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21