Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

LinkLabel - Libary

Reply
 
LinkBack Thread Tools Display Modes
  #31 (permalink)  
Old 10-15-2009, 04:50 AM
Senior Member
 
Join Date: Apr 2007
Location: Arlington, Washington USA
Posts: 180
Default

OK, I got it!

You were correct,
CellText = Sender.text
was causing an error, corrected by changing it to
CellText = Control(Sender,"LinkLabel").text

What I was slow to grasp, was that it was not JUST that line, but ALL lines containing "Sender.text" (I think there were 4 such lines in that Sub).

Substituting "Control(Sender,"LinkLabel").text" for "Sender.text" in all cases resolved the problem.

Many, many thanks!
Reply With Quote
  #32 (permalink)  
Old 10-15-2009, 04:09 PM
Senior Member
 
Join Date: Apr 2007
Location: Arlington, Washington USA
Posts: 180
Default

agraham:

I appreciate your help with all of this. In the end, I did have to write seperate event subs (double click) for each linklabel, but it wasn't that simple.

The labels were created within a loop.

(1) If I included
LLDblClick.New1(Control("Label" & i,"LinkLabel").Control,"DoubleClick")
within the loop, all labels get wired to the same sub (LLDblClick_NewEvent). It works just fine in the IDE, but when compiled only the last control activates the double click event.

(2) My first solution was to have separate subs and include
AddObject("LLDblClick" & i,"Event")
within the loop, and outside the loop have a series of lines:
LLDblClick1.New1(Control("Label1","LinkLabel").Con trol,"DoubleClick")
LLDblClick2.New1(Control("Label2","LinkLabel").Con trol,"DoubleClick")
etc. This works fine in the IDE, but when attempting to compile, I get an error "Unknown control type. Use Control("_main_lldblclick1,Type) instead."

(3) Leaving these lines alone, I deleted the AddObject within the loop and created the series of objects using the Tools menu. Doing this, the code works both in the IDE and when compiled.

Attached are examples of the three versions.

Also you will note the empty LLclick subroutine. If the single click event is not created, when compiled I get an "Unhandled exception" error when a label is clicked.

So, in the end my code is ugly and with 42 linklables quite tedious, but at least I can move on to something else. Thanks for the experience.
Reply With Quote
  #33 (permalink)  
Old 10-15-2009, 04:36 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by dlfallen View Post
but when compiled only the last control activates the double click event.
That is the behaviour I would expect because you are reusing the same event object each time. On NEW it should be disposed and recreated. That looks a bit like a bug in IDE, I'll point Erel at it.
Quote:
LLDblClick1.New1(Control("Label1","LinkLabel").Con trol,"DoubleClick")
etc. This works fine in the IDE, but when attempting to compile, I get an error "Unknown control type. Use Control("_main_lldblclick1,Type) instead."
I think it is telling you to use this
Control("Main.LLDblClick1", "Event").New1(Control("Label1", "LinkLabel").Control,"DoubleClick")
You could probably put this in the loop using Main.LLDblClick & i. I haven't checked this code fragment so there may be errors but you get the idea.
Quote:
If the single click event is not created, when compiled I get an "Unhandled exception" error when a label is clicked.
That's a bug in LinkLabel (which I didn't write )
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #34 (permalink)  
Old 10-15-2009, 06:52 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Objects in the IDE are not being disposed implicitly due to the way the IDE holds references to objects.
Explicitly disposing the object will prevent this discrepancy.
Code:
Sub App_Start

For i = 1 To 3
    AddObject(
"Label" & i,"LinkLabel")
    Control(
"Label" & i,"LinkLabel").New1("Form1",35,45*i,33,33)    
    Control(
"Label" & i,"LinkLabel").BackColor = cWhite
    Control(
"Label" & i,"LinkLabel").fontsize = 6
    Control(
"Label" & i,"LinkLabel").text = "Lbl " & i
    Control(
"Label" & i,"LinkLabel").underline = False
    AddEvent (
"Label" & i,Click,"LLclick")
    
If i > 1 Then LLDblClick.Dispose
    AddObject(
"LLDblClick","Event")
    LLDblClick.New1(Control(
"Label" & i,"LinkLabel").Control,"DoubleClick")
Next i
        
    Form1.Show
End Sub
You need to add an Event object for each event:
Code:
Sub App_Start

For i = 1 To 3
    AddObject(
"Label" & i,"LinkLabel")
    Control(
"Label" & i,"LinkLabel").New1("Form1",35,45*i,33,33)    
    Control(
"Label" & i,"LinkLabel").BackColor = cWhite
    Control(
"Label" & i,"LinkLabel").fontsize = 6
    Control(
"Label" & i,"LinkLabel").text = "Lbl " & i
    Control(
"Label" & i,"LinkLabel").underline = False
    AddEvent (
"Label" & i,Click,"LLclick")
    AddObject(
"LLDblClick" & i,"Event")
    Control(
"LLDblClick" & i, Event).New1(Control("Label" & i,"LinkLabel").Control,"DoubleClick")
    AddEvent(
"LLDblClick" & i, NewEvent, "LLDblClick_NewEvent")
Next i
        
    Form1.Show
End Sub
We plan to add a simpler syntax for runtime controls/objects which will make it simpler as it will allow the IDE to show the list of properties and methods for these objects as well.

I will describe the new syntax with following example:
Control("tree" & i, TreeView).Node will be equal to:
TreeView("tree" & i).Node
Reply With Quote
  #35 (permalink)  
Old 10-16-2009, 08:07 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Erel View Post
Control("tree" & i, TreeView).Node will be equal to:
TreeView("tree" & i).Node
I like that
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #36 (permalink)  
Old 10-17-2009, 05:46 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

LinkLabel with source and AutoScale support posted here http://www.basic4ppc.com/forum/share...html#post29060
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
NotifyIcon Libary dzt Additional Libraries 27 08-21-2009 06:51 PM


All times are GMT. The time now is 10:23 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0