Fenstergröße beim Borderless ändern
Fenstergröße beim Borderless ändern
hallo!
ich hab ein rahmenloses fenster, das ich jetzt gerne in der größe änderbar haben möchte (resizegadget klappt nicht)
hat da vielleicht jemand eine idee??
ich hab ein rahmenloses fenster, das ich jetzt gerne in der größe änderbar haben möchte (resizegadget klappt nicht)
hat da vielleicht jemand eine idee??

- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
>> ich möchte, dass der user an Rand klickt
Dein Fenster hat keinen Rand, also die Mousekoordinaten mußte laufend
prüfen, wenn er so und so dicht am rand ist und drückt, dann das Fenster
resizen. Sehr aufwendig
Dein Fenster hat keinen Rand, also die Mousekoordinaten mußte laufend
prüfen, wenn er so und so dicht am rand ist und drückt, dann das Fenster
resizen. Sehr aufwendig

PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

wir sind zwar hier im Anfängerforum und ich liefere ungern vorgekauten
Code, aber in diesem Fall mache ich eine Ausnahme:
Grüße ... Kiffi
Code, aber in diesem Fall mache ich eine Ausnahme:
Code: Alles auswählen
Enumeration
#frmResizeExample
#cmdTopLeft
#cmdTopRight
#cmdLeft
#cmdTop
#cmdRight
#cmdBottom
#cmdBottomLeft
#cmdBottomRight
#cmdExit
EndEnumeration
Procedure.l IsMouseOverGadget(Gadget.l)
Protected wnd.l
Protected re.RECT
Protected pt.POINT
wnd=GadgetID(Gadget)
If wnd
GetWindowRect_(wnd,re)
GetCursorPos_(pt)
ProcedureReturn PtInRect_(re,pt\x,pt\y)
EndIf
EndProcedure
Procedure ResizeGadgets()
Protected x.l, y.l, w.l, h.l
; Topleft braucht keinen resize
; [...]
; TopRight
x = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdTopRight)
y = 0
w = #PB_Ignore
h = #PB_Ignore
ResizeGadget(#cmdTopRight, x, y, w, h)
; Left
x = 0
y = GadgetHeight(#cmdTopLeft)
w = #PB_Ignore
h = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdTopLeft) - GadgetHeight(#cmdBottomLeft)
ResizeGadget(#cmdLeft, x, y, w, h)
; Top
x = GadgetWidth(#cmdTopLeft)
y = 0
w = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdTopLeft) - GadgetWidth(#cmdTopRight)
h = #PB_Ignore
ResizeGadget(#cmdTop, x, y, w, h)
; Right
x = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdRight)
y = GadgetHeight(#cmdTopRight)
w = #PB_Ignore
h = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdTopRight) - GadgetHeight(#cmdBottomRight)
ResizeGadget(#cmdRight, x, y, w, h)
; Bottom
x = GadgetWidth(#cmdBottomLeft)
y = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdBottom)
w = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdBottomLeft)- GadgetWidth(#cmdBottomRight)
h = #PB_Ignore
ResizeGadget(#cmdBottom, x, y, w, h)
; BottomLeft
x = 0
y = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdBottomLeft)
w = #PB_Ignore
h = #PB_Ignore
ResizeGadget(#cmdBottomLeft, x, y, w, h)
; BottomRight
x = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdBottomRight)
y = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdBottomRight)
w = #PB_Ignore
h = #PB_Ignore
ResizeGadget(#cmdBottomRight, x, y, w, h)
; Exit-Button
x = GadgetWidth(#cmdLeft)
y = GadgetHeight(#cmdTop)
w = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdLeft) - GadgetWidth(#cmdRight)
h = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdTop) - GadgetHeight(#cmdBottom)
ResizeGadget(#cmdExit, x, y, w, h)
EndProcedure
Procedure ResizeBorderlessWindow(ResizeWhat.l)
ReleaseCapture_()
SendMessage_(WindowID(#frmResizeExample), #WM_NCLBUTTONDOWN, ResizeWhat, 0)
EndProcedure
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 200, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(#frmResizeExample))
ButtonGadget(#cmdTopLeft, 0, 0, 30, 30, "tl")
ButtonGadget(#cmdTopRight, 0, 0, 30, 30, "tr")
ButtonGadget(#cmdLeft, 0, 0, 30, 0, "l")
ButtonGadget(#cmdTop, 0, 0, 0, 30, "t")
ButtonGadget(#cmdRight, 0, 0, 30, 0, "r")
ButtonGadget(#cmdBottom, 0, 0, 0, 30, "b")
ButtonGadget(#cmdBottomLeft, 0, 0, 30, 30, "bl")
ButtonGadget(#cmdBottomRight, 0, 0, 30, 30, "br")
ButtonGadget(#cmdExit, 25, 25, 50, 40, "Exit")
ResizeGadgets()
Repeat
WWE = WaitWindowEvent()
EG = EventGadget()
Select WWE
Case #WM_LBUTTONDOWN
If IsMouseOverGadget(#cmdTopLeft) : ResizeBorderlessWindow(#HTTOPLEFT)
ElseIf IsMouseOverGadget(#cmdTopRight) : ResizeBorderlessWindow(#HTTOPRIGHT)
ElseIf IsMouseOverGadget(#cmdTop) : ResizeBorderlessWindow(#HTTOP)
ElseIf IsMouseOverGadget(#cmdLeft) : ResizeBorderlessWindow(#HTLEFT)
ElseIf IsMouseOverGadget(#cmdRight) : ResizeBorderlessWindow(#HTRIGHT)
ElseIf IsMouseOverGadget(#cmdBottom) : ResizeBorderlessWindow(#HTBOTTOM)
ElseIf IsMouseOverGadget(#cmdBottomLeft) : ResizeBorderlessWindow(#HTBOTTOMLEFT)
ElseIf IsMouseOverGadget(#cmdBottomRight) : ResizeBorderlessWindow(#HTBOTTOMRIGHT)
ElseIf IsMouseOverGadget(#cmdExit) : Quit = #True
EndIf
Case #PB_Event_SizeWindow
ResizeGadgets()
EndSelect
Until Quit = #True
EndIf
EndIf
a²+b²=mc²
- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
Schöner Code Peter
Wenn man jetzt vor ResizeGadget() noch folgendes einfügt, kommts noch besser
Gruß
Thomas

Wenn man jetzt vor ResizeGadget() noch folgendes einfügt, kommts noch besser

Code: Alles auswählen
Define i.l
For i = 1 To 8
HideGadget(i, #True)
Next
Thomas
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

ich hab das auch nochmal versucht.
man hat jetzt auch die resize-cursor und kann eine fenster-mindestgröße festlegen (#WinWidthMin und #WinHeightMin).
#touchWidth ist die breite des randes.
man hat jetzt auch die resize-cursor und kann eine fenster-mindestgröße festlegen (#WinWidthMin und #WinHeightMin).
#touchWidth ist die breite des randes.
Code: Alles auswählen
#N=2
#S=4
#O=8
#W=16
#touchWidth=6
#WinWidthMin=150
#WinHeightMin=30
Global dmx.l ;DesktopMouseX
Global dmy.l ;DesktopMouseY
Global wmx.l ;WindowMouseX
Global wmy.l ;WindowMouseY
Global hC_N=LoadCursor_(0,#IDC_SIZENS) ; cursor |
Global hC_NO=LoadCursor_(0,#IDC_SIZENESW) ; cursor /
Global hC_O=LoadCursor_(0,#IDC_SIZEWE) ; cursor -
Global hC_SO=LoadCursor_(0,#IDC_SIZENWSE) ; cursor \
Declare.l getResizeFlag()
Declare setResizeCursor(flag.l)
Declare resizeWin(flag.l)
Declare refreshSize()
ww=200
wh=300
hWin=OpenWindow(0, 50,50, ww,wh, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
CreateGadgetList(hWin)
ButtonGadget(0, ww-#touchWidth-50, #touchWidth, 50,20, "exit")
ButtonGadget(1, ww-#touchWidth-50-4-50, #touchWidth, 50,20, "move")
;hC_Default=GetCursor_()
;######################### MAIN #########
Repeat
event=WaitWindowEvent(200)
dmx=DesktopMouseX()
dmy=DesktopMouseY()
wmx=WindowMouseX(0)
wmy=WindowMouseY(0)
eg=EventGadget()
Select event
Case #PB_Event_CloseWindow
quit=1
Case #PB_Event_Gadget
Select eg
Case 0 ;exit-button
quit=1
Case 1 ;move-button
;moveWin=1
EndSelect
Case #WM_LBUTTONDOWN
gaX=GadgetX(1) ;(move-button metrics)
gaY=GadgetY(1)
gaW=GadgetWidth(1)
gaH=GadgetHeight(1)
If wmx>=gaX And wmx<gaX+gaW And wmy>=gaY And wmy<gaY+gaH
ReleaseCapture_()
SendMessage_(hWin, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
Case #PB_Event_SizeWindow
refreshSize()
EndSelect
If Not GetAsyncKeyState_(#VK_LBUTTON)&(1<<15)
resFlag=getResizeFlag()
EndIf
setResizeCursor(resFlag)
If resFlag
resizeWin(resFlag)
EndIf
Until quit
;########################################
Procedure.l getResizeFlag()
Protected ret.l
Protected wx=WindowX(0)
Protected wy=WindowY(0)
Protected ww=WindowWidth(0)
Protected wh=WindowHeight(0)
If dmx >= wx And dmx < wx+#touchWidth
ret|#W
ElseIf dmx < wx+ww And dmx > wx+ww-#touchWidth
ret|#O
EndIf
If dmy >= wy And dmy < wy+#touchWidth
ret|#N
ElseIf dmy < wy+wh And dmy > wy+wh-#touchWidth
ret|#S
EndIf
ProcedureReturn ret
EndProcedure
Procedure setResizeCursor(flag.l)
If flag=#N Or flag=#S
SetCursor_(hC_N)
ElseIf flag=#W Or flag=#O
SetCursor_(hC_O)
ElseIf flag=(#W|#N) Or flag=(#S|#O)
SetCursor_(hC_SO)
ElseIf flag=(#S|#W) Or flag=(#N|#O)
SetCursor_(hC_NO)
EndIf
EndProcedure
Procedure resizeWin(flag.l)
Protected wx=WindowX(0)
Protected wy=WindowY(0)
Protected ww=WindowWidth(0)
Protected wh=WindowHeight(0)
Protected x=wx
Protected y=wy
Protected w=ww
Protected h=wh
If GetAsyncKeyState_(#VK_LBUTTON)&(1<<15)
If flag&#W
x=dmx
w=ww+(wx-x)
ElseIf flag&#O
x=wx
w=dmx-wx
EndIf
If flag&#N
y=dmy
h=wh+(wy-y)
ElseIf flag&#S
y=wy
h=dmy-wy
EndIf
If w<#WinWidthMin
w=#WinWidthMin
x=wx
EndIf
If h<#WinHeightMin
h=#WinHeightMin
y=wy
EndIf
ResizeWindow(0 ,x,y,w,h)
EndIf
EndProcedure
Procedure refreshSize()
Protected ww=WindowWidth(0)
Protected wh=WindowHeight(0)
ResizeGadget(0, ww-#touchWidth-50, #touchWidth, 50,20) ; exit-button
ResizeGadget(1, ww-#touchWidth-50-4-50, #touchWidth, 50,20) ; move-button
EndProcedure
@ Biedermeier:
#PB_Window_ResizeGadget und #PB_Window_BorderLess sind wie #Feuer und #Wasser oder #Katze und #Maus... Um ein fenster zu resizen, bedarf es einer #Titelleiste.
#PB_Window_ResizeGadget und #PB_Window_BorderLess sind wie #Feuer und #Wasser oder #Katze und #Maus... Um ein fenster zu resizen, bedarf es einer #Titelleiste.

PB 4.30
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
So geht es auch :
Code: Alles auswählen
hwnd = OpenWindow(0,0,0,300,300,"",#WS_SIZEBOX|#PB_Window_BorderLess)
Repeat
event = WaitWindowEvent()
Until event = 16 ; ohne titelleiste wird es schwer :D
son code is doch mal was , womit man was anfangen kannedel hat geschrieben:So geht es auch :
Code: Alles auswählen
hwnd = OpenWindow(0,0,0,300,300,"",#WS_SIZEBOX|#PB_Window_BorderLess) Repeat event = WaitWindowEvent() Until event = 16 ; ohne titelleiste wird es schwer :D
