Page 2 of 2

Re: Window With Border Without Caption

Posted: Wed Jul 04, 2018 4:04 pm
by Michael Vogel
Rashad, thanks a lot, works perfect now :wink:

Re: Window With Border Without Caption

Posted: Wed Jul 04, 2018 6:55 pm
by mk-soft
Now without API and moving window

Update
- Bugfix moving

Code: Select all

;-TOP by mk-soft ;)

Procedure MovingWindowCB()
  Static winpos_x, pos_x, delta_x
  Static winpos_y, pos_y, delta_y
  Static move

  Select EventType()
    Case #PB_EventType_LeftButtonDown
      winpos_x = WindowX(0)
      winpos_y = WindowY(0)
      pos_x = DesktopMouseX()
      pos_y = DesktopMouseY()
      move = #True
    Case #PB_EventType_LeftButtonUp
      move = #False
    Case #PB_EventType_MouseMove
      If move
        delta_x = pos_x - DesktopMouseX()
        delta_y = pos_y - DesktopMouseY()
        ResizeWindow(0, winpos_x - delta_x, winpos_y - delta_y, #PB_Ignore, #PB_Ignore)
      EndIf  
  EndSelect
  
EndProcedure


If OpenWindow(0, 0, 0, 800, 600, "ContainerGadget", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
  SetWindowColor(0, $00008B)
  CanvasGadget(0, 4, 4, WindowWidth(0) - 8, WindowHeight(0) - 8, #PB_Canvas_Border | #PB_Canvas_Container)
  ButtonGadget(1, GadgetWidth(0) - 36, 0, 32, 32, "X")
  
  ButtonGadget(2, 10, 15, 80, 24, "Button 1")
  ButtonGadget(3, 95, 15, 80, 24, "Button 2")
  CloseGadgetList()
  
  BindGadgetEvent(0, @MovingWindowCB(), #PB_All)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Break
        EndSelect
        
    EndSelect
  ForEver
  
EndIf
:wink:

Re: Window With Border Without Caption

Posted: Wed Oct 15, 2025 8:26 am
by Mindphazer
Hello mk-soft
I've been using your code in one of my apps
Since PB 6.21, something has changed. When there is a textgadget inside the CanvasGadget, clicking inside the textgadget to move the window doesn't work anymore. You have to click outside the textgadget.

Try this code with PB 6.20 and PB 6.21 to see the difference :

Code: Select all

;-TOP by mk-soft ;)

Procedure MovingWindowCB()
  Static winpos_x, pos_x, delta_x
  Static winpos_y, pos_y, delta_y
  Static move

  Select EventType()
    Case #PB_EventType_LeftButtonDown
      winpos_x = WindowX(0)
      winpos_y = WindowY(0)
      pos_x = DesktopMouseX()
      pos_y = DesktopMouseY()
      move = #True
    Case #PB_EventType_LeftButtonUp
      move = #False
    Case #PB_EventType_MouseMove
      If move
        delta_x = pos_x - DesktopMouseX()
        delta_y = pos_y - DesktopMouseY()
        ResizeWindow(0, winpos_x - delta_x, winpos_y - delta_y, #PB_Ignore, #PB_Ignore)
      EndIf  
  EndSelect
  
EndProcedure


If OpenWindow(0, 0, 0, 800, 600, "ContainerGadget", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
  SetWindowColor(0, $00008B)
  CanvasGadget(0, 4, 4, WindowWidth(0) - 8, WindowHeight(0) - 8, #PB_Canvas_Border | #PB_Canvas_Container)
  ButtonGadget(1, GadgetWidth(0) - 36, 0, 32, 32, "X")
  
  ButtonGadget(2, 10, 15, 80, 24, "Button 1")
  ButtonGadget(3, 95, 15, 80, 24, "Button 2")
  TextGadget(4, 10, 150, GadgetWidth(0) - 20, 200, "Test")
  CloseGadgetList()
  
  BindGadgetEvent(0, @MovingWindowCB(), #PB_All)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Break
        EndSelect
        
    EndSelect
  ForEver
  
EndIf

Re: Window With Border Without Caption

Posted: Wed Oct 15, 2025 1:36 pm
by mk-soft
Something has changed in the CanvasGadget.
Probably that there are no duplicate events from TextGadget and CanvasGadget.
Probably had a reason...

Re: Window With Border Without Caption

Posted: Wed Oct 15, 2025 1:41 pm
by Mindphazer
Yes, i'm not sure it can be called a "bug"
But it was very useful in my application.. So i have to compile with 6.20 :|

And there's the same bahaviour in PB6.30

Re: Window With Border Without Caption

Posted: Wed Oct 15, 2025 9:47 pm
by RASHAD
For Windows it's easy using API
For MAC Maybe
The code not supporting DPI

Code: Select all

Procedure MovingWindowCB()
  DisableGadget(4,1)
  Static winpos_x, pos_x, delta_x
  Static winpos_y, pos_y, delta_y
  Static move

  Select EventType()
    Case #PB_EventType_LeftButtonDown
      winpos_x = WindowX(0)
      winpos_y = WindowY(0)
      pos_x = DesktopMouseX()
      pos_y = DesktopMouseY()
      move = #True      
    Case #PB_EventType_LeftButtonUp
      move = #False
      DisableGadget(4,0)
    Case #PB_EventType_MouseMove
      If move
        delta_x = pos_x - DesktopMouseX()
        delta_y = pos_y - DesktopMouseY()
        ResizeWindow(0, winpos_x - delta_x, winpos_y - delta_y, #PB_Ignore, #PB_Ignore)
      EndIf  
  EndSelect
  
EndProcedure

Re: Window With Border Without Caption

Posted: Thu Oct 16, 2025 7:53 am
by Mindphazer
Thanks Rashad, it works, but the TextGadget stays disabled, whatever you do

By the way, this problem doesn't occur on MacOS, even with PB6.21. So it seems related to CanvasGadget on Windows

Re: Window With Border Without Caption

Posted: Thu Oct 16, 2025 8:44 am
by RASHAD
Hi Mindphazer
I thought that you are asking for MAC :D
Like I said it's easy for WINDOWS

Code: Select all

;-TOP by mk-soft ;)

Procedure MovingWindowCB()
  Static winpos_x, pos_x, delta_x
  Static winpos_y, pos_y, delta_y
  Static move

  Select EventType()
    Case #PB_EventType_LeftButtonDown
      winpos_x = WindowX(0)
      winpos_y = WindowY(0)
      pos_x = DesktopMouseX()
      pos_y = DesktopMouseY()
      move = #True
    Case #PB_EventType_LeftButtonUp
      move = #False
    Case #PB_EventType_MouseMove
      If move
        delta_x = pos_x - DesktopMouseX()
        delta_y = pos_y - DesktopMouseY()
        ResizeWindow(0, winpos_x - delta_x, winpos_y - delta_y, #PB_Ignore, #PB_Ignore)
      EndIf  
  EndSelect
  
EndProcedure


If OpenWindow(0, 0, 0, 800, 600, "ContainerGadget", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
  SetWindowColor(0, $00008B)
  CanvasGadget(0, 4, 4, WindowWidth(0) - 8, WindowHeight(0) - 8, #PB_Canvas_Border | #PB_Canvas_Container)
  ButtonGadget(1, GadgetWidth(0) - 36, 0, 32, 32, "X")
  
  ButtonGadget(2, 10, 15, 80, 24, "Button 1")
  ButtonGadget(3, 95, 15, 80, 24, "Button 2")
  TextGadget(4, 10, 150, GadgetWidth(0) - 20, 200, "Test")
  SetWindowLongPtr_(GadgetID(4),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(4),#GWL_STYLE)&~ #SS_NOTIFY)
  CloseGadgetList()   
  
  SetGadgetText(4," Hi Mindphazer")
  SetGadgetColor(4,#PB_Gadget_BackColor,0)
  SetGadgetColor(4,#PB_Gadget_FrontColor,$FFFFFF)
  
  BindGadgetEvent(0, @MovingWindowCB(), #PB_All)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Break
        EndSelect
        
    EndSelect
  ForEver
  
EndIf


Re: Window With Border Without Caption

Posted: Thu Oct 16, 2025 9:19 am
by Mindphazer
It works fine, thanks a lot

(Yeah, i'm using a Mac at home, but here it was for my work, on Windows :mrgreen: )

Re: Window With Border Without Caption

Posted: Thu Oct 16, 2025 9:37 am
by RASHAD
You are welcome :D