I have a custom shaped window that I want to move around. I turn the entire window into a gadget and move it around based on desktop coords ... I read:
http://forum.thegamecreators.com/?m=forum_view&t=66939&b=18
but using those same techniques it's not working.
The code below only moves the entire window when mouse button goes up and only if I am still under pnlCover1.
Also the pnlCover2 panel gadget transparency isn't working (set to 0 to be able to see 3d graphics thru it).
Thanks in advance!
global rox#
global roy#
global rCURRENTox#
global rCURRENToy#
global rLASTox#
global rLASToy#
global winGadgMain
global pnlCover1
global pnlCover2
global crox#
global croy#
global croz#
global btnCloseOn
global zox#
zox#=200
REM ************* Load tiny *****************
load object "Media\tiny.x",2
SCALE OBJECT 2, 25, 25, 25
SET OBJECT 2, 1, 100, 1, 0, 1, 0, 1
position object 2, 0, 0, 0
autocam off
set camera range 1,10000
position camera 0,0,-zox#
point camera 0,0,0
color backdrop black
REM *********** Create GUI ******************
createUI()
REM ************* MAIN LOOP *****************
do
getEvent
REM **Trying to get window *******
REM ** This code from RobK ** Thanks RobK
if (gadgetUnderMouse()=pnlCover1 and eventType()=LEFTBUTTON_DOWN)
dragging=1
offsetX=mousePosX(panelGadget)
offsetY=mousePosY(panelGadget)
endif
if (eventType()=MOUSE_MOVE and dragging=1)
positionGadget winGadgMain,mousePosX(desktopWindow())-offsetX,mousePosY(desktopWindow())-offsetY
endif
if (eventType()=LEFTBUTTON_UP)
dragging=0
endif
REM ***If mouse is in the drawing area move camera around **********
if gadgetUnderMouse() = winGadgMain
cameraMove()
endif
REM ** If upper right close button pressed pop close message ***
if eventType()=MOUSE_CLICK and gadgetUnderMouse()=btnCloseOn
questionMessage("Do you wish to exit?","Exit?")=1
exit
endif
REM ***Work around for window loosing focus problem **********
if SCREEN INVALID() = 1
bringToFront winGadgMain
bringToFront pnlCover1
bringToFront pnlCover2
bringToFront btnRotateOn
bringToFront btnCloseOn
endif
loop
end
`Create User Interface
`---------------------
function createUI()
If Not GUI_CONSTANTS Then errorMessage "GUI Constants not defined. gui.dba" : end
REM ********* Creates the custom window shape **********************
winGadgMain=createGadgetFromWindow(mainWindow())
setGadgetShape winGadgMain,"Media\GUI_Holder_1000x750_Mask.bmp"
pnlCover1=createPanel(-5,-23,1000,777,winGadgMain)
setGadgetShape pnlCover1,"Media\GUI_Holder_1000x750_Mask.bmp"
setPanelImage pnlCover1,"Media\Brilliant__GUI_4_1000x750.bmp"
pnlCover2=createPanel(0,0,1000,777,pnlCover1)
setGadgetShape pnlCover2,"Media\GUI_Holder_1000x750_SubMask.bmp"
setGadgetAlpha pnlCover2, 0
REM ************ ROTATE BUTTON ******************
btnRotateOn=createPanel(500,500,50,50,winGadgMain)
setGadgetShape btnRotateOn,"Media\Butt_Mask50.bmp"
setPanelImage btnRotateOn,"Media\Butt_Rotate_On.bmp"
bringToFront btnRotateOn
REM ************ Window Close BUTTON ******************
btnCloseOn=createPanel(904,72,922,106,winGadgMain)
setGadgetShape btnCloseOn,"Media\Close_Butt_Mask_25x25.bmp"
setPanelImage btnCloseOn,"Media\Close_Butt_On_25x25.bmp"
bringToFront btnCloseOn
endfunction
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents."
H. P. Lovecraft, "The Call of Cthulhu"