Page 97 of 98 FirstFirst ... 47879495969798 LastLast
Results 3,841 to 3,880 of 3888

Thread: CommonControls (Replacement of the MS common controls)

  1. #3841

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Mustaphi,
    which 1.8 version do you have ? (revision)

  2. #3842
    Fanatic Member
    Join Date
    Jan 2016
    Posts
    803

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Mustaphi,
    which 1.8 version do you have ? (revision)
    version 1.8.27
    https://www.vbforums.com/showthread....55#post5129155

  3. #3843
    Addicted Member gilman's Avatar
    Join Date
    Jan 2017
    Location
    Bilbao
    Posts
    207

    Re: CommonControls (Replacement of the MS common controls)

    I've the same problem, I try with the ocx and with the exe version. And, also, when I put a file jpg as picture in design time, this is not displayed, either at design time or at run time.
    Would be a problem with the OS version or VB6 version?
    Attached Images Attached Images   

  4. #3844

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Internal improvement for the ToolBar control.

    There are no redraw/refresh issues anymore on design time. (IDE)

    Also some code optimization to increase performance.

    Also adjustment for CoolBar concerning child sizes.
    Some childs, e.g. ToolBar, re-size itself.
    The CoolBar adjusted in the past when the child size increased, now it adjusts also when it decreases. (But CY must be > 0 for the child to avoid false adjustment)

    I didn't update change log, falls all under the recent internal improvement.

    Info: the reactos toolbar.c source helped a lot solving some last edge cases and be more straight forward in the quirks.

    Update: MaxTextRows property is now allowed to be set to 0 in the ToolBar control.
    Last edited by Krool; Aug 23rd, 2024 at 02:41 PM.

  5. #3845
    Junior Member
    Join Date
    Nov 2015
    Posts
    31

    Re: CommonControls (Replacement of the MS common controls)

    I noticed that MSCOMCTL had an enum defined called ClipboardConstants which VBCCR (1.7) does not seem to include. IDL definition from MSCOMCTL pasted below.

    While it would be nice if this were in VBCCR, I'm sure there was a good reason to omit it. Probably nothing else in the same library utilizes it. (It is similarly not referenced anywhere in the MSCOMCTL IDL).

    Are there any recommendations for a suitable replacement? Obviously I can define my own enum with the same values but if there is a pre-existing standard place [e.g, DLL] to get it from that would be better.

    Thanks!


    Code:
        typedef [uuid(D8898462-742F-11CF-8AEA-00AA00C00905), helpstring("Clipboard format constants."), helpcontext(0x00033681)]
        enum {
            ccCFText = 1,
            ccCFBitmap = 2,
            ccCFMetafile = 3,
            ccCFDIB = 8,
            ccCFPalette = 9,
            ccCFEMetafile = 14,
            ccCFFiles = 15,
            ccCFRTF = -16639
        } ClipBoardConstants;
    Last edited by DaveInCaz; Aug 29th, 2024 at 11:37 AM.

  6. #3846
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,098

    Talking Re: CommonControls (Replacement of the MS common controls)

    From MSDN:

    Code:
    Constant Value Description 
    vbCFRTF -16639 Rich Text Format (.rtf file) 
    vbCFLink -16640 DDE conversation information 
    vbCFText 1 Text (.txt file) 
    vbCFBitmap 2 Bitmap (.bmp file) 
    vbCFMetafile 3 Metafile (.wmf file) 
    vbCFDIB 8 Device-independent bitmap 
    vbCFPalette 9 Color palette 
    vbCFEMetaFile 14 Enhanced metafile (.emf file) 
    vbCFFiles 15 File list from Windows Explorer

  7. #3847

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    The height of the header will now be adjusted according to ColumnHeaderIcons in the ListView control.

    This is the same behavior as for the original MS ListView control for VB6. An ImageList of 32x32 will therefore increase the header portion.
    To note is that when VisualStyles are set or HDS_FLAT is set there is no extra spacing added as not necessary.
    Else the spacing (2x SM_CYEDGE) is added for the classic edges so that the icon better fits. (and to match MS ListView behavior)

    When HDS_FILTERBAR is set the header must be set x2. So, for an 32x32 icon the size is treated as 64px.

  8. #3848

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    Internal improvement for the ImplementThemedReBarFix for the CoolBar control. (usage of GetThemePartSize)

  9. #3849

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    Internal improvement in the DrawPanel method for the StatusBar control.
    For the center alignment there was a minor calc. bug when a picture is set and for higher dpi's it matches now 100% as a non-ownerdraw statusbar would display.
    Also there was 1px offset in the Y pos of the text output vs. non-ownerdraw statusbar.
    Also the internal GetGoodWidth function for auto-size is adjusted to these fixes.

  10. #3850
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,595

    Re: CommonControls (Replacement of the MS common controls)

    Deleted, Krool responded with good answer in the Q&A section of these forums.
    Last edited by Elroy; Sep 16th, 2024 at 08:07 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.

  11. #3851

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    Bugfix that the Text property was not the default property in the SbrPanel object.

    Included the PictureOnRight property of a Panel in the StatusBar control.

    I needed to edit the type lib for SbrPanel anyway in the VBCCR18.OCX. Thus the new PictureOnRight property is also included. (similar to IconOnRight in LvwColumnHeader)

    The Picture of a Panel will now be drawn embossed when the Enabled property is False in the StatusBar control.
    Also the grayed text is now drawn using TextOut instead of DrawState for standard VB-ish appearance.

    Bug in the internal ReCreateToolBar method that the button menus picture property was not restored.

  12. #3852
    Member
    Join Date
    Mar 2020
    Posts
    43

    Re: CommonControls (Replacement of the MS common controls)

    Maybe it is already known, but I did not :

    Code:
    Private Sub Form_Load()
    
    	ImageCombo1.Text = vbNullString	
    	ImageCombo2.Text = ""
    
    End Sub
    In this case, ImageCombo1 will not be empty whereas ImageCombo2 will. (only tested in the IDE).

  13. #3853

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Crapahute View Post
    Maybe it is already known, but I did not :

    Code:
    Private Sub Form_Load()
    
    	ImageCombo1.Text = vbNullString	
    	ImageCombo2.Text = ""
    
    End Sub
    In this case, ImageCombo1 will not be empty whereas ImageCombo2 will. (only tested in the IDE).
    Thanks. No it was not aware, will fix soon at next oppurtunity.
    It seems like the ComboBoxEx class doesn't like a null pointer.

    EDIT: Fixed. Thx
    Last edited by Krool; Sep 26th, 2024 at 01:32 AM.

  14. #3854

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    Bugfix in the ListBoxW when Style is 1 - Checkbox or 2 - Option at higher DPI.

    The old code for the checkbox or optionbutton image was:
    Code:
    ListBoxStateImageSize = (15 * PixelsPerDIP_X())
    However, at some DPI's it was wrong. The new code is:
    Code:
    ListBoxStateImageSize = (13 * PixelsPerDIP_X()) + 2
    The padding is always fixed at 2. (for hit-testing/item height etc. the 2 × 1px space padding is important)
    The actual image is then drawn without this padding. (then effectively ListBoxStateImageSize - 2)
    Last edited by Krool; Oct 13th, 2024 at 11:25 AM.

  15. #3855
    Fanatic Member
    Join Date
    Oct 2005
    Posts
    577

    Re: CommonControls (Replacement of the MS common controls)

    Ok... feeling stupid here. Most of the controls seem to work well but a few give an error when added to a form:

    The X control requires at least version 6.0 of comctl32.dll

    Now it wants me to make a manifest for my project. Bit lost here. Can somebody explain it to me like I'm 5... what am I supposed to do to make a manifest for version 6.0 of comctl32.dll?

  16. #3856
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,465

    Re: CommonControls (Replacement of the MS common controls)

    CommonControls (Replacement of the MS common controls)-VBForums
    ?I hope this control can also achieve full transparency.?

    https://www.vbforums.com/showthread....ntrol-supports
    Attached Images Attached Images   

  17. #3857
    Junior Member
    Join Date
    Jan 2014
    Location
    Oregon
    Posts
    26

    Re: CommonControls (Replacement of the MS common controls)

    On the treeview control, when there is images next to the check boxes there is no padding like there is with the text after the image.
    Is there a way to change the padding from the checkbox before the image? Possibly even the padding between nodes?

    Attachment 193151

  18. #3858
    Junior Member
    Join Date
    Jan 2014
    Location
    Oregon
    Posts
    26

    Re: CommonControls (Replacement of the MS common controls)

    Another problem I have ran into. Listview with groups. When you have a large number of groups, doing anything with the group header or looping through the groups slows down to a crawl.

    Example, Have 19,000 groups 57000 items. Everything loads up nice and fast.
    But loop through the groups for anything is a huge slow down, like looping through the groups to get the item count and update the group header to show have many items are in the group.
    Also looping through the groups to set the checkbox on everything except the first item in the group.

    When testing with say 150 groups there is no problem. I'm not sure what the number is on the groups to cause such a slow down. Not sure why simply looping through a high number of groups is so slow.

    Here is an code example

    Code:
        i = 0
        lListTotal = 0
        DoEvents
    
        lListTotal = ListViewDupFiles.Groups.count
    
        If Not lListTotal = 0 Then
    
            For i = 1 To lListTotal
                ListViewDupFiles.Groups(i).Header = ListViewDupFiles.Groups(i).Header & " (File Count: " & ListViewDupFiles.Groups(i).ListItemIndices.count & ")"
                DoEvents
            Next i
    
        End If
    Then an example of selecting everything in a group except the first item

    Code:
        Dim i          As Long
        Dim i2          As Long
        Dim lListTotal As Long
        Dim lListTotal2 As Long
        
        i = 0
        lListTotal = 0
        DoEvents
        
        lListTotal = ListViewDupFiles.Groups.count
        
        If Not lListTotal = 0 Then
    
            For i = 1 To lListTotal
                i2 = 0
                lListTotal2 = 0
                DoEvents
                lListTotal2 = ListViewDupFiles.Groups(i).ListItemIndices.count
                
                For i2 = lListTotal2 To 2 Step -1
                   ListViewDupFiles.ListItems.Item(ListViewDupFiles.Groups(i).ListItemIndices(i2)).Checked = True
                   DoEvents
                Next
                ListViewDupFiles.ListItems.Item(ListViewDupFiles.Groups(i).ListItemIndices(1)).Checked = False
                DoEvents
                
            Next i
    
        End If
        
        DoEvents
    Edit: I will do some testing and see if the problem is looping through a high number of groups or if the slow down is in calling the ListItemIndices on such a high number of groups.

    Edit2: Diffidently doing anything with the groups. Next code example is just looping through each group header and updating it.

    Code:
        Dim i          As Long
        Dim i2          As Long
        Dim lListTotal As Long
        Dim lListTotal2 As Long
        
        i = 0
        lListTotal = 0
        DoEvents
        
        lListTotal = ListViewDupFiles.Groups.count
        
        If Not lListTotal = 0 Then
    
            For i = 1 To lListTotal
                
                ListViewDupFiles.Groups(i).Header = ListViewDupFiles.Groups(i).Header & " - Done!"
                DoEvents
                
            Next i
    
        End If
        
        DoEvents
    Last edited by SMC1979; Oct 22nd, 2024 at 08:45 PM.

  19. #3859

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    SMC1979,

    Try a "For Each" loop with the groups. That's faster than accessing the collection by index.

  20. #3860
    Junior Member
    Join Date
    Jan 2014
    Location
    Oregon
    Posts
    26

    Re: CommonControls (Replacement of the MS common controls)

    Just tried that. Same slow down, updates the group at about 1 group per second. Again only when there is a TON of groups such as 19000. When I test with say 150 groups its nearly instant.

    I was able to get past the selecting everything in a group except the first one by putting a tag on that list item and then I just loop through all the items like normal putting the check box on while skipping any with the tag set. On the 57000 items that takes about 3 or 4 sec.

    For some reason once the groups have been created they are very slow to loop through.

    I will do a test now where I will just loop through the groups and have it simply add to counter, no changing anything of the group and see the speed it does. That way I can tell if it is the looping that is slow.

    Code:
    Dim gGroup As LvwGroup
    
    For Each gGroup In ListViewDupFiles.Groups
        gGroup.Header = gGroup.Header & " - " & gGroup.ListItemIndices.count
        DoEvents
    Next

  21. #3861
    Junior Member
    Join Date
    Jan 2014
    Location
    Oregon
    Posts
    26

    Re: CommonControls (Replacement of the MS common controls)

    OK just doing a simple loop was fast, 19000 groups took about 3 or 4 sec to count.

    So for some reason reading the ListItemIndices or changing the header is what is slow when there is a ton of groups.

    For now I will just have to skip changing the header to include the count.

    Code:
    Dim gGroup As LvwGroup
    Dim i As Long
     i = 0
    For Each gGroup In ListViewDupFiles.Groups
        i = i + 1
        Label1.Caption = i
        DoEvents
    Next

  22. #3862
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,465

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by SMC1979 View Post
    OK just doing a simple loop was fast, 19000 groups took about 3 or 4 sec to count.

    So for some reason reading the ListItemIndices or changing the header is what is slow when there is a ton of groups.

    For now I will just have to skip changing the header to include the count.

    Code:
    Dim gGroup As LvwGroup
    Dim i As Long
     i = 0
    For Each gGroup In ListViewDupFiles.Groups
        i = i + 1
        Label1.Caption = i
        DoEvents
    Next
    If you have tens of thousands to millions of data, you set it to the virtual table mode.Your data is only placed in the array, and the control does not participate in the processing.The size of the space determines how many rows it displays, for example, s rows, from which it will extract only the 20 rows of data it needs.

    So when you have 10,000 data and 10 million data, the speed is almost the same.

  23. #3863
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    The Aug 14th, 2014, 06:24 PM:
    https://www.vbforums.com/showthread....ntrols)/page12
    Quote Originally Posted by Krool View Post
    Quote Originally Posted by I-Like-Toast View Post
    Is it possible to set the RTB background to transparent?

    The following seems to work for the original Rich Text Box, but for some reason not the new one:

    SetWindowLong richtextbox1.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
    It actually works. But, as there is a underlying UserControl under the RichTextBox it will always show the background of the UserControl. Thus it is not visible transparent. But again, the actual RichTextBox is indeed transparent with this.

    I could make a 'Transparent' property for the RichTextBox which would do two things.
    1. Set the WS_EX_TRANSPARENT extended style to the RichtTextBox control.
    2. Make the background of the UserControl a replica of the underlying background to simulate transparency.
    Sorry Kroll, this message is the 10 years ago...

    If you can tell me, did you find any problem in making it transparent or allowing a background image to be put on it, features that can be interesting at certain times, or I can try to modify the OCX so that it does so...

    Well, if after 10 years the control still cannot be made transparent, it may not be possible, and in that case I won't waste time trying, Because I have to finish a program for my company and I am short on time...

    If you have time and want to answer me, of course...

    Thanks in advance... Greetings!!!
    Last edited by James Reynolds; Oct 25th, 2024 at 03:46 AM.

  24. #3864
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    I've done a little hack and it works for me, since I don't really want a RichTextBox, but a Label with full unicode support and SetAligment = 3 (Justified Text) and that I can put a background image on.

    I already have it by adding a PictureBox to the Krool Usercontrol, and:
    SetWindowLong RichtextBox1.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
    (I'll set it internally later)

    I don't know why the Krool usercontrol doesn't support Picture properties, do error when a Property is Picture and in code write RichTextBox1.Picture = LoadPicture(Path), but I've put a String property that is the Path of the Image that I want to load and there I do internally the Picture1.Picture = LoadPicture(String Path), I have to implement capturing what is behind the usercontrol as the 2nd option...

    But it doesn't work like a RichTextBox, but rather like a Label, it's not really transparent, but by capturing the image behind the control I can pass the Background to the RichTextBox... But it can be implemented so that if you don't want a Picture, it behaves like a Krool RichTextBox Control...

    When I have it polished, I'll put it here in case anyone is interested, but it's like a Label with a Background Image, which could be like transparent capturing what is behind the Control, and the Complete Unicode and Justified Text properties with the Margins...
    Last edited by James Reynolds; Oct 25th, 2024 at 08:43 AM.

  25. #3865
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,465

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by James Reynolds View Post
    I've done a little hack and it works for me, since I don't really want a RichTextBox, but a Label with full unicode support and SetAligment = 3 (Justified Text) and that I can put a background image on.

    I already have it by adding a PictureBox to the Krool Usercontrol, and:
    SetWindowLong RichtextBox1.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
    (I'll set it internally later)

    I don't know why the Krool usercontrol doesn't support Picture properties, do error when a Property is Picture and in code write RichTextBox1.Picture = LoadPicture(Path), but I've put a String property that is the Path of the Image that I want to load and there I do internally the Picture1.Picture = LoadPicture(String Path), I have to implement capturing what is behind the usercontrol as the 2nd option...

    But it doesn't work like a RichTextBox, but rather like a Label, it's not really transparent, but by capturing the image behind the control I can pass the Background to the RichTextBox... But it can be implemented so that if you don't want a Picture, it behaves like a Krool RichTextBox Control...

    When I have it polished, I'll put it here in case anyone is interested, but it's like a Label with a Background Image, which could be like transparent capturing what is behind the Control, and the Complete Unicode and Justified Text properties with the Margins...
    https://www.vbforums.com/showthread....ntrol-supports
    With this method, I can copy the background behind each space.It can be done with only one line of code.
    If there are multiple controls behind it, it's like true transparency.
    If your space is constantly moving, it can also achieve a transparent effect.

  26. #3866
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by xiaoyao View Post
    https://www.vbforums.com/showthread....ntrol-supports
    With this method, I can copy the background behind each space.It can be done with only one line of code.
    If there are multiple controls behind it, it's like true transparency.
    If your space is constantly moving, it can also achieve a transparent effect.
    Thanks xiaoyao, well, a question, I need to use in the VB6 ide?

    I'm already completing the RichTextcontrol and it works fine, and it will work as a complete RichTextBox, I have removed the Picture, and I load the Picture in Usercontrol.Picture, and if you do "ImagePath = valid path image", convert to transparent the richTextBoxHandle, and loads the Image in UserControl.Picture, if you do ImagePath = "" the transparency is removed and it works as it is in the original RichTextBox of Krool, without a background Image.

    I create this Property:

    Code:
    Public Property Get ImagePath() As String
        ImagePath = m_ImagePath
    End Property
    
    Public Property Let ImagePath(ByVal newPath As String)
        If newPath = "" Then
            Set UserControl.Picture = Nothing
            RemoveTransparency
            PropertyChanged "ImagePath"
            UserControl.Refresh
        ElseIf Dir(newPath) <> "" Then
            m_ImagePath = newPath
            SetWindowLong richTextBoxHandle, GWL_EXSTYLE, WS_EX_TRANSPARENT
            ' Load the image to the UserControl
            Set UserControl.Picture = LoadPicture(m_ImagePath)
            PropertyChanged "ImagePath"
            UserControl.Refresh
        Else
            MsgBox "The image is not found at the specified path.", vbExclamation
        End If
    End Property
    Public Sub RemoveTransparency()
        Dim currentStyle As Long
        currentStyle = GetWindowLong(richTextBoxHandle, GWL_EXSTYLE)
        currentStyle = currentStyle And Not WS_EX_TRANSPARENT
        SetWindowLong richTextBoxHandle, GWL_EXSTYLE, currentStyle
    End Sub
    Now I need to capture what is under the RichTextBox, add a property that tells the RichTextBox from Krool to make it transparent by capturing what is under the RichTextBox, but I want that process to be internal in the RichTextBox usercontrol itself... I'll look at your code there xiaoyao!!!

    Then I have to add some Stretch or Autosize property to the Image.

    But it's being easier than I thought... And it's going to have all the functionality of the Krool RichTextBox, I think, I still need to test it thoroughly...
    Last edited by James Reynolds; Oct 25th, 2024 at 01:13 PM.

  27. #3867
    Junior Member
    Join Date
    Jan 2014
    Location
    Oregon
    Posts
    26

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by xiaoyao View Post
    If you have tens of thousands to millions of data, you set it to the virtual table mode.Your data is only placed in the array, and the control does not participate in the processing.The size of the space determines how many rows it displays, for example, s rows, from which it will extract only the 20 rows of data it needs.

    So when you have 10,000 data and 10 million data, the speed is almost the same.
    Sadly, Group view doesn't work in virtual mode.

  28. #3868
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,465

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by James Reynolds View Post
    Thanks xiaoyao, well, a question, I need to use in the VB6 ide?

    I'm already completing the RichTextcontrol and it works fine, and it will work as a complete RichTextBox, I have removed the Picture, and I load the Picture in Usercontrol.Picture, and if you do "ImagePath = valid path image", convert to transparent the richTextBoxHandle, and loads the Image in UserControl.Picture, if you do ImagePath = "" the transparency is removed and it works as it is in the original RichTextBox of Krool, without a background Image.

    I create this Property:

    [CODE]Public Property Get ImagePath() As String
    ImagePath = m_ImagePath
    End Property

    Public Property Let ImagePath(ByVal newPath As String)
    If newPath = "" Then
    Set UserControl.Picture = Nothing
    RemoveTransparency
    PropertyChanged "ImagePath"
    UserControl.Refresh
    ElseIf Dir(newPath) <> "" Then
    m_ImagePath = newPath
    SetWindowLong richTextBoxH
    But it's being easier than I thought... And it's going to have all the functionality of the Krool RichTextBox, I think, I still need to test it thoroughly...
    Sub TransparentWithHdc(MyHwnd As Long, MyHdc As Long)
    If MyHdc = 0 Or MyHwnd = 0 Then MsgBox "Need CONTROL WITH HWND / HDC VALUE"



    UserControl.HDC,UserControl.HWND
    YOU ONLY NEED SET UserControl.AUTOREDRAW=TRUE

    code in UserControl.ctl
    Code:
    Private Sub UserControl_Initialize()
    UserControl.AutoRedraw = True
    
    End Sub
    Sub Transparent_Me()
        TransparentWithHdc UserControl.hwnd, UserControl.Hdc
    End Sub
    call on form1:

    Code:
    Private Sub Form_Load()
        Me.Picture = LoadPicture("img.jpg")
    End Sub
    
    Private Sub Command1_Click()
        UserControl11.Transparent_Me
    End Sub
    
    'FOR MOVE CONTROL
    Private Sub Command2_Click()
        UserControl11.Left = UserControl11.Left + UserControl11.Width / 2
        UserControl11.Transparent_Me
    End Sub
    Last edited by xiaoyao; Oct 28th, 2024 at 06:38 AM.

  29. #3869
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by xiaoyao View Post
    Sub TransparentWithHdc(MyHwnd As Long, MyHdc As Long)
    If MyHdc = 0 Or MyHwnd = 0 Then MsgBox "Need CONTROL WITH HWND / HDC VALUE"



    UserControl.HDC,UserControl.HWND
    YOU ONLY NEED SET UserControl.AUTOREDRAW=TRUE

    code in UserControl.ctl
    Code:
    Private Sub UserControl_Initialize()
    UserControl.AutoRedraw = True
    
    End Sub
    Sub Transparent_Me()
        TransparentWithHdc UserControl.hwnd, UserControl.Hdc
    End Sub
    call on form1:

    Code:
    Private Sub Form_Load()
        Me.Picture = LoadPicture("img.jpg")
    End Sub
    
    Private Sub Command1_Click()
        UserControl11.Transparent_Me
    End Sub
    
    'FOR MOVE CONTROL
    Private Sub Command2_Click()
        UserControl11.Left = UserControl11.Left + UserControl11.Width / 2
        UserControl11.Transparent_Me
    End Sub
    Ok xiaoyao, thanks, but I solutioned internally in the RichTextBox... Capturing the HDC of the container of the Krool RichTextBox...

  30. #3870
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Another question, in RichTextBox of Krool are any property for know the TextHeight for a given width?

  31. #3871

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    The MDI_ToolBar demo now uses WH_GETMESSAGE instead of WH_KEYBOARD_LL hook to avoid beep on alt key press.

  32. #3872
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by James Reynolds View Post
    Another question, in RichTextBox of Krool are any property for know the TextHeight for a given width?
    Check out the EM_FORMATRANGE message and the FORMATRANGE structure. If you set the bounds of your target rectangle but use &H7FFFFFFF for the rc.Bottom property value and send the EM_FORMATRANGE to the RTB with a wParam of 0 (to just measure, not render) then the rc.Bottom will be set to the height of the formatted text in twips. If the .Bottom value remains at &H7FFFFFFF then you should assume a height of 0 twips.

    Don't forget to cleanup when you are done by sending a second EM_FORMATRANGE message with wParam and lParam set to 0.

  33. #3873
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,465

    Re: CommonControls (Replacement of the MS common controls)

    The text box you designed can not set the margin. Like two pixels or eight pixels.
    Can text be centered vertically?
    Suppose the text box is 200 pixels high and the margins are set to two pixels. So the text should be set to 196 pixels.

    This is how to set auto height and auto width. Adapt according to the size of the space or the size of the text?
    autofill
    Or auto-crop to make the control smaller.
    Attached Images Attached Images   
    Last edited by xiaoyao; Oct 29th, 2024 at 05:05 AM.

  34. #3874
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by jpbro View Post
    Check out the EM_FORMATRANGE message and the FORMATRANGE structure. If you set the bounds of your target rectangle but use &H7FFFFFFF for the rc.Bottom property value and send the EM_FORMATRANGE to the RTB with a wParam of 0 (to just measure, not render) then the rc.Bottom will be set to the height of the formatted text in twips. If the .Bottom value remains at &H7FFFFFFF then you should assume a height of 0 twips.

    Don't forget to cleanup when you are done by sending a second EM_FORMATRANGE message with wParam and lParam set to 0.
    Thanks again jpbro, but uhmm, could you give me a little bit of the code, or don't you have it at hand...?

    On the other hand, I think that the control itself should have 2 properties, textWidth and textHeight, to know how much the text takes up in many situations, like, for example, I'm going to use it to have full Unicode in a Tooltip and justified with de margins, with this way it will look very perfect to the eye, and there I need to know the width and height of the text, because in a ToolTip there can't be scroll bars...

    Greetings jpbro, if you have the code at hand, if not, don't waste your time... Greetings to you and to everyone...

  35. #3875

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Update released

    Concerning the recent MDI_ToolBar demo change to use WH_GETMESSAGE instead of WH_KEYBOARD_LL hook to avoid the beeps on alt key press. (the beep was only when a modal popup drop-down menu is shown)

    In this regard I did also now a bugfix in the .ContainerKeyDown function in the ToolBar control.

    The function will now return Nothing when a popup menu is already present.

    It checks first, if it's own popup menu is present. (ToolBarPopupMenuHandle <> NULL_PTR)

    But in addition it checks whether an application popup menu (form menu, context menu etc.) is also shown. And when a popup menu is shown .ContainerKeyDown will return Nothing to intentionally cause a beep.
    For this the code from https://stackoverflow.com/questions/...ny-menu-opened was useful.
    I adopted it as following to be more efficient and faster:


    Code:
    If EnumThreadWindows(App.ThreadID, AddressOf ComCtlsTbrEnumThreadWndProc, 0) = 0 Then ' Menu is present
    Code:
    Public Function ComCtlsTbrEnumThreadWndProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
    If GetClassLong(hWnd, GCW_ATOM) = &H8000& Then ComCtlsTbrEnumThreadWndProc = 0 Else ComCtlsTbrEnumThreadWndProc = 1
    End Function

  36. #3876
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by jpbro View Post
    Check out the EM_FORMATRANGE message and the FORMATRANGE structure. If you set the bounds of your target rectangle but use &H7FFFFFFF for the rc.Bottom property value and send the EM_FORMATRANGE to the RTB with a wParam of 0 (to just measure, not render) then the rc.Bottom will be set to the height of the formatted text in twips. If the .Bottom value remains at &H7FFFFFFF then you should assume a height of 0 twips.

    Don't forget to cleanup when you are done by sending a second EM_FORMATRANGE message with wParam and lParam set to 0.
    Ok jpbro, I've fixed it, with chatGPT, it's a bit messy in Krool's richtextBox, but I've fixed it, apparently, with this:

    Code:
    'To avoid creating interference with the Krool Types
    Private Type CHARRANGE_HEIGHT
        cpMin As Long
        cpMax As Long
    End Type
    Private Type FORMATRANGE_HEIGHT
        hdc As Long
        hdcTarget As Long
        rc As RECT
        rcPage As RECT
        chrg As CHARRANGE_HEIGHT
    End Type
    
    Public Property Get TextHeight() As Long
        TextHeight = GetRichTextHeight(richTextBoxHandle)
    End Property
    
    Public Function GetRichTextHeight(richTextBoxHwnd As Long) As Long
        Dim fr As FORMATRANGE_HEIGHT
        Dim rc As RECT
        Dim rcPage As RECT
        Dim charRange As CHARRANGE_HEIGHT
        Dim result As Long
    
        Dim targetWidth As Long
        targetWidth = CalculateTargetWidth()
        
        ' Set the range of characters to measure (all text)
        charRange.cpMin = 0
        charRange.cpMax = -1
    
        ' Set the RECT to define the width of the target area and a very large height
        rc.Left = 0
        rc.Top = 0
        rc.Right = targetWidth
        rc.Bottom = &H7FFFFFFF ' High value to get the necessary height
    
        ' Set the RECT of the page
        rcPage = rc
    
        ' Fill the FORMATRANGE_HEIGHT structure
        fr.hdc = GetDC(richTextBoxHwnd) ' Get the RichTextBox device context
        fr.hdcTarget = fr.hdc ' The context of the target device (same in this case)
        fr.rc = rc
        fr.rcPage = rcPage
        fr.chrg = charRange
    
        ' Send the EM_FORMATRANGE message to measure the text
        result = SendMessage(richTextBoxHwnd, EM_FORMATRANGE, 0, fr)
    
        ' Release the device context
        ReleaseDC richTextBoxHwnd, fr.hdc
    
        ' Clean up after measuring
        SendMessage richTextBoxHwnd, EM_FORMATRANGE, 0, ByVal 0&
    
        ' Return the height in twips
        GetRichTextHeight = result
    End Function
    Private Function CalculateTargetWidth() As Long
        Dim borderWidthTwips As Long
        Dim BorderX As Long, BorderY As Long
    
        Const SM_CXEDGE As Long = 45
        Const SM_CYEDGE As Long = 46
        
        ' Get the border width dynamically based on system settings
        BorderX = GetSystemMetrics(SM_CXEDGE)
        BorderY = GetSystemMetrics(SM_CYEDGE)
    
        ' Determine the border width based on current properties
        If PropBorderStyle = vbFixedSingle Then
            If PropVisualStyles = True And RichTextBoxEnabledVisualStyles = True Then
                ' Visual style enabled, border could be thicker
                borderWidthTwips = 2 * BorderX
            Else
                ' Classic style, 1 pixel border on each side
                borderWidthTwips = 1 * BorderX
            End If
        Else
            ' Without border
            borderWidthTwips = 0
        End If
    
        ' Calculate the target width for the text
        CalculateTargetWidth = UserControl.ScaleWidth - borderWidthTwips
    End Function
    I don't know if the CalculateTargetWidth function is correct, I got a bit confused with RichTextBoxEnabledVisualStyles...

    And I'm almost completely ready to the RichTextBox have a background image, or a semi-transparent image capturing what's behind the user control, just a few flickering adjustments...

    Greetings...
    Last edited by James Reynolds; Oct 29th, 2024 at 05:10 PM.

  37. #3877
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by James Reynolds View Post
    Ok jpbro, I've fixed it, with chatGPT, it's a bit messy in Krool's richtextBox, but I've fixed it, apparently, with this:

    .../...

    I don't know if the CalculateTargetWidth function is correct, I got a bit confused with RichTextBoxEnabledVisualStyles...

    And I'm almost completely ready to the RichTextBox have a background image, or a semi-transparent image capturing what's behind the user control, just a few flickering adjustments...

    Greetings...
    It doesn't work, it doesn't give the full height of the text in the Krool RTB...

  38. #3878
    Addicted Member
    Join Date
    Jan 2008
    Posts
    153

    Re: CommonControls (Replacement of the MS common controls)

    At the moment, for text only, this code below perfectly measures the total height using a visible = false picturebox.

    But there should be, or maybe there is in subclassed RTB, a way to know the total height - including the non-visible parts - according to the width that the RTB has, but that includes the images or objects that an RTB can have...

    It works by calculating letter by letter - spaces and vbcr and vblf and so on - the width, when it exceeds the width of the RTB - which is the same in the Picturebox - it makes a line break in the last space, so as not to put cut words, and so on until the end, and the last currentY gives the total height, but only for text - unicode included -...

    Krool, sorry, you don't know how to put a property that gives the total height with rich text?

    Code:
    Private Declare Function GetTextExtentPoint32W Lib "gdi32" (ByVal hdc As Long, ByVal lpString As Long, ByVal c As Long, lpSize As SIZE) As Long
    
    Private Type SIZE
        cx As Long
        cy As Long
    End Type
    
    Private Function GetTotalTextHeightUsingPictureBox(rtbFont As StdFont, rtbWidth As Long, text As String, picBox As PictureBox) As Long
        ' Set the width of the PictureBox to match the width of the RichTextBox
        picBox.ScaleMode = vbPixels
        picBox.Width = rtbWidth / Screen.TwipsPerPixelX
    
        ' Copy the font from the RichTextBox to the PictureBox
        Set picBox.Font = rtbFont
    
        ' Prepare the PictureBox to measure the text
        picBox.AutoRedraw = True
    
        ' Get the device context (DC) of the PictureBox
        Dim hdc As Long
        hdc = picBox.hdc
    
        ' Variables for text size
        Dim currentX As Long, currentY As Long
        Dim lineHeight As Long
        Dim textSize As SIZE
        Dim charIndex As Long
        Dim currentChar As String
        Dim wordBuffer As String
        Dim wordWidth As Long
    
        ' Initialize coordinates and line height
        currentX = 0
        currentY = 0
        lineHeight = 0
        wordBuffer = ""
        wordWidth = 0
    
        ' Loop through each character in the text
        For charIndex = 1 To Len(text)
            currentChar = Mid$(text, charIndex, 1)
    
            ' If it is a line break, increment currentY and reset currentX
            If currentChar = vbCr Or currentChar = vbLf Then
                ' Add the height of the current line if it exists
                If lineHeight = 0 Then
                    ' If we haven't established a line height yet, measure a standard character to use it
                    GetTextExtentPoint32W hdc, StrPtr("A"), 1, textSize
                    lineHeight = textSize.cy
                End If
    
                currentY = currentY + lineHeight
                currentX = 0
                lineHeight = 0
                wordBuffer = ""
                wordWidth = 0
            ElseIf currentChar = " " Then
                ' Measure the current word buffer
                If Len(wordBuffer) > 0 Then
                    GetTextExtentPoint32W hdc, StrPtr(wordBuffer), Len(wordBuffer), textSize
                    wordWidth = textSize.cx
    
                    ' Check if the word exceeds the width of the PictureBox
                    If currentX + wordWidth > picBox.ScaleWidth Then
                        ' Make a line break
                        currentY = currentY + lineHeight
                        currentX = 0
                        lineHeight = 0
                    End If
    
                    ' Draw the word
                    currentX = currentX + wordWidth
    
                    ' Maintain the maximum height of the current line
                    If textSize.cy > lineHeight Then
                        lineHeight = textSize.cy
                    End If
                End If
    
                ' Add the space
                GetTextExtentPoint32W hdc, StrPtr(currentChar), 1, textSize
                currentX = currentX + textSize.cx
    
                ' Reset word buffer
                wordBuffer = ""
            Else
                ' Add character to word buffer
                wordBuffer = wordBuffer & currentChar
            End If
        Next charIndex
    
        ' Measure and add the last word if there is remaining text
        If Len(wordBuffer) > 0 Then
            GetTextExtentPoint32W hdc, StrPtr(wordBuffer), Len(wordBuffer), textSize
            wordWidth = textSize.cx
    
            If currentX + wordWidth > picBox.ScaleWidth Then
                ' Make a line break
                currentY = currentY + lineHeight
                currentX = 0
                lineHeight = 0
            End If
    
            currentX = currentX + wordWidth
    
            If textSize.cy > lineHeight Then
                lineHeight = textSize.cy
            End If
        End If
    
        ' Add the last line if there is remaining text
        If currentX > 0 Or lineHeight > 0 Then
            currentY = currentY + lineHeight
        End If
    
        ' Return the total height of the text in pixels
        GetTotalTextHeightUsingPictureBox = currentY
    End Function
    Last edited by James Reynolds; Oct 30th, 2024 at 04:59 AM.

  39. #3879
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by James Reynolds View Post
    It doesn't work, it doesn't give the full height of the text in the Krool RTB...
    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).

  40. #3880

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,513

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by SMC1979 View Post
    Sadly, Group view doesn't work in virtual mode.
    Sorry for late response.

    The Group.ListItemIndices is kind of slow as it needs to iterate through all items to know which indexes are attached to a group.
    If you only need the overall Count (not indexes) you might try below code if it is faster:

    Code:
    Dim LVG_V61 As LVGROUP_V61
    With LVG_V61
    .LVG.cbSize = LenB(LVG_V61)
    .LVG.Mask = LVGF_ITEMS
    End With
    SendMessage ListViewHandle, LVM_GETGROUPINFO, ID, ByVal VarPtr(LVG_V61)
    
    Debug.Print LVG_V61.cItems
    Unfortunately this is not in-built into the Group class object as a quick alternative. If you tried and confirm I might add it.
    I suggest as:
    Code:
    Public Property Get ListItemCount As Long
    in the Group class object.

    For the ListItemIndices property we can speed up the significantly as of Vista+. For XP it would need to fallback to the slow version.
    The improved code would be:
    Code:
    Dim LVG_V61 As LVGROUP_V61
    With LVG_V61
    .LVG.cbSize = LenB(LVG_V61)
    .LVG.Mask = LVGF_ITEMS
    SendMessage ListViewHandle, LVM_GETGROUPINFO, ID, ByVal VarPtr(LVG_V61)
    While .iFirstItem > -1
        FGroupListItemIndices.Add (.iFirstItem + 1)
        .iFirstItem = CLng(SendMessage(ListViewHandle, LVM_GETNEXTITEM, .iFirstItem, ByVal LVNI_ALL Or LVNI_VISIBLEORDER Or LVNI_SAMEGROUPONLY))
    Wend
    End With
    The msdn documentation is here misleading and I first thought LVNI_SAMEGROUPONLY is broken. It must be combined with LVNI_VISIBLEORDER even though they state those flags are mutually exclusive.

    Note that the following flags, for use only with Windows Vista, are mutually exclusive of any other flags in use: LVNI_VISIBLEONLY, LVNI_SAMEGROUPONLY, LVNI_VISIBLEORDER, LVNI_DIRECTIONMASK, and LVNI_STATEMASK.
    Last edited by Krool; Oct 31st, 2024 at 08:46 AM.

Page 97 of 98 FirstFirst ... 47879495969798 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