Some GREAT RASHAD.....like usually
Thanks for sharing
New Update :Windows Hand Made TitleBar (Windows)
- Kwai chang caine
- Always Here
- Posts: 5357
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: New Update :Windows Hand Made TitleBar (Windows)
The happiness is a road...
Not a destination
Not a destination
Re: New Update :Windows Hand Made TitleBar (Windows)
@KCC
Thank you very much
I updated the code see next
1- No more ToolBar the event loop is very slow and it is ugly after all
2- The code now compatible with PB x86,x64
3- Standard behavior for Maximized window (no Move no Resize)
4- Free to do any thing with the TitleBar
And more
I am trying to make it Prototype window for me
I will leave the previous as it is for comparison reason
Do not forget the DataSection
Thank you very much
I updated the code see next
1- No more ToolBar the event loop is very slow and it is ugly after all
2- The code now compatible with PB x86,x64
3- Standard behavior for Maximized window (no Move no Resize)
4- Free to do any thing with the TitleBar
And more
I am trying to make it Prototype window for me
I will leave the previous as it is for comparison reason
Code: Select all
Global x,y,cap,bor,oldl,oldt,oldr,oldb,maxflag,r.RECT,r2.RECT,im1.RECT,im2.RECT,im3.RECT,im4.RECT
Procedure WTButton(Posx)
StartDrawing(WindowOutput(2))
DrawingMode(#PB_2DDrawing_XOr)
Box(Posx,0,24,24)
StopDrawing()
EndProcedure
Procedure WndProc(hwnd, uMsg, wParam, lParam)
GetWindowRect_(WindowID(1),r.RECT)
x = r\left
y = r\top + 2
h = (r\bottom-r\top-cap-bor-35) ;35 = Gadget Height = 25 + Clearance = 10
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_WINDOWPOSCHANGED
Case #WM_SETTINGCHANGE
If maxflag = 1
SystemParametersInfo_(#SPI_GETWORKAREA, 0,r2.RECT, 0)
ResizeWindow(1,r2\left,r2\top,r2\right-r2\left-bor,r2\bottom-r2\top-cap-bor)
ElseIf maxflag = 0
ResizeWindow(1,oldl,oldt,oldr-oldl,oldb-oldt)
EndIf
Case #WM_GETMINMAXINFO
*pMinMax.MINMAXINFO = lParam
*pMinMax\ptMinTrackSize\x=300
*pMinMax\ptMinTrackSize\y=80
Case #WM_MOVING,#WM_SIZING
If maxflag = 1
SystemParametersInfo_(#SPI_GETWORKAREA, 0,r2.RECT, 0)
*wr.Rect = lparam
If *wr\left <= r2\left
*wr\left = r2\left
*wr\right = r2\right
EndIf
If *wr\Top < r2\top
*wr\Top = r2\top
*wr\bottom = r2\bottom
EndIf
If *wr\right >= r2\right
*wr\left = r2\left
*wr\right = r2\right
EndIf
If *wr\bottom >= r2\bottom-cap-bor Or *wr\bottom <= r2\bottom-cap-bor
*wr\Top = r2\top
*wr\bottom = r2\bottom
EndIf
EndIf
Case #WM_SIZE,#WM_MOVE,#WM_PAINT
ResizeWindow(2,x,y,r\right-r\left,26)
ResizeGadget(1,(r\right- r\left)/2 - 70,0,140,24)
ResizeGadget(2,r\right- r\left -120,0,r\right-r\left,24)
ResizeGadget(10,10,h,80,25)
ResizeGadget(11,100,h,80,25)
GetWindowRect_(WindowID(2),r2.RECT)
im1\top = r2\top + 3
im1\left = r2\right - 120
im1\right = im1\left + 24
im1\bottom = im1\top + 20
im2\top = r2\top + 3
im2\left = r2\right - 90
im2\right = im2\left + 25
im2\bottom = im2\top + 20
im3\top = r2\top + 3
im3\left = r2\right - 60
im3\right = im3\left + 25
im3\bottom = im3\top + 20
im4\top = r2\top + 3
im4\left = r2\right - 30
im4\right = im4\left + 25
im4\bottom = im4\top + 20
EndSelect
ProcedureReturn result
EndProcedure
x = 0
y = 0
w = 450
h = 300
CatchImage(0, ?Exit)
CatchImage(1, ?Expand)
CatchImage(2, ?Globe)
CatchImage(3, ?Blue_key)
ResizeImage(0, 16,16)
ResizeImage(1, 16,16)
ResizeImage(2, 16,16)
ResizeImage(3, 16,16)
CreateImage(4,30,24)
CreateImage(5,140,24)
CreateImage(6,114,24)
StartDrawing(ImageOutput(4))
Box(0,0,30,24,#White)
Circle(15,13,10,#Black)
Circle(15,13,6,#Red)
Circle(15,13,2,#Yellow)
StopDrawing()
StartDrawing(ImageOutput(5))
Box(0,0,140,24,#White)
DrawingMode(#PB_2DDrawing_Transparent )
DrawText(2, 4,"Hand Made Window",$000000,$FFFFFF)
DrawText(0, 5,"Hand Made Window",$CAFFFF)
StopDrawing()
StartDrawing(ImageOutput(6))
Box(0,0,114,24,#White)
DrawImage(ImageID(0),94,4)
Box(86,5,2,16,$979797)
DrawImage(ImageID(1),64,4)
Box(56,5,2,16,$979797)
DrawImage(ImageID(2),34,4)
Box(26,5,2,16,$979797)
DrawImage(ImageID(3),4,4)
StopDrawing()
OpenWindow(1,x,y,w,h,"",#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
StickyWindow(1,1)
cap = GetSystemMetrics_(#SM_CYCAPTION)
bor = 2*GetSystemMetrics_(#SM_CYFRAME)
ButtonGadget(10,0,0,0,0,"TEST")
ButtonGadget(11,0,0,0,0,"QUIT")
OpenWindow(2,0,0,0,0,"",#WS_POPUP|#PB_Window_BorderLess,WindowID(1))
SetWindowColor(2,#White)
ImageGadget(0,5,0,30,24,ImageID(4))
ImageGadget(1,140,0,140,24,ImageID(5))
ImageGadget(2,330,0,0,24,ImageID(6))
SetWindowLong_(WindowID(2),#GWL_EXSTYLE,GetWindowLong_(WindowID(2),#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(2),#White,0,#LWA_COLORKEY)
SetWindowCallback(@WndProc())
InvalidateRect_(WindowID(1),0,1)
SetActiveWindow(1)
Repeat
SetActiveWindow(1)
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 10
Case 11
Q = 1
EndSelect
Case #WM_MOUSEMOVE,#WM_NCMOUSEMOVE
RedrawWindow_(GadgetID(2),#Null,#Null,#RDW_INVALIDATE|#RDW_UPDATENOW)
GetCursorPos_(@p.POINT)
If GetKeyState_(#VK_LBUTTON) = 1
mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
EndIf
If PtInRect_(@im1,PeekQ(@p))
WTButton(r2\right - r2\left - 120)
If GetKeyState_(#VK_LBUTTON) & $8000 = 0 And GetKeyState_(#VK_LBUTTON) = 1
Debug "Fourth Button Pressed"
EndIf
ElseIf PtInRect_(@im2,PeekQ(@p))
WTButton(r2\right - r2\left - 90)
If GetKeyState_(#VK_LBUTTON) & $8000 = 0 And GetKeyState_(#VK_LBUTTON) = 1
Debug "Third Button Pressed"
EndIf
ElseIf PtInRect_(@im3,PeekQ(@p))
WTButton(r2\right - r2\left - 60)
If GetKeyState_(#VK_LBUTTON) And maxflag = 0
GetWindowRect_(WindowID(1),r.RECT)
SystemParametersInfo_(#SPI_GETWORKAREA, 0,r2.RECT, 0)
oldt = r\top
oldl = r\left
oldr = r\right
oldb = r\bottom
maxflag = 1
ResizeWindow(1,r2\left,r2\top,r2\right-r2\left-bor,r2\bottom-r2\top-cap-bor)
ElseIf GetKeyState_(#VK_LBUTTON)
maxflag =0
ResizeWindow(1,oldl,oldt,oldr-oldl,oldb-oldt)
RedrawWindow_(GadgetID(2),#Null,#Null,#RDW_INVALIDATE|#RDW_UPDATENOW)
EndIf
ElseIf PtInRect_(@im4,PeekQ(@p))
WTButton(r2\right - r2\left - 30)
If GetKeyState_(#VK_LBUTTON)
Q =1
EndIf
EndIf
EndSelect
Until Q = 1
;Copy DataSection from previous post in here
Egypt my love
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: New Update :Windows Hand Made TitleBar (Windows)
Great stuff.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system