Solved

Windows SDK: using CallWindowProc()

Posted on 1998-06-24
5
631 Views
Last Modified: 2013-12-03
Hi;

I am a beginning programmer a few months out of school.
I have been trying to become a windows programmer and have been studying Charels Petzold's
"PROGRAMMING WINDOWS95"

I have had trouble compiling some of his sample code that requires the SDK function
CallWindowProc().

The compiler tells me that the datatype for the first argument is wrong.  I checked the help
files and it isn't.  Changing the data type hasn't helped.

I don't know about size restrictions on posts here so I am not posting the whole program.
I can if someone wants me to.

I am listing the error message, the declaration of the first argument, the initialization of the
first argument, and the function call:

/*
***********************************************************
**        THE ERROR MESSAGE
***********************************************************
*/
C:\Program Files\DevStudio\MyProjects\W 25 Colors1\WinMain25.cpp(394) :
 error C2664: 'CallWindowProcA' : cannot convert parameter 1 from
 'long (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(void)'

//Declaration of first argument
WNDPROC fnOldScr[3] ;
.
.
// Initialization Of First Argument
fnOldScr[i] = (WNDPROC) SetWindowLong( hwndScrol[i],   GWL_WNDPROC, (LONG) ScrollProc);

// The function call
return CallWindowProc( fnOldScr[i], hwnd, iMsg, wParam, lParam) ;
0
Comment
Question by:anatta18
  • 3
5 Comments
 
LVL 3

Accepted Solution

by:
danny_pav earned 100 total points
ID: 1408496
check to see if you have STRICT defined.
If you do, you have to perform a cast.  Or just undefine STRICT

add this before the function as a test

#ifdef STRICT
#error "STRICT defined - ARRGGH!"
#endif



0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1408497
The CallWndProcA has to do with UNICODE and the multiple versions of many functions in Windows.  You will notice several functions of this form XxxxYyyy.  They are then implemented using XxxxYyyyA and XxxxYyyyW for Ansi and Wide character respectively.  There are macros and #ifdefs that determine which version gets called.

That's why the error is with CallWndProcA when your code says CallWndProc


0
 

Expert Comment

by:barlav
ID: 1408498
Or make the first parameter a FARPROC instead of a WNDPROC if STRICT is defined.
0
 

Author Comment

by:anatta18
ID: 1408499
Someone else told me the opposite of the first answer and it worked.  
( I fixed the problem by defining strict instead of undefining it ).    

I mentioned in my question that I was a beginning programmer and a beginning
windows programmer.   None of the answers really explained why I was having
a problem, why "strict" was involved, and how "strict" was involved.

This is fair enough.  Even good educators in computer science have trouble breaking
the jargon barrier with less experienced folks in explaining things, but I didn't get
much background that I could use in any of the answers I got.    Without background
in an answer my understanding can't improve.   If my understanding can't improve
all I can do is to code what people tell me to.  

I stop being a programmer and become someone who needs to hire a programmer
if  I don't have the situation explained to me or am directed to a source that can
explain the situation.
0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1408500
STRICT is supposed to be defined when you want strict type checking. Here is an example from windows.h

#ifdef STRICT
typedef signed long          LONG;
#else
#define LONG long
#endif

Does this help?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 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

21 Experts available now in Live!

Get 1:1 Help Now