home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!lax.pe-nelson.com!lax!twbrown
- From: twbrown@PE-Nelson.COM (Tom W. Brown)
- Newsgroups: comp.os.ms-windows.programmer.misc
- Subject: Re: Typecasting a pointer to member-function to unsigned long
- Message-ID: <685@lax.lax.pe-nelson.com>
- Date: 5 Nov 92 18:13:39 GMT
- References: <runehh.97.720902695@dhhalden.no>
- Sender: news@lax.pe-nelson.com
- Organization: PE-Nelson
- Lines: 32
-
- In article <runehh.97.720902695@dhhalden.no>, runehh@dhhalden.no (RUNE HALFDAN HOLST HUSEBY) writes:
- |>
- |> In a project I'm working on, I need to typecast a (far) pointer to a
- |> function to an unsigned long (DWORD). I need to do this because the
- |> MS Windows API requires me to do such a thing.
- |>
- |> This is the line that causes the error:
- |>
- |> SetWindowLong(GetDlgItem(HWindow, ID_TO), GWL_WNDPROC,
- |> (DWORD)&WCompose::ComboProc);
- |>
- |> What I'm trying to do, is to send over a callback function, using a generic
- |> function which set a lot of different properties, all the size of a long.
- |> Thus I need to typecast the function pointer to an unsigned long.
-
- Danger, Will Robinson, danger, danger !!! :-)
-
- A pointer to member function cannot be given to Windows as a callback because
- Windows does not know how to supply the 'this' parameter. However, if the
- function is declared as 'static' you may do so (since static member functions
- don't get a 'this' pointer).
-
- So, assuming that WCompose::ComboProc is declared as a static member
- function, the above syntax should work. I gather it does not, so you may
- want to double check that this function is, indeed, static.
-
-
- ----------------------------------------------------------------------------
- Tom Brown | "'ow d'you know 'e's a king?
- PE Nelson Systems | 'cause 'e 'asn't got shit all over 'im!"
- twbrown@pe-nelson.com | Monty Python and the Holy Grail
- ----------------------------------------------------------------------------
-