?
Solved

SetWindowLong

Posted on 2002-03-21
2
Medium Priority
?
266 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

777 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