|
! This way your Window can have a pretty Icon() but not a Minimize button that causes end users to lose the form |
|
|
|
MAP |
|
RemoveMinButton() !Remove Minimize button on the Current Window so can have Icon() but no Minimize |
|
MinButtonHide(BOOL HideMinimize=True),BOOL,PROC !Hide Minimize button (False Unhide) on the Current Window. Returns True if state changed. |
|
|
|
MODULE('Win32') |
|
GetWindowLong(LONG HndWindow, LONG nIndex),LONG,PASCAL,DLL(1),NAME('GetWindowLongA') |
|
SetWindowLong(LONG HndWindow, LONG nIndex, LONG dwNewLong),LONG,PROC,PASCAL,DLL(1),NAME('SetWindowLongA') |
|
END |
|
END |
|
|
|
RemoveMinButton PROCEDURE() !Remove Minimize button on the Current Window so can have Icon() but no Minimize |
|
Sty LONG,AUTO |
|
Hnd LONG,AUTO |
|
cbWS_MinimizeBox EQUATE(20000h) |
|
cbGWL_STYLE EQUATE(-16) |
|
CODE |
|
Hnd = 0{PROP:Handle} |
|
Sty = GetWindowLong(Hnd, cbGWL_STYLE) |
|
IF BAND(Sty,cbWS_MinimizeBox) THEN |
|
SetWindowLong(Hnd, cbGWL_STYLE, Sty - cbWS_MinimizeBox) |
|
END |
|
RETURN |
|
|
|
!---------------------------------------------------------------------- |
|
! MinButtonHide() also allows unhide by passing (False). It returns True if the state was changed |
|
|
|
MinButtonHide PROCEDURE(BOOL HideMinimize=True)!,BOOL,PROC !Hide Minimize button (False Unhide) on the Current Window so can have Icon() but no Minimize |
|
!Pass (False) to UnHide. Returns True if the Min Button Hide/UnHide state was changed |
|
Sty LONG,AUTO |
|
Hnd LONG,AUTO |
|
cbWS_MinimizeBox EQUATE(20000h) |
|
cbGWL_STYLE EQUATE(-16) |
|
CODE |
|
Hnd = 0{PROP:Handle} |
|
Sty = GetWindowLong(Hnd, cbGWL_STYLE) |
|
IF HideMinimize AND BAND(Sty,cbWS_MinimizeBox) THEN |
|
Sty -= cbWS_MinimizeBox |
|
ELSIF ~HideMinimize AND ~BAND(Sty,cbWS_MinimizeBox) THEN |
|
Sty = BOR(Sty,cbWS_MinimizeBox) |
|
ELSE |
|
RETURN False |
|
END |
|
SetWindowLong(Hnd, cbGWL_STYLE, Sty) |
|
RETURN True |
|
|
|
!------------------------------------------------------------------------------ |
|
!An alternative is in Event:Iconize to CYCLE. You must have IMM on window. |
|
!So when the user clicks nothing happens, this may be confusing. |
|
!------------------------------------------------------------------------------ |
|
|
|
!------------------------------------------------------------------------------ |
|
!For the MAX Button you can Hide/Unhide using Window{PROP:Max}=False/ True |
|
!The above function can be changed to Max using WS_MaxImizebox EQUATE(10000h) but why bother, use PROP:Max |
|
!------------------------------------------------------------------------------ |
|
|
|
|
|
!################################################################################################ |
|
|
|
! Disable Close is a way you can have a SYSTEM Menu and Icon but the Close Button will be enabled. |
|
! This is probably a bad idea as it will confuse and frustrate users who will feel trapped. |
|
! Better is in EVENT:CloseWindow (or for a Frame EVENT:CloseDown) show them a Message() |
|
! confirming they really want to close, if they say NO a CYCLE will stop the Close. |
|
|
|
!Read: How do I enable and disable the minimize, maximize, and close buttons in my caption bar? - The Old New Thing (microsoft.com) |
|
! https://devblogs.microsoft.com/oldnewthing/20100604-00/?p=13803#:~:text=If%20you%20never%20want%20the,item%20in%20your%20system%20menu. |
|
|
|
MAP |
|
CloseButtonDisable(BOOL DisableClose=True) !Disables Close button (False Enable) on the Current Window |
|
|
|
MODULE('Win32') |
|
GetSystemMenu(LONG hWnd, BOOL bRevert=False),LONG,PASCAL,DLL(1) !Returns hMenu |
|
EnableMenuItem(LONG hMenu, LONG uIDEnableItem, LONG uEnable ),LONG,PROC,PASCAL,DLL(1) !Returns Prior State |
|
END |
|
END |
|
|
|
|
|
CloseButtonDisable PROCEDURE(BOOL DisableClose=True) !Disables Close button (False Enable) on the Current Window |
|
hSysMenu LONG,AUTO |
|
uEnable LONG,AUTO |
|
cbSC_CLOSE EQUATE(0F060h) |
|
!MF_BYCOMMAND EQUATE(0) Indicates uIDEnableItem gives the identifier of the menu item i.e. cbSC_CLOSE |
|
!MF_ENABLED EQUATE(0) |
|
!MF_DISABLED EQUATE(2) 2+1 to Disable and make visually Gray |
|
!MF_GRAYED EQUATE(1) |
|
CODE |
|
hSysMenu=GetSystemMenu(0{PROP:Handle},False) |
|
IF hSysMenu THEN |
|
IF DisableClose THEN ! uEnable = 0 + CHOOSE(~DisableClose, 0, 2+1) |
|
uEnable = 0 + 2+1 ! Disable = 0 + 2 + 1 = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED |
|
ELSE |
|
uEnable = 0 + 0 ! Enable = 0 + 0 = MF_BYCOMMAND | MF_ENABLED |
|
END |
|
EnableMenuItem(hSysMenu, cbSC_CLOSE, uEnable) |
|
END |
|
RETURN |