KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

to Shawn: hotspots inside picturebox

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
pgilardi
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Oct 2003
Posts: 11
Location: Milano - Italy

PostPosted: Tue Nov 18, 2003 12:32 pm    Post subject: to Shawn: hotspots inside picturebox Reply with quote

it will be possible in next release to add hotspots over pictureboxes ?
Of course programmable hotspot objects : this to allow execute code while
mouse-over or mouse-click to the hotspot itself.
thanks,
paolo
Back to top
View user's profile Send private message
Chris S.
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 05 Mar 2003
Posts: 241

PostPosted: Tue Nov 18, 2003 2:51 pm    Post subject: Reply with quote

You should use $pbox.MouseX and $pbox.MouseY to get the coordinates of the mouse over your picuturebox object. You should be able to get your "hotspots" from that.
Back to top
View user's profile Send private message MSN Messenger
Bryce
KiXforms Supporter
KiXforms Supporter


Joined: 26 Mar 2003
Posts: 69

PostPosted: Wed Dec 03, 2003 9:32 pm    Post subject: Reply with quote

I asked for this too Very Happy

the problem with using $pbox.MouseX and $pbox.MouseY for your own hot sports become painful if you have a large picture that has a lot of hot spots.

The painful part really happens in mouse-over events... since the entire time that the mouse is over the picture it is firing off mouse-over event like crazy... and you have to code for a $pbox.MouseX and $pbox.MouseY check for every event that is generated just to catch when the mouse is over one of your hot spots.... and your hotspot will most likely be a wide area not just one or 2 points...

as for mouse-click events.... this is not so CPU intensive as a mouse-over event. But you still have to run a check against the current mouse x/y and see if it falls in one of your hotspots.

I had a project that I never finished that would have benefited greatly from this feature request.

Bryce
Back to top
View user's profile Send private message
Bryce
KiXforms Supporter
KiXforms Supporter


Joined: 26 Mar 2003
Posts: 69

PostPosted: Thu Dec 04, 2003 9:29 pm    Post subject: Reply with quote

ahh i found that project that i would love to have had hot spots for Smile

http://jumpgate.isorg.com/StationMap%20kix%20code.zip

I have... what... 127 hot spots on that bmp image Smile
Back to top
View user's profile Send private message
Bert
KiXforms Regular
KiXforms Regular


Joined: 06 Oct 2003
Posts: 56
Location: Netherlands

PostPosted: Tue Dec 09, 2003 12:47 am    Post subject: Reply with quote

Bryce wrote:
ahh i found that project that i would love to have had hot spots for Smile

http://jumpgate.isorg.com/StationMap%20kix%20code.zip

I have... what... 127 hot spots on that bmp image Smile


Hi,

I have done some rewriting on your code. It loads faster and reacts faster to a mouseclick. Also the display and handling of the popup is a little more stable.

Code:

break on

global $label[]

loadgui
LoadstationData
LoadData

While $gui.Visible
  $=Execute($gui.DoEvents())
Loop
exit(0)


Function LoadGUI
   $gui = createobject("Kixtart.form")
   if @error <> 0
      dim $yesno
      if @inwin = 2
         $systemroot = readvalue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion","systemroot")
         $systemroot = $systemroot+"\system"
      else
         $systemroot = "%systemroot%"
         $systemroot = $systemroot + "\system32"
      endif
   
      if exist(kixforms.dll)
         $yesno = messagebox('I need to install KixForms.dll.' +@crlf+@crlf+
                 'would you like to try to install the dll now?',"Attention!",48+4)
         if $yesno = 6
            shell '%comspec% /c $systemroot\regsvr32 kixforms.dll'
            IF @ERROR = 0
               $gui = createobject("Kixtart.form")
               if @error <> 0
                  $nul = messagebox("FatalError!","FatalError!",48)
               endif
            else
               $nul = messagebox("FatalError! Unable to install kixforms.dll","FatalError!",48)
               exit(0)
         ENDIF
         else
            $null = messagebox("Unable to Load KixForms.dll program halted","Attention",48)
            exit(0)
         endif
   
      endif
   endif


   if readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","SyncMode5") <> 3
      dim $yesno
      $yesno = messagebox('This program uses parts of IE5 to gather its' + @crlf +
            'information.  For increased performance it is' + @crlf +
            'recommended that the settings for' + @crlf +
            '"Temporary Internet files", be set to "Every' + @crlf +
            'Visit to a page".' + @crlf + @crlf +
            ' Would you like me to make this change now?',"Attention!",48+4)
      if $yesno = 6
         $nul = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","SyncMode5","3","reg_dword")
         if @error = 0
            $nul = messagebox("Change to IE was successful","Attention!",48)
         else
         $nul = messagebox("Unable to make change to IE","Attention!",48)
         endif
      else
         $nul = messagebox("Change was not made","Attention",48)
      endif
   endif

   $gui.clientsize    = 800,630
   $gui.center
   
   $image         = $gui.picturebox()
   $image.picture      = "map.bmp"
   $image.width      = 800
   $image.height      = 579
   $image.top      = 50
   $image.onmousemove   = "Map_mousemove($$image.mousex,$$image.mouseY)"
   $image.OnClick      = "Map_Click($$image.mousex,$$image.mouseY)"

   $MousePos       = $gui.label("",750,2,0,0)
   $MouseSec      = $gui.label("",650,2,70,0)

   $gui.show
   $gui.topmost = 1
   $gui.topmost = 0
endfunction

function map_mousemove($x,$y)
   $mousepos.caption = "$x,$y"
endfunction

function Map_Click($x,$y)
   dim $sec, $array, $secvar, $sectorstations
   for each $sec in $sectors
      $secvar = split($sec,"|")[0]
      $ = execute("$$array = $$$secvar")
      if $x >= val($array[0])-9 and $x <= val($array[0])+10 and $y >= val($array[1])-9 and $y <= val($array[1])+10
         $mousesec.caption = $secvar
         $sectorstations = getsectorstations(split($sec,"|")[2])

         if ubound($sectorstations) >= 0
            ? "popup"
            ? popup($gui.left+$image.left+$x,$gui.top+$image.top+$y+10,$sectorstations)
         endif
         exit(0)
      endif
   next
endfunction

function popup($x,$y,$dataarray)
   dim $o_popup, $x, $y, $i, $objectdata, $width, $lastwidth, $oldobject, $top, $close
   $o_popup = createobject("Kixtart.form")
   $o_popup.border = 0
   $o_popup.location = $x,$y
   $o_popup.onmousemove = "o_popupmouseover($$dataarray,-1,$$black,$$black)"

   $blue = $o_popup.rgb(50,0,238)
   $black = $o_popup.rgb(0,0,0)

   $close = $o_popup.label("X",0,0,0,0)
   $close.width = $close.width
   $close.onmousemove = "o_popupmouseover($$dataarray,-1,$$black,$$black)"
   $close.onclick = "$$o_popup=0 $$popup=-1"

   redim $label[ubound($dataarray)]
   $top = $close.bottom
   for $i = 0 to ubound($dataarray)
      $label[$i] = $o_popup.label ($dataarray[$i], 0, $top)
      $label[$i].width = $label[$i].width+5
      $label[$i].onmousemove = 'o_popupmouseover($$dataarray,$i,$blue,$black)'
      $label[$i].onclick = "$$popup = $i $$o_popup = 0"
      if $label[$i].width > $lastwidth
         $lastwidth = $label[$i].width + 6
      endif
      $top = $label[$i].bottom
   next

   for $i = 0 to ubound($label)
      $label[$i].width = $lastwidth
   next

   $o_popup.clientheight = $label[ubound($dataarray)].bottom
   $o_popup.width = $lastwidth

   $close.left = $lastwidth - $close.width-10
   $o_popup.show
   While $o_popup.Visible
     $=Execute($o_popup.DoEvents())
   Loop
endfunction

function o_popupMouseOver($array,$pointer,$oncolor, $offcolor)
   for $i = 0 to ubound($array)
      if $i = $pointer
         if $label[$i].forecolor <> $blue
            $label[$i].forecolor = $blue
         endif
      else
         if $label[$i].forecolor <> $black
            $label[$i].forecolor = $black
         endif
      endif
   next
endfunction

function GetSectorStations($sec)
   dim $pos,$line1, $i, $temparray, $stationname, $stationstats

   ? $sec
   $temparray = $pos_inv
   for each $pos in $pos_inv
      $pos = split($pos,chr(10))
      
      $StationName = substr(split($pos[0],'",')[0],2)
      $stationStats= split(split($pos[0],'",')[1],",")

      ;? $stationName
      ;? join($stationstats,",")

      if $stationstats[2] = $sec
         $temparray[$i] = $stationname
         $i = $i + 1
      endif
   next
   if $i > 0
      redim preserve $temparray[$i-1]
   else
      $temparray = -1
   endif
   $getsectorstations = $temparray
endfunction

function LoadData
   dim $temp, $temp2, $i, $load, $progbar, $label, $thing, $secname, $c
   $i = 1

   $load = createobject("Kixtart.form")
   $load.border = 0
   $load.clientsize = 320,50
   $label = $load.label
   $label.top=0
   $label.left = 0
   $label.fontsize=6
   $label.height=15
   $label.caption = "Loading Map.."
   
   $load.center
   $load.show

   $progbar = $load.progressbar("",10,15,300,20)
   $progbar.style=1

   $sectors = split(readprofilestring(".\data.ini","map-sectors",""),chr(10))
   redim preserve $sectors[ubound($sectors)-1]

   $progbar.max = ubound($sectors)

   for $c = 0 to ubound($sectors)
      $progbar.value = $c
      $sectors[$c] = $sectors[$c] + "|" + readprofilestring(".\data.ini","map-sectors",$sectors[$c])
      $temp = split(split($sectors[$c],"|")[1],",")
      $secname = split($sectors[$c],"|")[0]
      $ = execute("$$$secname = $$temp")
   next
endfunction

function LoadstationData
   ;the published stations list
   ;http://www.jossh.com/database/inventory/pos_inv.txt

   if not $josshdownload
      $josshdownload = createobject("microsoft.xmlhttp")
      if @Error <> 0
         exit(@error)
      endif
   endif

   $josshdownload.open("GET", "http://www.jossh.com/database/inventory/pos_inv.txt",not 1)
   $josshdownload.send

   if $josshdownload.responsetext
      $POS_INV = split($josshdownload.responsetext,chr(10)+chr(13)+chr(10))
      redim preserve $pos_inv[ubound($pos_inv)-1]
;      ? ubound($pos_inv)   
;      for each $pos in $pos_inv
;         ? split($pos,chr(10))[0]
;      next
   endif
endfunction


Hope this helps a little.

_________________
Bert

There are 10 kinds of people. Those who can count binary and those who can't.
Back to top
View user's profile Send private message
Bryce
KiXforms Supporter
KiXforms Supporter


Joined: 26 Mar 2003
Posts: 69

PostPosted: Wed Dec 10, 2003 3:10 pm    Post subject: Reply with quote

wow.... Bert.... just wow!!

nice changes!! and you are right, much faster on the load time since you are not building an entire array table of all possible x/y hot spots, and only doing a check with one line on a onclick event.

and nice trick on the popup... i will have to remember that.

Smile

Bryce
Back to top
View user's profile Send private message
Bryce
KiXforms Supporter
KiXforms Supporter


Joined: 26 Mar 2003
Posts: 69

PostPosted: Wed Dec 10, 2003 3:21 pm    Post subject: Reply with quote

ahhh i see.... the reworked popup udf requires a global array.... I think the effect i was going after was to have a UDF that 100% self contained... but had to settle for a 2 part UDF Smile

I will play with these ideas and see what i can come up with Smile
Back to top
View user's profile Send private message
Bert
KiXforms Regular
KiXforms Regular


Joined: 06 Oct 2003
Posts: 56
Location: Netherlands

PostPosted: Wed Dec 10, 2003 10:06 pm    Post subject: Reply with quote

Hi Bryce,

The $1, $2 to $n you created with the execute statement were global to.
Only this was less obvious.
You could declare $label in the popup itself and give it a more special name so it wont interfere with other global variables.
Something like: global $popup_label[]
That way the popup function would still be self contained.

Even better would be to dim the $label array inside popup and pass it as a parameter to o_popupmouseover.
(Functions can't reference arrays that are not global and not declared inside the function.)
This way the popup would be completely selfcontained.

The popup function and o_popmouseover functions would then look like this.

Code:

function popup($x,$y,$dataarray)

   dim $_label[]

   dim $o_popup, $x, $y, $i, $objectdata, $width, $lastwidth, $oldobject, $top, $close
   $o_popup = createobject("Kixtart.form")
   $o_popup.border = 0
   $o_popup.location = $x,$y
   $o_popup.onmousemove = "o_popupmouseover($$label, $$dataarray,-1,$$black,$$black)"

   $blue = $o_popup.rgb(50,0,238)
   $black = $o_popup.rgb(0,0,0)

   $close = $o_popup.label("X",0,0,0,0)
   $close.width = $close.width
   $close.onmousemove = "o_popupmouseover($$label, $$dataarray,-1,$$black,$$black)"
   $close.onclick = "$$o_popup=0 $$popup=-1"

   redim $label[ubound($dataarray)]
   $top = $close.bottom
   for $i = 0 to ubound($dataarray)
      $label[$i] = $o_popup.label ($dataarray[$i], 0, $top)
      $label[$i].width = $label[$i].width+5
      $label[$i].onmousemove = 'o_popupmouseover($$label, $$dataarray,$i,$blue,$black)'
      $label[$i].onclick = "$$popup = $i $$o_popup = 0"
      if $label[$i].width > $lastwidth
         $lastwidth = $label[$i].width + 6
      endif
      $top = $label[$i].bottom
   next

   for $i = 0 to ubound($label)
      $label[$i].width = $lastwidth
   next

   $o_popup.clientheight = $label[ubound($dataarray)].bottom
   $o_popup.width = $lastwidth

   $close.left = $lastwidth - $close.width-10
   $o_popup.show
   While $o_popup.Visible
     $=Execute($o_popup.DoEvents())
   Loop
endfunction

function o_popupMouseOver($label, $array,$pointer,$oncolor, $offcolor)
   for $i = 0 to ubound($array)
      if $i = $pointer
         if $label[$i].forecolor <> $blue
            $label[$i].forecolor = $blue
         endif
      else
         if $label[$i].forecolor <> $black
            $label[$i].forecolor = $black
         endif
      endif
   next
endfunction

_________________
Bert

There are 10 kinds of people. Those who can count binary and those who can't.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group