It is currently Sun Oct 25, 2020 3:21 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Borderless Window - Drag, Minimize, Close and TitleBar
PostPosted: Mon Aug 16, 2004 9:52 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
Code updated For 5.20+

I did not make this, the community did. I just searched the forum and put it all together. Thanks to GreenGiant for helping me on the minimizing. :D

Code:
#Win=0
#Button1=3
#Button2=4

Procedure SetFlat(gadgetnr)
  #BS_FLAT=$8000
  SetWindowLong_(GadgetID(gadgetnr),#GWL_STYLE,GetWindowLong_(GadgetID(gadgetnr),#GWL_STYLE) |#BS_FLAT)
EndProcedure

wnd = OpenWindow(#Win,0,0,400,300,"Borderless",#PB_Window_ScreenCentered | #PB_Window_BorderLess)


CreateImage(1, 398,28)

StartDrawing(ImageOutput(1))
Box(0,0,398,28, RGB(0,0,255))
BackColor(RGB(0,0,255))
FrontColor(RGB(255,255,255))
DrawText(10, 6,"Borderless")
StopDrawing()
ImageGadget(2, 1,1,398,28, ImageID(1))
DisableGadget(2,1)

ButtonGadget(#Button1,340,5,20,20,"_")
ButtonGadget(#Button2,370,5,20,20,"X")

FrameGadget(5, 0, 0, 400, 300, "", #PB_Frame_Flat)


SetFlat(3)
SetFlat(4)

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget
    GadgetID = EventGadget()
    Select GadgetID
       
      Case #Button1
        ShowWindow_(WindowID(#Win),#SW_MINIMIZE)
       
      Case #Button2
        End
       
    EndSelect
  EndIf
 
  If Event = #WM_LBUTTONDOWN
    SendMessage_(wnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
  EndIf
 
Until Event = #PB_Event_CloseWindow
End

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 1:39 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
No longer seems to work in the latest PB and I'm not sure why?

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 2:43 am 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5813
Location: Germany
The reason for this is that an ImageGadget now generates a Gadget event when
you click on it. (As a result, #WM_LBUTTONDOWN is no longer sent.)

Instead of doing it like this:
Code:
If Event = #WM_LBUTTONDOWN
   SendMessage_(wnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
EndIf


you must now catch the gadget event and act there:
Code:
  Case 2
    SendMessage_(wnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)

(inside the select statement)

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 3:33 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
Thanks freak but this new way kills because now the buttons don't work if there over an image gadget unless something about that needs changed as well?

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 4:24 am 
Offline
PureBatMan Forever
PureBatMan Forever
User avatar

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2307
Location: Ohio, USA
Try removing the #SS_NOTIFY from the ImageGadget...
Code:
SetWindowLong_(GadgetID(2), #GWL_STYLE, GetWindowLong_(GadgetID(2), #GWL_STYLE) &~#SS_NOTIFY)

_________________
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 9:41 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jul 09, 2003 11:33 am
Posts: 306
Location: France
to have a systemmenu with minimize available, you could use this :

Code:
wnd = OpenWindow(#Win,0,0,400,300,#PB_Window_ScreenCentered | #PB_Window_BorderLess | #WS_SYSMENU | #WS_MINIMIZEBOX,"Borderless")

_________________
LSI


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 3:21 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
Sparkie wrote:
Try removing the #SS_NOTIFY from the ImageGadget...
Code:
SetWindowLong_(GadgetID(2), #GWL_STYLE, GetWindowLong_(GadgetID(2), #GWL_STYLE) &~#SS_NOTIFY)


...

Le Soldat Inconnu wrote:
to have a systemmenu with minimize available, you could use this :
Code:
wnd = OpenWindow(#Win,0,0,400,300,#PB_Window_ScreenCentered | #PB_Window_BorderLess | #WS_SYSMENU | #WS_MINIMIZEBOX,"Borderless")


That doesn't help.

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 3:41 pm 
Offline
PureBatMan Forever
PureBatMan Forever
User avatar

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2307
Location: Ohio, USA
This works fine for me on WinXPhome SP2 / PB 3.93
Code:
#Win=0
#Button1=3
#Button2=4

Procedure SetFlat(gadgetnr)
  #BS_FLAT=$8000
  SetWindowLong_(GadgetID(gadgetnr),#gwl_style,GetWindowLong_(GadgetID(gadgetnr),#gwl_style) |#BS_FLAT)
EndProcedure

wnd = OpenWindow(#Win,0,0,400,300,#PB_Window_ScreenCentered | #PB_Window_BorderLess,"Borderless")
If CreateGadgetList(WindowID())
 
  CreateImage(1, 398,28)
  UseImage(1)
  StartDrawing(ImageOutput())
  Box(0,0,398,28, RGB(0,0,255))
  BackColor(0,0,255)
  FrontColor(255,255,255)
  Locate(10, 6)
  DrawText("Borderless")
  StopDrawing()
  ImageGadget(2, 1,1,398,28, UseImage(1))
 
  ButtonGadget(#Button1,340,5,20,20,"_")
  ButtonGadget(#Button2,370,5,20,20,"X")
 
  Frame3DGadget(5, 0, 0, 400, 300, "", #PB_Frame3D_Flat)
  SetWindowLong_(GadgetID(2), #gwl_style, GetWindowLong_(GadgetID(2), #gwl_style) &~#SS_NOTIFY)
EndIf

SetFlat(3)
SetFlat(4)

Repeat
  event = WaitWindowEvent()
  If event = #PB_EventGadget
    GadgetID = EventGadgetID()
    Select GadgetID
     
      Case #Button1
        ShowWindow_(WindowID(),#SW_MINIMIZE)
       
      Case #Button2
        End
       
    EndSelect
  EndIf
 
  If event = #WM_LBUTTONDOWN
    SendMessage_(wnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
  EndIf
 
Until event = #PB_Event_CloseWindow
End

_________________
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 29, 2005 4:19 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
Thanks Sparkie! :D

Your comment above confused me as it said to remove and not add the following line.

Code:
SetWindowLong_(GadgetID(2), #GWL_STYLE, GetWindowLong_(GadgetID(2), #GWL_STYLE) &~#SS_NOTIFY)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 30, 2005 2:52 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Oct 16, 2003 8:30 pm
Posts: 1998
Location: North Florida
Very nice code..

- np


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 20, 2005 6:34 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
Now it drags the window by the title bar and not the whole window. :wink:

Code:
#Win=0
#Button1=3
#Button2=4

Procedure SetFlat(gadgetnr)
  #BS_FLAT=$8000
  SetWindowLong_(GadgetID(gadgetnr),#gwl_style,GetWindowLong_(GadgetID(gadgetnr),#gwl_style) |#BS_FLAT)
EndProcedure

wnd = OpenWindow(#Win,0,0,400,300,#PB_Window_ScreenCentered | #PB_Window_BorderLess,"Borderless")
If CreateGadgetList(WindowID())
 
  CreateImage(1, 398,28)
  UseImage(1)
  StartDrawing(ImageOutput())
  Box(0,0,398,28, RGB(0,0,255))
  BackColor(0,0,255)
  FrontColor(255,255,255)
  Locate(10, 6)
  DrawText("Borderless")
  StopDrawing()
  ImageGadget(2, 1,1,398,28, UseImage(1))
 
  ButtonGadget(#Button1,340,5,20,20,"_")
  ButtonGadget(#Button2,370,5,20,20,"X")
 
  Frame3DGadget(5, 0, 0, 400, 300, "", #PB_Frame3D_Flat)
  SetWindowLong_(GadgetID(2), #gwl_style, GetWindowLong_(GadgetID(2), #gwl_style) &~#SS_NOTIFY)
EndIf

SetFlat(3)
SetFlat(4)

Repeat
  event = WaitWindowEvent()
  If event = #PB_EventGadget
    GadgetID = EventGadgetID()
    Select GadgetID
     
      Case #Button1
        ShowWindow_(WindowID(),#SW_MINIMIZE)
       
      Case #Button2
        End
       
    EndSelect
  EndIf
 
  For Xmouse = 0 To 400
   For Ymouse = 0 To 28
      If WindowMouseX() = Xmouse And WindowMouseY() = Ymouse And event = #WM_LBUTTONDOWN
         SendMessage_(wnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
      EndIf
   Next
  Next
 
Until event = #PB_Event_CloseWindow
End

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 20, 2005 4:11 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 997
Location: Canada
More optimized if you don't use For/Next loop to check every pixel :)

Code:
#Win=0
#Button1=3
#Button2=4

If OpenWindow(#Win,0,0,400,300,#PB_Window_ScreenCentered|#PB_Window_BorderLess|#WS_DLGFRAME,"Borderless")
  If CreateGadgetList(WindowID(#Win))
    CreateImage(1, 398,28)
    UseImage(1)
    StartDrawing(ImageOutput())
      Box(0,0,398,28, RGB(0,0,255))
      BackColor(0,0,255)
      FrontColor(255,255,255)
      Locate(10, 6)
      DrawText("Borderless")
    StopDrawing()
    ImageGadget(2, 1,1,398,28, UseImage(1))
 
    ButtonGadget(#Button1,350,5,20,20,"_")
    ButtonGadget(#Button2,375,5,20,20,"X")
 
    SetWindowLong_(GadgetID(2), #gwl_style, GetWindowLong_(GadgetID(2), #gwl_style) &~#SS_NOTIFY)
   
    Repeat
      Select WaitWindowEvent()
        Case #PB_EventGadget
          Select EventGadgetID()
            Case #Button1
              ShowWindow_(WindowID(#Win),#SW_MINIMIZE)
            Case #Button2
              quit=1
          EndSelect
   
        Case #WM_LBUTTONDOWN
          If WindowMouseX()<400 And WindowMouseY()<28
            SendMessage_(WindowID(#Win),#WM_NCLBUTTONDOWN, #HTCAPTION,0)
          EndIf
         
      EndSelect
    Until quit
  EndIf
EndIf

_________________
Image Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 20, 2005 5:16 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Apr 20, 2005 12:48 pm
Posts: 1104
Here is my small optimized version of Pauls version (this is 2,5k smaller :wink:
In this version even the buttons are directly visible !

Code:
#Win=0
#Button1=3
#Button2=4

If OpenWindow(#Win,0,0,400,300,#PB_Window_ScreenCentered|#PB_Window_BorderLess|#WS_DLGFRAME,"Borderless")
  If CreateGadgetList(WindowID(#Win))

    ButtonGadget(#Button1,350,5,20,20,"_")
    ButtonGadget(#Button2,375,5,20,20,"X")
 
    StartDrawing(WindowOutput())
      Box(0,0,398,28, RGB(0,0,255))
      BackColor(0,0,255)
      FrontColor(255,255,255)
      Locate(10, 6)
      DrawText("Borderless")
    StopDrawing()
   
    Repeat
      Select WaitWindowEvent()
        Case #PB_EventGadget
          Select EventGadgetID()
            Case #Button1
              ShowWindow_(WindowID(#Win),#SW_MINIMIZE)
            Case #Button2
              quit=1
          EndSelect
         
        Case #WM_LBUTTONDOWN
          If WindowMouseX()<400 And WindowMouseY()<28
            SendMessage_(WindowID(#Win),#WM_NCLBUTTONDOWN, #HTCAPTION,0)
          EndIf
         
      EndSelect
    Until quit
  EndIf
EndIf



Edit:
If you move the window, the blue titlebar will be destroyed! But you can check for #WM_Paint event and draw it new...

_________________
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye