tags:

views:

73

answers:

1

This should be simple, and I was hoping to do it in Delphi. The purpose of this is just supposed to be a joke.

On a windows form application I don't want the user to be able to click the X button on the main form. I want the cursor to either clip around the X button or just set it's position elsewhere.

A: 

Write

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure NcMouseMove(var Message: TWMNCMouseMove); message WM_NCMOUSEMOVE;
  public
    { Public declarations }
  end;

procedure TForm1.NcMouseMove(var Message: TWMNCMouseMove);
begin
  inherited;
  with Message do
    if HitTest = HTCLOSE then
      SetCursorPos(XCursor + GetSystemMetrics(SM_CXMENUSIZE), YCursor)
end;
Andreas Rejbrand