custom dragbar

BlitzPlus Forums/BlitzPlus Programming/custom dragbar

CS_TBL(Posted 2003) [#1]
It sounds little silly perhaps, but with some tweaking, it;s possible to create your own customized window. The problem here is that when dragging/resizing using my own dragbar, the window will be repositioned at the top y ooord, or top y, left x coord.. (just run it, makes more sense :).. I've watched it so long, I just don't see it anymore :) anyone a suggestion?
-----------------------------------

APP=CreateWindow("app",0,0,640,480):MaximizeWindow APP

win=CreateWindow("win",160,32,384,256,APP,1)

windrag=CreateCanvas(0,ClientHeight(win)-32,ClientWidth(win),32,win)
SetGadgetLayout windrag,0,0,0,1

choice=CreateButton("[ ]=size [x]=drag",32,32,128,16,APP,2)
SetButtonState choice, 1

;dragbar
dragIMG=CreateImage(4,4):SetBuffer ImageBuffer(dragIMG)
Color 192,192,192:Rect 0,0,4,4,True
Color 240,240,240:Plot 1,1
Color 144,144,144:Plot 2,2
SetBuffer CanvasBuffer(windrag):ClsColor 192,64,16:Cls:TileBlock dragIMG:FlipCanvas windrag

Repeat

WaitEvent()

; drag ?
If EventSource()=windrag
If EventID()=$201 ; mouse down
If Not drag
oldx=EventX()
oldy=EventY()
drag=True
EndIf
EndIf
If EventID()=$202 ; mouse up
drag=False
EndIf
If drag
If EventID()=$203 ; mouse move
newx=EventX()
newy=EventY()
If ButtonState(choice)
SetGadgetShape win,GadgetX(win)+newx-oldx,GadgetY(win)+newy-oldy,GadgetWidth(win),GadgetHeight(win)
Else
SetGadgetShape win,GadgetX(win),GadgetY(win),GadgetWidth(win),GadgetHeight(win)+newy-oldy
EndIf
EndIf
EndIf
EndIf


If KeyHit(1) Exit
Forever

FreeImage dragIMG
FreeGadget windrag
FreeGadget app

End

-----------------------------------


cyberseth(Posted 2003) [#2]
Try this instead: (use MouseX,Mousey)

APP=CreateWindow("app",0,0,640,480):MaximizeWindow APP 

win=CreateWindow("win",160,32,384,256,APP,1) 

windrag=CreateCanvas(0,ClientHeight(win)-32,ClientWidth(win),32,win) 
SetGadgetLayout windrag,0,0,0,1 

choice=CreateButton("[ ]=size [x]=drag",32,32,128,16,APP,2) 
SetButtonState choice, 1 

;dragbar 
dragIMG=CreateImage(4,4):SetBuffer ImageBuffer(dragIMG) 
Color 192,192,192:Rect 0,0,4,4,True 
Color 240,240,240:Plot 1,1 
Color 144,144,144:Plot 2,2 
SetBuffer CanvasBuffer(windrag):ClsColor 192,64,16:Cls:TileBlock dragIMG:FlipCanvas windrag 

Repeat 
	
	WaitEvent() 
	
	; drag ? 
	If EventSource()=windrag 
		If EventID()=$201 ; mouse down 
			If Not drag 
				oldx=MouseX() 
				oldy=MouseY() 
				drag=True 
			EndIf 
		EndIf 
		If EventID()=$202 ; mouse up 
			drag=False 
		EndIf 
		If drag 
			If EventID()=$203 ; mouse move 
				newx=MouseX()
				newy=MouseY() 
				If ButtonState(choice) 
					SetGadgetShape win,GadgetX(win)+newx-oldx,GadgetY(win)+newy-oldy,GadgetWidth(win),GadgetHeight(win) 
				Else
					SetGadgetShape win,GadgetX(win),GadgetY(win),GadgetWidth(win),GadgetHeight(win)+newy-oldy 
				EndIf
				oldx=newx oldy=newy
			EndIf 
		EndIf 
	EndIf 
	
	
	If KeyHit(1) Exit 
Forever 

FreeImage dragIMG 
FreeGadget windrag 
FreeGadget app 

End 


P.S. You're a Film/Game composer too? That's great! Feel free to check out my tunes at www.cyberseth.tk -- Also note, me and a group of other composers are starting up an organisation called "The Composers Cooperative" which is an online base for linking up composers with producers. If you're interested I'll let you know when it's ready so you can sign up and showcase your work..?


CS_TBL(Posted 2003) [#3]
I mostly do film and tv leaders here in NL, atm I'm doing music for the biggest teleshopping tv channel here ..

Here's a link with my remake of 3 Konami tunes. (the whole game is a remake) Note that the originals use 3 square-sound channels for music.. my versions use.. kinda.. 'more' than 3 channels :)

http://www.braingames.getput.com/mog/downloads/wolf-sound.zip