Solved

Trap WM_NCPAINT from an external form

Posted on 2008-10-21
4
471 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:
ciuly earned 250 total points
Comment Utility
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
Comment Utility
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:ciuly
Comment Utility
>> 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:ciuly
Comment Utility
ps: I'm going to sleep now. any issues, I will address in teh morning, unless addresseed by other experts ;)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

9 Experts available now in Live!

Get 1:1 Help Now