Re: WinAPI Library (Snippets) (548)
Verfasst: 02.07.2010 20:59
@neotoma
Wow, sehr fleißig, vielen lieben Dank für deine zahlreichen Beispielcodes

Wow, sehr fleißig, vielen lieben Dank für deine zahlreichen Beispielcodes


Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
SetWindowLongPtr_(WindowID(0),#GWL_EXSTYLE,$2000)
HideWindow(0,0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Alles auswählen
EnableExplicit
Procedure HideFromTaskBar(hWnd.l, Flag.l)
Protected TBL.ITaskbarList
CoInitialize_(0)
If CoCreateInstance_(?CLSID_TaskBarList, 0, 1, ?IID_ITaskBarList, @TBL) = #S_OK
TBL\HrInit()
If Flag
TBL\DeleteTab(hWnd)
Else
TBL\AddTab(hWnd)
EndIf
TBL\Release()
EndIf
CoUninitialize_()
DataSection
CLSID_TaskBarList:
Data.l $56FDF344
Data.w $FD6D, $11D0
Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
IID_ITaskBarList:
Data.l $56FDF342
Data.w $FD6D, $11D0
Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
EndDataSection
EndProcedure
If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
HideFromTaskBar(WindowID(0),1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Die html-Seite im Programmordner zeigt noch den alten Link zu http://www.rsbasic.i3h.deWinAPI Library hat geschrieben: [Window Title]
C:\Program Files\PureBasic\PureBasic.exe
[Content]
"C:\Program Files\PureBasic\PureBasic.exe" konnte nicht gefunden werden. Stellen Sie sicher, dass Sie den Namen richtig eingegeben haben und wiederholen Sie den Vorgang.
[OK]
Code: Alles auswählen
OpenConsole()
ConsoleTitle("Blablabla")
OpenWindow(0, 0, 0, 650, 400, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetParent_(FindWindow_(0, "Blablabla"), WindowID(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Alles auswählen
#SC_SYSSEPERATOR = $0
;Structure to keep the Infoprmation of a Window for restore them.
Structure sFullscreenWindow
bytState.i
tWinRect.RECT
lWinStyle.i
EndStructure
; For the 'courious' case with more than one Fullscreen-Windows
Global NewMap _Fullscreen_windows.sFullscreenWindow()
; Window-Fullscreen
;
;
Procedure WindowFullscreen(win_id.i, bState.i, bMenuClose.i = #True)
Protected lStyle.i, hMenu
LockWindowUpdate_( GetDesktopWindow_() )
If IsWindow(win_id)
;Noch nicht in der Vollansicht gewesen.
If FindMapElement( _Fullscreen_windows(),Str(win_id) ) = 0 And bState = #False
LockWindowUpdate_( #Null )
ProcedureReturn
EndIf
With _Fullscreen_windows(Str(win_id))
;Ist bereits vollansicht
If \bytState = #True And bState = #True
LockWindowUpdate_( #Null )
ProcedureReturn
EndIf
;Vollansicht?
If bState
\bytState = #True
;Gr÷¯e und Position merken
GetWindowRect_( WindowID(win_id), @\tWinRect )
;Stil merken
\lWinStyle = GetWindowLong_(WindowID(win_id), #GWL_STYLE)
;Titelleiste und (Gr÷¯enõnderungs-)Rahmen entfernen
lStyle = \lWinStyle & ~(#WS_CAPTION | #WS_THICKFRAME)
SetWindowLong_(WindowID(win_id), #GWL_STYLE, lStyle)
ExamineDesktops()
; Fenstergr÷¯e auf Bildschirm-Gr÷¯e setzen
SetWindowPos_(WindowID(win_id), #HWND_NOTOPMOST, 0, 0, DesktopWidth(0),DesktopHeight(0),#SWP_FRAMECHANGED)
; Handle des SystemMen³s ermitteln
hMenu = GetSystemMenu_(WindowID(win_id), #Null)
; Eintrõge aus dem SystemMen³ entfernen
If hMenu
; Wiederherstellen
DeleteMenu_(hMenu, #SC_RESTORE, #MF_BYCOMMAND)
; Verschieben
DeleteMenu_(hMenu, #SC_MOVE, #MF_BYCOMMAND)
; Gr÷¯e õndern
DeleteMenu_(hMenu, #SC_SIZE, #MF_BYCOMMAND)
; Minimieren
DeleteMenu_(hMenu, #SC_MINIMIZE, #MF_BYCOMMAND)
; Maxminieren
DeleteMenu_(hMenu, #SC_MAXIMIZE, #MF_BYCOMMAND)
; Trennlinie
DeleteMenu_(hMenu, #SC_SYSSEPERATOR, #MF_BYCOMMAND)
If bMenuClose = #False
; Schlie¯en
DeleteMenu_(hMenu, #SC_CLOSE, #MF_BYCOMMAND)
EndIf
EndIf
Else
; Status auf Normalansicht setzen
\bytState = #False
; Fenstergr÷¯e wiederherstellen
SetWindowPos_( WindowID(win_id), #HWND_NOTOPMOST, \tWinRect\left, \tWinRect\top, \tWinRect\right - \tWinRect\left, \tWinRect\bottom - \tWinRect\top, #SWP_FRAMECHANGED)
; Fensterstil wiederherstellen
SetWindowLong_( WindowID(win_id), #GWL_STYLE, \lWinStyle )
; Systemmen³ wiederherstellen
GetSystemMenu_( WindowID(win_id), #True)
EndIf
; Systemmen³ neu zeichnen
DrawMenuBar_(WindowID(win_id))
EndWith
EndIf
LockWindowUpdate_( #Null )
EndProcedure
; Vollansicht-Status ermitteln
Procedure WindowFullscreenState(win_id)
ProcedureReturn _Fullscreen_windows(Str(win_id))\bytState
EndProcedure
; Test
Define flag=0
If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(1,10,10,100,20,"FullscreenSwitch",0)
Repeat
EventID=WaitWindowEvent()
If EventID=#PB_Event_Gadget
Select EventGadget()
Case 1
WindowFullscreen(0, 1!WindowFullscreenState(0))
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf
; IDE Options = PureBasic 4.50 (Windows - x86)
; CursorPosition = 108
; FirstLine = 83
; Folding = -
; EnableXP