Solved

C++ Builder:How can I change WndProc to my own?

Posted on 1997-03-15
8
1,595 Views
Last Modified: 2012-08-13
Before starting my program by Application->Run() method,
I tried to change WndProc to my own by SetClassLong(), but
nothing happend. My own CALLBUCK MyWndProc() did't get
messages. My question is how can I replace address of WndProc in WNDCLASS to my own address for proceeding messages by MyWndProc()? If you can help me, please e-mail
to jcrsch@game-club.com Thank you.
0
Comment
Question by:alexander031597
  • 4
  • 2
  • 2
8 Comments
 

Author Comment

by:alexander031597
ID: 1162037
Edited text of question
0
 
LVL 23

Expert Comment

by:chensu
ID: 1162038
Are you using MFC?

0
 
LVL 23

Expert Comment

by:chensu
ID: 1162039
I am sorry that I clicked on the wrong button. I just wanted to add a comment.
0
 

Author Comment

by:alexander031597
ID: 1162040
No, I don't use MFC.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:alexander031597
ID: 1162041

0
 

Expert Comment

by:LeoV
ID: 1162042
If you are working with window of your own class, you probably used function RegisterClass(const WNDCLASS* lpWndCls)to register it.
In this case you simply have to assign ---address--- of your WndProc function to lpWndCls->lpfnWndProc before registring the class.
---
lpWndCls->lpfnWndProc=MyWndProc;
or
lpWndCls->lpfnWndProc=&(MyWndProc());
whatever your compiler will accept.
0
 

Author Comment

by:alexander031597
ID: 1162043
Your answer is good for C++ compiler, but we are tolking about C++ Builder compiler. So I didn't use RegisterClass function.
According to Borland's documentation (chapter Handling messages -> Understanding the message-handling system) I should use overriding the handler method. Component Writer's Guide say "You should never need to alter message-dispatch mechanism. All you'll need to do is create message-handling methods." Of course, I know
I should map the methods. But I can't understand why nothing
happened when I changed in WNDCLASS structure address of WndProc
function directly by SetClassLong() function and this address
really was changed, but my WndProc function didn,t receive any messages.

0
 

Accepted Solution

by:
LeoV earned 100 total points
ID: 1162044
Tere is easy way: overwrite virtual WindowProc function of your window class.
 The reason you cannot set WindowProc to YourWndProc is that you are not suposed to. when you are working with OWL, you are working with C++ classes, not with Windows classes (I am Sure you know it yourself) so, tere is actually code somewhere, that restres original window procedure and does not let you do stupid things. Or things that Borland considers stupid. If you want to use a hard way and set WindowProc dirrectly, yo have to find a place where C++ class keeps original pointer and change it. I didn't go so far yet.
 By the way, do You speak Russian?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 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 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.

919 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

13 Experts available now in Live!

Get 1:1 Help Now