mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-24 11:49:30 +01:00
lcl: add TPopupMenu.Alignment, TPopupMenu.TrackButton
win32: implement TPopupMenu.Alignment, TPopupMenu.TrackButton git-svn-id: trunk@22732 -
This commit is contained in:
parent
d7c68d6c15
commit
cc5896f4e7
@ -1389,14 +1389,22 @@ var
|
|||||||
MenuHandle: HMENU;
|
MenuHandle: HMENU;
|
||||||
AppHandle: HWND;
|
AppHandle: HWND;
|
||||||
const
|
const
|
||||||
lAlign: array[Boolean] of DWord = (TPM_LEFTALIGN, TPM_RIGHTALIGN);
|
lAlignment: array[TPopupAlignment, Boolean] of DWORD = (
|
||||||
|
{ left-to-rght } { right-to-left }
|
||||||
|
{ paLeft } (TPM_LEFTALIGN, TPM_RIGHTALIGN),
|
||||||
|
{ paRight } (TPM_RIGHTALIGN, TPM_LEFTALIGN),
|
||||||
|
{ paCenter } (TPM_CENTERALIGN, TPM_CENTERALIGN)
|
||||||
|
);
|
||||||
|
lTrackButtons: array[TTrackButton] of DWORD = (
|
||||||
|
{ tbRightButton } TPM_RIGHTBUTTON,
|
||||||
|
{ tbLeftButton } TPM_LEFTBUTTON
|
||||||
|
);
|
||||||
begin
|
begin
|
||||||
MenuHandle := APopupMenu.Handle;
|
MenuHandle := APopupMenu.Handle;
|
||||||
AppHandle := TWin32WidgetSet(WidgetSet).AppHandle;
|
AppHandle := TWin32WidgetSet(WidgetSet).AppHandle;
|
||||||
GetWin32WindowInfo(AppHandle)^.PopupMenu := APopupMenu;
|
GetWin32WindowInfo(AppHandle)^.PopupMenu := APopupMenu;
|
||||||
TrackPopupMenuEx(MenuHandle,
|
TrackPopupMenuEx(MenuHandle,
|
||||||
lAlign[APopupMenu.IsRightToLeft] or
|
lAlignment[APopupMenu.Alignment, APopupMenu.IsRightToLeft] or lTrackButtons[APopupMenu.TrackButton],
|
||||||
TPM_LEFTBUTTON or TPM_RIGHTBUTTON,
|
|
||||||
X, Y, AppHandle, nil);
|
X, Y, AppHandle, nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
11
lcl/menus.pp
11
lcl/menus.pp
@ -381,14 +381,17 @@ type
|
|||||||
{ TPopupMenu }
|
{ TPopupMenu }
|
||||||
|
|
||||||
TPopupAlignment = (paLeft, paRight, paCenter);
|
TPopupAlignment = (paLeft, paRight, paCenter);
|
||||||
|
TTrackButton = (tbRightButton, tbLeftButton);
|
||||||
|
|
||||||
TPopupMenu = class(TMenu)
|
TPopupMenu = class(TMenu)
|
||||||
private
|
private
|
||||||
|
FAlignment: TPopupAlignment;
|
||||||
FAutoPopup: Boolean;
|
FAutoPopup: Boolean;
|
||||||
FOnClose: TNotifyEvent;
|
FOnClose: TNotifyEvent;
|
||||||
FOnPopup: TNotifyEvent;
|
FOnPopup: TNotifyEvent;
|
||||||
FPopupComponent: TComponent;
|
FPopupComponent: TComponent;
|
||||||
FPopupPoint: TPoint;
|
FPopupPoint: TPoint;
|
||||||
|
FTrackButton: TTrackButton;
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
procedure DoPopup(Sender: TObject); virtual;
|
procedure DoPopup(Sender: TObject); virtual;
|
||||||
@ -398,12 +401,13 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure PopUp();
|
procedure PopUp();
|
||||||
procedure PopUp(X, Y: Integer); virtual;
|
procedure PopUp(X, Y: Integer); virtual;
|
||||||
property PopupComponent: TComponent read FPopupComponent
|
property PopupComponent: TComponent read FPopupComponent write FPopupComponent;
|
||||||
write FPopupComponent;
|
|
||||||
property PopupPoint: TPoint read FPopupPoint;
|
property PopupPoint: TPoint read FPopupPoint;
|
||||||
procedure Close;
|
procedure Close;
|
||||||
published
|
published
|
||||||
|
property Alignment: TPopupAlignment read FAlignment write FAlignment default paLeft;
|
||||||
property AutoPopup: Boolean read FAutoPopup write FAutoPopup default True;
|
property AutoPopup: Boolean read FAutoPopup write FAutoPopup default True;
|
||||||
|
property TrackButton: TTrackButton read FTrackButton write FTrackButton default tbRightButton;
|
||||||
property OnPopup: TNotifyEvent read FOnPopup write FOnPopup;
|
property OnPopup: TNotifyEvent read FOnPopup write FOnPopup;
|
||||||
property OnClose: TNotifyEvent read FOnClose write FOnClose;
|
property OnClose: TNotifyEvent read FOnClose write FOnClose;
|
||||||
end;
|
end;
|
||||||
@ -497,8 +501,7 @@ begin
|
|||||||
Result:=TPopupMenu.Create(Owner);
|
Result:=TPopupMenu.Create(Owner);
|
||||||
Result.Name:=AName;
|
Result.Name:=AName;
|
||||||
Result.AutoPopup:=AutoPopup;
|
Result.AutoPopup:=AutoPopup;
|
||||||
if Alignment=paLeft then ;
|
Result.Alignment:=Alignment;
|
||||||
// TODO Result.Alignment:=Alignment;
|
|
||||||
AddMenuItems(Result,Items);
|
AddMenuItems(Result,Items);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user