Window Min, Max & Close Buttons An- & Ausschalten
Verfasst: 20.01.2006 09:50
hi folks,
hab grad sowas gesucht, aber irgendwie nicht gefunden. also habe ich auf msdn geschaut und es selbst gecodet.
ich hoffe, dass es für den einen oder anderen, nützlich ist.
have fun.
edit 3: für pb4.00 angepasst.
c ya,
nco2k
hab grad sowas gesucht, aber irgendwie nicht gefunden. also habe ich auf msdn geschaut und es selbst gecodet.
ich hoffe, dass es für den einen oder anderen, nützlich ist.
Code: Alles auswählen
Procedure SetWindowMinButton(hWnd.l, Show.l)
If (Show = #True Or Show = #False) And hWnd
nWindowLong.l = GetWindowLong_(hWnd, #GWL_STYLE)
If nWindowLong
If Show = #True
SetWindowLong_(hWnd, #GWL_STYLE, nWindowLong | #WS_MINIMIZEBOX)
ElseIf Show = #False
SetWindowLong_(hWnd, #GWL_STYLE, nWindowLong & (#WS_MINIMIZEBOX ! - 1))
EndIf
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOZORDER | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
EndIf
EndIf
EndProcedure
Procedure SetWindowMaxButton(hWnd.l, Show.l)
If (Show = #True Or Show = #False) And hWnd
nWindowLong.l = GetWindowLong_(hWnd, #GWL_STYLE)
If nWindowLong
If Show = #True
SetWindowLong_(hWnd, #GWL_STYLE, nWindowLong | #WS_MAXIMIZEBOX)
ElseIf Show = #False
SetWindowLong_(hWnd, #GWL_STYLE, nWindowLong & (#WS_MAXIMIZEBOX ! - 1))
EndIf
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOZORDER | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
EndIf
EndIf
EndProcedure
Procedure SetWindowCloseButton(hWnd.l, Show.l)
If (Show = #True Or Show = #False) And hWnd
hSysMenu = GetSystemMenu_(hWnd, #False)
If hSysMenu
EnableMenuItem_(hSysMenu, #SC_CLOSE, #MF_BYCOMMAND | Show ! 1)
DrawMenuBar_(hWnd)
EndIf
EndIf
EndProcedure
Enumeration
#GadgetButton_DisableMinBox
#GadgetButton_DisableMaxBox
#GadgetButton_DisableCloseBox
#GadgetButton_Exit
EndEnumeration
If OpenWindow(0, 0, 0, 200, 145, "Disable Window Close Box - Example", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(#GadgetButton_DisableMinBox, 5, 5, 190, 25, "Disable Minimize Box", #PB_Button_Toggle)
ButtonGadget(#GadgetButton_DisableMaxBox, 5, 35, 190, 25, "Disable Maximize Box", #PB_Button_Toggle)
ButtonGadget(#GadgetButton_DisableCloseBox, 5, 65, 190, 25, "Disable Close Box", #PB_Button_Toggle)
ButtonGadget(#GadgetButton_Exit, 5, 115, 190, 25, "Exit")
AddKeyboardShortcut(0, #PB_Shortcut_Alt | #PB_Shortcut_F4, 0)
AddKeyboardShortcut(0, #PB_Shortcut_Escape, 0)
Repeat
WinEvent.l = WaitWindowEvent()
If WinEvent = #PB_Event_Gadget
Select EventGadget()
Case #GadgetButton_DisableMinBox
SetWindowMinButton(WindowID(0), GetGadgetState(#GadgetButton_DisableMinBox) ! 1)
Case #GadgetButton_DisableMaxBox
SetWindowMaxButton(WindowID(0), GetGadgetState(#GadgetButton_DisableMaxBox) ! 1)
Case #GadgetButton_DisableCloseBox
SetWindowCloseButton(WindowID(0), GetGadgetState(#GadgetButton_DisableCloseBox) ! 1)
Case #GadgetButton_Exit
If GetGadgetState(#GadgetButton_DisableCloseBox) = 0
End
EndIf
EndSelect
ElseIf WinEvent = #PB_Event_Menu And EventMenu() = 0
If GetGadgetState(#GadgetButton_DisableCloseBox) = 0
End
EndIf
EndIf
Until WinEvent = #PB_Event_CloseWindow
EndIf
EndIf
End

edit 3: für pb4.00 angepasst.
c ya,
nco2k