VC.窗口最前(置顶)

1、Delphi7的代码

procedure TfrmMain.cbWndTopmostClick(Sender: TObject);
var liExStyle :LongInt;
begin
  // 这种方式 设置之后,居然会收不到 WM_COPYDATA...不知道别的消息会不会也收不到??
//  if cbWndTopmost.Checked then
//    Self.FormStyle := fsStayOnTop
//  else
//    Self.FormStyle := fsNormal;

  // 这种方式没用,不能直接设置 WS_EX_TOPMOST??
//  liExStyle := GetWindowLong(Handle, GWL_EXSTYLE);
//  if cbWndTopmost.Checked then
//    liExStyle := liExStyle or WS_EX_TOPMOST
//  else
//    liExStyle := liExStyle and (not WS_EX_TOPMOST);
//  SetWindowLong(Handle, GWL_EXSTYLE, liExStyle);

  if cbWndTopmost.Checked then
    SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
  else
    SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end;

 

2、

3、

4、

5、

 

posted @ 2018-04-13 11:17  CppSkill  阅读(237)  评论(0编辑  收藏  举报