Author Topic: adding pictureBox when clicking a butten  (Read 1666 times)

arbel

  • Jr. Member
  • **
  • Posts: 62
adding pictureBox when clicking a butten
« on: November 15, 2009, 03:41:38 PM »
Hi

I want to add a picture box that has the picture that is on the butten that was pressed. I want that a new pictureBox will appeer avary time I  click the butten but in a different place. here is the code I got so far:
Code: [Select]
STATIC PUBLIC pics AS PictureBox
STATIC PUBLIC pic_num AS Integer

PUBLIC SUB _new()

END

PUBLIC SUB Form_Open()
pic_num = 0

END


PUBLIC SUB btnUp_Click()
'DIM pics AS NEW PictureBox[100]
DIM old_x AS Integer
DIM old_y AS Integer

DIM myPic AS Picture
myPic = btnUp.Picture
pics = NEW PictureBox(ME)
pics.Name = pic_num
pics.Border = 2
pics.Height = 38
pics.Width = 38
pics.x = old_x + 40
pics.y = old_y + 40
pics.Picture = myPic
old_x = pics.X
old_y = pics.Y
pic_num = pic_num + 1

   
 

END

the problem is that each time I click the butten, i get only one picture box at the same place.

Thanks
Arbel

Linux Basic

adding pictureBox when clicking a butten
« on: November 15, 2009, 03:41:38 PM »

buster7

  • Newbie
  • *
  • Posts: 26
Re: adding pictureBox when clicking a butten
« Reply #1 on: November 17, 2009, 06:07:53 AM »
You need to declare old_x And old_y  at the beginning of the program every time you click the button
they are recreated and end up being zero

arbel

  • Jr. Member
  • **
  • Posts: 62
Re: adding pictureBox when clicking a butten
« Reply #2 on: November 19, 2009, 04:26:07 PM »
And now, a new problem:

I got this function that create a button when I press a button.
I want that when I press a button that I just created (there will be a few of them) that specific button will be deleted.
how is it done????

here is the function (the function works...)
Code: [Select]
PUBLIC SUB pic(pict AS Picture, back AS Integer, speed AS Integer, delay AS Integer)

DIM myPic AS Picture

myPic = pict
pics = NEW button(ME)
pics.Name = pic_num
pics.Border = 2
pics.Height = 38
pics.Width = 38
pics.x = old_x
pics.y = old_y + 40
pics.Picture = myPic
pics.Background = back
pics.Enabled = TRUE
old_x = pics.X
old_y = pics.Y
pic_num = pic_num + 1
pics.ToolTip = "מהירות " & speed & " השהיה " & delay

thanks
Arbel

buster7

  • Newbie
  • *
  • Posts: 26
Re: adding pictureBox when clicking a butten
« Reply #3 on: November 20, 2009, 02:21:37 AM »
not sure what you are trying to do?
maybe some more Explanation?

arbel

  • Jr. Member
  • **
  • Posts: 62
Re: adding pictureBox when clicking a butten
« Reply #4 on: November 20, 2009, 03:07:02 AM »
I am creating buttons via code during runtime. after I created some buttons I want to delete some of them during runtime. Let's say i made 10 buttons during runtime and now I wont to delete the second and fourth button by cilcking them. Hoe do I get the specific button I clicked so that I can send it the DELETE comand?

buster7

  • Newbie
  • *
  • Posts: 26
Re: adding pictureBox when clicking a butten
« Reply #5 on: November 28, 2009, 03:03:57 AM »