Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Button for Insertion of Special Characters? (2003)

    Hi everyone and Hans [img]/forums/images/smilies/wink.gif[/img]

    I need a button which opens up the Special Character insertion box, just like you see in the screenshot below. It's used throughout Windows and Office Products and it can be accessed via the Start Menu too, so I think it's something global.

    I need to have this in my database because I have many names with special character just like

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Button for Insertion of Special Characters? (2003)

    You can use this code in the On Click event procedure of a command button on a form:

    Shell "Charmap", vbNormalFocus

    Is that enough to get you started, or do you need more help?

  3. #3
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button for Insertion of Special Characters? (2

    It would be good to know how to assign that button to a certain text-field.

    Click on button "Charmap" --> Select Character --> Hit OK --> Special Character is entered in textbox "txtBox"

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Button for Insertion of Special Characters? (2

    You can set the focus back to the text box, but the user will have to paste the character into the text box after having selected and copied it in the Character Map accessory. The accessory opens non-modal, so the code will finish before the user has closed Character Map.

    Private Sub cmdSpecialCharacter_Click()
    Me.txtBox.SetFocus
    Shell "CharMap", vbNormalFocus
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button for Insertion of Special Characters? (2

    Doesn't enter the values, the charmap is different from that on in word anyhow.

    I guess there is no solution for this, but popping up the Character map is enough for me.
    Thanks Hans!

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Button for Insertion of Special Characters? (2

    It doesn't enter the character indeed - as you mention, Character Map is different from the Insert | Symbol dialog in Word. The user can point to a character, then click Select and Copy. The character can then be pasted into the text box, but the user will have to do this manually.

  7. #7
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button for Insertion of Special Characters? (2

    that's what I wrote in the User Manual already - yeap.

  8. #8
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Button for Insertion of Special Characters? (2

    If you want user to be able to insert character(s) selected in Character Map into textbox in semi-automated fashion, see attached demo database. Instead of user copying/pasting characters, Windows API functions used to "capture" characters/symbols from CHARMAP. You can use SendMessage function with WM_GETTEXT message to capture text in a control, given the control's hwnd (window handle). In demo, EnumChildWindows function is used to get hwnd for the edit control in Character Map that contains the "Characters to Copy". This edit box is actually a Rich Edit control (class name "RichEdit20W") not a "standard" Edit control like the others, so can easily be identified. See code module to see how this works. Open Form1 to test inserting characters by clicking button, or using ALT+I shortcut to insert characters & "keep your place" in textbox. Note that textbox is Arial font, so it'd be recommended user use same font in CHARMAP for best results. Also note, should work OK with standard, printable ASCII characters between ASCII 32 and 255, Unicode characters may or may not display correctly in textbox. And inserting "smilies" from WingDings font will not work unless the textbox on form is also WingDings. Demo database is A2K format.

    For more info on using WM_GETTEXT message, see MSDN:

    MSDN Library - Window Messages - WM_GETTEXT Message

    Tip: when using this technique in VB/VBA, ensure string buffer used to capture text is passed to SendMessage BY VALUE. Example:

    <code>lResult = SendMessage(hwnd, WM_GETTEXT, Len(sBuffer), ByVal sBuffer)</code>

    When testing this earlier, I neglected this "minor" detail, resulting in several spectacular crashes.... always test with BACKUP of your database.

    HTH
    Attached Files Attached Files

  9. #9
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button for Insertion of Special Characters? (2

    Sounds VERY interesting Mark. And I get what the VB code SHOULD do.... the only problem is that not even the Demo database works. Could be the window's version I'M using (2000 pro) but if that's the case the demo wouldn't work anyhow since it's supposed to work at least on ME, 2000, XP.
    Check out "my Charactermap" which pops up. <IMG SRC=http://www.8ung.at/voystar/Snap3.gif>

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Button for Insertion of Special Characters? (2

    Does it work if you change the line

    hwnd = FindWindow("MyDlgClass", "Character Map")

    to

    hwnd = FindWindow("MyDlgClass", "Zeichentabelle")

    Note: you must use the Insert button to pop up the character map, select one or more characters, then click Insert again or press Alt+I to insert the characters. You can switch back and forth between the Access form and the character map, and press Alt+I in the text box each time you have selected one or more characters in character map.

  11. #11
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button for Insertion of Special Characters? (2

    How sad I didn't look that closely into the code. Works fine now - hate those language dependant codes, I'll work on that using the Window ID or something... we'll see.

    Thanks to all, I think this problem can't be solved any better.
    Great forums

  12. #12
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Button for Insertion of Special Characters? (2

    I had a chance to fool around with this some more, see attached revised demo database (A2K format). See form "frmCharMap". Instead of relying on Windows Character Map, form uses a subform with labels that display ASCII characters 32 to 255 for the selected font - emulating an ersatz, low-rent Character Map, but with no Unicode characters, just extended ASCII. The combo lists all installed fonts on system (populated by callback function, uses EnumFontFamilies API to enumerate fonts). Click on label on subform (will be highlighted in yellow when clicked) to insert character in textbox on main form (inserted at end of existing text). Click first label (no visible caption) to insert space (Chr(32)) that will "stick" in textbox. Select another font from combo to see characters available for that font (textbox font will also be updated to match bogus Character Map). There are also buttons to display font in Bold or Italic.

    Note on subform, creating individual event procedures for all 224 labels would not have been very productive, instead created 3 "generic" functions (see "LabelClickEvent", "LabelMouseDownEvent", and "LabelMouseUpEvent" in form module), then ran ModifySubform sub (in modUtility) to programatically assign applicable function to corresponding event procedure property for each label (this took appx one second to run). Normally would not recommend assigning function as property on property sheet but this case it seems an exception was warranted.

    You may be able to adapt some of this for your project. Demo worked OK on A2K on Windows 2000 & Windows XP. Don't know if any language "issues" will cause errors - I'm using "English - U.S." versions of everything.

    HTH
    Attached Files Attached Files

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Button for Insertion of Special Characters? (2

    The new form works well on my Dutch language system. There is only one nit, but that's probably due to EnumFontFamilies, not to you: the font combo box lists many variants for some fonts (Arial, Arial Baltic, Arial CYR, Arial Greek, Arial TUR, ...), and the list begins with some duplicates (?) whose names begin with @, such as @Arial Unicode MS.

  14. #14
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Button for Insertion of Special Characters? (2

    Thanx for feedback on non-US system. I see some of the "@" dupes too, as well as the language variations for Arial, etc. Not sure if there is easy way to weed them out - for example, on home system (Office 2K, Win XP) if in Access form/report design mode, the font list includes all the variations as seen in demo form. Excel lists the "dupes" also. But in Word 2K, the Font list does NOT list the duplicates/variations (typically Office is not consistent - maybe Word is "smarter" than the other apps?). So there should be way to weed them out....

  15. #15
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button for Insertion of Special Characters? (2

    This IS very useful, that's what I'm gonna implent for sure. No language problems on the german side either - funnily enough you used "ersatz" in one of your previous postings, which is pure german [img]/forums/images/smilies/wink.gif[/img]

    You gave me the perfect idea for this, now I'm gonna have a button popping up another form, which will only let the user choose some needed characters, beginning at ASCII 128. The Font choice is also nice, but I can delete that one aswell since the database is using a systemwide font.

    Great solution.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •