Sometimes you want to create a fancy looking form from a bitmap, like WinAMP or K-Jöfol. This part isn't too hard. All you have to do is make a cool graphic, use the TImage component and set the form's border style to bsNone. Well, all's good until we want to move the form... Since there is no title bar there may be problems with this:) Well, as you should already know Delphi can get over any problem. All we have to do is manually take care of the WM_NCHITTEST Windows message.
In this example a TImage component named imgTitle will act like the windows title bar.
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, ExtCtrls, jpeg;
type
TForm1 = class(TForm)
imgTitle: TImage;
private
{ Private declarations }
public
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
var P: TPoint;
begin
inherited;
P := ScreenToClient(SmallPointToPoint(Message.Pos));
with imgTitle do
if (P.X >= Left) and (P.X < Left + Width) and (P.Y >= Top) and (P.Y < Top + Height) then
Message.Result := htCaption;
end;
end.
Credit for: mailto:m3rlin@programmer.netm3rlin
When you left click and move mouse this form will move.
Android smartphone
Showing posts with label Form. Show all posts
Showing posts with label Form. Show all posts
2010-06-17
Scrollbar, hide main form, hide the titlebar, Combobox
[quote=mailto:info@delphitips.comGustav Evertsson]
How can I get a horizontal scrollbar on a list box?
Send a LB_SetHorizontalExtent message to the listbox's window handle.For example, the message could be sent in the form's OnCreate:
procedure TForm1.FormCreate(Sender: TObject);
begin
SendMessage(Listbox1.Handle, LB_SetHorizontalExtent, 1000, Longint(0));
end;
---------------------------------------------End----------------------------------------------
How to hide the main form ?
If you do not want your program starting up showing your main form, then add this line in your project (DPR) file, just after the Application.Initialize line.
Application.ShowMainForm := False;
---------------------------------------------End----------------------------------------------
How to hide the Titlebar ?
//Here is how to hide the titlebar:
Procedure TYourFormName.HideTitlebar;
Var
Save : LongInt;
Begin
If BorderStyle=bsNone then Exit;
Save:=GetWindowLong(Handle,gwl_Style);
If (Save and ws_Caption)=ws_Caption then
Begin
Case BorderStyle of bsSingle,
bsSizeable : SetWindowLong(Handle,gwl_Style,Save and
(Not(ws_Caption)) or ws_border);
bsDialog : SetWindowLong(Handle,gwl_Style,Save and
(Not(ws_Caption)) or ds_modalframe or ws_dlgframe);
End;
Height:=Height-getSystemMetrics(sm_cyCaption);
Refresh;
End;
end;
//And here is how we show it again:
Procedure TYourFormName.ShowTitlebar;
Var
Save : LongInt;
begin
If BorderStyle=bsNone then Exit;
Save:=GetWindowLong(Handle,gwl_Style);
If (Save and ws_Caption)<>ws_Caption then
Begin
Case BorderStyle of bsSingle,
bsSizeable : SetWindowLong(Handle,gwl_Style,Save or
ws_Caption or ws_border);
bsDialog : SetWindowLong(Handle,gwl_Style,Save or
ws_Caption or ds_modalframe or ws_dlgframe);
End;
Height:=Height+getSystemMetrics(sm_cyCaption);
Refresh;
End;
end;
---------------------------------------------End----------------------------------------------
How to make a TComboBox drop?
There is a windows API call to do it.
function SendMessage(Handle of the ComboBox, 1039, 1, 0);
So, if I had a TComboBox that was named LouieCombo, I would use the following code:
Procedure DropCombo(LouieCombo : TComboBox);
var
ReturnValue : Longint;
begin
ReturnValue := SendMessage(LouieCombo.Handle, 1039, 1, 0);
end;
---------------------------------------------End----------------------------------------------
[/quote]
Subscribe to:
Posts (Atom)