Solved

Trap WM_NCPAINT from an external form

Posted on 2008-10-21
4
473 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
  • 3
4 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 250 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

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

16 Experts available now in Live!

Get 1:1 Help Now