Solved

Trap WM_NCPAINT from an external form

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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