Results 1 to 7 of 7

Thread: how can create user control like charachter map for show on form?

  1. #1

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Post how can create user control like charachter map for show on form?

    hi i want show font icons like webgings font or other fonts and use in label or textbox or ...
    Name:  001.jpg
Views: 517
Size:  118.2 KB

    but my problem is about limited ascii code from 0 to 255 and i can not use from 0x21 to 0xb325 and sometime icons will be display like unknown.
    i did try for chrw$ or like this,but not work yet.

    i want create a user control or use label ( transparnet background is matter for me). for show a charachter or charachters on label or textbox or ... .

    any body can send a simple user control or code to work ?

  2. #2
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: how can create user control like charachter map for show on form?

    See if you can modify the code here to suit your needs.





    BTW, you should not have posted your question in the CodeBank. I've already requested for this thread to be moved to the appropriate forum by clicking the Report Post button.

  3. #3

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how can create user control like charachter map for show on form?

    your souce code have same problem,use charachter map in windows and then select copy charachters and then paste in paste on right click on your sample code,some charachters can not show correct for example charachter ascii code from charachter map -> 0xb2d2 or more than 200 charachters like this.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: how can create user control like charachter map for show on form?

    I posted another answer (my RTF label in codebank) in another thread, but here's some code that could be used to do it (at runtime) using a TextBox (or other control with a hWnd):

    Code:
    
    Option Explicit
    '
    Private Type RECT
        Left   As Long
        Top    As Long
        Right  As Long ' This is +1 (right - left = width)
        Bottom As Long ' This is +1 (bottom - top = height)
    End Type
    '
    Private Declare Function DefWindowProcW Lib "user32.dll" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function GetClientRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare Function InvalidateRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
    Private Declare Function SysAllocStringLen Lib "oleaut32.dll" (ByVal OleStr As Long, ByVal bLen As Long) As Long
    Private Declare Sub PutMem4 Lib "MSVBVM60.DLL" (ByRef Ptr As Any, ByRef Value As Any)
    '
    
    Public Property Let UniCaption(TheHwnd As Long, sUniCaption As String)
        ' Set Unicode string into the caption.
        '
        ' This is known to work on Checkbox, CommandButton, Frame, & OptionButton.
        ' Other controls are not known.
        '
        Const WM_SETTEXT As Long = &HC
        Dim uRect As RECT
        DefWindowProcW TheHwnd, WM_SETTEXT, 0&, ByVal StrPtr(sUniCaption)
        GetClientRect TheHwnd, uRect
        InvalidateRect TheHwnd, uRect, 1&
    End Property
    
    Public Property Get UniCaption(TheHwnd As Long) As String
        ' Get Unicode string from caption.
        '
        ' This is known to work on Checkbox, CommandButton, Frame, & OptionButton.
        ' Other controls are not known.
        '
        Const WM_GETTEXT As Long = &HD
        Const WM_GETTEXTLENGTH As Long = &HE
        Dim lLen As Long
        Dim lPtr As Long
        lLen = DefWindowProcW(TheHwnd, WM_GETTEXTLENGTH, 0&, ByVal 0&)  ' Get length of caption.
        If lLen Then ' Must have length.
            lPtr = SysAllocStringLen(0&, lLen)                          ' Create a BSTR of that length.
            PutMem4 ByVal VarPtr(UniCaption), ByVal lPtr                ' Make the property return the BSTR.
            DefWindowProcW TheHwnd, WM_GETTEXT, lLen + 1&, ByVal lPtr   ' Call the default Unicode window procedure to fill the BSTR.
        End If
    End Property
    
    Enjoy,
    Elroy

    EDIT1: Oops (as Rick Perry says), as is, that doesn't work on a TextBox. It'll work on many other controls though.
    Last edited by Elroy; Feb 16th, 2018 at 09:17 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how can create user control like charachter map for show on form?

    Quote Originally Posted by Elroy View Post
    I posted another answer (my RTF label in codebank) in another thread, but here's some code that could be used to do it (at runtime) using a TextBox (or other control with a hWnd):

    Code:
    
    Option Explicit
    '
    Private Type RECT
        Left   As Long
        Top    As Long
        Right  As Long ' This is +1 (right - left = width)
        Bottom As Long ' This is +1 (bottom - top = height)
    End Type
    '
    Private Declare Function DefWindowProcW Lib "user32.dll" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function GetClientRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare Function InvalidateRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
    Private Declare Function SysAllocStringLen Lib "oleaut32.dll" (ByVal OleStr As Long, ByVal bLen As Long) As Long
    Private Declare Sub PutMem4 Lib "MSVBVM60.DLL" (ByRef Ptr As Any, ByRef Value As Any)
    '
    
    Public Property Let UniCaption(TheHwnd As Long, sUniCaption As String)
        ' Set Unicode string into the caption.
        '
        ' This is known to work on Checkbox, CommandButton, Frame, & OptionButton.
        ' Other controls are not known.
        '
        Const WM_SETTEXT As Long = &HC
        Dim uRect As RECT
        DefWindowProcW TheHwnd, WM_SETTEXT, 0&, ByVal StrPtr(sUniCaption)
        GetClientRect TheHwnd, uRect
        InvalidateRect TheHwnd, uRect, 1&
    End Property
    
    Public Property Get UniCaption(TheHwnd As Long) As String
        ' Get Unicode string from caption.
        '
        ' This is known to work on Checkbox, CommandButton, Frame, & OptionButton.
        ' Other controls are not known.
        '
        Const WM_GETTEXT As Long = &HD
        Const WM_GETTEXTLENGTH As Long = &HE
        Dim lLen As Long
        Dim lPtr As Long
        lLen = DefWindowProcW(TheHwnd, WM_GETTEXTLENGTH, 0&, ByVal 0&)  ' Get length of caption.
        If lLen Then ' Must have length.
            lPtr = SysAllocStringLen(0&, lLen)                          ' Create a BSTR of that length.
            PutMem4 ByVal VarPtr(UniCaption), ByVal lPtr                ' Make the property return the BSTR.
            DefWindowProcW TheHwnd, WM_GETTEXT, lLen + 1&, ByVal lPtr   ' Call the default Unicode window procedure to fill the BSTR.
        End If
    End Property
    
    Enjoy,
    Elroy

    EDIT1: Oops (as Rick Perry says), as is, that doesn't work on a TextBox. It'll work on many other controls though.
    hi,i created a user control and then i added your code and then i used a picture box in form and then writed this code :

    Code:
    Private Sub Command1_Click()
    UserControl11.UniCaption(p.hWnd) = ChrW(&HB2D2)
    End Sub
    and not happened.

    my porblme is about 2 things:

    1- i writed in my question #1 ( transparent is matter for me, so i want show my charachter on label)

    2- for a simple example i want can show all of charachters in webings font in a label(transparent background is matter for me).
    i tested webdings font on a label but some charachters (more than 200 charachters cant shown on label)
    for example check it :

    Code:
    ' label1 font set to webdings
    label1.Caption = ChrW(&HB2F4)   '  means 0xb2f4 in charachter map
    label1.Caption = ChrW(&HB2F6)   '  means 0xb2f6 in charachter map
    ' or like this

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: how can create user control like charachter map for show on form?

    Hmmm, I didn't study what you did in detail, but I'm not sure you're going to get Unicode into a VB6 Label. These light-weight handle-less things are difficult to use in any kind of "fancy" way. IMHO, you're better off possibly taking a look at the RTB (used in a read-only, locked way), or possibly biting-the-bullet and taking a look at Krool's replacement controls. Specifically, he has a control named LabelW that should do precisely what you're trying to do.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how can create user control like charachter map for show on form?

    can u have any sample code like charachter map?my question and my porblem is about charachters codes in charachter map.
    i want can show all of icons in webdings font or windings font on label,but all of charachters can not display correct.
    put a label on form and set font to webdings or like that and then check charachters like code ( 0xb2f4 or 0xb2f6 or 0xb2d2 or ... in charachter map )

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width