Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
I can't find the OLEDragDrop event in the VBCCR17.RichTextBox (it's exposed in other VBCCR17 controls). There's instead a OLEDragDrop property that should enable the window as a OLE drop target but it doesn't actually do it here. What am I doing wrong? Or is there a workaround for this? If there is one, can anyone provide an example? Thanks !
I'm running the VB6 Ide sp5 & 6 in a 64 bit Windows 10 OS.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
@jpfa
You are right, some events are missing at Krool's Richtextbox control. Maybe Krool forgot to implement them?
Microsoft Richtetxbox events:
Code:
Private Sub mS_RichTextBox_OLECompleteDrag(Effect As Long)
Private Sub mS_RichTextBox_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
Private Sub mS_RichTextBox_OLEDragOver(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
Private Sub mS_RichTextBox_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
Private Sub mS_RichTextBox_OLESetData(Data As RichTextLib.DataObject, DataFormat As Integer)
Private Sub mS_RichTextBox_OLEStartDrag(Data As RichTextLib.DataObject, AllowedEffects As Long)
VBCCR17 Richtextbox events:
Code:
Private Sub VBCCR_RichTextBox_OLECompleteDrag()
Private Sub VBCCR_RichTextBox_OLEContextMenuClick(ByVal ID As Long)
Private Sub VBCCR_RichTextBox_OLEDeleteObject(ByVal LpOleObject As Long)
Private Sub VBCCR_RichTextBox_OLEGetContextMenu(ByVal SelType As Integer, ByVal LpOleObject As Long, ByVal SelStart As Long, ByVal SelEnd As Long, hMenu As Long)
Private Sub VBCCR_RichTextBox_OLEGetDropEffect(Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Private Sub VBCCR_RichTextBox_OLEStartDrag(AllowedEffects As Long)
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
For now I'm processing the clipboard myself like this, but it's not elegant. I'd like to use OLE events provided by the control itself.
Code:
Private WithEvents cIDT As cDropTarget
Private Sub Form_Load()
txtSrt.OLEDragDrop = False
Set cIDT = New cDropTarget
cIDT.Attach txtSrt.hWnd
End Sub
Private Sub cIDT_Drop(pDataObj As oleexp.IDataObject, grfKeyState As Long, ptx As Long, pty As Long, pdwEffect As oleexp.DROPEFFECTS)
Dim Fmt As FORMATETC
Fmt.cfFormat = CF_HDROP
Fmt.TYMED = TYMED_HGLOBAL
Fmt.dwAspect = DVASPECT_CONTENT
Fmt.lindex = -1
Dim stg As STGMEDIUM
If pDataObj.QueryGetData(Fmt) = S_OK Then
pDataObj.GetData Fmt, stg
Dim nFiles As Long, sFiles() As String
Dim i As Long
Dim sBuffer As String
nFiles = DragQueryFileW(stg.data, &HFFFFFFFF, 0, 0)
If nFiles > 0 Then
ReDim sFiles(nFiles - 1)
For i = 0 To nFiles - 1
SysReAllocStringLen VarPtr(sBuffer), , DragQueryFileW(stg.data, i)
DragQueryFileW stg.data, i, StrPtr(sBuffer), Len(sBuffer) + 1&
sFiles(i) = sBuffer
Next
TxtSrtDroppedFiles sFiles, ScaleY(ptx, vbPixels, vbTwips), grfKeyState, pdwEffect
End If
Else
Debug.Print "failed querygetdata"
End If
pdwEffect = DROPEFFECT_NONE
End Sub
Private Sub TxtSrtDroppedFiles(Files() As String, ByVal y As Single, ByVal Shift As Long, Effect As oleexp.DROPEFFECTS)
Dim FileName As Variant
Effect = DROPEFFECT_COPY
For Each FileName In Files
MsgBoxW FileName
Next
DoEvents
End Sub
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Mith
@jpfa
You are right, some events are missing at Krool's Richtextbox control. Maybe Krool forgot to implement them?
Microsoft Richtetxbox events:
Code:
Private Sub mS_RichTextBox_OLECompleteDrag(Effect As Long)
Private Sub mS_RichTextBox_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
Private Sub mS_RichTextBox_OLEDragOver(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
Private Sub mS_RichTextBox_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
Private Sub mS_RichTextBox_OLESetData(Data As RichTextLib.DataObject, DataFormat As Integer)
Private Sub mS_RichTextBox_OLEStartDrag(Data As RichTextLib.DataObject, AllowedEffects As Long)
VBCCR17 Richtextbox events:
Code:
Private Sub VBCCR_RichTextBox_OLECompleteDrag()
Private Sub VBCCR_RichTextBox_OLEContextMenuClick(ByVal ID As Long)
Private Sub VBCCR_RichTextBox_OLEDeleteObject(ByVal LpOleObject As Long)
Private Sub VBCCR_RichTextBox_OLEGetContextMenu(ByVal SelType As Integer, ByVal LpOleObject As Long, ByVal SelStart As Long, ByVal SelEnd As Long, hMenu As Long)
Private Sub VBCCR_RichTextBox_OLEGetDropEffect(Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Private Sub VBCCR_RichTextBox_OLEStartDrag(AllowedEffects As Long)
True.
OLEDragDrop is RichText specific.
Will implement OLEDropMode and OLEDrag in 1.8. (Can be used if OLEDragDrop is False only for back-compat)
The command .AddItem "C:\test_1" replaces the text "C:\test_" in the editbox!
AddItem should extend the dropdown-list but not replace the text in the editbox.
When i manually change the text in the editbox to "C:\test_" and open the dropdown-list the text will be changed back to "C:\test_1" again without clicking on the first item in the dropdown-list!
Any idea how to get the same behavior as the original MS controls?
The command .AddItem "C:\test_1" replaces the text "C:\test_" in the editbox!
AddItem should extend the dropdown-list but not replace the text in the editbox.
When i manually change the text in the editbox to "C:\test_" and open the dropdown-list the text will be changed back to "C:\test_1" again without clicking on the first item in the dropdown-list!
Any idea how to get the same behavior as the original MS controls?
The command .AddItem "C:\test_1" replaces the text "C:\test_" in the editbox!
AddItem should extend the dropdown-list but not replace the text in the editbox.
When i manually change the text in the editbox to "C:\test_" and open the dropdown-list the text will be changed back to "C:\test_1" again without clicking on the first item in the dropdown-list!
Any idea how to get the same behavior as the original MS controls?
The problem with .AddItem is fixed with the new update.
But when i open the dropdown-list the text still got replaced.
It looks like after opening the drop-down list, some kind of "autocomplete" is triggered and the control searches all items for a match to the text and then replaces it.
Any idea how to deactivate the auto-complete feature?
The problem with .AddItem is fixed with the new update.
But when i open the dropdown-list the text still got replaced.
It looks like after opening the drop-down list, some kind of "autocomplete" is triggered and the control searches all items for a match to the text and then replaces it.
Any idea how to deactivate the auto-complete feature?
The MS control behaves the same. This "feature" can be deactivated by only blocking LB_FINDSTRING and returning -1.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
I think I found another problem on the RichTextBox: the comands in the context menu Replace, Copy, Paste don't seem to support Unicode. Maybe the problem lies in my code. I'll perform more tests. Anyway, I think I can work around this issue by supplying a custom context menu instead of using the default one. However, it would be nice to have complete Unicode support provided natively by the control.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by jpfa
My version of VBCCR17.OCX is:
Control ActiveX 1.7.0.44 VBCCR17 1.07.0044
5,31 MB 30/08/202213:48
Is yours rhe same?
My VBCCR version is 1.7.80.
I only know that you can activate the property "Autoverbmenu" at the MS RichTextBox to get the system context menu.
But the VBCCR RichTextBox doesnt have this property.
How did you activate the context menu?
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Mith
How did you activate the context menu?
I didn't do it on purpose and I can't seem to find anything in my code related to that behavior.
This is an old project (maybe from 2008 or so) that I'm updating to support Unicode. Could it be that some hidden leftover from the old project is triggering it?
I just started a new project to test this. I didn't write any code; just used the default main form and placed a VBCCR17.RichTextBox in it. I can confirm that it doesn't expose a context menu, just like you said. I don't have a clue about why.
I guess I'll have to a lot more testing to shed some light over this mystery. Maybe you can give me some pointers?
What I use to do in situations like this is to start a new project setting the components and references as used in the old project and copy all the code into it; then I see if the weird behavior is present here too. If it isn't and the Guids of the components are the same as in the old project, I'll be lost. If it is present then I comment out the code a piece at a time until the weird behavior desapears.
This may take some time and I don't know if it's worth the effort. I may just implement a custom context menu, like you did. Speaking of which, if you're willing to share your code it will spare me some coding effort. I'd appreciate that. I planned to override the default menu anyway so to include some specialized commands in it.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Update:
I found the bug in my code: I had already implemented a custom context menu that I was sure I wasn't using anymore but actually it was still active. That code didn't support Unicode.
I just added Unicode support to it using https://www.vbforums.com/showthread....=1#post5067907 for the Clipboard and TextBoxW in the "Replace" form I already had instead of VB6 native TextBox. So I won't post my code because I didn't write any myself; it's all in the posted link.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Mith
@jpfa
You are right, some events are missing at Krool's Richtextbox control. Maybe Krool forgot to implement them?
Microsoft Richtetxbox events:
Code:
Private Sub mS_RichTextBox_OLECompleteDrag(Effect As Long)
Private Sub mS_RichTextBox_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
Private Sub mS_RichTextBox_OLEDragOver(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
Private Sub mS_RichTextBox_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
Private Sub mS_RichTextBox_OLESetData(Data As RichTextLib.DataObject, DataFormat As Integer)
Private Sub mS_RichTextBox_OLEStartDrag(Data As RichTextLib.DataObject, AllowedEffects As Long)
VBCCR17 Richtextbox events:
Code:
Private Sub VBCCR_RichTextBox_OLECompleteDrag()
Private Sub VBCCR_RichTextBox_OLEContextMenuClick(ByVal ID As Long)
Private Sub VBCCR_RichTextBox_OLEDeleteObject(ByVal LpOleObject As Long)
Private Sub VBCCR_RichTextBox_OLEGetContextMenu(ByVal SelType As Integer, ByVal LpOleObject As Long, ByVal SelStart As Long, ByVal SelEnd As Long, hMenu As Long)
Private Sub VBCCR_RichTextBox_OLEGetDropEffect(Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Private Sub VBCCR_RichTextBox_OLEStartDrag(AllowedEffects As Long)
The RichTextBox control is now updated. Can you check if everything is fine ? To note is that of course only the Std-EXE version is updated. The OCX will be updated in a year or so when more updates got accumulated.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Thanks, Krool! It'll take some days to have time to test the update. Also I'm affraid my tests will be quite shallow (my coding skills are rather poor). So far I've only used the ocx control. I hope using the exe won't be hard and the debugger stepping into your subclassing can be avoided. Else my tests will be even more shallow. I wish somone else will join me in the testing.
Meanwhile I had an issue with the Common Dialog replacement: the FileValidate event isn't firing. I just stumbled on this and didn't have time for further testing. This is most likely a bug in my code. I'll test the RichTextBox update first, though. The FileValidate issue can wait. Anyway this probably wouldn't help with what I wanted to achieve: to be able to accept an empty filename as valid (allowing the OK button to close the dialog even in this case).
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by jpfa
Thanks, Krool! It'll take some days to have time to test the update. Also I'm affraid my tests will be quite shallow (my coding skills are rather poor). So far I've only used the ocx control. I hope using the exe won't be hard and the debugger stepping into your subclassing can be avoided. Else my tests will be even more shallow. I wish somone else will join me in the testing.
Meanwhile I had an issue with the Common Dialog replacement: the FileValidate event isn't firing. I just stumbled on this and didn't have time for further testing. This is most likely a bug in my code. I'll test the RichTextBox update first, though. The FileValidate issue can wait. Anyway this probably wouldn't help with what I wanted to achieve: to be able to accept an empty filename as valid (allowing the OK button to close the dialog even in this case).
MSDN
The system sends this notification only if the dialog box was created using the OFN_EXPLORER value.
Did you use CdlOFNExplorer in the .Flags property ?
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Thanks, Krool! I wasn't aware of that. That must be it. I didn't set the CdlOFNExplorer flag because I thought the new style was enabled by default. I didn't realize CdlOFNExplorer could have other effects. I still have so much to learn!
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
I have been reading thru the post, ( I have not got thru all of them yet), but was wondering if anybody knows if there is a replacement OCX for Media player. I have been scouring the internet, but have not found one yet. I have an Old program I wrote years ago that uses Media Player, and I would really love to get that program re going again.
Thanks in advance,
Susan Grant
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
The RichTextBox control is now updated. Can you check if everything is fine ? To note is that of course only the Std-EXE version is updated. The OCX will be updated in a year or so when more updates got accumulated.
I tested the updated ComCtlsDemo. The new events seem to work OK. It was a very shallow test; just added some Debug.Print to the events to display the values of the arguments and triggered the events.
I didn't dare to add the source code to my projects. I'll wait for a new release of the OCX. Since I'm already using a workaround I may even skip some releases.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by grantsr1
I have been reading thru the post, ( I have not got thru all of them yet), but was wondering if anybody knows if there is a replacement OCX for Media player. I have been scouring the internet, but have not found one yet. I have an Old program I wrote years ago that uses Media Player, and I would really love to get that program re going again.
Thanks in advance,
Susan Grant
I still use the Windows Media Player in my project. Works from Win7 to Win11 including events.
Example for late binding:
Code:
Private WithEvents xWMP As WMPLib.WindowsMediaPlayer
Private MPlayer As VBControlExtender
Set MPlayer = Controls.Add("WMPlayer.OCX.7", "MPlayer4")
Set xWMP = MPlayer.Object
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Quote Originally Posted by jpfa
Meanwhile I had an issue with the Common Dialog replacement: the FileValidate event isn't firing. I just stumbled on this and didn't have time for further testing. This is most likely a bug in my code. I'll test the RichTextBox update first, though. The FileValidate issue can wait. Anyway this probably wouldn't help with what I wanted to achieve: to be able to accept an empty filename as valid (allowing the OK button to close the dialog even in this case).
Originally Posted by Krool
MSDN
Did you use CdlOFNExplorer in the .Flags property ?
I did a few tests using CdlOFNExplorer in the .Flags property. None of the events were triggered. I did the tests on a barebones app in the Ide. I didn't test a compiled exe. I did the tests in 2 different machines both running Windows 10 22H2. Same results.
So I switched to using the CmnDialogEx.cls class by LaVolpe in my projects. It behaves as expected and adds additional functionality which I already found useful.
Anyway the CmnDialogEx.cls classdidn't help with what I wanted to achieve: to be able to accept an empty filename as valid (allowing the OK button to close the dialog even in this case). The DialogOnFileOk event isn't triggered if the filename is empty.
I was able to device a workaround for an issue I had like forever: the file CommonDialog locks the last selected folder (even if I hit Cancel) forbiding me to delete it. This happens with all of the flavors of file CommonDialog I've tested (MS's, yours, LaVolpe's). The workaround is to select a different folder (I used App.Path) on a 2nd call to ShowOpen/ShowSave immediately after the first, and calling CloseDialog inside the DialogOnInit event of this 2nd call to ShowOpen/ShowSave. The dialog window flickers on this 2nd call, but this is just a small price to pay.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Krool,
I have a question about the ListView control. You have an event raised when the left mouse button is down along with the shift status. There is a similar event for a right click. I would like to be able to detect when the user scrolls the mouse wheel with or without shift keys while inside the ListView control. I can't find any of the events that might cover this. Am I overlooking something? If not, could this be added fairly easily? Thanks.
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Krool,
I am having a problem with events MouseEnter and MouseLeave not ever firing in ListView. Atached i a simple example. When the mouse enters or leaves the form's Listview control, there should be a beep but there is nothing. The event subroutines are never called. However, the MouseDown event fires properly and I have the code beep when a button is pressed inside ListView.
Am I doing something wrong or is there a bug in the code? Thanks.