Solved

SetWindowLong

Posted on 2002-03-21
2
251 Views
Last Modified: 2008-02-01
Hellow experts...

In a cpp file almost the first line is this prototype.

LRESULT CALLBACK ShowPointWndProc(HWND, UINT, WPARAM, LPARAM);

Of course that function is defined at the bottom of the file.

The problem is this one.

In the InitDialog message (I am trying to subclass an item in the dialog) I am trying to:

WNDPROC OldAdd = SetWindowLong (hItemWnd, GWL_WNDPROC, (LONG)ShowPointWndProc);

This will never be compiled because the error is this.

DialogProcs.cpp(34) : error C2440: '=' : cannot convert from 'long' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'

I tried:

WNDPROC OldAdd = SetWindowLong (hItemWnd, GWL_WNDPROC, (LONG)&ShowPointWndProc);

WNDPROC OldAdd = SetWindowLong (hItemWnd, GWL_WNDPROC, (WNDPROC)&ShowPointWndProc);

But nothing works...

Please help me.

Thank you very much.





0
Comment
Question by:Marsc
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 6885477
Make it read

WNDPROC OldAdd = (WNDPROC) SetWindowLong (hItemWnd, GWL_WNDPROC, (LONG)ShowPointWndProc);

'SetWindowLong()' returns a 'long', you'll have to typecast when storing it as a 'WNDPROC'...
0
 
LVL 1

Author Comment

by:Marsc
ID: 6886292
Problem solved :-)
Thank you very much...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now