Re: CommonControls (Replacement of the MS common controls)
Code:
Public Sub SetForeColor(Optional lForeColor As ColorConstants = vbBlack)
Dim tCharFormat As CHARFORMAT2
With tCharFormat
.cbSize = LenB(tCharFormat): .crTextColor = lForeColor: .dwMask = CFM_COLOR
End With
SendMessage RTB.hWnd, EM_SETCHARFORMAT, SCF_ALL, VarPtr(tCharFormat)
End Sub
Re: CommonControls (Replacement of the MS common controls)
yeah, it's not liking any RTB as Richtexbox functions in my program
wont color the string using it
oddly though no type mismatch error, it just never even enters the function
X = 0
Do Until X > UBound(Keywords1)
sFindit = Keywords1(X) HighlightWords rtxtMarc, sFindit, vbBlue, Cntr2
Cntr = Cntr + Cntr2
X = X + 1
Loop
red text supposed to jump into function here, but stepping thru skips past it and no error!
EDIT, fixed by doing this
Public Function HighlightWords(RTB As VBCCR17.RichTextBox, _
sFindstring As String, _
lcolor As Long, _
ccntr As Integer) _
As Integer
Code:
Public Function HighlightWords(RTB As RichTextBox, _
sFindstring As String, _
lcolor As Long, _
ccntr As Integer) _
As Integer
Dim lFindLength As Long 'Length of string to find
Dim iMatchCount As Integer 'Number of matches
Dim boolon As Boolean
Dim aa As Long
boolon = RTB.Visible
RTB.Visible = False
frmDatatrapUndo = False 'set to false since highlighting is not a recognized change
'Cache the length of the string to find
lFindLength = Len(sFindstring)
'needs to always start at 1, but after finding can start at aa + lFindLength
'match test to get going
aa = InStr(1, RTB.Text, sFindstring, vbTextCompare)
'match found
If aa <> 0 Then
iMatchCount = iMatchCount + 1
RTB.SelStart = aa - 1 'rtb counts first position as 0
RTB.SelLength = lFindLength
RTB.SelBold = True
RTB.SelColor = lcolor
Do
aa = InStr(aa + lFindLength, RTB.Text, sFindstring, vbTextCompare)
If aa = 0 Then Exit Do
iMatchCount = iMatchCount + 1
RTB.SelStart = aa - 1 'rtb counts first position as 0
RTB.SelLength = lFindLength
RTB.SelBold = True
RTB.SelColor = lcolor
Loop
End If
'Restore the insertion point to zero
RTB.SelStart = 0
'Return the number of matches
ccntr = iMatchCount
If boolon = True Then
RTB.Visible = True
Else
RTB.Visible = False
End If
End Function
Last edited by sdowney1; Apr 18th, 2024 at 07:00 AM.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
If you have 2 references you can't declare "As RichTextBox" w/o putting the lib before, e.g. "As VBCCR17.RichTextBox".
If you want both in 1 sub then resort to "As Object".
Hi, thanks very much
Doing that has fixed my public function for coloring rtxtMarc
I suppose this will work for all the RTB functions
Public Function HighlightWords(RTB As VBCCR17.RichTextBox, _
sFindstring As String, _
lcolor As Long, _
ccntr As Integer) _
As Integer
EDIT, I am switching to using as Object as that works and I think it's a better idea rather than hardcoding in the ocx version
Public Function HighlightWords(RTB As Object, _
sFindstring As String, _
lcolor As Long, _
ccntr As Integer) _
As Integer
Last edited by sdowney1; Apr 18th, 2024 at 07:31 AM.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by VanGoghGaming
Code:
Public Sub SetForeColor(Optional lForeColor As ColorConstants = vbBlack)
Dim tCharFormat As CHARFORMAT2
With tCharFormat
.cbSize = LenB(tCharFormat): .crTextColor = lForeColor: .dwMask = CFM_COLOR
End With
SendMessage RTB.hWnd, EM_SETCHARFORMAT, SCF_ALL, VarPtr(tCharFormat)
End Sub
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by sdowney1
thanks for this
I copied that from my own RichTextBox class, you may want to take a look at it if you want to learn more about RichTextBoxes. For example you don't need to implement your own text search routine since the RichTextBox can do that for you in a much better way (with the EM_FINDTEXTEX message), it can search forward, backward, case sensitive/insensitive, match whole word or partial.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by VanGoghGaming
You can send the "EM_EXLIMITTEXT" message to increase the characters limit:
Code:
Private Const EM_EXLIMITTEXT As Long = &H435, lMaxLimit As Long = &H7FFFFFFF
SendMessage RichTextBox.hWnd, EM_EXLIMITTEXT, 0&, lMaxLimit
That is helpful
I was then able to load a 139mb text file into this RTB control, it took couple minutes to load and then to be able to access it.
How big a file does that sendmessage command allow to load into a RTB?
Is that as big as it gets or can you get more.
139 mb in the file corresponds with 75,000 individual MARC records in my file. Which is a lot of records.
Think 75,000 items in a library. And all in one file. Conceivably most people would break up a file to make it more manageable.
Re: CommonControls (Replacement of the MS common controls)
It takes 9 secs to load the 139mb into a MS RTB and it takes 3 minutes to load in the Krool unicode RTB.
I am using this method here, is there a better way?
Re: CommonControls (Replacement of the MS common controls)
I finally get to see unicode languages in the MariaDB and the program
I had to put this in my.ini and restart the DB server
and then had to modify the database and a table to use CHARACTER SET utf8;
I's all in these links. Will work for MySql or MariaDB
C:\Program Files\MariaDB 11.3\bin>mariadb -u root -p --port=3308
Enter password: ****
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 11.3.2-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> ALTER DATABASE testspecialchars CHARACTER SET utf8;
Query OK, 1 row affected (0.007 sec)
MariaDB [(none)]> use testspecialchars;
Database changed
MariaDB [testspecialchars]> ALTER TABLE bookdata CONVERT TO CHARACTER SET utf8;
Query OK, 3 rows affected (0.051 sec)
Records: 3 Duplicates: 0 Warnings: 0
And the picture shows greek and chinese text in the DB displaying properly
I am able to just copy, paste, update unicode now
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
Update released.
Included the AutoVerbMenu in the RichTextBox control.
Small change..
Ctrl+Alt+V shortcut changed to Ctrl+Shift+V as this is common for Me.PasteSpecial CF_UNICODETEXT.
Menu text changed from 'Paste Special' to 'Paste as plain text'.
Ctrl+Alt+V should be reserved for a paste special dialog box to choose a format. (like Wordpad)
German translation also added. I may add others as well soon without further notice.
Re: CommonControls (Replacement of the MS common controls)
Hi, wide combo box is the new combobox?
This no longer works with the new control
Any ideas why?
it's listcount when form loads is zero
EDIT, it looks like an empty wCombobox does not work anymore here.
As I put in a value cboFind.AddItem ("test"), and then the cboFind.list(0) came up with 'test'
So it does not like a totally empty combo box which the original non unicode control was ok with
Private Sub cmbFindCheck()
For xxx = 0 To cboFind.ListCount
If cboFind.List(xxx) = cboFind.Text Then Exit Sub 'found in box
Next xxx
If Trim(cboFind.Text) <> "" Then cboFind.AddItem cboFind.Text ' not found add it
End Sub
I added this in the formload
cboFind.AddItem ("")
cboReplace.AddItem ("")
And changed to this
For xxx = 0 To cboFind.ListCount - 1
Which allows the form to function, and it does find all the individual chinese and greek and english chars, and can replace them.
But it then has an empty added in item first in the box which you see when it drops down, prefer not to see that empty string in the combo box.
At least right now it works.
EDIT again. I got it like it should be working.
I left off the additem "" at form load and everything is as it was.
It really needed 'Listcount - 1' to be there to let it not enter the For Next when the box is empty.
Last edited by sdowney1; Apr 18th, 2024 at 12:12 PM.
Re: CommonControls (Replacement of the MS common controls)
Is there a way for the msgbox to display the unicode string chars in a message?
It will just show question marks like this for cboFind variable, which is a unicode string.
So in the msgbox, it says, "Finished searching for ?" rather than showing the unicode chars.
Code:
If lngResult = -1 Then
'Text not found
MsgBox "Finished searching for '" & cboFind & "'", vbInformation, "BookStore Editor"
cmdFind.Caption = "&Find" 'Set caption
cmdReplace.Enabled = False 'Disable Replace button
cmdReplaceAll.Enabled = False 'Disable ReplaceAll button
Re: CommonControls (Replacement of the MS common controls)
SOLVED!
Can't believe how much progress I made today.
Found this function for a wide msgbox, and it works. I have frmFind.hWnd in there as that is my form running the finds.
The code is in a module.
Code:
Private Declare Function MessageBoxW Lib "User32" (ByVal hWnd As Long, ByVal lpText As Long, ByVal lpCaption As Long, ByVal uType As Long) As Long
Public Function MsgBoxW(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String = "Microsoft Access") As VbMsgBoxResult
MsgBoxW = MessageBoxW(frmFind.hWnd, StrPtr(Prompt), StrPtr(Title), Buttons)
End Function
run it like this in program
MsgBoxW "Finished searching for '" & cboFind & "'", vbInformation, "BookStore Editor"
results in the pic
Last edited by sdowney1; Apr 18th, 2024 at 01:11 PM.
Re: CommonControls (Replacement of the MS common controls)
Hello Krool!
Compilation Error Feedback:
1?ComCtlsDemo.zip "Last edited by Krool; Yesterday at 07:24 PM. "
2. In the IDE environment, there is garbled characters, and it cannot be compiled normally. This has never happened before. Related process name "Friend Sub FIRichEditOleCallback_GetContextMenu"
3?"VBCCR17 1.7.104 Last edited by Krool; Yesterday at 02:23 AM." ---OK
4. Operating system version "Win10 Chinese Simplified Chinese Version"
5. VB6 version: VB6 SP6, VBA9782
Please help resolve this error, thank you very much!
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by smileyoufu
Hello Krool!
Compilation Error Feedback:
1?ComCtlsDemo.zip "Last edited by Krool; Yesterday at 07:24 PM. "
2. In the IDE environment, there is garbled characters, and it cannot be compiled normally. This has never happened before. Related process name "Friend Sub FIRichEditOleCallback_GetContextMenu"
3?"VBCCR17 1.7.104 Last edited by Krool; Yesterday at 02:23 AM." ---OK
4. Operating system version "Win10 Chinese Simplified Chinese Version"
5. VB6 version: VB6 SP6, VBA9782
Please help resolve this error, thank you very much!
Re: CommonControls (Replacement of the MS common controls)
smileyoufu,
below is the adjustment which should work and display the characters correctly even when the non-unicode app option "utf-8" is enabled.
Can you confirm ? Then I would update the project soon.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
smileyoufu,
below is the adjustment which should work and display the characters correctly even when the non-unicode app option "utf-8" is enabled.
Can you confirm ? Then I would update the project soon.
Hello Krool!
Thank you very much for your quick response.
It is confirmed that the solution works properly under the IDE and compiles to .exe files successfully.
Thank you very much!
Ooops! As usual it seems you were right and I was wrong.
I didn't know the source code for the MS control was available. Where did you get it?
That code clearly shows that the menu items labels are hardcoded. So there must be different versions of the ocx for each language (?). What a mess! I thought all the lanaguage dependent text was provided by the OS. Now I realize that some of the text could be provided by the runtime and some be hardcoded. Now I undestand the installation warning about the language supported by some controls / dlls.
My OSs (Windows 10 & XP) are Spanish. Most of the software I use is either Spanish or language agnostic. VB6 is Spanish. I don't have VB.NET installed now, but the version I used time ago (2008) was Spanish. So that's why the controls in the projects I download seem to be localized?
My conclussion: for compatibility with the MS control yours should support translations. That's overkill, isn't it? Maybe some resource file can be used if present? Or at least let the user create a custom menu calling the functions originally called by the default menu?
For my personal use (and I don't create distributable software) I don't mind having mixed Spanish & English (or even Italian or French) text, so for me everything's OK as it is now.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by jpfa
Ooops! As usual it seems you were right and I was wrong.
I didn't know the source code for the MS control was available. Where did you get it?
That code clearly shows that the menu items labels are hardcoded. So there must be different versions of the ocx for each language (?). What a mess! I thought all the lanaguage dependent text was provided by the OS. Now I realize that some of the text could be provided by the runtime and some be hardcoded. Now I undestand the installation warning about the language supported by some controls / dlls.
My OSs (Windows 10 & XP) are Spanish. Most of the software I use is either Spanish or language agnostic. VB6 is Spanish. I don't have VB.NET installed now, but the version I used time ago (2008) was Spanish. So that's why the controls in the projects I download seem to be localized?
My conclussion: for compatibility with the MS control yours should support translations. That's overkill, isn't it? Maybe some resource file can be used if present? Or at least let the user create a custom menu calling the functions originally called by the default menu?
For my personal use (and I don't create distributable software) I don't mind having mixed Spanish & English (or even Italian or French) text, so for me everything's OK as it is now.
Thanks!
I think some major languages are now supported. You should see spanish now.
And fallback is anyway then english.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by smileyoufu
Hello Krool!
Compilation Error Feedback:
1?ComCtlsDemo.zip "Last edited by Krool; Yesterday at 07:24 PM. "
2. In the IDE environment, there is garbled characters, and it cannot be compiled normally. This has never happened before. Related process name "Friend Sub FIRichEditOleCallback_GetContextMenu"
3?"VBCCR17 1.7.104 Last edited by Krool; Yesterday at 02:23 AM." ---OK
4. Operating system version "Win10 Chinese Simplified Chinese Version"
5. VB6 version: VB6 SP6, VBA9782
Please help resolve this error, thank you very much!
Re: CommonControls (Replacement of the MS common controls)
Update released.
Included the Span/UpTo method in the RichTextBox control. (richtx32.ocx compatibility)
The lack of these methods was complained already several times. Anyway, now it's done.
Re: CommonControls (Replacement of the MS common controls)
Update released.
ToolBar buttons can have a dropdown button menu only without submenus.
Of course you can handle the ButtonDropDown event and show your own menu. However, it would be easier to just supply a menu handle to a button object which takes care of positioning, exclude rects, WM_CANCELMODE upon recursive invocation, left or right align etc. already built-in in the ToolBar control.
Therefore included the hMenu run-time property in the TbrButton object.
Returns/sets a handle to a popup menu which will be used as a button dropdown menu.
This is especially useful when a menu with submenus is needed. You can supply whatever menu which is accepted by TrackPopupMenuEx. (e.g. GetMenu()+GetSubMenu() of a VB.Form)
Included ButtonMenuClick2 event in the ToolBar control.
Your application is responsible for destroying the menu handle when it is no longer needed. Best is to also set Button.hMenu to 0 when your app destroys the menu handle.
Re: CommonControls (Replacement of the MS common controls)
Update released.
Included the PasteSpecialDlg method in the RichTextBox control. (OleUIPasteSpecialW)
Ctrl+Alt+V shortcut now invokes the paste special dialog box.
The AutoVerbMenu is added with a paste special menu entry.
The OCX VBCCR18 was also updated. The internal type lib version is now 1.1.
As it's early stage of VBCCR18 I decided to increase type lib version. (requires a re-register)
However, I plan now to keep things as they are and do bugfixes only. But I saw this feature quite useful..
Re: CommonControls (Replacement of the MS common controls)
Hi,
Maybe I miss something, but when using ImageCombo with 'MS Common Controls' with this example :
Code:
Private Sub Form_Load()
ImageCombo1.ComboItems.Add , , "Test", "printer"
ImageCombo1.ComboItems.Add , , "Test2", "printer"
ImageCombo1.ComboItems.Add , , "Test3", "printer"
ImageCombo1.ComboItems(1).Selected = True
End Sub
The item is selected and displayed with its icon.
But When I do the same with Krool's CommonControls, there is no icon next to the selected item. I have to click ImageCombo1 to get the list with the icons.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Crapahute
Hi,
Maybe I miss something, but when using ImageCombo with 'MS Common Controls' with this example :
Code:
Private Sub Form_Load()
ImageCombo1.ComboItems.Add , , "Test", "printer"
ImageCombo1.ComboItems.Add , , "Test2", "printer"
ImageCombo1.ComboItems.Add , , "Test3", "printer"
ImageCombo1.ComboItems(1).Selected = True
End Sub
The item is selected and displayed with its icon.
But When I do the same with Krool's CommonControls, there is no icon next to the selected item. I have to click ImageCombo1 to get the list with the icons.
I can't reproduce as it's working for me. Can you show a full demo ? Maybe I am missing something.
Re: CommonControls (Replacement of the MS common controls)
Sorry, that had nothing to do with your CommonControls' ImageCombo.
In fact, I use a class FormResize.cls to resize the form and its objects.
When loading, the form resizes and changing font size of the objects made the icon disappear in my ImageCombo.
So selecting the default item of the combo after the resize solved my problem.