Page 98 of 99 FirstFirst ... 48889596979899 LastLast
Results 3,881 to 3,920 of 3935

Thread: CommonControls (Replacement of the MS common controls)

  1. #3881

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    Major performance improvement of the .ListItemIndices property in the LvwGroup class. (comctl version 6.1 [Vista+]; 6.0 remains slow [XP])
    Included the .ListItemCount property in the LvwGroup class. (comctl version 6.1 [Vista+] only)

  2. #3882
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by jpbro View Post
    You are returning the result of the SendMessage/EM_FORMATRANGE call in GetRichTextHeight, which I believe is the number of characters printed. Instead your should return fr.rc.bottom to get the height of the text in twips (or 0 if fr.rc.bottom = &H7FFFFFFF).
    Ok and Thanks jpbro, but I tested with ChatGPT and there has been no way to make it work, there is this that does work but without taking into account images or objects:
    Code:
    Private Function GetTotalTextHeight(rtbHwnd As Long, rtbFont As StdFont, Text As String) As Long
        Dim iPT1 As POINTAPI
        Dim iPt2 As POINTAPI
        Dim iCharPos As Long
        Dim lTotalHeight As Long
    
        ' Get the position of the first character (start of the text)
        SendMessageAnyAny rtbHwnd, EM_POSFROMCHAR, iPT1, ByVal CLng(0)
    
        ' Get the index of the first character of the last line
        Dim lastLineIndex As Long
        lastLineIndex = SendMessage(rtbHwnd, EM_LINEFROMCHAR, Len(Text) - 1, 0&)
        
        ' Get the position of the first character of the last line
        iCharPos = SendMessage(rtbHwnd, EM_LINEINDEX, ByVal lastLineIndex, 0&)
        
        ' Get the position of the last line
        If iCharPos > -1 Then
            SendMessageAnyAny rtbHwnd, EM_POSFROMCHAR, iPt2, ByVal iCharPos
            ' Calculate the total height of the text
            lTotalHeight = iPt2.Y - iPT1.Y
    
            ' Ensure to add the font height if necessary
            If Not IsNull(rtbFont.Size) Then
                lTotalHeight = lTotalHeight + ScaleY(rtbFont.Size, vbPoints, vbPixels)
            End If
        End If
    
        ' Return the total height in pixels
        GetTotalTextHeight = lTotalHeight
    End Function
    And I cannot understand why in years an RTBTotalHeight property or something similar has not been added, because in many cases if you want to show all the content of the RTB, it is important to know the height of everything in the RTB... For example for put in a ToolTip with RichTextBox - a very good tooltip -, is necessary know the total height of the content of the RTB...

    I haven't checked by looking at the subclassed vertical scroll bar, I have to try to look there...

    At the moment I'm finishing treating the text as simple html, that is, with bold, italic, underline, and font color and font size, I've added 2 properties:
    HtmlDefColor (The color you want to set by default to the Text)
    HtmlText (true or false)

    And I am finishing the code for manage this codes... It works for my needs, because Krool's RTB doesn't seem to support the \b \b0 style codes (At least I've tried and it doesn't recognize them)...

    And I understand that Krool doesn't tell me anything, what a job he's done, ufff!!! And what a good job he's done with all these ocx with Unicode, excellent work to give it away for free too...
    Last edited by James Reynolds; Nov 1st, 2024 at 09:59 AM.

  3. #3883
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,619

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by James Reynolds View Post
    Ok and Thanks jpbro, but I tested with ChatGPT and there has been no way to make it work
    There is a way to make it work. Take your original ChatGPT code, put Option Explicit at the top and try running it. It won't work because there are missing bits (SendMessage and other API declarations, RECT definition, EM_FORMATRANGE constant, etc...). Add all the missing bits as necessary, until it runs. Once it will run, change the GetRichTextHeight = result line to:

    Code:
    GetRichTextHeight = IIf(fr.rc.Bottom = &H7FFFFFFF, 0, fr.rc.Bottom)
    And GetRichTextHeight will now return the height of the RTF content (including images and whatever else might be there).

  4. #3884
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by jpbro View Post
    There is a way to make it work. Take your original ChatGPT code, put Option Explicit at the top and try running it. It won't work because there are missing bits (SendMessage and other API declarations, RECT definition, EM_FORMATRANGE constant, etc...). Add all the missing bits as necessary, until it runs. Once it will run, change the GetRichTextHeight = result line to:

    Code:
    GetRichTextHeight = IIf(fr.rc.Bottom = &H7FFFFFFF, 0, fr.rc.Bottom)
    And GetRichTextHeight will now return the height of the RTF content (including images and whatever else might be there).
    So simple!!!

    And that's it, ChatGPT may have excellent AI for those who use it, but the one they give to normal people is very bad!!!

    It is very useful for consulting things, and very simple codes, but as soon as something gets complicated, just a little, little by little, ChatGPT gets complicated, and more than helping, it wastes time, as soon as I see that it is going to mess things up, I say goodbye, and I go look for myself here...

    And what danger does it have for the future...

    Thanks jpbro, you have helped me a lot, and couldn't ChatGPT know that simple code? Incredible...

  5. #3885
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    [QUOTE=jpbro;5661220]There is a way to make it work. Take your original ChatGPT code, put Option Explicit at the top and try running it. It won't work because there are missing bits (SendMessage and other API declarations, RECT definition, EM_FORMATRANGE constant, etc...). Add all the missing bits as necessary, until it runs. Once it will run, change the GetRichTextHeight = result line to:

    Code:
    Private Function GetRichTextHeight(rtbHwnd As Long, rtbFont As StdFont, Text As String, rtbWidth As Long) As Long
        Dim fr As FORMATRANGE
        Dim rcDrawTo As RECT
        Dim rcPage As RECT
        Dim iPT1 As POINTAPI
        Dim lTotalHeight As Long
        Dim hdc As Long
    
        ' Get a device context for the entire screen
        hdc = GetDC(0)
    
        ' Initialize the FORMATRANGE structure
        With fr
            ' Use the same device context for measuring and rendering
            .hdc = hdc
            .hdcTarget = hdc
    
            ' Set up the print area dimensions (rcPage) and the drawing area dimensions (rcDrawTo)
            rcPage.Left = 0
            rcPage.Top = 0
            rcPage.Right = rtbWidth
            rcPage.Bottom = 20000
    
            rcDrawTo.Left = 0
            rcDrawTo.Top = 0
            rcDrawTo.Right = rtbWidth
            rcDrawTo.Bottom = &H7FFFFFFF
    
            .rc = rcDrawTo
            .rcPage = rcPage
    
            ' Set the range of characters to format
            .chrg.cpMin = 0
            .chrg.cpMax = Len(Text)
    
            ' Send EM_FORMATRANGE message to measure the content
            SendMessage rtbHwnd, EM_FORMATRANGE, True, ByVal VarPtr(fr)
    
            ' Release the device context
            ReleaseDC 0, hdc
        End With
    
        ' Return the height of the RTF content
        GetRichTextHeight = IIf(fr.rc.Bottom = &H7FFFFFFF, 0, fr.rc.Bottom)
    End Function
    But not work well...
    Last edited by James Reynolds; Nov 1st, 2024 at 11:30 AM.

  6. #3886
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by jpbro View Post
    There is a way to make it work. Take your original ChatGPT code, put Option Explicit at the top and try running it. It won't work because there are missing bits (SendMessage and other API declarations, RECT definition, EM_FORMATRANGE constant, etc...). Add all the missing bits as necessary, until it runs. Once it will run, change the GetRichTextHeight = result line to:

    Code:
    GetRichTextHeight = IIf(fr.rc.Bottom = &H7FFFFFFF, 0, fr.rc.Bottom)
    And GetRichTextHeight will now return the height of the RTF content (including images and whatever else might be there).
    Well, this appear to be work well:

    Code:
    Private Function GetRichTextHeight(rtbHwnd As Long, rtbFont As StdFont, Text As String, rtbWidth As Long) As Long
        ' Declare required variables
        Dim fr As FORMATRANGE
        Dim rcDrawTo As RECT, rcPage As RECT
        Dim hdcPrinter As Long
        Dim result As Long
    
        ' Get the device context for the display
        hdcPrinter = CreateDC("DISPLAY", vbNullString, vbNullString, ByVal 0&)
    
        ' Set up the FORMATRANGE structure
        fr.hdc = hdcPrinter
        fr.hdcTarget = hdcPrinter
    
        ' Define the printable area (relative to page size)
        With rcPage
            .Left = 0
            .Top = 0
            .Right = rtbWidth ' Use the provided width of the RichTextBox/UserControl
            .Bottom = &H7FFFFFFF ' Set the bottom to maximum to measure the height
        End With
    
        ' Define the drawing area on the page (same as the printable area)
        rcDrawTo = rcPage
    
        ' Set up FORMATRANGE with page and drawing area
        fr.rcPage = rcPage
        fr.rc = rcDrawTo
        fr.chrg.cpMin = 0 ' Start of the text
        fr.chrg.cpMax = -1 ' End of the text
    
        ' Send EM_FORMATRANGE message to measure the text without rendering
        result = SendMessage(rtbHwnd, EM_FORMATRANGE, False, fr)
    
        ' Return the height of the formatted text
        GetRichTextHeight = IIf(fr.rc.Bottom = &H7FFFFFFF, 0, fr.rc.Bottom)
    
        ' Release resources
        DeleteDC hdcPrinter
        SendMessage rtbHwnd, EM_FORMATRANGE, False, ByVal CLng(0)
    End Function

  7. #3887
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    And I don't know if there is any way to know how many visible lines there are in Krool's RTB - it is possible perhaps that by mixing some methods this data can be obtained, but I prefer to have it in a direct property, more than anything to easily go to the end of the text or to the beginning -, I have done this and it works for me, and in case it is useful to someone, I think it is also an important piece of data to know, how many lines are visible:

    Code:
    Public Property Get GetLinesVisibles() As Long
        GetLinesVisibles = GetLinesVisiblesFunc(richTextBoxHandle)
    End Property
    
    Private Function GetLinesVisiblesFunc(rtbHwnd As Long) As Long
        Dim firstVisibleLine As Long
        Dim totalLines As Long
        Dim clientHeight As Long
        Dim lineIndex As Long
        Dim charIndex As Long
        Dim linePos As POINTAPI
        Dim nextLinePos As POINTAPI
        Dim visibleLines As Long
        Dim cumulativeHeight As Long
        Dim prevLinePosY As Long
        Dim rc As RECT
        
        ' Get the index of the first visible line
        firstVisibleLine = SendMessage(rtbHwnd, EM_GETFIRSTVISIBLELINE, 0, ByVal 0&)
        
        ' Get the total number of lines
        totalLines = SendMessage(rtbHwnd, EM_GETLINECOUNT, 0, ByVal 0&)
        
        ' Get the height of the RichTextBox client area
        GetClientRect rtbHwnd, rc
        clientHeight = rc.Bottom - rc.Top
        
        ' Initialize variables
        lineIndex = firstVisibleLine
        cumulativeHeight = 0
        visibleLines = 0
        
        ' Iterate over the lines starting from the first visible one
        Do While lineIndex < totalLines
            ' Get the character index of the current line
            charIndex = SendMessage(rtbHwnd, EM_LINEINDEX, lineIndex, ByVal 0&)
            
            ' Get the character's position in client coordinates
            If SendMessage(rtbHwnd, EM_POSFROMCHAR, VarPtr(linePos), ByVal charIndex) = -1 Then
                Exit Do
            End If
            
            ' Get the position of the next line
            If lineIndex + 1 < totalLines Then
                Dim nextCharIndex As Long
                nextCharIndex = SendMessage(rtbHwnd, EM_LINEINDEX, lineIndex + 1, ByVal 0&)
                If SendMessage(rtbHwnd, EM_POSFROMCHAR, VarPtr(nextLinePos), ByVal nextCharIndex) = -1 Then
                    Exit Do
                End If
            Else
                ' If it's the last line, estimate the line height
                nextLinePos.Y = linePos.Y + (linePos.Y - prevLinePosY)
            End If
            
            ' Calculate the height of the line
            Dim lineHeight As Long
            lineHeight = nextLinePos.Y - linePos.Y
            
            ' Handle possible zero or negative line heights
            If lineHeight <= 0 Then
                ' Use an average line height if necessary
                lineHeight = clientHeight / (visibleLines + 1)
            End If
            
            ' Add the line height to the cumulative total
            cumulativeHeight = cumulativeHeight + lineHeight
            
            ' Check if the cumulative total exceeds the client area height
            If cumulativeHeight > clientHeight Then
                Exit Do
            End If
            
            ' Increment the visible lines counter
            visibleLines = visibleLines + 1
            
            ' Save the previous Y position
            prevLinePosY = linePos.Y
            
            ' Prepare for the next iteration
            lineIndex = lineIndex + 1
        Loop
        
        ' Display the number of visible lines
        GetLinesVisiblesFunc = visibleLines
    End Function
    Now if I want to go to the last line starting with text that is visible, I do this:
    Code:
    RichTextBox1.ScrollToLine RichTextBox1.GetLineCount - RichTextBox1.GetLinesVisibles + 1
    Although I still need to check if the first visible line is a VbCrLf or VbCr or VbLf, because it would be better if that line was skipped...

    Maybe it can be done with what the Krool RTB already has, but I would like to know the content of each line, it must be easy...

    One GetTextLine method passing the parameter of the line you want to know, it would be interesting...

    Greetings...
    Last edited by James Reynolds; Nov 2nd, 2024 at 08:37 AM.

  8. #3888
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Well, here is the Krool RichTextBox user control with my additions, it accepts basic html text (<font name, font color, font size, bold, italic, underline)

    It is semi-transparent capturing from the container's hdc, I can know the total height of the content of the Krool RichTextBox Unicode Utf8, I can know the text of each line, and maybe I'm forgetting something else, but for my needs it is almost complete, when I consider it checked and complete, I will upload it to the CodeBank:


    Greetings...

  9. #3889
    Fanatic Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    654

    Re: CommonControls (Replacement of the MS common controls)

    Does anyone have some code handy to sort the VBCCR Listview rows when a column header is clicked on? The sort needs to be able to handle/differentiate between numeric/date/string data types.

    I've tried to create this myself but am running into numerous hurdles. Figured it's so common that someone else has surely already created this.

    TIA!

  10. #3890
    Hyperactive Member
    Join Date
    Jan 2012
    Location
    Recently moved from Europe to Panama
    Posts
    276

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by AAraya View Post
    Does anyone have some code handy to sort the VBCCR Listview rows when a column header is clicked on? The sort needs to be able to handle/differentiate between numeric/date/string data types.

    I've tried to create this myself but am running into numerous hurdles. Figured it's so common that someone else has surely already created this.

    TIA!
    See below how I dealt with it. Columheader text gets a + or - sign to show ascending or descending sorting. Sort column and sort order are stored in the registry and retrieved and applied when the form with the listview is opened.


    Code:
    Private Sub lvMerchandiseSectionDetails_ColumnClick(ByVal ColumnHeader As VBCCR17.LvwColumnHeader)
        Dim iLastColumnSortedOn As Integer
        
        If ColumnHeader.Index > 0 Then
            iLastColumnSortedOn = CInt(GetSetting(Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastColumnSortedOn", Default:=-1))
            If iLastColumnSortedOn <> -1 Then
                If iLastColumnSortedOn <> (ColumnHeader.Index) Then
                    'Remove sorting sign from current sort column, as the user clicked another column
                    If lvMerchandiseSectionDetails.ColumnHeaders.Count >= iLastColumnSortedOn Then
                        lvMerchandiseSectionDetails.ColumnHeaders(iLastColumnSortedOn).Text = Left$(lvMerchandiseSectionDetails.ColumnHeaders(iLastColumnSortedOn).Text, Len(lvMerchandiseSectionDetails.ColumnHeaders(iLastColumnSortedOn).Text) - 2)
                    End If
                    'Sort the new column ascending
                    With lvMerchandiseSectionDetails
                        .ColumnHeaders(ColumnHeader.Index).Text = .ColumnHeaders(ColumnHeader.Index).Text & " +"
                        .SortKey = ColumnHeader.Index - 1
                        .SortOrder = lvwAscending
                        .Sorted = True
                        If ColumnHeader.Tag = "Numeric" Then
                            .SortType = LvwSortTypeNumeric
                        ElseIf ColumnHeader.Tag = "Date" Then
                            .SortType = LvwSortTypeDate
                        Else
                            .SortType = LvwSortTypeText
                        End If
                    End With
                    'Save the settings in the registry
                    SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastColumnSortedOn", Setting:=(ColumnHeader.Index)
                    SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastSortType", Setting:=lvwAscending
                Else
                    'User clicked same column, change the sorting order
                    'Remove sorting sign from current sort column
                    lvMerchandiseSectionDetails.ColumnHeaders(iLastColumnSortedOn).Text = Left$(lvMerchandiseSectionDetails.ColumnHeaders(iLastColumnSortedOn).Text, Len(lvMerchandiseSectionDetails.ColumnHeaders(iLastColumnSortedOn).Text) - 2)
                    If CInt(GetSetting(Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastSortType", Default:=-1)) = lvwAscending Then
                        'Sort the column descending
                        With lvMerchandiseSectionDetails
                            .ColumnHeaders(iLastColumnSortedOn).Text = .ColumnHeaders(iLastColumnSortedOn).Text & " -"
                            .SortKey = ColumnHeader.Index - 1
                            .SortOrder = lvwDescending
                            .Sorted = True
                            If ColumnHeader.Tag = "Numeric" Then
                                .SortType = LvwSortTypeNumeric
                            ElseIf ColumnHeader.Tag = "Date" Then
                                .SortType = LvwSortTypeDate
                            Else
                                .SortType = LvwSortTypeText
                            End If
                        End With
                        'Save the settings in the registry
                        SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastColumnSortedOn", Setting:=(ColumnHeader.Index)
                        SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastSortType", Setting:=lvwDescending
                    Else
                        'Remove the sorting, i.e. apply default sort based on the ID column
                        With lvMerchandiseSectionDetails
                            .SortKey = 1
                            .SortOrder = lvwAscending
                            .Sorted = True
                            If ColumnHeader.Tag = "Numeric" Then
                                .SortType = LvwSortTypeNumeric
                            ElseIf ColumnHeader.Tag = "Date" Then
                                .SortType = LvwSortTypeDate
                            Else
                                .SortType = LvwSortTypeText
                            End If
                        End With
                        'Save the settings in the registry
                        SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastColumnSortedOn", Setting:=-1
                        SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastSortType", Setting:=-1
                    End If
                End If
            Else
                'First time the user clicked on something.
                'Sort the new column ascending
                With lvMerchandiseSectionDetails
                    .ColumnHeaders(ColumnHeader.Index).Text = .ColumnHeaders(ColumnHeader.Index).Text & " +"
                    .SortKey = ColumnHeader.Index - 1
                    .SortOrder = lvwAscending
                    .Sorted = True
                    If ColumnHeader.Tag = "Numeric" Then
                        .SortType = LvwSortTypeNumeric
                    ElseIf ColumnHeader.Tag = "Date" Then
                        .SortType = LvwSortTypeDate
                    Else
                        .SortType = LvwSortTypeText
                    End If
                End With
                'Save the setting in the registry
                SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastColumnSortedOn", Setting:=(ColumnHeader.Index)
                SaveSetting Appname:=APPLICATION_NAME, Section:="Merchandise Section Lists", Key:=Me.Name & "." & lvMerchandiseSectionDetails.Name & ".LastSortType", Setting:=lvwAscending
            End If
        End If
    End Sub

  11. #3891
    Fanatic Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    654

    Re: CommonControls (Replacement of the MS common controls)

    The SortType property along with associated lvwSortTypeConstant values was the key I was missing. All's working properly now. Thanks!

  12. #3892

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    Included enum value 'SbrPanelAlignmentLeftRight' for the Alignment property of a Panel in the StatusBar control.
    The picture will be left-aligned and the text right-aligned. (instead of aligning both together)
    If PictureOnRight property is true the logic is reversed. If no picture exists it behaves the same as 'SbrPanelAlignmentLeft'.

    The 1.8 OCX has been updated with the new enum value. (type lib edit)

  13. #3893
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    459

    Question SpinBox control bug?

    Win10, VB6sp6, VBCCR 1.8.55

    I have set up a max value of 9999 for the SpinBox but i still can enter higher numbers via the number keys.
    After pressing TAB the control doenst check the curent value in the spinbox against the max value setting.

    Is this behavior a bug or by design?

  14. #3894

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: SpinBox control bug?

    Quote Originally Posted by Mith View Post
    Win10, VB6sp6, VBCCR 1.8.55

    I have set up a max value of 9999 for the SpinBox but i still can enter higher numbers via the number keys.
    After pressing TAB the control doenst check the curent value in the spinbox against the max value setting.

    Is this behavior a bug or by design?
    The Text can be altered to higher than 9999 in your example.
    The Value property however is still 9999.
    Usually I call .ValidateText method in the SpinBox_Validate event to sync the text by the value.

  15. #3895
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    459

    Re: SpinBox control bug?

    Quote Originally Posted by Krool View Post
    The Text can be altered to higher than 9999 in your example.
    The Value property however is still 9999.
    Usually I call .ValidateText method in the SpinBox_Validate event to sync the text by the value.
    calling .ValidateText in the SpinBox_Validate event fixed the problem!

    Thx a lot!

  16. #3896
    Lively Member ScriptBASIC's Avatar
    Join Date
    Oct 2014
    Location
    Anacortes, WA
    Posts
    76

    Re: CommonControls (Replacement of the MS common controls)

    *** deleted ***
    Last edited by ScriptBASIC; Jan 13th, 2025 at 07:25 PM.

  17. #3897
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Krool, many thanks for the VBCCR controls.
    I'm using VBCCR18.ocx for building a listview on a userform in MS Excel VBA.
    Since MS's own listview does not support unicode, I found your listview control very useful and I'm very thankful to you about this.
    I am now in the process of rewriting my code to use VBCCR18's listview control.

    1. I'd like to report that while the listitems in MS's listview control could be checked (with checkboxes on) like LV1.Listitem(1).Checked=True and there will be a checkmark on that listitem's checkbox without triggering the LV1_ItemCheck(ByVal Item As MSComctlLib.ListItem) event!
    However, with the VBCCR18's listview, the ItemCheck event was triggered.
    This maybe by design by your intentionally.
    I am just reporting what I found.
    While I can work around this without much hassle, do you think that this should be this way or should I prepare for a change in this behavior in the future releases?

    2.With the VBCCR18's Treeview, I found that the Treeview's checkboxes are a bit lower than the +/- signs and the Node's Text in terms of vertical alignment.
    Therefore, is there any option to change the said text vertical alignment?

    3.I am also using VBFlexGrid18.ocx and I implemented a columnheader click to change sort direction and sort behavior.
    In this manner, I found that
    .Col = Col
    .ColSort(Col) = FlexSortGenericAscending
    .Sort = FlexSortUseColSort
    inside FG_CellClick(ByVal Row As Long, ByVal Col As Long, ByVal Button As Integer) sub.
    I have to include .Col=Col for Col0 which is a fixedColumn. The other non-fixedcolumns do not need that part.
    Is that intentional?
    Many thanks in advance.
    I can make videos or screenshots if you need a clearer picture.

  18. #3898

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by tragicshadow View Post
    Krool, many thanks for the VBCCR controls.
    I'm using VBCCR18.ocx for building a listview on a userform in MS Excel VBA.
    Since MS's own listview does not support unicode, I found your listview control very useful and I'm very thankful to you about this.
    I am now in the process of rewriting my code to use VBCCR18's listview control.

    1. I'd like to report that while the listitems in MS's listview control could be checked (with checkboxes on) like LV1.Listitem(1).Checked=True and there will be a checkmark on that listitem's checkbox without triggering the LV1_ItemCheck(ByVal Item As MSComctlLib.ListItem) event!
    However, with the VBCCR18's listview, the ItemCheck event was triggered.
    This maybe by design by your intentionally.
    I am just reporting what I found.
    While I can work around this without much hassle, do you think that this should be this way or should I prepare for a change in this behavior in the future releases?

    2.With the VBCCR18's Treeview, I found that the Treeview's checkboxes are a bit lower than the +/- signs and the Node's Text in terms of vertical alignment.
    Therefore, is there any option to change the said text vertical alignment?

    3.I am also using VBFlexGrid18.ocx and I implemented a columnheader click to change sort direction and sort behavior.
    In this manner, I found that
    .Col = Col
    .ColSort(Col) = FlexSortGenericAscending
    .Sort = FlexSortUseColSort
    inside FG_CellClick(ByVal Row As Long, ByVal Col As Long, ByVal Button As Integer) sub.
    I have to include .Col=Col for Col0 which is a fixedColumn. The other non-fixedcolumns do not need that part.
    Is that intentional?
    Many thanks in advance.
    I can make videos or screenshots if you need a clearer picture.
    Thanks for your feedback.

    1.
    Interesting that the ItemCheck event is not fired when checking a listitem by code in the MS listview.
    However, in the VBCCR ListView I just handle LVN_ITEMCHANGED and test for LVIS_CHECKED.
    So it could be a change in comctl32.dll. Because mscomctl.oxc is a zombie version of comctl32.dll. (very old)
    Bottom line, I won't artificially interrupt in the event handling. So adjust your code accordingly..

    2.
    no idea. Seems to be new windows default design.

    3.
    A fixed column is a non-movable area for your focus caret. So putting .Col = Col (change focus caret by code) is a necessary.

  19. #3899
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Thanks for your feedback.

    1.
    Interesting that the ItemCheck event is not fired when checking a listitem by code in the MS listview.
    However, in the VBCCR ListView I just handle LVN_ITEMCHANGED and test for LVIS_CHECKED.
    So it could be a change in comctl32.dll. Because mscomctl.oxc is a zombie version of comctl32.dll. (very old)
    Bottom line, I won't artificially interrupt in the event handling. So adjust your code accordingly..

    2.
    no idea. Seems to be new windows default design.

    3.
    A fixed column is a non-movable area for your focus caret. So putting .Col = Col (change focus caret by code) is a necessary.
    Many thanks for your kind reply.
    For 1.I will adjust my code but for clarity's sake, allow me to attach 2 .GIFs.
    a). for MSCOMCTL listview
    Name:  MSCOMCTL.jpg
Views: 929
Size:  35.7 KB
    b). for VBCCR18 listview
    Name:  VBCCR8.jpg
Views: 927
Size:  34.7 KB

    For 2.I will try to live with it but let me upload a screenshot. As for further info on this, I am using a screen scaling factor of 125% from Windows Settings because the resolution is set at 1920x1200 on a 3200x2000 (recommended) screen. I am not sure whether this affects or not, just wanted to give you as much info as I could.
    Name:  2025-01-18_11-48-14.jpg
Views: 925
Size:  45.2 KB

    For 3.Thanks to your kind explanation, I understand the concept now. Thank you.

    Have a nice weekend!

  20. #3900
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by tragicshadow View Post
    Many thanks for your kind reply.
    For 1.I will adjust my code but for clarity's sake, allow me to attach 2 .GIFs.
    a). for MSCOMCTL listview
    Name:  MSCOMCTL.jpg
Views: 929
Size:  35.7 KB
    b). for VBCCR18 listview
    Name:  VBCCR8.jpg
