Solved

Trap WM_NCPAINT from an external form

Posted on 2008-10-21
4
478 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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