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. |
27th April 2011, 19:12 | #1 | Link |
RipBot264 author
Join Date: May 2006
Location: Poland
Posts: 7,816
|
[Windows7] Delphi 7 -> Form without top title
Does anybody know how to create that kind of form in delphi?
__________________
Windows 7 Image Updater - SkyLake\KabyLake\CoffeLake\Ryzen Threadripper |
27th April 2011, 20:11 | #2 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
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; [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;
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 27th April 2011 at 21:11. |
28th April 2011, 11:17 | #3 | Link |
RipBot264 author
Join Date: May 2006
Location: Poland
Posts: 7,816
|
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?
__________________
Windows 7 Image Updater - SkyLake\KabyLake\CoffeLake\Ryzen Threadripper |
28th April 2011, 11:37 | #4 | Link | |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
Quote:
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;
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 28th April 2011 at 19:33. |
|
28th April 2011, 21:20 | #5 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
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;
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 28th April 2011 at 21:29. |
29th April 2011, 15:39 | #6 | Link |
RipBot264 author
Join Date: May 2006
Location: Poland
Posts: 7,816
|
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); Code:
procedure TForm1.JvAppEvents1Deactivate(Sender: TObject); begin if GetForegroundWindow() <> form1.Handle then form1.Hide; end;
__________________
Windows 7 Image Updater - SkyLake\KabyLake\CoffeLake\Ryzen Threadripper |
29th April 2011, 19:46 | #7 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
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...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 29th April 2011 at 19:53. |
|
|