whenever I click on my combobox, it passes a MENU_CLICK event with event data for the first 2 cases. Is this a bug, or is it something I'm doing wrong?
Here's the code:
sync on:autocam off:position camera 0, 0, -20.0:backdrop on
startblue "***", "****"
#constant crlf = chr$(13) + chr$(10)
global oax# as float
global oay# as float
global oaz# as float
global cz# as float
global mnuMain
global mnuFile
global mnuOpt
global col
global winRes
gosub createUI
do:getevent
col = point(1, 1)
keys(scancode())
mouse()
gosub sel
if eventtype() = 0x111
gosub menu
endif
if eventsource() = cmdOK and eventtype() = MOUSE_CLICK
i = selecteditem(cboRes)
res$ = itemtext(cboRes, i)
if len(res$) = 10
a = val(left$(res$, 4))
b = val(mid$(res$, 5) + mid$(res$, 6) + mid$(res$, 7) + mid$(res$, 8))
c = val(right$(res$, 2))
endif
if len(res$) = 9
a = val(left$(res$, 4))
b = val(mid$(res$, 5) + mid$(res$, 6) + mid$(res$, 7))
c = val(right$(res$, 2))
endif
if len(res$) = 8
a = val(left$(res$, 3))
b = val(mid$(res$, 4) + mid$(res$, 5) + mid$(res$, 6))
c = val(right$(res$, 2))
endif
if check display mode(a, b, c)
set display mode a, b, c
else
errormessage "Display mode not available."
endif
endif
if eventsource() = cmdCan and eventtype() = MOUSE_CLICK then setgadgetvisible winRes, 0
sync:loop
createUI:
winRes = createwindow(100, 100, 300, 100, "Resolution", WINDOW_FIXED, 0, 0, 0)
setgadgetvisible winRes, 0
lbl = createlabel(5, 20, 100, 20, "Resolution", winRes)
cboRes = createcombobox(125, 20, 100, 20, winRes)
cmdOK = createbutton(185, 45, 50, 30, "OK", 0, winRes)
cmdCan = createbutton(245, 45, 50, 30, "Cancel", 0, winRes)
mnuMain = createmenu(0)
addmenuitem mnuMain, "File", 1
mnuFile = createsubmenu(mnuMain, 1)
addmenuitem mnuFile, "Open F2", 10
addmenuitem mnuFile, "Save Shot Enter", 11
addmenusplitter mnuFile
addmenuitem mnuFile, "Exit", 12
addmenuitem mnuMain, "Options", 2
mnuOpt = createsubmenu(mnuMain, 2)
addmenuitem mnuOpt, "Backdrop Color F3", 20
addmenuitem mnuOpt, "Resolution F4", 21
addmenuitem mnuMain, "Help", 3
return
function open()
file$ = opendialog("Load Object", "DBO|*.dbo|DirectX|*.x|3DS|*.3ds")
if object exist(1) then delete object 1
if image exist(1) then delete image 1
if file$ = "" then exitfunction
if right$(file$, 2) <> ".x" and right$(file$, 4) <> ".dbo" and right$(file$, 4) <> ".3ds"
message "Error", "File type not currently supported."
else
load object file$, 1
oax# = object angle x(1)
oay# = object angle y(1)
oaz# = object angle z(1)
endif
endfunction
function keys(code as integer)
select code
case 28
if image exist(1) then delete image 1
if x2 > x3 and y2 > y3 then get image 1, x3, y3, x2, y2
if x2 > x3 and y2 < y3 then get image 1, x3, y2, x2, y3
if x2 < x3 and y2 > y3 then get image 1, x2, y3, x3, y2
if x2 < x3 and y2 < y3 then get image 1, x2, y2, x3, y3
if x2 = x3 and y2 = y3 or x2 = 0 and y2 = 0 and x3 = 0 and y3 = 0 then get image 1, 0, 0, screen width(), screen height()
save$ = savedialog("Save Image", "Bitmap|*.bmp|Jpeg|*.jpg|DDS|*.dds|DIB|*.dib")
if save$ <> ""
if file exist(save$)
answer = questionmessage("Do you want to overwrite " + crlf + save$, "Overwrite?")
if answer = 0 then save$ = savedialog("Save Image", "Bitmap|*.bmp|Jpeg|*.jpg|DDS|*.dds|DIB|*.dib")
if answer = 1
delete file save$
save image save$, 1
endif
if answer <> 0 and answer <> 1 then `do nothing
else
save image save$, 1
endif
else
`do nothing
endif
endcase
case 57
point object 1, oax#, oay#, oaz#
endcase
case 59
message "Help", "F1 - Help" + crlf + "F2 - Load an object." + crlf + "F3 - Change background color." + crlf + "F4 - Change Resolution." + crlf + "Enter - take screenshot." + crlf + "Space Bar - Reset object to original Rotation." + crlf + "Hold right mouse button and move mouse to rotate object." + crlf + "Mouse wheel zooms in and out."
endcase
case 60
open()
endcase
case 61
color = colordialog()
if color = rgb(255, 255, 255)
color = col
endif
color backdrop 0, color
if color = 16777215
ink 0, 0
else
ink rgb(255, 255, 255), 0
endif
endcase
case 62:
perform checklist for display modes
for dis = 1 to checklist quantity()
additem cboRes, str$(checklist value a(dis)) + " x " + str$(checklist value b(dis)) + " x " + str$(checklist value c(dis))
next dis
empty checklist
setgadgetvisible winRes, 1
endcase
endselect
endfunction
function mouse()
mc = mouseclick()
mmx# = mousemovex()
mmy# = mousemovey()
mmz# = mousemovez()
if mc = 2
if mmx# > 0 then yrotate object 1, wrapvalue(object angle y(1) - 1.0)
if mmx# < 0 then yrotate object 1, wrapvalue(object angle y(1) + 1.0)
if mmy# > 0 then xrotate object 1, wrapvalue(object angle x(1) - 1.0)
if mmy# < 0 then xrotate object 1, wrapvalue(object angle x(1) + 1.0)
endif
if mmz# > 0 then move camera 0, 1.0
if mmz# < 0 then move camera 0, -1.0
endfunction
menu:
select eventdata()
case 3:
keys(59)
endcase
case 10:
open()
endcase
case 11:
keys(28)
endcase
case 12:
end
endcase
case 20:
keys(61)
endcase
case 21:
keys(62)
endcase
endselect
return
sel:
mx = mousex()
my = mousey()
mc = mouseclick()
global x2
global y2
global x3
global y3
while mc = 1
mc = mouseclick()
mxnew = mousex()
mynew = mousey()
line mx, my, mxnew, my
line mxnew, my, mxnew, mynew
line mxnew, mynew, mx, mynew
line mx, my, mx, mynew
sel1 = 1
x = mx
y = my
x1 = mxnew
y1 = mynew
sync
endwhile
x2 = x
x3 = x1
y2 = y
y3 = y1
if mc = 0 and mxnew > 0 and mynew > 0 and sel1 = 1
line x, y, x1, y
line x1, y, x1, y1
line x1, y1, x, y1
line x, y, x, y1
else
x = 0
y = 0
x1 = 0
y1 = 0
sel1 = 0
endif
return
I know the code looks sloppy, but if anyone can help, it would be much appreciated.
I have a lil' white jacket that lets me hug myself forever.