Window With Border Without Caption

Just starting out? Need help? Post your questions and find answers here.
User avatar
Michael Vogel
Addict
Addict
Posts: 2819
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Window With Border Without Caption

Post by Michael Vogel »

Rashad, thanks a lot, works perfect now :wink:
User avatar
mk-soft
Always Here
Always Here
Posts: 6313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window With Border Without Caption

Post 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:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 486
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Window With Border Without Caption

Post 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
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
mk-soft
Always Here
Always Here
Posts: 6313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window With Border Without Caption

Post by mk-soft »

Something has changed in the CanvasGadget.
Probably that there are no duplicate events from TextGadget and CanvasGadget.
Probably had a reason...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 486
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Window With Border Without Caption

Post 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
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Window With Border Without Caption

Post 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
Egypt my love
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 486
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Window With Border Without Caption

Post 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
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Window With Border Without Caption

Post 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

Egypt my love
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 486
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Window With Border Without Caption

Post 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: )
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Window With Border Without Caption

Post by RASHAD »

You are welcome :D
Egypt my love
Post Reply