Standard "Choose contact" dialog

Elrick

Member
Licensed User
Hello. As i see in "Help", we can only get contacts's details. In many programs (include ones written on .NET) i saw standard dialog (attached) like "choose file" one. Is it possible to add this functionality to Basic4PPC? I need to choose a contact but i have to create my own contact lists what is not beautiful:)
 

Attachments

  • capture000.jpg
    capture000.jpg
    38.1 KB · Views: 399

Mr_Gee

Active Member
Licensed User
Longtime User
I need to choose a contact but i have to create my own contact lists what is not beautiful:)

It requires a bit of coding, but you can get pretty close, I did this in 2 minutes

You could use the treeview together with the outlook lib and even have those little images in front of the names
 

Attachments

  • 01-19-2009 5-04-01 PM.jpg
    01-19-2009 5-04-01 PM.jpg
    22 KB · Views: 353

Elrick

Member
Licensed User
No, i believe i can "code" it. But, i'm too lazy, my program will be more complicated, less attractive, and if i have more than one number for contact i'll have to provide another "choose contacts's phone" dialog:) Really can it be implemented in b4p? We all use the "Open file" dialog, it will be so nice to see this dialog too. It is (as i can see) the standard functionality of .NET compact. I really need this feature...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've attached a module which allows you to show the built in contacts dialog.
It requires the door library and Outlook/OutlookDesktop libraries.

The usage is pretty simple. You should first call ChooseContact.Initialize with the dialog's title.
Later you call ChooseContact.Show and the Contact will be returned in ChooseContact.SelectedContact.

A small program is also attached.
 

Attachments

  • ChooseContact.bas
    889 bytes · Views: 377
  • ChooseContact.sbp
    597 bytes · Views: 386

taximania

Well-Known Member
Licensed User
Longtime User
This dialog is available in .NET on WM5.0 and later devices. Try the attached dlls. If it looks OK I will tidy it up as a proper library.

Your example doesn't work for me.

You can achieve the contact dialog directly by using Microsoft.WindowsMobile.Forms.dll on the device.
What you don't get are any other details than the contact name.


Here's my previous attempt at such a project.
On my website
It was all done using standard Basic4ppc libraries, outlook etc.
Still a bit buggy though.

I've just noticed that when you relist the contacts array,
there's no way to reset it back to the original list.
(Which seems to be ok on most devices)


I don't really see the OP's point of wanting a contact dialog.
Everything he wants is available via Basic4ppc.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Your example doesn't work for me.
In what way? Doesn't it bring up the dialog?

You can achieve the contact dialog directly by using Microsoft.WindowsMobile.Forms.dll on the device.
That's what this library and Erel's example do. Or did you mean something else?

What you don't get are any other details than the contact name.
The Dialog contains a SelectedContact object. After assigning this to an Outlook library Contact object you should be able to access all the details of the contact - but I haven't gone on to check this out yet.
 

taximania

Well-Known Member
Licensed User
Longtime User
In what way? Doesn't it bring up the dialog?
ret is unused variable in sub main.Button1_Click

I had to Uncheck 'Checked Unsigned Variables'


The Dialog contains a SelectedContact object. After assigning this to an Outlook library Contact object you should be able to access all the details of the contact - but I haven't gone on to check this out yet.

Not all the 'Objects' are available using the Misro$^%$% .dll directly.

Perhaps I forgot to mention this in my previous post :signOops:

BUT, am I right in thinking all 'fields' are available via B4ppc Libs ?
We don't need another dll for this.
 

agraham

Expert
Licensed User
Longtime User
ret is unused variable in sub main.Button1_Click
I had to Uncheck 'Checked Unsigned Variables'
So it did work for you :confused:


BUT, am I right in thinking all 'fields' are available via B4ppc Libs ?
We don't need another dll for this.
The point was not to access a contacts details, the point was to make it easy to select the contact itself without writing your own dialog.
 

taximania

Well-Known Member
Licensed User
Longtime User
No it doesn't, yes it doesn't :sign0137:

It shows the dialog, now, but,

