Standard "Choose contact" dialog

Discussion in 'Code Samples & Tips' started by Elrick, Jan 19, 2009.

  1. Elrick

    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:)
     

    Attached Files:

  2. Mr_Gee

    Mr_Gee Active Member Licensed User

    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
     

    Attached Files:

  3. Elrick

    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...
     
  4. Erel

    Erel Administrator Staff Member Licensed 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.
     

    Attached Files:

  5. agraham

    agraham Expert Licensed 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.
     

    Attached Files:

  6. Erel

    Erel Administrator Staff Member Licensed User

    Lol :)
     
  7. agraham

    agraham Expert Licensed User

    :(
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Basic4ppc starts faster than Visual Studio ;)
     
  9. taximania

    taximania Well-Known Member Licensed User

    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: Jan 19, 2009
  10. agraham

    agraham Expert Licensed User

    In what way? Doesn't it bring up the dialog?

    That's what this library and Erel's example do. Or did you mean something else?

    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.
     
  11. taximania

    taximania Well-Known Member Licensed User

    ret is unused variable in sub main.Button1_Click

    I had to Uncheck 'Checked Unsigned Variables'


    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.
     
  12. agraham

    agraham Expert Licensed User

    So it did work for you :confused:


    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.
     
  13. taximania

    taximania Well-Known Member Licensed 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:

    Code:
    Sub Globals
    End Sub

    Sub App_Start
    form1.Show
    ChooseDialog.New1
    End Sub

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

    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: Jan 29, 2009
  15. taximania

    taximania Well-Known Member Licensed 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.


    Code:
    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
     

    Attached Files:

  16. taximania

    taximania Well-Known Member Licensed User

    You cannot select or choose contact details from the ContactDialog

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

    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?
     
  18. agraham

    agraham Expert Licensed User

    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?
     
  19. Elrick

    Elrick Member Licensed User

    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?
     
  20. agraham

    agraham Expert Licensed User

    No. What makes Force QVGA work is the same thing that makes the dialog the wrong size so you can't have both at the same time.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice