-
Nov 22nd, 2023, 06:35 PM
#121
Member
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.
-
Nov 22nd, 2023, 07:39 PM
#122
Hyperactive Member
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)
-
Nov 23rd, 2023, 12:09 AM
#123
Member
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
-
Dec 7th, 2023, 12:01 PM
#124
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)
-
Dec 7th, 2023, 11:15 PM
#125
Member
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
True.
OLEDragDrop is RichText specific.
Will implement OLEDropMode and OLEDrag in 1.8. (Can be used if OLEDragDrop is False only for back-compat)
Thanks, Krool!
-
Dec 8th, 2023, 11:45 PM
#126
Hyperactive Member
ComboBoxW text replacing bug
I found a bug at the ComboBoxW control using the style "dropdowncombo", all other control properties are "Standard".
I get different results for the text property when using this code:
Code:
cboMS.Text = "C:\test_"
cboMS.AddItem "C:\test_1"
cboMS.AddItem "C:\data"
cboVBCCR.Text = "C:\test_"
cboVBCCR.AddItem "C:\test_1"
cboVBCCR.AddItem "C:\data"
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?
Last edited by Mith; Dec 8th, 2023 at 11:54 PM.
-
Dec 10th, 2023, 05:30 AM
#127
Re: ComboBoxW text replacing bug
Originally Posted by Mith
I found a bug at the ComboBoxW control using the style "dropdowncombo", all other control properties are "Standard".
I get different results for the text property when using this code:
Code:
cboMS.Text = "C:\test_"
cboMS.AddItem "C:\test_1"
cboMS.AddItem "C:\data"
cboVBCCR.Text = "C:\test_"
cboVBCCR.AddItem "C:\test_1"
cboVBCCR.AddItem "C:\data"
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?
That's really strange.
If you do
Code:
cboMS.Text = "C:\test_"
cboMS.AddItem "C:\test_1"
cboMS.AddItem "C:\data"
cboMS.Width = cboMS.Width + 30
You get the same behavior in the MS combo box.
The problem is in the CheckDropDownHeight handler where MoveWindow is used..
Workaround could be to block LB_FINDSTRING in the list windowproc during that MoveWindow.
EDIT: Found a solution to use SetWindowPos on the list handle directly upon CheckDropDownHeight. Will roll out the fix release soon.
Last edited by Krool; Dec 10th, 2023 at 08:04 AM.
-
Dec 10th, 2023, 08:33 AM
#128
Re: ComboBoxW text replacing bug
Originally Posted by Mith
I found a bug at the ComboBoxW control using the style "dropdowncombo", all other control properties are "Standard".
I get different results for the text property when using this code:
Code:
cboMS.Text = "C:\test_"
cboMS.AddItem "C:\test_1"
cboMS.AddItem "C:\data"
cboVBCCR.Text = "C:\test_"
cboVBCCR.AddItem "C:\test_1"
cboVBCCR.AddItem "C:\data"
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?
Update released. Fixed.
-
Dec 10th, 2023, 09:06 AM
#129
Hyperactive Member
Re: ComboBoxW text replacing bug
Originally Posted by Krool
Update released. Fixed.
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?
-
Dec 10th, 2023, 09:09 AM
#130
Re: ComboBoxW text replacing bug
Originally Posted by Mith
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.
-
Dec 10th, 2023, 09:16 AM
#131
Hyperactive Member
Re: ComboBoxW text replacing bug
Originally Posted by Krool
The MS control behaves the same. This "feature" can be deactivated by only blocking LB_FINDSTRING and returning -1.
Is it possible for you to add a new "AutoComplete" property (true/false) for this case?
-
Dec 10th, 2023, 05:52 PM
#132
Member
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.
-
Dec 10th, 2023, 08:31 PM
#133
Hyperactive Member
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by jpfa
I think I found another problem on the RichTextBox: the comands in the context menu Replace, Copy, Paste don't seem to support Unicode.
My RichTextBox doesnt have a context menu for Replace, Copy & Paste (Win10). I had to code my own context menu (with unicode support).
-
Dec 10th, 2023, 08:51 PM
#134
Member
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Mith
My RichTextBox doesnt have a context menu for Replace, Copy & Paste (Win10). I had to code my own context menu (with unicode support).
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?
-
Dec 10th, 2023, 10:40 PM
#135
Hyperactive Member
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?
-
Dec 11th, 2023, 01:32 AM
#136
Member
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.
-
Dec 11th, 2023, 02:13 AM
#137
Hyperactive Member
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by jpfa
I guess I'll have to a lot more testing to shed some light over this mystery. Maybe you can give me some pointers?
check the mouse click events for some code to display a context menu.
Originally Posted by jpfa
Speaking of which, if you're willing to share your code it will spare me some coding effort.
Sorry, i can't, because im using a commercial control for the context menu.
Maybe useful for you: https://www.vbforums.com/showthread....dows-clipboard
Last edited by Mith; Dec 11th, 2023 at 02:17 AM.
Reason: added info link
-
Dec 11th, 2023, 08:13 AM
#138
Member
Re: [VB6] ActiveX CommonControls (Replacement of the MS common controls)
Originally Posted by Mith
check the mouse click events for some code to display a context menu.[/url]
Sure! Why didn't I do that first thing? That's what I usualy do. I must have been too sleepy last night.
Originally Posted by Mith
Sorry, i can't, because im using a commercial control for the context menu.
[/url]
That's totally fair. I'll post my code when I get it done.
Originally Posted by Mith
Sure! That's what I had planned to use. I'm already using part of that code for the Ole drag drop event replacement and it works as expected.
Thanks for your help!
-
Dec 11th, 2023, 09:13 AM
#139
Member
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.
Thanks again Mith for your help!
-
Dec 19th, 2023, 05:33 PM
#140
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.
-
Dec 19th, 2023, 10:34 PM
#141
Member
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).
-
Dec 20th, 2023, 02:51 AM
#142
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 ?
-
Dec 20th, 2023, 04:44 AM
#143
Member
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!
-
Dec 27th, 2023, 04:29 PM
#144
New Member
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
-
Feb 8th, 2024, 12:55 AM
#145
Member
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.
-
Feb 8th, 2024, 01:13 AM
#146
Hyperactive Member
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
-
Feb 8th, 2024, 01:47 AM
#147
Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|