was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

51 Visitors Online


 
...das Systemmenü einer Anwendung beliebig anzeigen?
Autor: Mike Shkolnik
Homepage: http://www.scalabium.com
[ Tip ausdrucken ]  

Tip Bewertung (4):  
     



(*
As you know, every form/window in MS Windows (TForm in VCL terms) have a system menu.
Usually there are pre-defined items like Close, Mimimize, Maximize, Move etc

But, of course, you also may add any own item in this system menu (see my tip#30 for
sample - http://www.scalabium.com/faq/dct0030.htm)

So sometimes you may want to show this system menu for form but in any own position
and from any your event. For example, user'll click on some your button and will see
this system menu:
*)

procedure TForm1.Button1Click(Sender: TObject);
var
  
hMenuHandle: hMENU;
  hMenuItem: DWORD;
  p: TPoint;
begin
  
{recalculate button coordinates to screen coordinates}
  
p.X := Button1.Left;
  p.Y := Button1.Top;
  p   := Button4.ClientToScreen(p);

  hMenuHandle := GetSystemMenu(Handle, False);
  hMenuItem   := Longword(Windows.TrackPopupMenu(hMenuHandle,
    TPM_LEFTBUTTON or TPM_RIGHTBUTTON or TPM_RETURNCMD, p.X, p.Y, 0, Handle, nil));
  if hMenuItem > 0 then
    
SendMessage(Handle, WM_SYSCOMMAND, hMenuItem, 0);
end;

(*
This could be really useful if you replace standard caption and draw own "header".
Generally better for this task to process the WM_NCPAINT and WM_NCHITTEST messages
but I saw a few implementations without these messages too...
*)

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners