Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #6  
Antiguo 30-01-2006
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Ahora que, si insisten, aquí está lo básico para empezar:

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    LinkCaption: String;

    (*
      Windows pinta el título en cualquiera de estos dos mensajes, así
      que hay que interceptarlos para dibujar el título nosotros mismos
    *)
    procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;
    procedure WMNCActivate(var Msg: TWMNCActivate); message WM_NCACTIVATE;
    procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;

  public
    (* Método para dibujar el título *)
    procedure PaintCaption;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  LinkCaption := 'Enviar sugerencia';
end;

procedure TForm1.WMNCActivate(var Msg: TWMNCActivate);
begin
  inherited;
  PaintCaption; // Pintar el título
end;

procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
begin
  inherited;
  PaintCaption; // Pintar el título
end;

procedure TForm1.PaintCaption;
var
  ncCanvas: TCanvas;
  cxSmIcon: Integer;
  cxSizeFrame: Integer;
  cySizeFrame: Integer;
  cyCaption: Integer;
  cxText: Integer;
  cyText: Integer;

begin
  ncCanvas := TCanvas.Create;
  try
    { Obtener un canvas que incluya el área no-cliente }
    ncCanvas.Handle := GetWindowDC(Handle);
    with ncCanvas do
    begin
      { Usar fondo transparente }
      Brush.Style := bsClear;

      { Fuente del título }
      if Windows.GetForegroundWindow = Self.Handle
        then Font.Color := clCaptionText
        else Font.Color := clInactiveCaptionText;

      Font.Style := Font.Style + [fsBold, fsUnderline];

      { Medidas para colocar el título }
      cxSmIcon := GetSystemMetrics(SM_CXSMICON);
      cxSizeFrame := GetSystemMetrics(SM_CXSIZEFRAME);
      cySizeFrame := GetSystemMetrics(SM_CYSIZEFRAME);
      cyCaption := GetSystemMetrics(SM_CYCAPTION);
      cxText := TextWidth(LinkCaption);
      cyText := TextHeight(LinkCaption);

      { Pintar el título }
      TextOut(
        ClientWidth - (cxSizeFrame + 3*cxSmIcon + cxText),
        cySizeFrame + ((cyCaption - cyText) div 2) - 1,
        LinkCaption);
    end;
  finally
    ReleaseDC(Handle, ncCanvas.Handle);
    ncCanvas.Free;
  end;
end;

procedure TForm1.WMSetCursor(var Msg: TWMSetCursor);
var
  ncCanvas: TCanvas;
  cxSmIcon: Integer;
  cxSizeFrame: Integer;
  cxText: Integer;
  htPoint: TPoint;

begin
  inherited;

  if Msg.HitTest = HTCAPTION then
  begin
    htPoint := ScreenToClient(Mouse.CursorPos);

    ncCanvas := TCanvas.Create;
    try
      { Obtener un canvas que incluya el área no-cliente }
      ncCanvas.Handle := GetWindowDC(Handle);

      with ncCanvas do
      begin
        Font.Style := Font.Style + [fsBold, fsUnderline];

        cxSmIcon := GetSystemMetrics(SM_CXSMICON);
        cxSizeFrame := GetSystemMetrics(SM_CXSIZEFRAME);
        cxText := TextWidth(LinkCaption);
      end;

      if (htPoint.X >= ClientWidth - (2*cxSizeFrame + 3*cxSmIcon + cxText)) then
      begin
        SetCursor(Screen.Cursors[crHandPoint]);

        if Msg.MouseMsg = WM_LBUTTONDOWN then
          ShowMessage('Enviando comentario');
      end;
    finally
      ncCanvas.Free;
    end;
  end
  else
    Screen.Cursor := crDefault;
end;

end.

Está muy sucio y hay que refinar muchas cosas pero más o menos funciona. Se basa en un formulario con borde normal y sus tres botones que corresponden al 3 que aparece como factor en las fórmulas de arriba.

Aquí no estamos añadiendo un botón sino literalmente añadiendo una "url" en la parte derecha de la barra de título.

// Saludos
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
"Cuarto" Boton en barra de titulo (como el EMule) DTAR Varios 3 05-01-2006 00:12:24
Deshabilitar boton de la barra de título abracadabra OOP 2 21-12-2005 23:51:46
Como quitar la barra de título a una ventana hija de una aplicación MDI abracadabra OOP 1 15-12-2005 00:59:29
Label en la Barra de Titulo... nicolasdom Varios 1 04-10-2004 23:46:31
barra de titulo [Internet explore] acertij022 API de Windows 5 27-10-2003 14:41:15


La franja horaria es GMT +2. Ahora son las 15:08:39.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi