吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1023|回复: 2
收起左侧

[求助] 求教,以下代码为啥挂起了?

[复制链接]
冥界3大法王 发表于 2020-10-5 23:03
[Delphi] 纯文本查看 复制代码
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    procedure sysmenu(var msg: twmmenuselect); message wm_syscommand;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  i := getsystemmenu(handle, false);
  appendmenu(i, mf_separator, 0, nil);
  appendmenu(i, mf_string, 100, '窗口置顶');
end;

procedure TForm1.sysmenu(var msg: twmmenuselect);
begin
  if msg.IDItem = 100 then
    SetWindowPos(Form1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
  else
    SetWindowPos(Form1.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end;

end.

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

bookaccount 发表于 2020-10-6 00:24
 楼主| 冥界3大法王 发表于 2020-10-6 08:50
明白了,
procedure TForm1.sysmenu(var msg: TWMMenuSelect);
begin
  if msg.IDItem = 100 then
    SetWindowPos(Form1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
  else
    inherited;


  if msg.IDItem = 101 then
    SetWindowPos(Form1.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
  else
    inherited;
end;
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 12:00

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表