Change Active Title Bar color of a Dialog

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Change Active Title Bar color of a Dialog

Post by jpuziano » Thu Mar 03, 2011 7:13 pm

Hi Marcus,

Is there a way to change the Active Title Bar color of a Macro Scheduler Dialog?

In v12, the Dialog property called "Color" pertains to the whole Dialog and there is not a separate property for the Active Title Bar color.

Yes I know I can change that color in the Windows OS itself... but I do not want to change it for all apps and windows... just for my one compiled macro.

I found this: http://stackoverflow.com/questions/2018 ... -title-bar

Which led me to this: http://delphi.about.com/od/adptips2006/ ... ionbar.htm

...and the following Delphi code:

Code: Select all

type
    TCustomCaptionForm = class(TForm)
    private
      procedure WMNCPaint(var Msg: TWMNCPaint) ; message WM_NCPAINT;
      procedure WMNCACTIVATE(var Msg: TWMNCActivate) ; message WM_NCACTIVATE;
      procedure DrawCaptionText() ;
    end;
 
 ...
 
 implementation
 
 
 procedure TCustomCaptionForm .DrawCaptionText;
 const
    captionText = 'delphi.about.com';
 var
    canvas: TCanvas;
 begin
    canvas := TCanvas.Create;
    try
      canvas.Handle := GetWindowDC(Self.Handle) ;
      with canvas do
      begin
        Brush.Style := bsClear;
        Font.Color := clMaroon;
        TextOut(Self.Width - 110, 6, captionText) ;
      end;
    finally
      ReleaseDC(Self.Handle, canvas.Handle) ;
      canvas.Free;
    end;
 end;
 
 procedure TCustomCaptionForm.WMNCACTIVATE(var Msg: TWMNCActivate) ;
 begin
    inherited;
    DrawCaptionText;
 end;
 
 procedure TCustomCaptionForm.WMNCPaint(var Msg: TWMNCPaint) ;
 begin
    inherited;
    DrawCaptionText;
 end;
From the above, I take it that I could add the following two event handlers...

AddDialogHandler>Dialog1,,OnActivate,SUBROUTINE_NAME

AddDialogHandler>Dialog1,,OnPaint,SUBROUTINE_NAME

...but I am at a loss as to how I would translate the above Delphi code into something that would work in Macro Scheduler... perhaps some mix of MS and Win API calls? In any case, Marcus can you provide any insight here?

Or does anyone out there have a way to set the Active Title Bar color of an MS Dialog... to a color of one's choosing?

Thanks and take care
Last edited by jpuziano on Thu Mar 03, 2011 10:35 pm, edited 1 time in total.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 03, 2011 9:41 pm

No, you can't. It's not a standard Windows concept and the code you found can not be replicated in Macro Scheduler. As you have found the only way to do it (in any language) is to trap some windows messages to detect windows painting and writing the caption and then custom draw on the title bar canvas. Not something you can do in Macro Scheduler.
.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts