🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8921

SetClassLong problems

#8921
From: Lynn Morrison
Date: Fri, 03 Sep 2004 19:56
42 lines
2198 bytes
Hi, I created an HWND to get messages from the OS for a socket class(WSA
style) I am writing. Because a member function used as a WindProc has to be
static, I wish to set the classes memory pointer to the cbClsExtra member in
my WNDCLASSEX struct using SetClassLong...

problem is that I keep getting errors when compiling it... "Cannot cast from
MSocket to long"...

FWindowHandle =
CreateWindowEx(WS_EX_TOOLWINDOW,"MSocket",NULL,WS_POPUP,0,0,0,0,0,0,HInstanc
e,NULL);

SetClassLong(FWindowHandle,0,(long)*this);  // gives me an error

I am doing all of this so that when I get messages(which can be for any of
the MSocket classes) I want to know if the message is for "THIS" object and
not another, because of the static WindProc. Is this the way to do it or is
there a better solution?

long _stdcall MSocket::MWindProc(HWND Wnd,UINT Msg,WPARAM WParam, LPARAM
LParam)
{
  long TempMSocketClassPointer = GetClassLongr(Wnd,0);
  if((long) TempMSocketClassPointer != (long)&FWindowHandle) // E2031 Cannot
cast from void * MSocket::* to long
    return DefWindowProc(Wnd,Msg,WParam,LParam);
  else
 {
  // handle message, its for us (note: finish this last )
    switch(Msg)
    {
      default:
          break;
    }
  }
}

the 'if' line gives me the same error as above.

Any ideas on how I can accomplish this?

Thanks,  Lynn.
Technical Details
Message-ID: <4138cc6a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ce81aceba334526c,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Lynn Morrison" <Cranky@__whisp.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: SetClassLong problems
Date: Fri, 3 Sep 2004 15:56:27 -0400
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
NNTP-Posting-Host: 209.202.121.7
Message-ID: <4138cc6a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1094241386 209.202.121.7 (3 Sep 2004 12:56:26 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail