Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 27th April 2011, 19:12   #1  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,412
[Windows7] Delphi 7 -> Form without top title

Does anybody know how to create that kind of form in delphi?

Atak_Snajpera is offline   Reply With Quote
Old 27th April 2011, 20:11   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,125
You will probably need some SetWindowLong() magic

This is code I used for my "Drop Box" widget:
Code:
procedure TForm_DropBox.FormShow(Sender: TObject);
begin
  // Make window stay on top
  SetWindowPos(Handle, HWND_TOPMOST, Left, Top, Width, Height, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
  // Set Parent to desktop
  SetWindowLong(Handle, GWL_HWNDPARENT, 0);
  // Hide window from the taskbar
  SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
end;
(BTW: I also set the form's "BorderStyle" property to "bsNone")


[UPDATE]

After thinking a bit more about this, I think this is what you need:

Code:
procedure TForm1.FormShow(Sender: TObject);
begin
  SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and (not WS_CAPTION));
  SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOMOVE or SWP_NOSIZE);
end;
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 27th April 2011 at 21:11.
LoRd_MuldeR is offline   Reply With Quote
Old 28th April 2011, 11:17   #3  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,412
Thanks alot LoRd_MuldeR! I knew that I could count on you. Second code works but only if bsSizeable or bsSizeToolWin is set. Now I have to figure out how to disable resizing of my window. Any ideas? Btw. Do you know how to hide form by clicking outside the form?
Atak_Snajpera is offline   Reply With Quote
Old 28th April 2011, 11:37   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,125
Quote:
Originally Posted by Atak_Snajpera View Post
Thanks alot LoRd_MuldeR! I knew that I could count on you. Second code works but only if bsSizeable or bsSizeToolWin is set. Now I have to figure out how to disable resizing of my window. Any ideas? Btw. Do you know how to hide form by clicking outside the form?
Have a look at:
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

Use like this:

Code:
type
  TForm1 = class(TForm)
    Button1: TButton;
  private
    procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
  public
    { Public-Deklarationen }
  end;
Code:
procedure TForm1.WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo);
begin
  with Msg.MinMaxInfo^ do
  begin
    ptMinTrackSize.X := 300; {Minimum width}
    ptMinTrackSize.Y := 300; {Minimum height}
    ptMaxTrackSize.X := 300; {Maximum width}
    ptMaxTrackSize.Y := 300; {Maximum height}
  end;
  Msg.Result := 0;
  inherited;
end;
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 28th April 2011 at 19:33.
LoRd_MuldeR is offline   Reply With Quote
Old 28th April 2011, 21:20   #5  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,125
Here is an even better method, which will also prevent the cursor from turning into a "resize" icon:

Code:
type
  TForm1 = class(TForm)
    procedure FormShow(Sender: TObject);
  private
    procedure WMNCHitTest(var Msg: TMessage); message WM_NCHITTEST;
  public
    { Public-Deklarationen }
  end;
Code:
procedure TForm1.FormShow(Sender: TObject);
begin
  SetWindowLong(Handle, GWL_STYLE, WS_OVERLAPPEDWINDOW and (not WS_CAPTION));
  SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOMOVE or SWP_NOSIZE);
end;

procedure TForm1.WMNCHitTest(var Msg: TMessage);
begin
  inherited;
  case Msg.Result of
    HTTOP: Msg.Result := HTCLIENT;
    HTTOPLEFT: Msg.Result := HTCLIENT;
    HTTOPRIGHT: Msg.Result := HTCLIENT;
    HTBOTTOM: Msg.Result := HTCLIENT;
    HTBOTTOMLEFT: Msg.Result := HTCLIENT;
    HTBOTTOMRIGHT: Msg.Result := HTCLIENT;
    HTLEFT: Msg.Result := HTCLIENT;
    HTRIGHT: Msg.Result := HTCLIENT;
  end;
end;
(Note: The usual method to avoid resizing, i.e remove the WS_THICKBORDER bit from the GWL_STYLE flags, doesn't work with caption-less windows, as it would also remove the "Aero-style" border)
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 28th April 2011 at 21:29.
LoRd_MuldeR is offline   Reply With Quote
Old 29th April 2011, 15:39   #6  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,412
Once again thank you for your help! You gave me everything ready on plate In meantime I had problem with 'focusing'. form1 (second form in my app) was always appearing without focus. With little help with google I managed to solve my problem.

I had to add this to form1.show
Code:
SetForegroundWindow(Application.MainForm.Handle);
Also I wanted to hide that form automatically when form looses focus (like volume, calendar in windows 7). So I put JvAppEvents and added

Code:
procedure TForm1.JvAppEvents1Deactivate(Sender: TObject);
begin
     if GetForegroundWindow() <> form1.Handle then form1.Hide;
end;
and here is my question. Is this the best place? I've noticed that it also works in OnMessage, OnIdle. Btw. Where can i find more help about those events?
Atak_Snajpera is offline   Reply With Quote
Old 29th April 2011, 19:46   #7  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,125
Well, I think the "OnMessage" event is triggered for every message that is sent to any window in your application. You can check the 'Msg' parameter to handle the individual message.

At the same time "OnDeactivate" is called when the application is deactivated (i.e. looses focus) and "OnIdle" is called when the application becomes idle (i.e. when all current messages have been processed).

For what you are doing the "OnDeactivate" event seems to be the most suitable one. I guess your code would also work in "OnMessage", but that might cause an unnecessary overhead...
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 29th April 2011 at 19:53.
LoRd_MuldeR is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.