Solved

SetWindowLong

Posted on 2002-03-21
2
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

691 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