label1.text=ChooseDialog.SelectedContact , shows nothing :(

Alter your .dll and use .SelectedContactName

Or, add Micro$.Windows.Forms.dll to a new project,
add a ChooseContactDialog, New1 it and here's code that works.
As I stated earlier, you don't need a new .dll to do this.

I, my mistake, :( , thought the OP wanted a dialog box that returns all Contact fields :signOops:

B4X:
Sub Globals
End Sub

Sub App_Start
form1.Show
ChooseDialog.New1
End Sub

Sub Button1_Click
ChooseDialog.ShowDialog
Msgbox(ChooseDialog.SelectedContactName)
AppClose
End Sub
 

Elrick

Member
Licensed User
Thanks for the help, but there are two problems:
1. Erel's example shows attached dialog on my THC Touch Pro (VGA). Not so beautiful... :)
2. Agraham's example just dont run... It raises "System.TypeLoadException"...
Anyway, it is nice to have as less additional libraries, as possible (to reduce output size of program) so i hope this problem may be solved in Erel's way :)

And a little addition:
If the contact have more than one phone number stored, Erel's example don't show the list with ability to choose one of them...
 
Last edited:

taximania

Well-Known Member
Licensed User
Longtime User
Try this app. Attached .sbp file below.

All contact numbers on 'my' device seem to be stored in
con.BusinessTelephoneNumber field

This app searches for a string match on the name(s) returned
from the ContactDialog. Stored in global 'dianame', if found.

a=con.FirstName & " " & con.LastName
If a = dianame Then

if no match is found it looks for

a=con.FirstName
If a = dianame AND con.LastName="" Then

Windows Mobile seems to treat 'Mum Home' different to 'Mum'.
'Mum' is saved as con.FirstName
'Home' gets saved as con.LastName

I havent considered 'Mum Mobile Work' :sign0148:

Just search con.?TelephoneNumber for other numbers once
you have a string match on the name's.


B4X:
Sub Globals
dianame=""
End Sub

Sub App_Start
form1.Show
phone.New2
diag.New1
hw.New1
con.New1
pim.New1("Contacts")
End Sub

Sub findu
WaitCursor(True)
For b=1 To pim.Count -1
con.value=pim.GetItem(b)
a=con.FirstName & " " & con.LastName
If a = dianame Then
Msgbox(con.[COLOR="Red"]BusinessTelephoneNumber[/COLOR],a)
WaitCursor(False)
Return
End If
Next


For b=1 To pim.Count -1
con.value=pim.GetItem(b)
a=con.FirstName
If a = dianame AND con.LastName="" Then
Msgbox(con.[COLOR="red"]BusinessTelephoneNumber[/COLOR],a)
WaitCursor(False)
Return
End If
Next
WaitCursor(False)
End Sub

Sub Button1_Click
diag.ShowDialog
dianame=diag.SelectedContactName
findu
End Sub
 

Attachments

  • callite.sbp
    1.2 KB · Views: 327

taximania

Well-Known Member
Licensed User
Longtime User
And a little addition:
If the contact have more than one phone number stored, Erel's example don't show the list with ability to choose one of them...

The point was not to access a contacts details, the point was to make it easy to select the contact itself without writing your own dialog.

You cannot select or choose contact details from the ContactDialog

Thanks to Agraham for pointing me in the right direction, again ;)
 

Elrick

Member
Licensed User
taximania, your example shows the same dialog, as i've attached to my previous post. It looks like this method not work properly on the VGA screens - all controls are so big... Any ideas on what may be wrong?
 

agraham

Expert
Licensed User
Longtime User
It looks like this method not work properly on the VGA screens - all controls are so big... Any ideas on what may be wrong?
I see this on my VGA devices when running my test program for this dialog in the device IDE which is a .NET 1.0 application. When optimised compiled as a .NET 2.0 application the dialog displays correctly.

I have no idea why my little library doesn't work for you, it works fine on my devices. Any further details on the error, like the line number?
 

Elrick

Member
Licensed User
When optimised compiled as a .NET 2.0 application the dialog displays correctly.
Yes. This is it. This method shows the big controls when i use "Force QVGA" compilation. Optimized compilation works properly... But i always compile my programs in "Force QVGA" mode, to handle VGA screens easily... Well... Is there any chance to get it working with "Force QVGA" compilation?
 
Top