mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 05:09:39 +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;
|
||||
AppHandle: HWND;
|
||||
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
|
||||
MenuHandle := APopupMenu.Handle;
|
||||
AppHandle := TWin32WidgetSet(WidgetSet).AppHandle;
|
||||
GetWin32WindowInfo(AppHandle)^.PopupMenu := APopupMenu;
|
||||
TrackPopupMenuEx(MenuHandle,
|
||||
lAlign[APopupMenu.IsRightToLeft] or
|
||||
TPM_LEFTBUTTON or TPM_RIGHTBUTTON,
|
||||
lAlignment[APopupMenu.Alignment, APopupMenu.IsRightToLeft] or lTrackButtons[APopupMenu.TrackButton],
|
||||
X, Y, AppHandle, nil);
|
||||
end;
|
||||
|
||||
|
||||
11
lcl/menus.pp
11
lcl/menus.pp
@ -381,14 +381,17 @@ type
|
||||
{ TPopupMenu }
|
||||
|
||||
TPopupAlignment = (paLeft, paRight, paCenter);
|
||||
TTrackButton = (tbRightButton, tbLeftButton);
|
||||
|
||||
TPopupMenu = class(TMenu)
|
||||
private
|
||||
FAlignment: TPopupAlignment;
|
||||
FAutoPopup: Boolean;
|
||||
FOnClose: TNotifyEvent;
|
||||
FOnPopup: TNotifyEvent;
|
||||
FPopupComponent: TComponent;
|
||||
FPopupPoint: TPoint;
|
||||
FTrackButton: TTrackButton;
|
||||
protected
|
||||
class procedure WSRegisterClass; override;
|
||||
procedure DoPopup(Sender: TObject); virtual;
|
||||
@ -398,12 +401,13 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure PopUp();
|
||||
procedure PopUp(X, Y: Integer); virtual;
|
||||
property PopupComponent: TComponent read FPopupComponent
|
||||
write FPopupComponent;
|
||||
property PopupComponent: TComponent read FPopupComponent write FPopupComponent;
|
||||
property PopupPoint: TPoint read FPopupPoint;
|
||||
procedure Close;
|
||||
published
|
||||
property Alignment: TPopupAlignment read FAlignment write FAlignment default paLeft;
|
||||
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 OnClose: TNotifyEvent read FOnClose write FOnClose;
|
||||
end;
|
||||
@ -497,8 +501,7 @@ begin
|
||||
Result:=TPopupMenu.Create(Owner);
|
||||
Result.Name:=AName;
|
||||
Result.AutoPopup:=AutoPopup;
|
||||
if Alignment=paLeft then ;
|
||||
// TODO Result.Alignment:=Alignment;
|
||||
Result.Alignment:=Alignment;
|
||||
AddMenuItems(Result,Items);
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user