Views: 927
Size:  34.7 KB

    For 2.I will try to live with it but let me upload a screenshot. As for further info on this, I am using a screen scaling factor of 125% from Windows Settings because the resolution is set at 1920x1200 on a 3200x2000 (recommended) screen. I am not sure whether this affects or not, just wanted to give you as much info as I could.
    Name:  2025-01-18_11-48-14.jpg
Views: 925
Size:  45.2 KB

    For 3.Thanks to your kind explanation, I understand the concept now. Thank you.

    Have a nice weekend!
    I didn't know that .GIF's don't get animated. So, I am posting this to youtube and sharing the links here.
    1.MSCOMCTL ocx listview
    https://youtu.be/nwPJSuM628w

    2.VBCCR18 ocx listview
    https://youtu.be/o-yNDWdevQE

    Additional finding, I just found out (after making and uploading the videos to youtube) while fixing the code, that even with Application.EnableEvents=False, the ItemCheck event still got fired with VBCCR18's listview, when setting checked=true via Excel VBA code!

    I apologize for multiple posts but I honestly thought that .GIFs would be animated.

  21. #3901

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    2.
    Maybe you don't have a manifest to be DPI-Aware ? So windows is bitmap scaling and maybe messes up with the checkbox image as that maybe is scaled differently..
    So try a manifest or check if that issue persists in 100% DPI.

    3.
    You can use .Cell(FlexCellSort... to avoid changing the caret (.Col = Col or .Row = Row) at all.

  22. #3902
    Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    32

    Re: CommonControls (Replacement of the MS common controls)

    Hallo Krool,

    Using you ListView is extremely slow on my W7 machine.
    To load 900 items (adding3 subitems) takes about 30 sec.
    I turned off VisualStyles property, but it hardly helped.

    (I use .Redraw = false when loading)

    When I swap out the your ListView with the one from Common Controls Ocx v6, it only takes 1 sec.

    Can you help out?

    Thank you in advance!!

  23. #3903
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    2.
    Maybe you don't have a manifest to be DPI-Aware ? So windows is bitmap scaling and maybe messes up with the checkbox image as that maybe is scaled differently..
    So try a manifest or check if that issue persists in 100% DPI.

    3.
    You can use .Cell(FlexCellSort... to avoid changing the caret (.Col = Col or .Row = Row) at all.
    For 2., I tested with 100% scaling but still no go. It's okay. I can live with it.

    For 3., I will try it but I'm not sure how it works yet. Have to dig into it.

    The major headache now is 1.
    I uploaded 2 new videos to youtube to show some bizarre scenarios where:
    a) setting VBCCR18 listitem.checked=true/false triggers itemchecked event even when application.enableevents=false
    https://youtu.be/8hHECRpTaWo

    b) setting MSCOMCTL listitem.checked=true/false via Excel VBA code doesn't trigger ItemCheck event and also independent of application.enableevents
    https://youtu.be/OJJElXM4ZI8

    Even though I said it's a headache, I got over that issue with ItemCheck event using a module level variable so this is just me reporting my weird findings.

    And there's a new issue No.4 with VBCCR18, showing an empty line when listitems were added which did not happen with MSCOMCTL listview or vbflexgrid.
    c) VBCCR18 listview visible extra row (at the bottom) after adding listitems (though NO extra listitem was added)
    https://youtu.be/SeKV1s2aD-o

    d)MSCOMCTL listview NO extra row visible after adding listitems
    https://youtu.be/DmccNE3_Am8

    Sorry to be bothering you with too many issues.
    I am just reporting my findings while always thanking you, for these controls.

  24. #3904

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    tragicshadow,
    The list item height is slightly different from MS to VBCCR. When you want to set the height of the ListView exactly to a certain count of list items then use .ComputeControlSize.

    clintc,
    please provide demo replicating your issue.

  25. #3905
    Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    32

    Re: CommonControls (Replacement of the MS common controls)

    Hi Krool,

    Thanks for responding!

    I think the problem is on my side.

    I will test on Monday or Tuesday again and let you know!

  26. #3906
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    tragicshadow,
    The list item height is slightly different from MS to VBCCR. When you want to set the height of the ListView exactly to a certain count of list items then use .ComputeControlSize.
    Krool, I will play with .ComputeControlSize.
    Please allow me to ask for another issue. Really sorry about that especially during a weekend.

    I am not sure how to assign an array into a VBCCR18 ComboboxW.List.
    For the MSCOMCTL, we can assign just like Combobox.List=Array(1,2,3,4,5) and there is also support for multiple-column dropdown using the ColumnCount and ColumnWidths properties too.
    Name:  mscomctl comboboxw list.png
