如何将文字写到屏幕上,而且处于最前端,就像是调节显示器设置时显示的那样?
最好不是写在透明窗体上的那种,因为弹出窗体的时候可能会导致其他窗体失去焦点!我想要实现的是直接利用显示器的编程接口来写屏幕。如何做?

解决方案 »

  1.   


    hdc = CreateDC (TEXT ("DISPLAY"), NULL, NULL, NULL)取得屏幕句柄       
    ... 
    其它程序行
    ...
    DeleteDC (hdc) ;
      

  2.   

    如果要捕获键盘,可用hook技术,这方面的内容网上很多
      

  3.   

    用了TransForm控件unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      TransForm, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        TranForm1: TTranForm;
        Button1: TButton;
        Timer1: TTimer;
        Button2: TButton;
        Label1: TLabel;
        procedure FormPaint(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormPaint(Sender: TObject);
    var
      hdc: THandle;
    begin
      hdc := GetDC(Handle);
      if hdc <> 0 then
      begin
        TextOut(hdc, 20, 20, 'Front Text Example', 18);
      end;
      ReleaseDC(Handle, hdc);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Close();
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      if Left < 0 then
        Left := Left + 10000;
      SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      Left := Left - 10000;
    end;end.
      

  4.   

    object Form1: TForm1
      Left = 388
      Top = 328
      BorderIcons = []
      BorderStyle = bsNone
      ClientHeight = 130
      ClientWidth = 174
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnPaint = FormPaint
      PixelsPerInch = 96
      TextHeight = 13
      object Label1: TLabel
        Left = 64
        Top = 48
        Width = 32
        Height = 13
        Caption = 'Label1'
      end
      object Button1: TButton
        Left = 104
        Top = 80
        Width = 49
        Height = 25
        Caption = 'Close'
        TabOrder = 0
        OnClick = Button1Click
      end
      object Button2: TButton
        Left = 24
        Top = 80
        Width = 49
        Height = 25
        Caption = 'Hide'
        TabOrder = 1
        OnClick = Button2Click
      end
      object TranForm1: TTranForm
        AlphaValue = 180
        TransMouse = False
        Left = 160
        Top = 64
      end
      object Timer1: TTimer
        Interval = 5000
        OnTimer = Timer1Timer
        Left = 40
        Top = 16
      end
    end
      

  5.   

    用ALWAYSONTOP窗口
    PS:此贴转移到VC区
      

  6.   

    使用一个部分透明的窗口
    在 2000 和 XP 系统中,可以使用 WS_EX_LAYERED 风格加上 UpdateLayeredAttribute 来完成