How to make a window like Windows 7 Notifications Flyouts, (WS_THICKFRAME but NOT-RESIZABLE)
Asked Answered
I

4

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

Insuperable answered 13/9, 2011 at 21:28 Comment(6)
Yes, WS_THICKFRAME makes it resizable. WS_BORDER is enough, Aero makes it fat too.Landpoor
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.ExStyleBasilio
@Basilio I already tried this before post here, unsucessfuly. Style: 0x94800000 ExStyle:0x00000008 but my window is invisible after that. img641.imageshack.us/img641/5403/prtscrcapturen.jpgInsuperable
@Hans Passant: if that is the solution, make your comment an answer.Acaudal
I've found that if you give the form BorderStyle:=bsNone at design time the window is not sizeable.Wineskin
possible duplicate of Windows 7 style Notifications Flyouts in DelphiLegitimatize
I
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.

Imperious answered 14/9, 2011 at 0:46 Comment(1)
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.Insuperable
B
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.

Brennabrennan answered 1/10, 2012 at 8:8 Comment(0)
T
0

Try this style: WS_DLGFRAME (0x00400000)

Tenrec answered 7/10, 2013 at 8:32 Comment(0)
L
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.
Liver answered 10/3, 2014 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.