Views: 733
Size:  3.8 KB
    But for VBCCR18, I can't just assign an array to the .List like that because it keeps giving error like "Argument not optional".
    I tried different ways to use Index to assign single values or array of values but there's just no love.
    Name:  vbccr18 combobox list.png
Views: 733
Size:  3.6 KB
    I understand that they are of different data types and that I can use a loop with VBCCR18 ComboBoxW.AddItem, I am just wondering whether there's a way to add to ComboBoxW's list that I didn't know and is it possible to use a multi-column dropdown?
    Thanks in advance.

  27. #3907
    Registered User
    Join Date
    Jan 2025
    Posts
    1

    Re: CommonControls (Replacement of the MS common controls)

    Hello, this is my first post so apologies if this has already been asked before.

    I've checked the version 1.8 Krool CommonControls (Replacement of the MS common controls) revision history and haven't found any reference to the following.
    The replacement imagecombo control (I'm using the ActiveX Control version) doesn't appear to include either backcolor nor forecolor properties like the MS common controls imagecombo has, is this something that is possible or likely to be implemented?

    Many thanks for a great project.

  28. #3908

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by cydonia View Post
    Hello, this is my first post so apologies if this has already been asked before.

    I've checked the version 1.8 Krool CommonControls (Replacement of the MS common controls) revision history and haven't found any reference to the following.
    The replacement imagecombo control (I'm using the ActiveX Control version) doesn't appear to include either backcolor nor forecolor properties like the MS common controls imagecombo has, is this something that is possible or likely to be implemented?

    Many thanks for a great project.
    Unfortunately it's not possible. The ImageCombo (ComboBoxEx class) is a MS superclassed owner-drawn combo box control.
    We would need to overwrite complete owner-drawing which would nullify the ImageCombo per se, as you can then just resort to a normal ComboBox and set DrawMode accordingly.

    The MS ImageCombo is a zombified ComboBoxEx and include the source code directly, so they could influence the colors. It's unfair but that's how it is..

  29. #3909
    Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    32

    Re: CommonControls (Replacement of the MS common controls)

    Hi Krool,

    The problem was that the property "Sorted" was set to True prior to loading the data.
    Setting it to false afterwards solved the problem!

    Thank you!
    Last edited by clintc; Jan 19th, 2025 at 06:09 AM.

  30. #3910
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    526

    Re: CommonControls (Replacement of the MS common controls)

    IMAGE COMBO QUESTION

    I have an ImageCombo with images and text.
    When an item is selected, the ImageCombo has the focus.
    The image is also focused and doesn't look good.
    The image is clear when I move the focus to another control (e.g. on ImageCombo1_CloseUp).

    I want the image to be clear when an item is selected.
    Is there a way to do this without moving the focus to another control?

    ImageCombo.zip

  31. #3911

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    IMAGE COMBO QUESTION

    I have an ImageCombo with images and text.
    When an item is selected, the ImageCombo has the focus.
    The image is also focused and doesn't look good.
    The image is clear when I move the focus to another control (e.g. on ImageCombo1_CloseUp).

    I want the image to be clear when an item is selected.
    Is there a way to do this without moving the focus to another control?

    ImageCombo.zip
    I am not aware of how to avoid that. The ComboBoxEx class is using the ILD_SELECTED flag when using ImageList_Draw.
    To overcome that you would need to to use the classic ComboBox and use DrawMode as OwnerDrawn and draw it yourself.

  32. #3912
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    526

    Re: CommonControls (Replacement of the MS common controls)

    I am not aware of how to avoid that.
    I thought I'd miss a simple setting or so.
    SOLVED:
    No problem at all, I set the ImageCombo in a PictureBox and set the focus to it.

    Thanks Krool

  33. #3913
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    tragicshadow,
    The list item height is slightly different from MS to VBCCR. When you want to set the height of the ListView exactly to a certain count of list items then use .ComputeControlSize.
    Krool, VBCCR18 listview ocx version, doesn't respect the columnwidth set when the columns were first added like:
    Code:
    LV1.columnheaders.add Text:="abc", Width:=0
    and had to be set again after all listitems were loaded like
    Code:
    LV1.columnheaders(1).Width=0
    to hide them in report view.
    And I wish that the columnheaders(1).autosize=false to turn off column autofit feature from adjusting the column width so that columnwidths would stay the same as when they were first added, rather than setting them again later after the listitems were loaded.
    Above situation can be view at:https://youtu.be/qlDB1bLFznc
    Thanks in advance.

  34. #3914

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by tragicshadow View Post
    Krool, VBCCR18 listview ocx version, doesn't respect the columnwidth set when the columns were first added like:
    Code:
    LV1.columnheaders.add Text:="abc", Width:=0
    and had to be set again after all listitems were loaded like
    Code:
    LV1.columnheaders(1).Width=0
    to hide them in report view.
    And I wish that the columnheaders(1).autosize=false to turn off column autofit feature from adjusting the column width so that columnwidths would stay the same as when they were first added, rather than setting them again later after the listitems were loaded.
    Above situation can be view at:https://youtu.be/qlDB1bLFznc
    Thanks in advance.
    What you mean from adjusting the column width ? You can use ListView1.ColumnHeaders(1).Resizable = False so that a user cannot resize a column. Is that what you meant ?

    If confirm that the Width argument is flaw at interface design.. It should have been
    Code:
    Optional ByVal Width As Variant
    instead of
    Code:
    Optional ByVal Width As Single
    .
    Because the "default" width is now applied when Width is 0, but it should be only the default width when the argument is missing. When 0 is supplied the width should really be zero and not resorting to the default width.

  35. #3915

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    tragicshadow, good news. I managed to update the type lib to change the
    Code:
    Optional ByVal Width As Single
    into
    Code:
    Optional ByVal Width As Variant
    and this fixes your issue of:
    Code:
    LV1.columnheaders.add Text:="abc", Width:=0
    not working before. But now it works as the MS ListView control. When Width argument is missing at all it applies the default width, then as intended.

    Thanks for pointing this bug out.
    Last edited by Krool; Jan 25th, 2025 at 08:39 AM.

  36. #3916
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Update released.

    tragicshadow, good news. I managed to update the type lib to change the
    Code:
    Optional ByVal Width As Single
    into
    Code:
    Optional ByVal Width As Variant
    and this fixes your issue of:
    Code:
    LV1.columnheaders.add Text:="abc", Width:=0
    not working before. But now it works as the MS ListView control. When Width argument is missing at all it applies the default width, then as intended.

    Thanks for pointing this bug out.
    Krool, thanks for fixing that issue. Confirmed solved.

    One more thing, whenever I clicked the last visible row, NOT the last row, in a Listview, let's say containing like 20 rows, which is currently showing only the first 10 rows with row10 at the visible bottom, the rows automatically scrolled and showed me row11 without my intent.
    mscomctl listview doesn't have this behaviour. I am not saying it is wrong or bad because I have seen the same thing in some other windows applications.
    Could you please give us some form of control over that to not do it?

    I think this is the reason behind my earlier report (#3903 numbered c) about an inactive row added at the end of Listview.

    Thanks again for all your hard work!

  37. #3917

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by tragicshadow View Post
    Krool, thanks for fixing that issue. Confirmed solved.

    One more thing, whenever I clicked the last visible row, NOT the last row, in a Listview, let's say containing like 20 rows, which is currently showing only the first 10 rows with row10 at the visible bottom, the rows automatically scrolled and showed me row11 without my intent.
    mscomctl listview doesn't have this behaviour. I am not saying it is wrong or bad because I have seen the same thing in some other windows applications.
    Could you please give us some form of control over that to not do it?

    I think this is the reason behind my earlier report (#3903 numbered c) about an inactive row added at the end of Listview.

    Thanks again for all your hard work!
    You designed the UI and height based on the old controls.
    The new ListView has slightly different item heights which causes non-integral height and thus causes a scroll when you click on the half visible 11 row.
    Solution 1: use no manifest, thus VBCCR links to old comctl32 v 5.8
    Solution 2. Use .ComputeControlSize to change your UI during Form_Load.

  38. #3918
    New Member
    Join Date
    Oct 2020
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    You designed the UI and height based on the old controls.
    The new ListView has slightly different item heights which causes non-integral height and thus causes a scroll when you click on the half visible 11 row.
    Solution 1: use no manifest, thus VBCCR links to old comctl32 v 5.8
    Solution 2. Use .ComputeControlSize to change your UI during Form_Load.
    Hi, Krool, you ARE so right! It works now, I mean adjusting the height of VBCCR18 listview. There is NO extra row at the end and NO more scrolling up unnecessarily.
    I did try the .ComputeControlSize as soon as you mentioned it several posts above, but then I failed to get it working.

    I must admit that I have never seen or use that sub before. So, I assumed WRONGLY that I have to use the ProposedWidth and ProposedHeight because I misunderstood them like "if I set Width:=currentWidth and Height:=currentHeight and the Sub will propose suitable width and height in ProposedWidth and ProposedHeight!" after execution but then the returned(set) ProposedWidth and ProposedHeight were always the same as I set them before calling it.

    I search for others' examples on using .ComputeControlSize and I found an example but it was totally different from your method, so, I got more confused.
    I also found your code in your comment here,
    and I realized from your code that I have to use the actual Width and Height arguments and then, BAMM! it returned the corrected Width and Height, though in my case, I can use only Height as not all my columns are of the same width.

    My apologies for misunderstanding your kind instructions and many thanks for your help.

  39. #3919

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,545

    Re: CommonControls (Replacement of the MS common controls)

    Important note!

    When updating VBCCR18.OCX the interface of the Add method in LvwColumnHeaders changed.
    For compiled exe this can cause a crash, so just re-compile the exe. The project will run fine in the IDE of the new updated VBCCR18.

    Just compiled exe are affected which uses ListView column headers. It will crash on the Add method. So again, re-compile exe fixes the crash.

    Sorry, but this must have been fixed as this was a critical bug and to match behavior with MS ListView.
    Last edited by Krool; Jan 28th, 2025 at 03:00 AM.

  40. #3920
    New Member
    Join Date
    Jan 2025
    Posts
    6

    Re: CommonControls (Replacement of the MS common controls)

    greetings krool, with your rich textbox control, is this possible ? a textbox that accepts text and pictures can also be pasted in ? i would like the user to have note taking ability's, but more than just text, sometimes the user will want to take screen shots of an area of the desktop. that needs to fall into the rich textbox control . much like in ms word. text is great but sometimes a pic speaks volumes. right now if i try to paste a screenshot into the richtextbox a path to the file is inserted instead of the pic. i'm using the program called greenshot to grab a piece of the desktop. perhaps i should use a different screenshot program that fits the richtextbox better ?

Page 98 of 99 FirstFirst ... 48889596979899 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
  •  



Click Here to Expand Forum to Full Width