我做了小申请,
我的主变形符form.color := clolive ;
并设置了transparentcolor := true;
和TransparentColorvalue := clolive;
它在没有桌面效果的Windows 8.1上运行良好。
我可以在mainform.canvas
当我在Windows 7上使用视觉样式测试这个迷你应用程序时,表单透明度被忽略,我无法绘制,我的鼠标光标“触摸”了mainform
任何想法如何解决?
感谢
我的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
application.minimize;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.terminate;
end;
procedure TForm1.FormClick(Sender: TObject);
var p: TPoint;
begin
form1.Canvas.Pen.Color:=clyellow;
form1.Canvas.Pen.Width:=5;
p.X:=mouse.CursorPos.X;
p.y:=mouse.CursorPos.Y;
form1.Canvas.PenPos:=p;
form1.Canvas.LineTo(p.x,p.y);
end;
end.
Form1中:
formstyle:=fsStayOnTop;
borderstyle:=bsNone;
WindowState:=wsMaximized;
TransparentColor:=true;
TransparentColorValue:=clOlive;
Color:=clOlive;
答案 0 :(得分:0)
您的代码存在的一个大问题是您在错误的位置绘画。您需要绘制以响应Windows绘制消息WM_PAINT
。在VCL应用程序的上下文中,通常表示在重写的Paint
方法或OnPaint
事件处理程序中。
为了在表单上绘画,您可以处理表单的OnPaint
事件并在那里进行绘画。这意味着您需要记住在表单上进行的每次单击,并且当要求您绘制窗口时,为每次发生的点击绘制一些内容。
这是一个常见的错误。窗口没有持久绘图画布。窗户必须能够在任何时间点按需涂漆。我建议您阅读Win32图形的入门教程。你可能会比从Petzold的书开始更糟糕。
答案 1 :(得分:0)
当我在Windows 7上使用视觉样式测试这个迷你应用程序时, 表单透明度被忽略,我无法绘制,我的鼠标光标 "触摸"图标和对象"背后"主体形式。
在启用Windows 7和Aero主题的情况下,表单是透明的,但会对鼠标点击做出反应,因此绘图工作正常。鼠标点击(或移动)没有通过表单进入表单下面的任何内容。
关闭Windows 7和Aero主题后,表单对于鼠标操作也是透明的,随后绘制不起作用,鼠标操作会对表单下面的任何内容起作用。
所以存在差异,但我不清楚你想拥有什么。
也许你的问题是你的Windows设置?见http://www.sevenforums.com/tutorials/283-transparency-enable-disable.html
答案 2 :(得分:-1)
感谢您的回复,我尝试更改Windows设置,但我想制作通用应用程序...所以我制作了一个框架并放入表单中,并将void remove(Node *n){
if(n == NULL) return;
if(n == head){
head = n->next;
if ( head )
head->previous =NULL;
}
else if(n == tail){
tail = n->previous;
if ( tail )
tail->next = NULL;
}
else{
if ( n->previous )
n->previous->next = n->next;
if ( n->next )
n->next->previous = n->previous;
}
delete n;
}
设置为True,值为{ {1}}设置为1(非常透明:))..它适用于Windows 7,Windows 8,8.1和Windows 10 ...它不是很好的解决方案,但至少工作... < / p>