TIP: Click on subject to list as thread! ANSI
echo: win32
to: ALL
from: JOHN A. GRANT
date: 1997-11-18 01:48:00
subject: Re: WIN32 CALLBACK problems - PLEAS01:48:0311/18/97

comp.lang.c++,comp.os.ms-windows.programmer.win32,fido.win32,microsoft.public.
win32,microsoft.public.win32.programmer,microsoft.public.win32.programmer.kern
el
Don wrote in message ...
>Please e-mail responses to:     puppy@dog.astra.co.uk
>your help would be greatly appreciated
>If you need help- just ask!!
>
>
>Here's the problem:
>
>I want to encapsulate my WIN32 application in a class "DbApp"
>However when I try to assign my "WndProc" function to the
>WindowsClass.lpfnWndProc variable for WindowsClass registration I get the
>ERROR:
>
>"Cannot convert 'long (__stdcall DbApp::*)(void *,unsigned int,unsigned
>int,long)' to 'long (__stdcall *)(void *,unsigned int,unsigned int,long)'"
>
>Notice the (__stdcall DbApp::*) to (__stdcall *) difference!
>I don't understand what I need to do to allow the Windows-API to access my
>"class member functions" without it being a global function,
>I tried many different combinations of pointer declarations with no avail
    The problem is that every class function has a hidden 'this' parameter
    so your WndProc() function in the class actually has 5 parameters
    in the calling sequence. But the lpfnWndProc is required to be a
    WndProc() with only 4 parameters.
    That's the problem with trying to use C++ with the Windows API - you
    can't. Well, not without a lot of kludges anyway. One of the primary
    reasons for the existence of OWL/MFC is to solve this problem.
    Generally speaking, they use a static WndProc() with 4 parameters
    for the lpfnWndProc and at runtime, they forward those messages to
    the appropriate instance of YourClass::WndProc(). It's ugly, but it
works.
--
John A. Grant   * I speak only for myself *   jagrant@znrcan.gc.ca (remove
'z')
Airborne Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here.
--- FIDOGATE 4.2.7
---------------
* Origin: gsc (2:50/128.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.