窗口自己激活自己


const
  LSFW_LOCK     
=   1 ;
  LSFW_UNLOCK   
=   2 ;
  function LockSetForegroundWindow(uLockCode: DWORD): BOOL; stdcall;
var
  Form1: TForm1;
implementation
  function LockSetForegroundWindow; external  
' user32.dll '  name  ' LockSetForegroundWindow ' ;
...

{ TForm1 }

function wdSetForegroundWindow(Handle: THandle): Boolean;
begin
  
if  ((Win32Platform  =  VER_PLATFORM_WIN32_NT) and (Win32MajorVersion >   4 )) // up win 2000
    or ((Win32Platform  =  VER_PLATFORM_WIN32_WINDOWS) and   // up win 98
    ((Win32MajorVersion  >   4 ) or
    ((Win32MajorVersion 
=   4 ) and
    (Win32MinorVersion 
>   0 )))) then
    LockSetForegroundWindow(LSFW_UNLOCK);
  Result :
=  SetForegroundWindow(Handle);
end;

procedure TForm1.tmr1Timer(Sender: TObject);
begin
  
//  Timer的Timer事件
  Application.Restore;
  wdSetForegroundWindow(Handle);
end;

  
强制窗口最前显示,摘自Raize组件包中TRzTrayIcon.RestoreApp过程
   Application.Restore;
  ShowWindow( Application.Handle, sw_Restore );
  SetForegroundWindow( Application.Handle );

procedure TRzTrayIcon.RestoreApp;
begin
  if FMenuVisible then
    Exit;
  FManualRestore := True;
  try
    Application.Restore;
    if FEnabled then
    begin
      ShowWindow( Application.Handle, sw_Restore );
      SetForegroundWindow( Application.Handle );
    end;
    DoRestoreApp;
  finally
    FManualRestore := False;
  end;
end;

 

 

Delphi获取Windows版本号、描述等信息,可获取到主版本号、次版本号、系统描述、系统平台、构建号等,相关代码如下:   //设置版本信息结构的大小    GetVersionEx(OSVI);    //获取版本信息    is98orlater:=    //判断是否98或以后版本    (osvi.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS) and    ((osvi.dwMajorVersion>4) or    ((osvi.dwMajorVersion=4) and (osvi.dwMinorVersion>0)));   //DOWNLOAD BY HTTP://WWW.CODEFANS.NET    //下面开始显示信息    case OSVI.dwPlatformId of    //根据OSVI.dwPlatformId的数值的不同显示具体的平台描述    VER_PLATFORM_WIN32s:    // Windows 3.1平台    s:='Windows 3.1';    VER_PLATFORM_WIN32_WINDOWS:    // Windows 95/98平台    if(is98orlater) then    //98    s:='Windows 98'    else    //95    s:='Windows 95';    VER_PLATFORM_WIN32_NT:    // Windows NT平台    s:='Windows NT/XP';    end;    Edit1.Text:=s;    Edit2.Text:=IntToStr(OSVI.dwMajorVersion);    Edit3.Text:=IntToStr(OSVI.dwMinorVersion);    case OSVI.dwPlatformId of    //根据平台的不同具体处理OSVI.dwBuildNumber信息    VER_PLATFORM_WIN32_WINDOWS:    // Windows 95/98平台则取OSVI.dwBuildNumber的低位字    Edit4.Text:=IntToStr(LOWORD(OSVI.dwBuildNumber));    VER_PLATFORM_WIN32_NT:    // Windows NT平台则取所有位的值    Edit4.Text:=IntToStr(OSVI.dwBuildNumber);    else    Edit4.Text:='';   // Windows 3.1平台此值位空    end;    Edit5.Text:=OSVI.szCSDVersion;   end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值