Home > Enterprise >  Block form resize and show a hint when hovering
Block form resize and show a hint when hovering

Time:12-08

Delphi 11 How to make it so that when you hover the cursor over the resizing of the form, a cross appears with some inscription like: "Do not resize" and it was impossible to resize the form?

I need to block my first form resize when I call my second form. I'm quite new to Delphi, can you help me, please?

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
  Form1.Caption:= 'Main';
  Form1.BorderStyle:= bsSingle;
  //And Form1.OnCanResize() or in some other way?
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Form1.Caption:= 'Main Form';
  Form1.BorderStyle:= bsSizeable;
  Form2.Hide;
end;

CodePudding user response:

The question is settled.

"If you don't like the answer it's doesn't mean that it's not right. But continue to delete my comments :)"

It's so sad when professionals cannot help you but only express arrogance. Carry on, you are so funny)

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
  Form1.Caption:= 'Main';
  Form1.BorderStyle:= bsSingle;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Form1.Caption:= 'Main Form';
  Form1.BorderStyle:= bsSizeable;
  Form1.Cursor:= crDefault;
  Form1.Hint:= '';
  Form1.ShowHint:= False;
  Form2.Hide;
end;

procedure TForm1.Timer1Timer(Sender: TObject); //Interval = 1
var
  pt: TPoint;
  Width, Heigth: Integer;
begin
  GetCursorPos(pt);
  if Form2.Visible then
    begin
      if (ScreenToClient(pt).X > ClientWidth - 10) or (ScreenToClient(pt).Y > ClientHeight - 10) then
        begin
          Cursor:= crNo;
          Hint:= 'No resize';
          ShowHint:= True;
        end
      else
        begin
          Cursor:= crDefault;
          Hint:= '';
          ShowHint:= False;
        end;
    end;
end;
  • Related