AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi How to draw button in non client area vista aero
Thema durchsuchen
Ansicht
Themen-Optionen

How to draw button in non client area vista aero

Ein Thema von haidomingo · begonnen am 23. Jul 2009 · letzter Beitrag vom 26. Jul 2009
Antwort Antwort
haidomingo

Registriert seit: 23. Jul 2009
23 Beiträge
 
#1

How to draw button in non client area vista aero

  Alt 23. Jul 2009, 00:23
Hi, for what I do I need componet delphi similar this
http://www.codeproject.com/KB/dialog...eaButtons.aspx
many thanks

Sorry for my bad english.
  Mit Zitat antworten Zitat
haidomingo

Registriert seit: 23. Jul 2009
23 Beiträge
 
#2

Re: How to draw button in non client area vista aero

  Alt 24. Jul 2009, 01:35
Hi,
I tried to convert the project but I get this
can someone help me?

The conversion is incomplete in some rows.

see:
http://img269.imageshack.us/img269/3387/immaginekan.jpg

code
Delphi-Quellcode:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,JwaDwmapi, ExtCtrls,jwauxtheme, Buttons;

type
  TForm3 = class(TForm)
    btn1: TSpeedButton;

    procedure FormActivate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormCreate(Sender: TObject);

  private
    { Private declarations }
    dwmMargins : MARGINS;
    _marginOk : Boolean;
    _AeroEnabled: Boolean;
     FRectText: TRect;
    FDown:boolean;
    procedure WndProc(var Message : TMessage) ; override ;
    function HitTestNCA(hwnd:HWND;wparam:WPARAM;lparam:LPARAM):Integer;

  public
    { Public declarations }
    function AeroEnabled: Boolean;
    procedure CheckGlassEnabled;
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

function TForm3.AeroEnabled: Boolean;
begin
  Result:=_AeroEnabled
end;


procedure TForm3.CheckGlassEnabled;
var
  Response: Integer;
  Enabled : bool;
begin
  if (Win32MajorVersion >= 6) then begin
     Enabled:=False;
     response :=DwmIsCompositionEnabled(Enabled);
     _aeroEnabled:= enabled;
  end;
end;

procedure TForm3.FormActivate(Sender: TObject);
begin
   inherited;
   if (dwmMargins.cyTopHeight < (btn1.Height+btn1.Top)) then
       dwmMargins.cyTopHeight:= (btn1.Height+btn1.Top);
   DwmExtendFrameIntoClientArea(Handle,dwmMargins);
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
   // InitializeComponent();
   // tsNonClientToolStrip.Renderer = new NonClientAreaRenderer();
    DoubleBuffered:=true;
    CheckGlassEnabled
end;

procedure TForm3.FormPaint(Sender: TObject);
var
  r : TRect;
begin
  inherited;
  if _aeroEnabled then begin
      Canvas.Brush.Color:=TransparentColorValue;
      Canvas.FillRect(Form3.ClientRect);
  end
  else begin
      Canvas.Brush.Color:=RGB($00C2, $00D9, $00F7);
      Canvas.FillRect(Form3.ClientRect);
      //
  end;
  r.Left:=dwmMargins.cxLeftWidth - 0;
  r.Top:= dwmMargins.cyTopHeight - 0;
  r.Right:= Width - dwmMargins.cxRightWidth - 0;
  r.Bottom:= Height - dwmMargins.cyBottomHeight - 0;
  Canvas.Brush.Color:=clBtnface;
  Canvas.FillRect(r);

end;


function TForm3.HitTestNCA(hwnd:HWND; wparam:WParam; lparam:LPARAM):Integer;
var
  P : TPoint;

begin
  P.X:=LoWord(integer(lparam));
  P.Y:=HiWord(integer(lparam));

end;




procedure TForm3.WndProc(var Message : TMessage);
const
    WM_NCCALCSIZE = $0083;
    WM_NCHITTEST = $0084;
var
    Result : LResult;
    dwmHandled : bool;
    nccsp: TNCCalcSizeParams;

begin
    dwmHandled:=DwmDefWindowProc(Form3.Handle, Message.Msg, Message.WParam, Message.LParam, result);
    if (dwmHandled = true) then begin
        message.Result:=result;
        //return
    end;
    if ( (Message.Msg = WM_NCCALCSIZE) and (message.WParam = 1)) then begin

       // Adjust (shrink) the client rectangle to accommodate the border:
       nccsp.rgrc0.Top :=0;
       nccsp.rgrc0.Bottom:= 0;
       nccsp.rgrc0.Left :=0;
       nccsp.rgrc0.Right:=0;
       if (_marginOk=false) then begin
             //Set what client area would be for passing to DwmExtendIntoClientArea
           dwmMargins.cyTopHeight:= nccsp.rgrc0.Top - nccsp.rgrc0.Top;
           dwmMargins.cxLeftWidth:= nccsp.rgrc0.Left - nccsp.rgrc0.Left;
           dwmMargins.cyBottomHeight:= nccsp.rgrc0.Bottom - nccsp.rgrc0.Bottom;
           dwmMargins.cxRightWidth:= nccsp.rgrc0.Right - nccsp.rgrc0.Right;
           _marginOk := true;
       end;
       //Marshal.StructureToPtr(nccsp, m.LParam, false);
       Message.Result:=0;
    end
    else if (message.Msg = WM_NCHITTEST) and (Integer(Message.Result)= 0) then
       Message.Result:= HitTestNCA(Form3.Handle, Message.WParam, message.LParam)
    else
       inherited;
end;


end.
  Mit Zitat antworten Zitat
Benutzerbild von MarcoWarm
MarcoWarm

Registriert seit: 10. Sep 2003
Ort: Großhennersdorf
532 Beiträge
 
Delphi 10.1 Berlin Professional
 
#3

Re: How to draw button in non client area vista aero

  Alt 24. Jul 2009, 11:39
An example on how you could do it you will find here:
http://theunknownones.googlecode.com...lbarInCaption/
Marco Warm
TUO
TheUnknownOnes.net
  Mit Zitat antworten Zitat
haidomingo

Registriert seit: 23. Jul 2009
23 Beiträge
 
#4

Re: How to draw button in non client area vista aero

  Alt 24. Jul 2009, 22:19
Zitat von MarcoWarm:
An example on how you could do it you will find here:
http://theunknownones.googlecode.com...lbarInCaption/
Thanks.
  Mit Zitat antworten Zitat
haidomingo

Registriert seit: 23. Jul 2009
23 Beiträge
 
#5

Re: How to draw button in non client area vista aero

  Alt 26. Jul 2009, 17:10
Through the example works fine.
Just what I was looking for.

But if I put a component with subcomponent (like a tlabeldedit)
I close the form (that includes your code) when you get key violation error.
I do not know if my problem.

Maybe it's a problem destroy subcomponent.

Thanks and sorry for my bad english.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz