7

I just made a small app here in Delphi 7 that simulates the default system icons, like Volume, Battery, Clock, Network.

I'm trying to follow all Microsoft recomendations here http://msdn.microsoft.com/en-us/library/aa511448.aspx#flyouts

To make a window look like a flyout, i'm using this code:

//declaration

TForm1 = class(TForm)

protected
  procedure CreateParams(var Params: TCreateParams); override;
end;

implementation

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := WS_POPUP or WS_THICKFRAME;
  Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;
end;

My problem is the WS_THICKFRAME allows user to resize the window. How can I fix this?

Resizable Window Issue

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
Vitim.us
  • 20,746
  • 15
  • 92
  • 109
  • Yes, WS_THICKFRAME makes it resizable. WS_BORDER is enough, Aero makes it fat too. – Hans Passant Sep 13 '11 at 21:41
  • You can use a tool like Spy++ to determine the values of the windows styles and the extended styles of the `Battery Meter` window and then apply these values to the `Params.Style` and `Params.ExStyle` – RRUZ Sep 14 '11 at 02:10
  • @RRUZ I already tried this before post here, unsucessfuly. Style: 0x94800000 ExStyle:0x00000008 but my window is invisible after that. http://img641.imageshack.us/img641/5403/prtscrcapturen.jpg – Vitim.us Sep 14 '11 at 04:06
  • @Hans Passant: if that is the solution, make your comment an answer. – The_Fox Sep 14 '11 at 10:13
  • I've found that if you give the form BorderStyle:=bsNone at design time the window is not sizeable. – avenmore Dec 10 '11 at 08:49
  • possible duplicate of [Windows 7 style Notifications Flyouts in Delphi](http://stackoverflow.com/questions/2105010/windows-7-style-notifications-flyouts-in-delphi) – jachguate Jun 26 '15 at 00:58

4 Answers4

6

You can prevent resizing by handling WM_GETMINMAXINFO.

However, this won't prevent the resize cursor from being used. For that, you can handle WM_NCHITTEST.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • not the best solution, anyway the only one that works. I tried almost all styles combinations, no one give me the same visual as WM_THICKFRAME. – Vitim.us Sep 15 '11 at 17:05
1

Just handle the WM_NCHITTEST message and always return HTCLIENT value.

Which will mean for OS that it is over the client area of the app. It will not then show the resize cursor.

I'm using this approach in WPF app.

Evgenyt
  • 10,201
  • 12
  • 40
  • 44
0

Try this style: WS_DLGFRAME (0x00400000)

tmplinshi
  • 1
  • 1
  • 3
0

Use the following code and you will get rid of the resize mouse cursor.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  protected
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style or WS_THICKFRAME;
end;

procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
  inherited;
  with Message do begin
    Result := HTCLIENT;
  end;
end;

end.
Bashk
  • 85
  • 4
  • 9