Desplegar por código el menú de sistema de una ventana
Programar en cualquier componente que se desee que responda al click el siguiente código en el evento MouseDown.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var h: HMENU; p:TPoint; begin // El componente que llama deriva de TControl? if (Sender is TControl) then begin // Posicion del click p.X := x; p.Y := y; // Calculamos las coordenadas relativas P := Self.ScreenToClient(TControl(Sender).ClientToScreen(P)); // Mostrar el menú h := GetSystemMenu(handle, false); TrackPopupMenu(h, TPM_LEFTALIGN or TPM_LEFTBUTTON, ClientOrigin.X + p.X , ClientOrigin.Y + p.y, 0, handle, nil); end; end; |