Restored from previous forum. Originally posted by pusztry.
Is there a way to change the cursor when you are over the grabber? I think this would help clarify when to try and resize or more a gadget.
- Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra
Drag'n'Drop?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
The windows XP theme ads 7 pixels to the caption of the window.
So mouse positions are not correct.
just test this, it works here even when switching theme when app is running.
Regards,
Berikco
http://www.benny.zeb.be/purebasic.htm
The windows XP theme ads 7 pixels to the caption of the window.
So mouse positions are not correct.
just test this, it works here even when switching theme when app is running.
Code: Select all
Global XP
XP = 4+GetSystemMetrics_(#SM_CYSIZE)
Structure boxjes
x.l
y.l
EndStructure
Dim selpoint.boxjes(8)
Structure gdgets
id.l
type.l
x.l
y.l
w.l
h.l
t.s
EndStructure
Dim db.gdgets(10)
num=1
db(num)\id=num
db(num)\type=1 ;textgadget
db(num)\x=20
db(num)\y=10
db(num)\w=100
db(num)\h=20
db(num)\t="Hoegaarden"
num+1
db(num)\id=num
db(num)\type=2 ;stringgadget
db(num)\x=20
db(num)\y=40
db(num)\w=200
db(num)\h=20
db(num)\t="Goedendag allemaal, voor mij een pintje"
num+1
db(num)\id=num
db(num)\type=3 ;buttongadget
db(num)\x=150
db(num)\y=190
db(num)\w=100
db(num)\h=20
db(num)\t="Beer Here"
num+1
db(num)\id=num
db(num)\type=4 ;panelgadget
db(num)\x=250
db(num)\y=20
db(num)\w=150
db(num)\h=150
db(num)\t=""
num+1
db(num)\id=num
db(num)\type=5 ;frame3dgadget
db(num)\x=10
db(num)\y=250
db(num)\w=300
db(num)\h=100
db(num)\t="Empty Bottle"
Global numgadget, SelectedGadget, BoxW, MouseDown, SelectedPoint, imagehandle
numgadget=5
#Color=$F5080A
#ColorS=$1351EC
BoxW=7
Global hwnd
hwnd=OpenWindow(0,100,350,400,400, #PB_Window_SystemMenu ,"BeerGUI")
Procedure Clear_screen()
b.RECT
b\right=WindowWidth()
b\bottom=WindowHeight()
InvalidateRect_(hwnd,@b,1)
sendmessage_(hwnd,#WM_PAINT,0,0)
EndProcedure
Procedure redraw()
For s=1 To numgadget
Select db(s)\type
Case 1
TextGadget (db(s)\id, db(s)\x, db(s)\y, db(s)\w, db(s)\h, db(s)\t)
Case 2
StringGadget (db(s)\id, db(s)\x, db(s)\y, db(s)\w, db(s)\h, db(s)\t)
Case 3
ButtonGadget (db(s)\id, db(s)\x, db(s)\y, db(s)\w, db(s)\h, db(s)\t)
Case 4
PanelGadget (db(s)\id, db(s)\x, db(s)\y, db(s)\w, db(s)\h)
Case 5
Frame3DGadget (db(s)\id, db(s)\x, db(s)\y, db(s)\w, db(s)\h, db(s)\t, 0)
EndSelect
Next s
EndProcedure
Procedure draw_sizer()
If SelectedGadget
StartDrawing(WindowOutput())
DrawingMode(4)
Box(db(SelectedGadget)\x-1,db(SelectedGadget)\y-1,db(SelectedGadget)\w+2,db(SelectedGadget)\h+2,#Color)
selpoint(1)\x = db(SelectedGadget)\x-BoxW
selpoint(1)\y = db(SelectedGadget)\y-BoxW
selpoint(2)\x = db(SelectedGadget)\x+db(SelectedGadget)\w
selpoint(2)\y = db(SelectedGadget)\y-BoxW
selpoint(3)\x = db(SelectedGadget)\x+db(SelectedGadget)\w
selpoint(3)\y = db(SelectedGadget)\y+db(SelectedGadget)\h
selpoint(4)\x = db(SelectedGadget)\x-BoxW
selpoint(4)\y = db(SelectedGadget)\y+db(SelectedGadget)\h
selpoint(5)\x = db(SelectedGadget)\x+(db(SelectedGadget)\w/2)-BoxW/2
selpoint(5)\y = db(SelectedGadget)\y-BoxW
selpoint(6)\x = db(SelectedGadget)\x+(db(SelectedGadget)\w/2)-BoxW/2
selpoint(6)\y = db(SelectedGadget)\y+db(SelectedGadget)\h
selpoint(7)\x = db(SelectedGadget)\x+(db(SelectedGadget)\w)
selpoint(7)\y = db(SelectedGadget)\y+(db(SelectedGadget)\h/2)-BoxW/2
selpoint(8)\x = db(SelectedGadget)\x-BoxW
selpoint(8)\y = db(SelectedGadget)\y+(db(SelectedGadget)\h/2)-BoxW/2
DrawingMode(0)
Box(selpoint(1)\x, selpoint(1)\y, BoxW, BoxW, #ColorS)
Box(selpoint(2)\x, selpoint(2)\y, BoxW, BoxW, #Color)
Box(selpoint(3)\x, selpoint(3)\y, BoxW, BoxW, #Color)
Box(selpoint(4)\x, selpoint(4)\y, BoxW, BoxW, #Color)
Box(selpoint(5)\x, selpoint(5)\y, BoxW, BoxW, #Color)
Box(selpoint(6)\x, selpoint(6)\y, BoxW, BoxW, #Color)
Box(selpoint(7)\x, selpoint(7)\y, BoxW, BoxW, #Color)
Box(selpoint(8)\x, selpoint(8)\y, BoxW, BoxW, #Color)
StopDrawing()
EndIf
EndProcedure
Procedure moved()
If MouseDown
XP=4+GetSystemMetrics_(#SM_CYSIZE)
x=WindowMouseX()-2
y=WindowMouseY()-XP ; looks like XP got wider borders
Select SelectedPoint
Case 1
;extra=db(SelectedGadget)\x - x
db(SelectedGadget)\x = x
;db(SelectedGadget)\w = db(SelectedGadget)\w + extra
;extra=db(SelectedGadget)\y - y
db(SelectedGadget)\y = y
;db(SelectedGadget)\h = db(SelectedGadget)\h + extra
Case 2
db(SelectedGadget)\w = x-db(SelectedGadget)\x
extra=db(SelectedGadget)\y - y
db(SelectedGadget)\y = y
db(SelectedGadget)\h = db(SelectedGadget)\h + extra
Case 3
db(SelectedGadget)\w = x-db(SelectedGadget)\x
db(SelectedGadget)\h = y-db(SelectedGadget)\y
Case 4
extra=db(SelectedGadget)\x - x
db(SelectedGadget)\x = x
db(SelectedGadget)\w = db(SelectedGadget)\w + extra
db(SelectedGadget)\h = y-db(SelectedGadget)\y
Case 5
extra=db(SelectedGadget)\y - y
db(SelectedGadget)\y = y
db(SelectedGadget)\h = db(SelectedGadget)\h + extra
Case 6
db(SelectedGadget)\h = y-db(SelectedGadget)\y
Case 7
db(SelectedGadget)\w = x-db(SelectedGadget)\x
Case 8
extra=db(SelectedGadget)\x - x
db(SelectedGadget)\x = x
db(SelectedGadget)\w = db(SelectedGadget)\w + extra
EndSelect
If selectedpoint>0 And selectedpoint=selpoint(s)\x And x=selpoint(s)\y And y<=selpoint(s)\y+BoxW
SelectedPoint=s
MouseDown=1
s=9
result=0
DisableGadget(SelectedGadget,1)
EndIf
Next s
If MouseDown=0
For s=1 To numgadget
If ChildWindowFromPoint_(hwnd,x,y) = GadgetID(db(s)\id)
SelectedGadget = db(s)\id
s=NumGadget
Clear_screen()
draw_sizer()
result = 0
EndIf
Next s
EndIf
Case #WM_MOUSEMOVE
Moved()
Case #WM_LBUTTONUP
If MouseDown
If SelectedGadget
ResizeGadget(db(SelectedGadget)\id, db(SelectedGadget)\x, db(SelectedGadget)\y, db(SelectedGadget)\w, db(SelectedGadget)\h)
Clear_screen()
draw_sizer()
DisableGadget(SelectedGadget,0)
EndIf
EndIf
MouseDown=0
SelectedPoint=0
Case #WM_PAINT
;draw_sizer()
Default
;Debug message
EndSelect
ProcedureReturn Result
EndProcedure
If CreateGadgetList(WindowID())
redraw()
SetWindowCallback(@myCallback())
Repeat
EventID=WaitWindowEvent()
If EventID = #PB_EventGadget
SelectedGadget=EventGadgetID()
Clear_screen()
draw_sizer()
EndIf
Until EventID = #PB_EventCloseWindow
EndIfRegards,
Berikco
http://www.benny.zeb.be/purebasic.htm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
Hi Bericko
This new one works great here.
To avoid that everything is repainted with any movement of the gadget you can only repaint the lines and the points... i know its demand to store the position of every line and point and then invalidate the rect of every one and repaint only this part of the screen, but the result is more 'stable'.
Im coding myself a little gui builder on PB if you want (or anybody) to check my code or maybe give me some feedback, send me an email to [url]mailto:ricardoarias@yahoo.com">ricardoarias@yahoo.com (sendinf mails from the forums dosent works anymore!!).
I have found some solutions to make the gui-builder works smooth on every gadget but still have some bugs
A small example that drags/resize almost every gadget (still have bugs and dont generate any code, tis just a test)
Feedback (ideas and helping hands) are welcome!!
Best Regards
Ricardo
Dont cry for me Argentina...
Hi Bericko
This new one works great here.
To avoid that everything is repainted with any movement of the gadget you can only repaint the lines and the points... i know its demand to store the position of every line and point and then invalidate the rect of every one and repaint only this part of the screen, but the result is more 'stable'.
Im coding myself a little gui builder on PB if you want (or anybody) to check my code or maybe give me some feedback, send me an email to [url]mailto:ricardoarias@yahoo.com">ricardoarias@yahoo.com (sendinf mails from the forums dosent works anymore!!).
I have found some solutions to make the gui-builder works smooth on every gadget but still have some bugs
A small example that drags/resize almost every gadget (still have bugs and dont generate any code, tis just a test)
Feedback (ideas and helping hands) are welcome!!
Best Regards
Ricardo
Dont cry for me Argentina...
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
In fact Windows offers itself a way to resize gadgets. Its comfortable since windows manage all the resize stuff transparently, but...
Its not 'elegant' but work well with most gadgets, but some -combo per example- cant get rid off some line that stay there, take a look:
Best Regards
Ricardo
Dont cry for me Argentina...
In fact Windows offers itself a way to resize gadgets. Its comfortable since windows manage all the resize stuff transparently, but...
Its not 'elegant' but work well with most gadgets, but some -combo per example- cant get rid off some line that stay there, take a look:
Code: Select all
If OpenWindow(0, 10, 10, 450, 450, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
ButtonGadget(0, 10, 10, 150, 25, "Resize Mode= Off",#PB_Button_Default|#PB_Button_Toggle)
ButtonGadget(1, 200, 100, 120, 25, "Drag Me")
ComboBoxGadget(2,160,60,80,75,"Combobox5")
MessageRequester("Info","Click the gadget that you want to resize and the push the design button",0)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case 0
If Selected = 0
Selected = 1
EndIf
Style = GetWindowLong_(GadgetID(Selected),#GWL_STYLE)
If OldStyle 0
SetWindowLong_(GadgetID(Selected),#GWL_STYLE,OldStyle)
SetWindowPos_(GadgetID(Selected),0,GadgetX(Selected),GadgetY(Selected),GadgetWidth(Selected),GadgetHeight(Selected),#SWP_SHOWWINDOW)
OldStyle = 0
HideGadget(Selected,1);Neccesary to dissapear the frame of the button (why?)
HideGadget(Selected,0)
SetGadgetText(Selected,"Drag Me")
SetGadgetText(0,"Resize Mode= Off")
SetWindowText_(WindowID(),"Resize Mode: OFF")
Else
OldStyle.l = Style
Style = Style + #WS_THICKFRAME
SetWindowLong_(GadgetID(Selected),#GWL_STYLE,Style)
SetWindowPos_(GadgetID(Selected),0,0,0,0,0,#SWP_NOZORDER | #SWP_NOSIZE | #SWP_NOMOVE | #SWP_DRAWFRAME)
SetGadgetText(Selected,"Resize Me")
SetGadgetText(0,"Resize Mode= On")
SetWindowText_(WindowID(),"Resize Mode: ON")
EndIf
Default
If EventGadgetID() >= 1;Just can resize both controls
Selected.l = EventGadgetID()
Else
Selected = 1
EndIf
EndSelect
Case #WM_MOUSEMOVE
GetCursorPos_(mouse.POINT)
Handle = ChildWindowFromPoint_(WindowID(),mouse\x-5,mouse\y-30);the handle of the gadget that has the mouse over
If Handle = GadgetID(1); Just drag the designeable butto
ReleaseCapture_()
SendMessage_(GadgetID(1), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
ElseIf Handle = GadgetID(2); Just drag the designeable button
DisableGadget(2,0)
ReleaseCapture_()
SendMessage_(GadgetID(2), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
EndSelect
Until EventID = #PB_EventCloseWindow
EndIf
; ExecutableFormat=
Best Regards
Ricardo
Dont cry for me Argentina...