delphi 动态控制窗口置顶且界面不闪
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE)
else
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE);
end;//使用Self.FormStyle := fsStayOnTop;会使界面闪烁一下
为什么使用FormStyle会出现界面闪烁呢?跟踪了一下代码,我觉得TWinControl.UpdateShowing有很大嫌疑……
关于SetWindowPos的使用可从 delphi 提供的帮助得知。
The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen.
BOOL SetWindowPos(
HWND hWnd, // handle of window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning flags
);
HWND_NOTOPMOST Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOPMOST Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
SWP_NOMOVE Retains the current position (ignores the X and Y parameters).
SWP_NOSIZE Retains the current size (ignores the cx and cy parameters).
相关文档:
1.被装饰者
{《HeadFirst设计模式》之装饰模式 }
{ 本单元中的类为被装饰者 }
{ 编译工具: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uComponent;
interface
type
TBeverage = class(TObject) //抽象饮料类
protected
FDescription: String;
public
......
在Delphi中使用RAS实现对系统拨号的控制
在企业应用中有时候希望能在程序中实现对拨号网络的控制,以实现自动拨号、自动断开网络。在尝试了多种方式之后,认为RAS是一种比较稳定的方式。在google了网上一些资料后,现整理如下:
一、首先需要有个针对RAS的头文件定义,Ras.pas代码如下
{* Cop ......
获得网卡的MAC地址在很多地方都有很大的用处,下面的函数以XX-XX-XX-XX-XX-XX 的格式返回远程或本地机器的MAC地址。
Function to return the MAC address of a remote or local machine in the format XX-XX-XX-XX-XX-XX
返回的MAC地址是一个能用在多个方面的唯一标识。使用方法:
ShowMessage(GetMacAddress( ......
@符号返回一个变量的地址
例:
var
f:string;
p:^string; //声明一个字符串类型的指针
begin
f ='demo'; ......
一、整数类型
类型 所占字节数 取值范围
byte 1 0-255
word 2 0-65535
shortint 1 -128-127
smallint 2 -32768-32767
integer 4 -214748648-214748467
longint 4 -214748648-214748467
cordinal 4 0-2147483647
二、实数类型
类型 所点字节数 取值范围
Real 6 ±2.9×10的负39次方到1.7× ......