Page 62 of 105 FirstFirst ... 12525960616263646572 ... LastLast
Results 2,441 to 2,480 of 4199

Thread: CommonControls (Replacement of the MS common controls)

  1. #2441

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    In CmoboBoxW , How Can I draw items manually ? and What is the difference between Fixed and Variable drawing Enums in DrawMode property .

    I am asking this question because I - in most cases - use the combo style "List" , which draws a gray background for the combo box , once I changed the DrawMode property , the backcolor I set is what is shown .
    My last concern is , If I draw items manually , would this affect some features or other properties ?

    Thanks in advance .

    Edit 1 :
    Another question . what is the property ExtendedUI is intended to do . The only effect I noticed is that : If it is set to true , scrolling the combobox opens the list otherwise , scrolling does not open the list and changes the list index and text of the combobox while the list is not opened or dropped down .

    Edit 2 :
    I have tested the ItemDraw Event and noticed that it is not fired when the DrawMode property is set to Normal . Thus I thought it would be something to start with . But , I did not get the point of some parameters like ItemAction and ItemState . Or This is not right start point ?
    The Style 'List' has special appearance. However, on OwnerDrawn only the normal appearance is drawn by default by the OS. When DrawMode is <> Normal the ItemDraw event is fired, else it's not fired.
    The difference between Fixed and Variable DrawMode is that on Variable an additional event ItemMeasure is fired to let you size the height of each particular item individually instead of all items having same height.

    Concerning ExtendedUI. Normally (ExtendedUI = False) the Dropdown list is rolled out by pressing F4 or Alt+Down (or Alt+Up)
    If ExtendedUI is set (True) the F4 is dismissed and just Down arrow key will roll out the Dropdown list.

  2. #2442
    Member
    Join Date
    Aug 2016
    Posts
    52

    Re: CommonControls (Replacement of the MS common controls)

    Hello,
    Could you replace FileExists() by this?

    Is Full Unicode and Universal.


    Code:
    Private Declare Function PathFileExists Lib "shlwapi" Alias "PathFileExistsW" (ByVal pszPath As Long) As Long
     
    Public Function FileExists(ByVal PathName As String) As Boolean
        FileExists = CBool(PathFileExists(StrPtr(PathName)))
    End Function

  3. #2443
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: CommonControls (Replacement of the MS common controls)

    Here's a better one.

  4. #2444
    New Member
    Join Date
    Aug 2019
    Posts
    12

    Re: CommonControls (Replacement of the MS common controls)

    Hi Krool, thanks for this great project.
    I'm using ItemBkColor event of listview to change back color of items in report mode
    but back color of the selected column is not changing
    is there a way to fix this ?

  5. #2445
    Member
    Join Date
    Aug 2016
    Posts
    52

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Victor Bravo VI View Post
    Here's a better one.
    This is not good, it generates an error, even if it is controlled with On Error Summary, which is not good in programming.
    Code:
     On Error Resume Next
        FileExists = (GetAttr(sFileName) And vbDirectory) <> vbDirectory
        On Error GoTo 0
    Krool, please could you change the function by the API of Windows?

  6. #2446
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by pepegriyo2016 View Post
    This is not good, it generates an error, even if it is controlled with On Error Summary, which is not good in programming.
    While it is indeed good practice to avoid excessive use of On Error Resume Next, there's really nothing wrong with it when employed in situations like in that ANSI-only FileExists function. There's really no way of preventing the GetAttr function from raising an error when supplied with an invalid path, is there?

    That said, it seems you've overlooked the other Unicode-aware FileExists routine there, which is what I actually wanted to refer you to, but obviously did a poor job of pointing it out.

    Quote Originally Posted by pepegriyo2016 View Post
    Krool, please could you change the function by the API of Windows?
    PathFileExists isn't really the best choice because it doesn't distinguish files from folders:

    Quote Originally Posted by MSDN
    Determines whether a path to a file system object such as a file or folder is valid.
    Quote Originally Posted by Kenny Kerr
    The shell provides the PathFileExists function which is simpler than the approaches mentioned thus far but is limited in that it does not distinguish between files and directories.
    Also, as it turns out, PathFileExists relies on GetFileAttributes anyway, so why not call GetFileAttributes directly ourselves? (and in the process, avoid loading shlwapi.dll if that's the only thing we need it for)

    Quote Originally Posted by Kenny Kerr
    Incidentally, the PathFileExists function I mentioned above uses GetFileAttributes internally if it determines that you’re running on a supported version of Windows.
    See these articles if you are still unconvinced GetFileAttributes is the way to go:


  7. #2447
    Hyperactive Member
    Join Date
    Feb 2015
    Location
    Colorado USA
    Posts
    271

    Re: CommonControls (Replacement of the MS common controls)

    Below is code I use to determine if a file exists or not or whether it is a folder. It is unicode and can take path names up to 32,767 characters.

    Code:
    Option Explicit
    
    ' The function "Exists" allows you to determine if a specified path is a folder, a file or
    ' non-existent. It is unicode and works for 32-bit VB6 and 32 or 64-bit VBA.
    ' A test sub called Main at the end of this module shows exaamples of each.
    
    #If Win64 Then
    Private Declare PtrSafe Function GetFileAttributesW Lib "kernel32.dll" (ByVal lpFileNamePtr As LongPtr) As Long
    #Else
    Private Declare Function GetFileAttributesW Lib "kernel32.dll" (ByVal lpFileNamePtr As Long) As Long
    #End If
    
    Dim UCPath As String
    
    #If Win64 Then
    Public Function UniCodePtr(ByRef Filename As String) As LongPtr
    #Else
    Public Function UniCodePtr(ByRef Filename As String) As Long
    #End If
    ' Returns a pointer to module variable UCPath (32 or 64-bit) that is set to allow
    '  filenames in unicode that can be up to 32,757 characters.
    ' UCPath is a module-level string because if it is local to this function then
    '  the variable is destroyed and the pointer points to a variable location that
    '  no longer exists.
    ' Values from this function are used in Windows API calls that end in "W" (wide, unicode)
    '  instead of "A" (ANSI) such as CreateFileW, RemoveDirectoryW, CopyFileW, DeleteFileW, etc.
    '  that Windows allows to have up to 32,767 characters in the name instead of
    '  MAX_PATH (about 260).
    If LenB(Filename) > 0 Then
       If AscW(Filename) = 92 Then ' starts with a \
          If AscW(Mid$(Filename, 2, 1)) = 92 Then ' starts with \\
             UCPath = "\\?\UNC\" & Right$(Filename, Len(Filename) - 2)
          Else
             UCPath = "\\?\" & Left$(CurDir$, 2) & Filename
             End If
       Else
          UCPath = "\\?\" & Filename
          End If
       UniCodePtr = StrPtr(UCPath)
       End If
    End Function
    
    Function Exists(Filename As String) As Long
    ' Filename is treated as unicode, can be up to 32,757 characters long
    'Return values
    ' -1 Filename specifies a folder
    '  0 Filename does not exist (can use Err.LastDllError to get Windows error code if you want to know more)
    '  1 Filename sepecifies a file
    Dim i As Long
    i = GetFileAttributesW(UniCodePtr(Filename))
    If i <> &HFFFFFFFF Then
       Exists = IIf((i And vbDirectory) <> 0, -1, 1)
       End If
    End Function

    Below is a simple test sub you can use either in VB6 or Excel to show samples of each.

    Code:
    Sub Main()
    #If VBA6 Then
     MsgBox Exists(ThisWorkbook.Path) & vbCrLf & vbCrLf & "Should be -1 (Found a directory)"
     MsgBox Exists(ThisWorkbook.Path & "\" & ThisWorkbook.Name) & vbCrLf & vbCrLf & "Should be 1 (found a file)"
     MsgBox Exists(ThisWorkbook.Path & "1") & vbCrLf & vbCrLf & "Should be 0 (Specified path or file does not exist.)"
    #Else
     ' save this project somewhere on your hard drive
     MsgBox Exists(App.Path) & vbCrLf & vbCrLf & "Should be -1 (Found a directory)"
     MsgBox Exists(App.Path & "\" & App.EXEName & ".vbp") & vbCrLf & vbCrLf & "Should be 1 (found a file)"
     MsgBox Exists(App.Path & "1") & vbCrLf & vbCrLf & "Should be 0 (Specified path or file does not exist.)"
    #End If
    End Sub
    I have attached a simple VB6 project and an Excel file that have the above code in it.

    MountainMan
    Attached Files Attached Files

  8. #2448

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Please don't bring this thread off-topic with this FileExists() function.
    I don't change because it uses already an unicode replacement version of GetAttr() which can also take names up to 32,767 characters.
    So in my view it's already best set..

  9. #2449
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    Re: CommonControls (Replacement of the MS common controls)

    Hi Krool! Thanks for this amazing work. Do you have any plans for a flat version of the controls?

  10. #2450

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by shagratt View Post
    Do you have any plans for a flat version of the controls?
    No. Comctl32.dll doesn't support it.

  11. #2451
    New Member
    Join Date
    Dec 2019
    Posts
    4

    Re: CommonControls (Replacement of the MS common controls)

    @Krool,
    in the Form I am using splitter on the Top I am using TreeView and now i am replacing it with your TreeView (to get unicode Support) but when I am Dragging and Dropping on the top of Splitter, VB6 is getting crashed.
    can you please check it, whether it has any issue with the existing controls or other third party controls.
    Last edited by ayu2127; Dec 12th, 2019 at 05:48 AM. Reason: Last thread reported error solved

  12. #2452

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by ayu2127 View Post
    @Krool,
    in the Form I am using splitter on the Top I am using TreeView and now i am replacing it with your TreeView (to get unicode Support) but when I am Dragging and Dropping on the top of Splitter, VB6 is getting crashed.
    can you please check it, whether it has any issue with the existing controls or other third party controls.
    Please provide a demo

  13. #2453
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    When I began using VBCCR I experienced 'unexplainable' crashes as well.
    But I didn't give up...

    In some scenarios the IDE failed to write the .frx files correctly.
    It took me some time to find out, because the .frm/.bas etc. were identical to the working version.

    Check the .frx files.
    Just an idea.
    Meant to reply earlier that I do believe Karl77 is right on the cause of my issues. Since copying/pasting non-CCR controls onto new forms was then triggering CCR bugs, and other forms with CCR controls lacked bugs, I went back and tried some of my backup frx files instead of trying to recreate the forms manually, and the bugs seem to be related to some frx issue. Something appears to trigger some frx issue and then the CCR bugs pop. Things have stabilized.

  14. #2454
    Addicted Member
    Join Date
    Jul 2016
    Posts
    230

    Re: CommonControls (Replacement of the MS common controls)

    What does "the .frm/.bas etc. were identical to the working version" mean?

  15. #2455
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    536

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by OldClock View Post
    What does "the .frm/.bas etc. were identical to the working version" mean?
    When I WinMerged a working backup-version with failing version, there was no difference in frm/bas files.

  16. #2456
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    I have two issues concerning ListView ,

    1- The first item is always selected even if the property AutoSelectFirstItem is set to False . This was unexpected to me as I thought it will do this if only AutoSelectFirstItem is set to True .
    2- The Item_Select Event is not fired in the previous case ( AutoSelectFirstItem is set to False ) although there is an item selected as I mentioned above . This also sounds strange to me . The event fires only if AutoSelectFirstItem is set to True and this is logical and no problem with it .

    I wonder , First , Why does ListView select the first item while the AutoSelectFirstItem is set to False ? . Second , while the first item is selected with the previous circumstances , Why does the event Item_Select is not fired ?

  17. #2457
    Addicted Member
    Join Date
    Jul 2016
    Posts
    230

    Re: CommonControls (Replacement of the MS common controls)

    How do I initialize visual styles on program startup when using the ActiveX version of VBCCR? The only documentation is MountainMan's, and in the "VBCCR OCX Version Guide" section it says to call InitVisualStyles, but that procedure is only present in the StdEXE version of VisualStyles.bas. In the same section it also says, "The easiest thing to do is to include the standard module VisualStyles.bas from the StdEXE version and then in your program". Why would I include the StdEXE version of VisualStyles.bas when using the OCX? Is this an error in the documentation?

  18. #2458

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by OldClock View Post
    How do I initialize visual styles on program startup when using the ActiveX version of VBCCR? The only documentation is MountainMan's, and in the "VBCCR OCX Version Guide" section it says to call InitVisualStyles, but that procedure is only present in the StdEXE version of VisualStyles.bas. In the same section it also says, "The easiest thing to do is to include the standard module VisualStyles.bas from the StdEXE version and then in your program". Why would I include the StdEXE version of VisualStyles.bas when using the OCX? Is this an error in the documentation?
    The documentation is not wrong.

    The visual styles have nothing todo with the OCX.

    Always the EXE is responsible to apply visualstyles.

    It would be possible to make an isolate aware manifest for the OCX, but that would be not good as maybe some apps (EXE) want to run w/o visual styles by design.

    Quote Originally Posted by Hosam AL Dein View Post
    I have two issues concerning ListView ,

    1- The first item is always selected even if the property AutoSelectFirstItem is set to False . This was unexpected to me as I thought it will do this if only AutoSelectFirstItem is set to True .
    2- The Item_Select Event is not fired in the previous case ( AutoSelectFirstItem is set to False ) although there is an item selected as I mentioned above . This also sounds strange to me . The event fires only if AutoSelectFirstItem is set to True and this is logical and no problem with it .

    I wonder , First , Why does ListView select the first item while the AutoSelectFirstItem is set to False ? . Second , while the first item is selected with the previous circumstances , Why does the event Item_Select is not fired ?
    The first item is always focused. The AutoSelectFirstItem just controls if it is also being selected. I hope this answers all.

    The inner purpose of AutoSelectFirstItem is to behave like either as v5 or v6 MS ListView.
    Last edited by Krool; Dec 20th, 2019 at 06:40 AM.

  19. #2459
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    Thanks a lot for clarification krool . You are right about
    Code:
    The AutoSelectFirstItem just controls if it is also being selected
    but I will add the word Fully before the word selected . And I mean by fully : the item is Selected and the Item_Select event is raised as
    The first item is always focused
    and selected too regardless of AutoSelectFirstItem property but the event is not fired in absence of AutoSelect or when set to false .

    Directly after the ListView population , this code returns 1

    Code:
    Msgbox ListView1.selectedItem.Index
    But , with AutoSelectFirstItem set to True, the Item_Select event is fired , otherwise , it is not - although being focused and selected - . Anyway , this is intrinsic behavior and it is better to be not touched as I guess you prefer . That`s why I think MS added the property AutoSelectFirstItem : to select the first item then raises the event Item_Select as it is not raised at the point after the list item is populated although the item is already selected .

  20. #2460

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    Thanks a lot for clarification krool . You are right about
    Code:
    The AutoSelectFirstItem just controls if it is also being selected
    but I will add the word Fully before the word selected . And I mean by fully : the item is Selected and the Item_Select event is raised as and selected too regardless of AutoSelectFirstItem property but the event is not fired in absence of AutoSelect or when set to false .

    Directly after the ListView population , this code returns 1

    Code:
    Msgbox ListView1.selectedItem.Index
    But , with AutoSelectFirstItem set to True, the Item_Select event is fired , otherwise , it is not - although being focused and selected - . Anyway , this is intrinsic behavior and it is better to be not touched as I guess you prefer . That`s why I think MS added the property AutoSelectFirstItem : to select the first item then raises the event Item_Select as it is not raised at the point after the list item is populated although the item is already selected .
    ListView1.selectedItem.Index returns the focused item, not the selected item.
    I know it's all a little bit confusing with the wordings and detailed.. but it's "correct" as it is now.

  21. #2461
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    68

    Re: CommonControls (Replacement of the MS common controls)

    Question about disabled CCR Button (Style 1-Graphic) Bitmap Picture
    It seems to work well for Icons but not for bitmaps.
    The first two pics in the attached shows a regular VB Button Enabled/Disabled
    The third shows the CCR Button disabled.
    I've tried the DrawState function with my own buttons and get the
    same result as the CCR Button. Any hints?

    Name:  OptionsAll.JPG
Views: 4466
Size:  2.2 KB

  22. #2462

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by VBClassic04 View Post
    Question about disabled CCR Button (Style 1-Graphic) Bitmap Picture
    It seems to work well for Icons but not for bitmaps.
    The first two pics in the attached shows a regular VB Button Enabled/Disabled
    The third shows the CCR Button disabled.
    I've tried the DrawState function with my own buttons and get the
    same result as the CCR Button. Any hints?

    Name:  OptionsAll.JPG
Views: 4466
Size:  2.2 KB
    Please provide demo and picture files.

  23. #2463
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    68

    Re: CommonControls (Replacement of the MS common controls)

    See attached zip
    Attached Files Attached Files

  24. #2464

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    I need some advise.. (the trick ? )

    Concerning my VTable.bas handling.
    I am quite happy with it but looking always for optimization.

    Only two "base VTables" remain subclassed.
    IOleControl and IPerPropertyBrowsing.

    I am eveluating if the subclass of those base VTable can be avoided and to replace only the VTable of the individidual instance.

    It "works". But then I am 100% responsible for it. (Downside)
    Therefore I need a way to redirect to the original VTable in some cases.

    When I try to call the original VTable "within" my VTable I get a StackHash crash.

    How to solve?

    Info:
    IOleInPlaceActiveObject works already complete isolated. But it does not crash as I don't change the ObjPtr's VTable but rather supply a brand new object on .SetActiveObject.
    So I can provide my own lightweight COM object and redirect to original VTable, if necessary.

  25. #2465

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    I need some advise.. (the trick ? )

    Concerning my VTable.bas handling.
    I am quite happy with it but looking always for optimization.

    Only two "base VTables" remain subclassed.
    IOleControl and IPerPropertyBrowsing.

    I am eveluating if the subclass of those base VTable can be avoided and to replace only the VTable of the individidual instance.

    It "works". But then I am 100% responsible for it. (Downside)
    Therefore I need a way to redirect to the original VTable in some cases.

    When I try to call the original VTable "within" my VTable I get a StackHash crash.

    How to solve?

    Info:
    IOleInPlaceActiveObject works already complete isolated. But it does not crash as I don't change the ObjPtr's VTable but rather supply a brand new object on .SetActiveObject.
    So I can provide my own lightweight COM object and redirect to original VTable, if necessary.
    Ok, I have to quote myself right now.. as I found the solution.

    However, I need to check it carefully before any new release.
    But it would be worth the change, because no subclass is a stability plus and no theoritcal conflicts with other (foreign) vtable subclasses.

  26. #2466

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Update released. (also for OCX)

    As previously mentioned, the VTableHandle.bas, got once again improved.
    The IOleControl interface is NOT subclassed anymore.

    The only remaining left, which is being subclassed, is IPerPropertyBrowsing.

    So, the goal to abolish 'VTableSubclass.cls' and throw it away is getting closer.

  27. #2467
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    68

    Re: CommonControls (Replacement of the MS common controls)

    Any uipdate on the disabled button issue?

  28. #2468

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by VBClassic04 View Post
    Any uipdate on the disabled button issue?
    I use DrawState API with DSS_DISABLED flag.
    For DST_ICON type it seems to work properly whereas for DST_BITMAP it looks odd.
    Looks like a often asked issue in the net.
    (E.g. https://www.autoitscript.com/forum/t...-dss_disabled/)

    VB seems to handle this somehow different.
    Workaround would be to use 'DisabledPicture' with exactly that picture how you expect.

  29. #2469
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    68

    Re: CommonControls (Replacement of the MS common controls)

    Regarding disabled bitmap button, what about GreyScale?
    Don't know much about it, but this renders
    a fairly close approximation of a disabled picture.
    Using the same Options.bmp as in my download above
    Code:
    Option Explicit
    
    Private Function GreyScale(ByVal lColor As Long) As Long
     Dim lGrayValue As Long
     lGrayValue = (77& * (lColor And &HFF&) + 150& * (lColor And &HFF00&) \ &H100& + 28& * ((lColor And &HFF0000) \ &H10000)) \ 255&
     GreyScale = RGB(lGrayValue, lGrayValue, lGrayValue)
     If GreyScale <= &H151515 Then  '?????
      GreyScale = &H808080             'dark gray
     End If
    End Function
    
    Private Sub Form_Load()
     Dim X As Single, Y As Single
     Dim c As Long
     For Y = 0 To Picture1.ScaleHeight    'Picture1 autoredraw = true, scalemode = pixels
      For X = 0 To Picture1.ScaleWidth
       c = Picture1.Point(X, Y)
       Picture1.PSet (X, Y), GreyScale(c)
      Next
     Next
    End Sub

  30. #2470

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Updated released. (also for OCX)

    No VTable subclassing anymore at all. VTableSubclass.cls got removed.

    I claim now that VTableHandle.bas has reached it's final state now.

    Unfortunately in OLEGuids.tlb was a bug for IPerPropertyBrowsing and it was necessary to re-compile it again. (with same uuid)

  31. #2471
    Addicted Member
    Join Date
    Jul 2016
    Posts
    230

    Re: CommonControls (Replacement of the MS common controls)

    What does this mean for us users? What is lost, what is gained?

  32. #2472

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by OldClock View Post
    What does this mean for us users? What is lost, what is gained?
    Good question. For "most of the users" there is no visible change.

    However, from the principles point of view it has following gains: (no losses)

    1) 1 less .cls file
    2) VTable Subclass needs to manage *all* calls (global), whereas now only the affected objects needs to be managed. (= performance gain)
    3) Because as VTable subclass is so global it can lead to conflicts when multiple things want to subclass the same VTable.

    A practical example of such a conflict situation was VBCCRxx.OCX and VBFLXGRDxx.OCX.
    They both need to manage the same VTables.
    (Std-EXE version was not affected, because only one VTable subclass was compiled into the EXE, but OCX are pre-compiled and they both had their own VTable subclass)

    In the past I used the hidden ThunderMain window to avoid conflicts between VBCCRxx.OCX and VBFLXGRDxx.OCX.

    However, now that's not needed anymore as only each private VTable for the individual objects are managed and therefore the global base VTable remains untouched.
    So, when a projects uses now VBCCRxx.OCX and VBFLXGRDxx.OCX, then it has the freedom or ability to subclass all VTables.
    Which leads to the last gain point..

    4) Clean solution

    Quote Originally Posted by HosseinMoradi View Post
    I'm using ItemBkColor event of listview to change back color of items in report mode
    but back color of the selected column is not changing
    is there a way to fix this ?
    There is a undocumented feature to change the backcolor of the selected column. So then it would all look the same in a row.
    See thread from fafalone: http://www.vbforums.com/showthread.p...ghlight-column
    I bundled it quickly into following helper function:
    Code:
    Private Type CLSID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
    End Type
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
    Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, ByRef lpRect As Any, ByVal bErase As Long) As Long
    Private Declare Function UpdateWindow Lib "user32" (ByVal hWnd As Long) As Long
    
    Public Sub LvwSetSelectedColumnBkColor(ByVal hLV As Long, ByVal RGBColor As Long)
    Const LVM_FIRST As Long = &H1000
    Const LVM_QUERYINTERFACE As Long = (LVM_FIRST + 189)
    Dim IID_IVisualProperties As CLSID, pIVisualProperties As IUnknown
    ' {E693CF68-D967-4112-8763-99172AEE5E5A}
    With IID_IVisualProperties
    .Data1 = &HE693CF68: .Data2 = &HD967: .Data3 = &H4112
    .Data4(0) = &H87: .Data4(1) = &H63: .Data4(2) = &H99: .Data4(3) = &H17
    .Data4(4) = &H2A: .Data4(5) = &HEE: .Data4(6) = &H5E: .Data4(7) = &H5A
    End With
    SendMessage hLV, LVM_QUERYINTERFACE, VarPtr(IID_IVisualProperties), ByVal VarPtr(pIVisualProperties)
    If Not pIVisualProperties Is Nothing Then
        Const VPCF_SORTCOLUMN As Long = 3
        VTableCall vbLong, ObjPtr(pIVisualProperties), 5, VPCF_SORTCOLUMN, RGBColor
        InvalidateRect hLV, ByVal 0&, 1
        UpdateWindow hLV
    End If
    End Sub
    The function VTableCall (red marked) you can find in the VTableHandle.bas module if you want to copy it into your project. (in case you use OCX)

    I might include in future in the ListView a property so no helper function would be necessary.
    Last edited by Krool; Jan 5th, 2020 at 12:44 PM.

  33. #2473
    Lively Member
    Join Date
    Oct 2016
    Posts
    115

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

    in the CommonDialog.ShowColor is it possible to predefine the custom colour(s) and is it possible to retrieve the custom colours that were defined (even it was not selected at the close of the dialog)?


    thanks

  34. #2474

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Semke View Post
    in the CommonDialog.ShowColor is it possible to predefine the custom colour(s) and is it possible to retrieve the custom colours that were defined (even it was not selected at the close of the dialog)?
    Good point. Update released.

    A new property named 'CustomColors' is included in the CommonDialog class.

    To retrieve the custom colors use this:
    Code:
    Dim Arr16() As Long ' 0 to 15 (zero-based always)
    Arr16() = CommonDialog1.CustomColors
    Changing the custom colors is very flexible, you can take whatever single-dimensioned array with numeric values.
    Also if it's zero-based or whatever else doesn't matter. It will take the first 16 values.
    Example:
    Code:
    Dim MyArr(-1 To 100) As Long
    MyArr(-1) = vbHighlight ' First color
    MyArr(0) = vbRed ' Second color
    ' And so on
    CommonDialog1.CustomColors = MyArr()
    Another example with same effect:
    Code:
    CommonDialog1.CustomColors = Array(vbHighlight, vbRed)

  35. #2475
    Lively Member
    Join Date
    Oct 2016
    Posts
    115

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Good point. Update released.

    A new property named 'CustomColors' is included in the CommonDialog class.
    Thanks, works very well

  36. #2476
    Addicted Member
    Join Date
    Jul 2016
    Posts
    230

    Re: CommonControls (Replacement of the MS common controls)

    Hey

    I used VBCCR16.OCX 1.06.0052, and now am updating to 1.06.0057. I have a few questions. I prefer using git instead of downloading files from forums, as git allows complete clarity regarding what and when.

    1. I use side-by-side and want to enable visual styles in my shipped application (don't care about IDE). I read the whole guide from MountainMan, but it's convoluted and a bit outdated now. I used to use VBCCR16SideBySideAndVisualStyles.res, but now I can't find it anywhere (not in the first post, not in your git repo). MountainMan's docs says:
    There are also 2 VB6 resource files in the first post on VBForums: “VBCCR16SideBySide.res” and “VBCCR16SideBySideAndVisualStyles.res”
    The first post in this thread no longer has that. The ComCtlsDemo.zip file contains only Resources.res. Why are the files gone, and will my old VBCCR16SideBySideAndVisualStyles.res still work with VBCCR 1.6.57?

    2. I copied the new VBCCR16.OCX file from git master (commit e5546a6) into my project (also updated the other files - Common.bas, VisualStyles.bas, etc.). When I opened the project and saved it, the modified VBP file changed like so (git diff):
    Code:
    -Object={0DF5D14C-08DD-4806-8BE2-B59CB924CFC9}#1.6#0; VBCCR16.OCX
    +Object={0DF5D14C-08DD-4806-8BE2-B59CB924CFC9}#1.7#0; VBCCR16.OCX
    The old file was 1.6.52, the new one is 1.6.57 - still 1.6.x, so why does the VBP contain 1.7? Confusing.

    3. MountainMan's documentation says I should call InitVisualStyles before any form loads. However, that procedure is only available in Standard EXE Version/Common/VisualStyles.bas:143. If I want to use visual styles with the OCX version, do I not need to call InitVisualStyles? If I still do need to call it, why does ActiveX Control Version/Common/VisualStyles.bas not include it?

    4. If the manifest file embedded in the resource file is what actually enables visual styles, what does InitVisualStyles do? I read somewhere that visual styles have some issues (I couldn't find a list of these issues, just mentioned a missing button border) - is InitVisualStyles's job only to fix those issues? If so, it would be good to rename that function to InitVisualStyleFixes to make things more clear.
    Last edited by OldClock; Jan 9th, 2020 at 11:14 AM.

  37. #2477

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by OldClock View Post
    I used VBCCR16.OCX 1.06.0052, and now am updating to 1.06.0057. I have a few questions. I prefer using git instead of downloading files from forums, as git allows complete clarity regarding what and when.
    OK, see below.

    Quote Originally Posted by OldClock View Post
    1. I use side-by-side and want to enable visual styles in my shipped application (don't care about IDE). I read the whole guide from MountainMan, but it's convoluted and a bit outdated now. I used to use VBCCR16SideBySideAndVisualStyles.res, but now I can't find it anywhere (not in the first post, not in your git repo). MountainMan's docs says: The first post in this thread no longer has that. The ComCtlsDemo.zip file contains only Resources.res. Why are the files gone, and will my old VBCCR16SideBySideAndVisualStyles.res still work with VBCCR 1.6.57?
    You looked in the wrong thread (post). (Std-EXE)
    Please go into the ActiveX Thread (1st Post) and there you find the needed .res file.

    Quote Originally Posted by OldClock View Post
    2. I copied the new VBCCR16.OCX file from git master (commit e5546a6) into my project (also updated the other files - Common.bas, VisualStyles.bas, etc.). When I opened the project and saved it, the modified VBP file changed like so (git diff):
    Code:
    -Object={0DF5D14C-08DD-4806-8BE2-B59CB924CFC9}#1.6#0; VBCCR16.OCX
    +Object={0DF5D14C-08DD-4806-8BE2-B59CB924CFC9}#1.7#0; VBCCR16.OCX
    The old file was 1.6.52, the new one is 1.6.57 - still 1.6.x, so why does the VBP contain 1.7? Confusing.
    The version of the VBCCR16.OCX is still 1.6. Just the TypeLib version increased from 1.6 to 1.7 due to the recent included property 'CustomColors' in CommonDialog.cls.
    The TypeLib version of VBCCR16.OCX started from 1.0.
    So it's just a coincidence that the TypeLib version was 1.6 and the VBCCRxx.OCX is version 1.6.

    A TypeLib version has a Major and Minor number. If only the Minor changes, a Project using that TypeLib does NOT need to re-compile. So, there is no harm.

    Quote Originally Posted by OldClock View Post
    3. MountainMan's documentation says I should call InitVisualStyles before any form loads. However, that procedure is only available in Standard EXE Version/Common/VisualStyles.bas:143. If I want to use visual styles with the OCX version, do I not need to call InitVisualStyles? If I still do need to call it, why does ActiveX Control Version/Common/VisualStyles.bas not include it?
    That's the common miss-understanding between Std-EXE and OCX version.
    The OCX is independent from any manifest.

    Ever, ever the Std-EXE project is responsible to include manifest files.

    So, if you have a Std-EXE project that uses VBCCR16.OCX, then you can include manifest files.

    The VisualStyles.bas differs from the OCX and Std-EXE version, because the OCX version has a shrinked subset of VisualStyles.bas. The reason is that the OCX can't fix any VisualStyles issues. It just needs to know with which version of comctl32.dll to deal with, because of the functional differences.

    6.x enables more functions than 5.8x. So it's not only theming.
    To complicate matters 6.1 (Vista+) has more functions than 6.0 (WinXP).
    So the OCX needs to know 3 Levels currently. Level 0 by default.
    If Major number is exactly 6 and Minor 0 then Level 1.
    If Major number is exactly 6 and Minor greater 0 OR Major greater 6 then Level 2.

    Quote Originally Posted by OldClock View Post
    4. If the manifest file embedded in the resource file is what actually enables visual styles, what does InitVisualStyles do? I read somewhere that visual styles have some issues (I couldn't find a list of these issues, just mentioned a missing button border) - is InitVisualStyles's job only to fix those issues? If so, it would be good to rename that function to InitVisualStyleFixes to make things more clear.
    Ok, let's agree on that point. InitVisualStylesFixes would be more clear.
    Last edited by Krool; Jan 9th, 2020 at 12:50 PM.

  38. #2478
    Addicted Member
    Join Date
    Jul 2016
    Posts
    230

    Re: CommonControls (Replacement of the MS common controls)

    Thank you Krool.

  39. #2479
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    In CommandButtonW ,
    1- What is the method SetShield is intended to do ?
    2- There are some properties about ImageList and this implies that I can set the picture by an imagelist and I could not find any method or event that can do this . I noticed this while I was trying to align the picture right ,left , top , or bottom and this only appears in properties related to imagelist .

  40. #2480

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    In CommandButtonW ,
    1- What is the method SetShield is intended to do ?
    2- There are some properties about ImageList and this implies that I can set the picture by an imagelist and I could not find any method or event that can do this . I noticed this while I was trying to align the picture right ,left , top , or bottom and this only appears in properties related to imagelist .
    1- Read the description of the method.
    2- You need to apply a ImageList object to the 'CommandButtonW1.ImageList' property at run-time or already at design-time. Only then the additional ImageList* properties are meaningful.

Page 62 of 105 FirstFirst ... 12525960616263646572 ... 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