Alpha混合器可以对TForm进行VCL控制吗
问题说明
Alpha Blend可以实现或者对TForm上的VCL控件实现类似的效果?
Is it possible to Alpha Blend or implement a similar effect for a VCL control on a TForm?
例如,考虑以下屏幕截图,除了其他控件之外,还有两个TPanels放在TForm上。两个面板均可拖动(请参阅 如何移动和调整大小控制在运行时间)。
For example, consider the following screenshot where two TPanels are placed on a TForm in addition to other controls. Both the panels are made draggable (See How to Move and Resize Controls at Run Time).
现在,可以让这些面板在拖动时半透明,以便您可以看到下面的内容? (如通过图像处理产生的第二个图像所示)
Now, is it possible to make these panels translucent while dragging so that you can see what is underneath? (as shown in the second image which was produced by image manipulation)
正确答案
您也可以在Delphi中执行此操作。基本思想是将控件放入自动化的边框形式,并启用Alpha混合。
You can do this in Delp too. The basic idea is to place the control into an autosized, borderles form with alpha blending enabled.
根据您链接的文章,在MouseDown事件中添加以下行:
According to the article you linked to, in the MouseDown event add the following lines:
P := TWinControl(Sender).ClientToScreen(Point(0,0));
frm := TForm.Create(nil);
TWinControl(Sender).Parent := frm;
frm.BorderStyle := bsNone;
frm.AlphaBlend := true;
frm.AlphaBlendValue := 128;
frm.AutoSize := true;
frm.Left := P.X;
frm.Top := P.Y;
frm.Position := poDesigned;
frm.Show;
在MouseMove事件中,设置控件父项的Left和Top属性:
In the MouseMove event set the Left and Top properties of the controls parent:
GetCursorPos(newPos);
Screen.Cursor := crSize;
Parent.Left := Parent.Left - oldPos.X newPos.X;
Parent.Top := Parent.Top - oldPos.Y newPos.Y;
oldPos := newPos;
并在MouseUp事件中发布表单,将控件父级设置为原始父级,并将屏幕位置相对于新的位置:
and in the MouseUp event release the form, set the controls parent back to the original parent and translate the screen position to the new position relative to it:
frm := TWinControl(Sender).Parent;
P := Point(frm.Left, frm.Top);
P := ScreenToClient(P);
TWinControl(Sender).Parent := Self;
TWinControl(Sender).Left := P.X;
TWinControl(Sender).Top := P.Y;
frm.Free;
Screen.Cursor := crDefault;
ReleaseCapture;
inReposition := False;
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfhcie
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20