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.


Capture name of control that has focus


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-21-2008, 08:14 AM
Junior Member
 
Join Date: Jun 2008
Posts: 39
Default Capture name of control that has focus

Hi, I'm trying to get the ID of a form control that has the current focus. It seemed to me the AddEvent in combination with the Sender function would do the trick, but it doesn't seem to work when I try the example in the help.

Here's the code:

Sub App_Start
AddEvent("cbShipName", Click, "FieldGotFocus")
End Sub

FieldGotFocus
Msgbox(Sender)
End Sub

Anyone have any ideas? Do I have to add a library or something like that?

Tks, AB
Reply With Quote
  #2 (permalink)  
Old 06-21-2008, 09:43 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

Which type of controls do you have on your form?
For controls that support the GotFocus event you can use something like:
Code:
Sub Globals
    'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
    AddEvent("TextBox1",GotFocus,"GotFocus")
    AddEvent("TextBox2",GotFocus,"GotFocus")
    AddEvent("TextBox3",GotFocus,"GotFocus")
End Sub

Sub GotFocus
    form1.Text = Sender
    Sender.Color = cGreen
End Sub
Reply With Quote
  #3 (permalink)  
Old 06-21-2008, 05:34 PM
Junior Member
 
Join Date: Jun 2008
Posts: 39
Default Capture name of control that has focus

Hi Erel, thanks, that works perfectly, it's just what I needed.

But, I'm wondering why it doesn't work when I use the event Click instead of GotFocus? When I run it on the desktop and click the field, there's no response ...

Also, is there a list of the different event types somewhere?

Thanks, Adrian
Reply With Quote
  #4 (permalink)  
Old 06-21-2008, 06:14 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,755
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by aerohost View Post
But, I'm wondering why it doesn't work when I use the event Click instead of GotFocus?
Do the controls you are using actually support the Click event? Only a very few do!
Reply With Quote
  #5 (permalink)  
Old 06-21-2008, 06:34 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

Quote:
Also, is there a list of the different event types somewhere?
The help description of each control contains the list of events.
Reply With Quote
  #6 (permalink)  
Old 06-21-2008, 11:31 PM
Junior Member
 
Join Date: Jun 2008
Posts: 39
Default

Ok, thanks to you both, I get it. I was using a control that doesn't support the Click event - now I understand where to see the list of supported events for each control.

Regards, AB
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
Capture basic drawings? tsteward Questions & Help Needed 14 08-19-2008 03:40 PM
Desktop Videocam image capture library agraham Additional Libraries 6 05-25-2008 11:00 AM
Screen Capture App sahoopes Share Your Creations 3 04-17-2008 08:05 AM
Focus pmu5757 Questions & Help Needed 2 03-21-2008 06:16 PM
Signature capture and label autosize ohkovar Questions & Help Needed 7 06-26-2007 10:45 PM


All times are GMT. The time now is 01:38 PM.


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