home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!ux1.cso.uiuc.edu!mp.cs.niu.edu!uxa.ecn.bgu.edu!garrot.DMI.USherb.CA!trepe00
- From: trepe00@DMI.USherb.CA (ERIC TREPANIER)
- Newsgroups: comp.os.ms-windows.programmer.misc
- Subject: Re: Typecasting a pointer to member-function to unsigned long
- Summary: Subclassing a WndProc with an OWL member function
- Keywords: WndProc, OWL, SubClass
- Message-ID: <Bx9BEr.n0z@DMI.USherb.CA>
- Date: 5 Nov 92 18:59:14 GMT
- Article-I.D.: DMI.Bx9BEr.n0z
- References: <runehh.97.720902695@dhhalden.no>
- Sender: usenet@DMI.USherb.CA (Pour courrier Usenet)
- Organization: Universite de Sherbrooke -- Dept. d'Informatique
- Lines: 55
- Nntp-Posting-Host: roselin
-
- 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.
-
- It looks like you are trying to subclass a combobox control. If that is
- what you want to do, then there are two things you should be aware of:
-
- 1) The new window procedure (WCompose::ComboProc) *MUST* be declared
- "static" in the WCompose object definition, and it *MUST* be a public
- member function. If done correctly, it should look like this:
-
- class WCompose: public TWindow
- {
- // protected variables & member functions
- public:
- ...
- static CALLBACK _export ComboProc(HWND hwnd, UINT msg,
- WPARAM wparam, LPARAM lparam);
- ...
- }
-
- 2) There is a new file included with BC++ 3.1, "windowsx.h" which contains
- a lot of useful macros, especially if you are using "#define STRICT".
- This file defines a special macro called "SubClassWindow".
- Have a look at the file "win31.doc" in your Borland's DOC directory to
- see how it works exactly. If I remember correctly:
-
- WNDPROC oldWndProc;
-
- oldWndProc = SubClassWindow(GetDlgItem(HWindow, ID_TO), WCompose::ComboProc);
-
- Now, in your ComboProc, you should make sure that you call oldWndProc for all
- messages that you are not processing explicitly. If you are not using Smart
- CallBacks, you'll also need to call MakeProcInstance / FreeProcInstance.
-
- If this sounds a bit complicated, email-me and I'll explain in more details.
-
-
- Eric
- --
- Eric Trepanier
- eric@tgm.CAM.ORG
- "Everybody has a right to believe in something.
- I believe I'll have another beer."
-