dcsimg
Results 1 to 20 of 20

Thread: Microsoft Forms 2.0 Object Library

  1. #1

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Microsoft Forms 2.0 Object Library

    Anyone familiar with that component?

    Is that normal, that when pasting unicode text into for example Label Caption it still will be displayed as ANSI text?
    Your comments please,
    jas

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,655

    Re: Microsoft Forms 2.0 Object Library

    If you are talking about the Properties Window in the IDE, then yes. Also setting the Caption to a literal String in code does the same thing. All literal values in VB6 are ANSI.

  3. #3

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    Thank you, that's what I thought.
    I am really confused about using Unicode characters.
    For example:
    I can paste directly into Text Box the Unicode text.
    It is displayed correctlly, but when the same Text Box is loaded programmatically with the same text , the text is not displayed correctly.

    Even when the text is displayed properly (by pasting it), analyzing it byte by byte does not show that right.


    What I want to do is just display Unicode text in the Text Box programmatically, just to have the same visual effect as by pasting unicode text.
    Thanks,
    jas

    Maybe I will explain that more.
    I have the unicode text stored as a text file.
    When I open that file in Notepad, I can copy and paste that text into TextBox and the text is displayed properly.
    However, when programmatically I open that file (for Binary), read that file byte by byte and display the result in TextBox the result is not the same as pasting.
    Why?
    Last edited by jastrzebiec; Jul 4th, 2012 at 12:55 AM.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,655

    Re: Microsoft Forms 2.0 Object Library

    If you use VB6's native I/O statements I/O with a String also expects the file to have ANSI data, not Unicode.

    You must either use Byte arrays or use the FSO, specifying Unicode on the OpenTextFile() call.

  5. #5
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    Sample code to set text in MSForms TextBox using:
    1. Literal
    2. From File
    3. Resource File
    Attached Images Attached Images  
    Attached Files Attached Files

  6. #6

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    I have a problem when trying to load Microsoft Forms 2.0 Object Library component in Windows 7 Ultimate 64 bit.
    The error is:


    Is it only me? Any workaround?

    There is not a problem when loading it in Windows XP.
    Thanks,
    jas

  7. #7
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    I have a problem when trying to load Microsoft Forms 2.0 Object Library component in Windows 7 Ultimate 64 bit.
    Check to see if you have FM20ENU.Dll installed.

    FM20ENU.Dll - Automatically installed with English versions of Office. Users who have installed Office with another language should check Windows\System32 folder for presence of this file. If it is not present you can download and install it free as part of ActiveXControlPad. You must have FM20ENU.Dll present to make Forms 2.0 Object Library controls available in Vb6. The symptoms are that the controls appear in the Vb Toolbox panel but an error occurs when you try to place one onto a form.
    http://download.microsoft.com/downlo...S/setuppad.exe

  8. #8
    Member sgarv's Avatar
    Join Date
    Jul 2012
    Posts
    34

    Re: Microsoft Forms 2.0 Object Library

    Just as a quick note. the FM20*.dll is not freely redistributable with our applications. The only way to do this correctly is to first (download and) install the ActiveX Control Pad and then the application. the FM20 dll cannot be included as part of the VB's setup app.

    Or at least this is the way it used to be years ago. I don't know if this has changed. More info:

    http://support.microsoft.com/default...;en-us;Q224305

    Note the last paragraph before the "References" section. What this means is that MS might change the way that these controls work in future releases of the FM20 DLL which might break your code. Of course since ths is from years ago, perhaps at this time this is no longer applicable. Regards,SgarV.

  9. #9

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    I believe that if I did not have installed that file then it would be impossible to select
    Microsoft Forms 2.0 Object Library from the Components list.

    Besides that, I have tried your link for setup.
    1.
    When I save it to a file and run it I have "....not valid Win32 application" error.
    2.
    When I run it from web I have: "The application was unable to start correctly..." error.
    Thanks,
    jas

  10. #10
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    I believe that if I did not have installed that file then it would be impossible to select Microsoft Forms 2.0 Object Library from the Components list.
    It will appear in Component list. You just can't instantiate a control without FM20ENU.DLL.
    This is a known issue.
    Besides that, I have tried your link for setup.
    Right-click on setuppad.exe and run elevated (as administrator).
    http://download.microsoft.com/downlo...S/setuppad.exe

  11. #11

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    It does not work.
    I think it does not like 64 bit It is 1997 file!
    /jas

    Nope.
    I have tried it in Windows 7 32 bit and there is the same error!
    Last edited by jastrzebiec; Jul 4th, 2012 at 09:45 PM.

  12. #12
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    I am using Windows 7 32 bit and setuppad.exe runs OK here if you run it elevated (as administrator).

  13. #13

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    OK, I am giving up on Microsoft Forms 2.0 Object Library component.

    But maybe there is an another way to do what I need.
    I have tested it and I can confirm that Clipboard can keep Unicode strings.
    I do not need to display that string.
    I need to pass it to T-T-S voice in unchanged format.
    How to do that?
    When I use Clipboard.GetText directly like for example this:
    moVoice.Speak Clipboard.GetText, flags
    the voice speaks ANSI not Unicode.
    Any idea how to accomplish that?
    /jas

  14. #14
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    The Vb6 clipboard object is not Unicode aware.
    Try this class to get Unicode string from clipboard.
    Attached Files Attached Files

  15. #15

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    OK. Thank you. I grabbed the concept.
    Instead of using vbasic Clipboard object use the Clipboard() API.
    So far so good.

    It works nicely,
    Thanks,
    jas
    Last edited by jastrzebiec; Jul 5th, 2012 at 01:18 AM.

  16. #16

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    One more question.
    How to store Unicode string within vbasic code?
    Let say the Unicode text from Clipboard is kept by lpString variable.
    How to store that to the file and retrieve that later?
    Thanks,
    jas

  17. #17
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    Unicode File I/O requires a UTF-16 BOM marker and must use binary file I/O.
    Here are 2 functions to Write/Read Unicode text to file.

    Code:
    Option Explicit
    
    Private Sub Form_Load()
       Dim sUni As String
       
       sUni = "JPN: " & ChrW$(&H3088) & ChrW$(&H3046) & ChrW$(&H3053) & ChrW$(&H305D)
       UnicodeFile_Write_VB App.Path & "\UniTest.txt", sUni
       'Prove it works
       sUni = UnicodeFile_Read_VB(App.Path & "\UniTest.txt")
       MsgBox sUni, vbInformation, "Unicode File I/O"
    End Sub
    
    'Purpose: Override Vb6 MsgBox with Unicode aware MsgBox. HelpFile/Context not supported.
    Function MsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String) As VbMsgBoxResult
       MsgBox = CreateObject("WScript.Shell").Popup(Prompt, 0&, Title, Buttons)
    End Function
    
    'Purpose: Note that sFileName must be ANSI. The content can be Unicode or ANSI.
    Public Function UnicodeFile_Read_VB(ByVal sFileName As String) As String
       Dim FF               As Long
       Dim b()              As Byte
       Dim s                As String
    
       On Error Resume Next
    
       FF = FreeFile
       Open sFileName For Binary Access Read As FF
       ReDim b(LOF(FF) - 1)
       Get FF, , b
       Close FF
       'Detect file encoding
       If b(0) = 255 And b(1) = 254 Then 'UTF-16 BOM FF FE
          s = b
          s = Mid$(s, 2) 'Remove BOM
       Else
          s = StrConv(b, vbUnicode)   'ANSI file
       End If
    
       UnicodeFile_Read_VB = s
       
    End Function
    
    Public Sub UnicodeFile_Write_VB(ByVal sFileName As String, _
       ByVal strText As String, _
       Optional ByVal bUnicode As Boolean = True)
    
       Dim FF               As Long
       Dim b()              As Byte
    
       On Error Resume Next
       Kill sFileName
       On Error GoTo 0
       FF = FreeFile
       Open sFileName For Binary Access Write As #FF
    
       If bUnicode Then
          Put #FF, , CInt(&HFEFF) 'UTF16 BOM
          b = strText
       Else
          b = StrConv(strText, vbFromUnicode)
       End If
    
       Put #FF, , b
       Close #FF
    End Sub

  18. #18

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    Boy, thank you very much.
    Surely, you deserve your title!
    One extra question. I believe I can keep it such binary file in my Resource file.
    Is there some special way to read it back?
    Thanks,
    jas

  19. #19
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Microsoft Forms 2.0 Object Library

    Basically all you need to do for Unicode strings in a resource file is just paste them in using Notepad and clicking SaveAs where you specify Encoding as "Unicode". This ensures that a UTF-16 BOM marker is inserted at beginning of file and that the strings are saved as Unicode.
    Finally compile this file using Rc.exe

    Attached is a sample Unicode resource file, a batch file to compile it and the final .Res file.
    All you need to do is load the string using Vb "LoadResString(iD)" and you will have Unicode.
    Demo has Unicode aware MsgBox since Vb6 MsgBox is ANSI only.

    Note: Once you have a string saved as a file you can cut/paste into a new Notepad file and create your resource.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by DrUnicode; Jul 7th, 2012 at 10:42 AM. Reason: Screenshot

  20. #20

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: Microsoft Forms 2.0 Object Library

    Thanks a lot. No more questions.
    /jas

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width