Click function

Discussion in 'Questions (Windows Mobile)' started by neilnapier, Oct 31, 2007.

  1. neilnapier

    neilnapier Active Member Licensed User

    Well... I'm making my first program on the ppc and I was using the function Click on image boxes to change the colour of them. On the computer it works perfectly but then on the ppc the image boxes don't show up at all, so I can't click on them. This is my code...

    Code:
    Sub Globals

    End Sub

    Sub App_Start
       Form1.Show
    End Sub

    Sub Image2_Click
    Image2.color = 
    255,0,0
    End Sub
    Sub Image3_Click
    Image3.color = 
    255,0,0
    End Sub
    Sub Image4_Click
    Image4.color = 
    255,0,0
    End Sub
    Sub Image5_Click
    Image5.color = 
    255,0,0
    End Sub
    Sub Image6_Click
    Image6.color = 
    255,0,0
    End Sub
    Sub Image7_Click
    Image7.color = 
    255,0,0
    End Sub
    Sub Image8_Click
    Image8.color = 
    255,0,0
    End Sub
    Sub Image9_Click
    Image9.color = 
    255,0,0
    End Sub
    Sub Image10_Click
    Image10.color = 
    255,0,0
    End Sub
    Sub Image11_Click
    Image11.color = 
    255,0,0
    End Sub
    Sub Image12_Click
    Image12.color = 
    255,0,0
    End Sub
    Sub Image13_Click
    Image13.color = 
    255,0,0
    End Sub
    Sub Image14_Click
    Image14.color = 
    255,0,0
    End Sub
    Sub Image15_Click
    Image15.color = 
    255,0,0
    End Sub
    Sub Image16_Click
    Image16.color = 
    255,0,0
    End Sub
    Sub Image17_Click
    Image17.color = 
    255,0,0
    End Sub
    Sub Image18_Click
    Image18.color = 
    255,0,0
    End Sub
    Sub Image19_Click
    Image19.color = 
    255,0,0
    End Sub
    Sub Image20_Click
    Image20.color = 
    255,0,0
    End Sub
    Sub Image21_Click
    Image21.color = 
    255,0,0
    End Sub
    Sub Image22_Click
    Image22.color = 
    255,0,0
    End Sub
    Sub Image23_Click
    Image23.color = 
    255,0,0
    End Sub
    Sub Image24_Click
    Image24.color = 
    255,0,0
    End Sub
    Sub Image25_Click
    Image25.color = 
    255,0,0
    End Sub
    Sub Image26_Click
    Image26.color = 
    255,0,0
    End Sub
    Sub Image27_Click
    Image27.color = 
    255,0,0
    End Sub
    Sub Image28_Click
    Image28.color = 
    255,0,0
    End Sub
    Sub Image29_Click
    Image29.color = 
    255,0,0
    End Sub
    Sub Image30_Click
    Image30.color = 
    255,0,0
    End Sub
    Sub Image31_Click
    Image31.color = 
    255,0,0
    End Sub
    Sub Image32_Tap
    Image32.color = 
    255,0,0
    End Sub

    Sub Form1_Show

    End Sub
    Thanks for any help you can give me!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload your source code as a file?
    BTW, you can change your code to:
    Code:
    Sub App_Start
     Form1.Show
     
    For i = 2 to 32
      AddEvent(
    "Image" & i, Click, "ImageClick")
     
    Next
    End Sub

    Sub ImageClick
     
    Sender.Color = cRed
    End Sub
    It is a bit shorter ;)
    See this tutorial for more information: http://www.basic4ppc.com/forum/showthread.php?t=907
     
  3. neilnapier

    neilnapier Active Member Licensed User

    That is a bit shorter... lol!

    I'll upload it as a source code... here you go
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Your code works fine here.
    What device are you using?
    If it is a Pocket PC 2002 or WM2003 (not SE) then you should install .Net CF 1.0 SP3.
     
  5. neilnapier

    neilnapier Active Member Licensed User

    I'll try installing it... my pocket pc is normal 2003.

    How would you do it so that it is single pixels (instead of boxes) that can be draged on?

    EDIT: it works now... thanks! Now however when it is on my pocket pc the boaxes are a bit spaced out randomly.
     
    Last edited: Oct 31, 2007
  6. Erel

    Erel Administrator Staff Member Licensed User

    What are you trying to achieve?
     
  7. neilnapier

    neilnapier Active Member Licensed User

    Have you ever heard of the game Falling Sand?

    Something along the lines of that... (of course as I have just started to learn how to code so it will take a while) but that is what I hope to achieve.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    You should draw directly on the form.
    Use Form_MouseDown / MouseMove / MouseUp events.
     
  9. agraham

    agraham Expert Licensed User

    Erel - I've remarked on this before. You seem still to be under the impression that all 2003SE based devices come with SP3. This is not so. The Axim X30, for one, comes with only SP2 in ROM and requires SP3 to be installed for B4PPC to operate correctly.
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    I wasn't accurate earlier but .Net CF 1.0 SP2 is also fine for Basic4ppc.
     
  11. Cableguy

    Cableguy Expert Licensed User

    I wonder if its not only a "bringTo Front" issue...hum...
     
  12. agraham

    agraham Expert Licensed User

    Apoplogies Erel - I thought it was for B4PPC that I needed SP3 installed to get working properly but if SP2 is OK then it must have been some other application that needed it.
     
  13. neilnapier

    neilnapier Active Member Licensed User

    OK... i'm doing better, but I have another glitch... when I press run it comes up

    Object Reference not set to an instance of an object... with this code

    Code:
    Sub App_Start
     BurningSand.Show
     
    For i = 1 to 75
      AddEvent(
    "Image" & i, Click, "ImageClick")
     
    Next
    End Sub

    Sub ImageClick
     
    Sender.Color = cGray
    End Sub
    I don't want to send the file because it has images and I don't know if it saves it in the file itself.


    EDIT: Nevermind sorted it!


    How do you restart an app (eg having a restart button)
     
    Last edited: Nov 3, 2007
Loading...