Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Problem with AddEvent and ImageList


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-28-2008, 09:45 PM
Newbie
 
Join Date: Feb 2008
Location: Germany
Posts: 4
Default Problem with AddEvent and ImageList

I've a problem with the "ButtonDown" and "ButtonUp" Event

I set it with

AddEvent("ib"&j+i*3,ButtonDown,"frmNum_ButtonDown")

in a loop to serveral ImageButtons in RunTime. But they did not trigger.

In my routines I will change the look of those ImageButtons while they are pressed with a different Image from a ImageList.
If I set they with single events with the Designer it will work. If I use Click instead of ButtonDown or ButtonUp it will work too.

If the sub will be called, it will change the image, but it shows me a red rectangle with a cross in it.

Thanks for any help

If I send the image from the ImageList to the form, it will appear correctly.

I have no idea what's going on.

Maybe someone had the same trouble before and shares the solution or have another idea.
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 07:48 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Can you upload a small example that shows this problem?
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:28 PM
Newbie
 
Join Date: Feb 2008
Location: Germany
Posts: 4
Default

Hi Erel,

sure, here is my sample:

The following function will called to show form (it is a key pad with 3x4 ImageButtons)

Sub ShowNumForm
For i = 0 To 3 Step 1
For j = 1 To 3 Step 1
AddEvent("ib"&j+i*3,ButtonDown,"frmNum_ButtonDown" )
AddEvent("ib"&j+i*3,ButtonUp,"frmNum_ButtonUp")
AddEvent("ib"&j+i*3,Click,"frmNum_Click")[/indent]Next j
Next i
frmNum.Show
End Sub

Sub frmNum_ButtonDown
Sender.Image = il1.Item(3)
End Sub

Sub frmNum_ButtonUp
Sender.Image = il1.Item(2)
End Sub

Sub frmNum_Click
ValPanel.Text = ValPanel.Text & Sender.Text
End Sub

The il1 is a ImageList filled up with (serveral) Images for the buttons.
The ImageButtons are not created by AddImageButton Function, they are set with the designer.

The frmNum_Click Function will trigger if I press a button. But not the Button Up nor Down.
If I use the Designer to create the Events for one of those Buttons (Event for Up and Down) then it works.

But there I have my second problem. The Image will not changed or it get the wrong one. Actually I found that this will happens only if I use transparent. If it is not transparent, then the correct image will show on ButtonDown and Up.

If you could not exactly understand what I mean, I'm sorry for my english, lol.

Thanks for your help.
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 10:51 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default

Haschi, I've tried everything I know to make your code work, but cannot.

It seems that an ImageButton created in the Designer will respond normally to Click, ButtonUp, and ButtonDown events.

An ImageButton created dynamically can be made to respond to Click events, but not ButtonUp or ButtonDown events.

Perhaps you and I are using the wrong parameter for the event in AddEvent?

Code:
   controlName = "ib" & ( j+i*3 )

   AddEvent( controlName, ButtonDown, "fni_ButtonDown" )
   AddEvent( controlName, ButtonUp,   "fni_ButtonUp"   )
   AddEvent( controlName, Click,      "fni_Click"      )
Anyone see anything wrong with this?


Gary
__________________
PC: Windows XP Pro SP3 / Basic4PPC v6.5
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #5 (permalink)  
Old 03-01-2008, 05:27 AM
Newbie
 
Join Date: Feb 2008
Location: Germany
Posts: 4
Default

Hi Gary

Yes, that is what I mean too. If you take a look in the help file, you will see, that the ImageButton has the Events ButtonDown ButtonUp Click listed.

But if you look at AddEvent(), the ImageButton is not listet as a Control which support events.
My opinion was: There is the button listed and ImageButton is a member of buttons or buttons are the parent of it and ImageButton will inherit the same events. After a look at the designer by Events for a ImageButton, I found it there too. So for me it was clear. ImageButon has those three events.

Now I think it is forgotten to implement or the connections from the Button Class do not trigger correctly.

How ever, it is a work for Erel I think. You and me can't found a wrong code on this smal example and it is a quite easy one.

At time I use the FormEvent MouseDown(x,y) and MouseUp(x,y) for analysing the position and for to get my information which button is down or up.

Thanks for your help

Haschi
Reply With Quote
  #6 (permalink)  
Old 03-01-2008, 07:32 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

You are right. At this time it is not possible to add ButtonDown / ButtonUp events using AddEvent.
It will be supported in the next release.
Reply With Quote
  #7 (permalink)  
Old 03-01-2008, 09:22 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Erel View Post
You are right. At this time it is not possible to add ButtonDown / ButtonUp events using AddEvent.
Small correction, it is already available if you use DZT's Magic Events, see here dzEventsMagic (Post #13)
An example is given already

I think that I am also right in saying that catching the mouseup/down event on the form won't work when run on the device because the imagebutton blocks the event from happening, unlike on the desktop.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 03-01-2008, 12:06 PM
Newbie
 
Join Date: Feb 2008
Location: Germany
Posts: 4
Default

Thank you RandomCoder,

I didn't known this. I didn't have test my application on ppc.
At time I'm on beginning to develope a new project and I think it will need a longer time to finish. If Erel has released a new version with those events, I will use that one. But I will take a look on DZT's Magic Events. Maybe this one is helpfull for other points too.

Have a nice weekend

Haschi
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ImageList items as Reference? DaveW Questions & Help Needed 3 11-07-2008 08:35 AM
Problem using AddEvent EdQas Questions & Help Needed 7 09-09-2007 10:51 AM
How to save images after they have been placed in an imagelist XerVision Questions & Help Needed 2 07-13-2007 09:59 PM
Can we compare imagelist items? Cableguy Questions & Help Needed 1 06-02-2007 06:03 PM
I need examples for imagelist imagebutton sloopa Questions & Help Needed 2 05-19-2007 05:00 PM


All times are GMT. The time now is 02:22 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0