?
Solved

Trap WM_NCPAINT from an external form

Posted on 2008-10-21
4
Medium Priority
?
484 Views
Last Modified: 2008-10-22
Hello again,

  I am trying to create an OCX control that receives the windows hwnd from a MDI application and modifies the captionbar (I want to change the color).  To do this, I need to trap the WM_NCPAINT from the passed window.  How can this be done?

Tom T.
0
Comment
Question by:tturney
[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
  • 3
4 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 1000 total points
ID: 22771470
you must "hook" the forms windowproc. use
oldwndproc:=getwindowlong(hwnd, ;GWL_WNDPROC);
setwindowlong(hwnd, ;GWL_WNDPROC, integer(@mywndproc));
and after you have done your job call
setwindowlong(hwnd, ;GWL_WNDPROC, oldwndproc);

and your proc looks like:

type
  pwndproc=^TWndProc;

procedure mywndproc(var msg:tmessage);
begin
  if msg.msg=WM_NCPAINT then
    dowhatever you need
  else
    pwndproc(oldwndproc)^(msg);
end;

note that I wrote everyting in the browser so some typos might have happened, but this is the general idea.
0
 

Author Comment

by:tturney
ID: 22771606
Ciuly,

  This looks like what I'm looking for.  When you say "after you have done your job", do you mean after I'm through changing the captions colors or after the program terminates?
0
 
LVL 28

Expert Comment

by:2266180
ID: 22771679
>> do you mean after I'm through changing the captions colors

yes. I suspect you do that only once. if you need that throughout the life of the ocs or program, then the latter. you finished your job when you no longer need to do it :) you're the only onw who know when that is :P
0
 
LVL 28

Expert Comment

by:2266180
ID: 22771684
ps: I'm going to sleep now. any issues, I will address in teh morning, unless addresseed by other experts ;)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month13 days, 6 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