Probably a Timer, start it at the end of the click event to begin populating the ListView.
Printable View
Probably a Timer, start it at the end of the click event to begin populating the ListView.
Yes, I could add an event TabChange that would be raised after the tab already changed, but for now perhaps you could set a timer of 15 ms in the Click event.
Update released.
Added something in the Refresh method.
It turned to be that there is already an event that is raised after the tab already changed, it is named TabChange.
But, for the visual of the control to be updated, you'll need to call the Refresh method.
Why? Because the control can receive many actions, and it won't update for each one individually. So calling the Refresh method forces the visual update in that moment.
Download the latest version because I added something in the Refresh method.
Great! Using the TabSelChange in combination with the Refresh did solve the issue. Didn't even need to download the latest version.
Hi Eduardo,
This is what the code looks like:
Regards,Code:Private Sub tabMainForm_Click(PreviousTab As Integer)
'Is here only to change the tab, allowing for a quick display of the controls, and where applicable showing the progress bar while updating the details listview
End Sub
Private Sub tabMainForm_TabSelChange()
tabMainForm.Refresh
'Rest of code
End Sub
Erwin
I mean the "Rest of code" must have something that allows the control to paint.
I tested with a tight loop, and it needed the "fix" (available in the last update) to do the Refresh immediately.
At least in my Windows 11.
And if you remove (comment) the call to Refresh, the control is updated or not?
If I comment out the call to Refresh, the tab is still redrawn.
The rest of the code
1. Resizes and relocates the controls on the tab
2. Colors a picturebox with a gradient fill, and writes a text on it
3. Fills a TreeView control
4. Fills a ListView control
During the population of the ListView, a progress bar is updated to provide feedback to the user.
Note: I'm running this in the VB6 IDE which runs in Windows XP in a virtual machine. (Oracle VM Virtual Box.)
Yes, it seems that at some point (in your code) the control is allowed to process the WM_PAINT message.
what's control-source\cmp?
whye NewTab01.ocx have 1.3MB?
VB6.EXE ONLY 1.8mb
It is the reference for binary compatibility. It is a previous version of the ocx where the file was renamed to *.cmp. VB6 takes the typelib in the ocx for reference, to make the typelib of the new file compatible.
I don't know why VB6 doesn't produce smaller binaries, but is is not a problem at all nowadays (in 99,99% of cases). If you really need smaller files, you could use UPX, it can reduce a lot the size.
Sorry for the delayed response. I fell ill suddenly the Wednesday before the last (more than 2 weeks back).
While recuperating, I did see your message in my mobile and felt very happy to read the news of you having readily included the new theme (that too as "Apple Green" itself) and also pleased to see the pleasant sample image to illustrate the new theme.
Thanks for the other explanation (on 'ambient colors').
I take this opportunity to thank you once again, Eduardo, for your wonderful control.
Kind regards.
Hi Eduardo,
When the user selects a tab, is there a way to know what the previous tab was? (Other than tracking it from Form load onwards in a module or global variable.)
Regards,
Erwin
I knew I had seen it somewhere, but couldn't find it anymore. Too focused on the Tab-events... :rolleyes:
I don't know who deleted my reply.
I'm not malicious because I saw The resulting OCX file. it ended up being 1.3 MB.
If we can make it smaller, it must be a good thing.
Then I also want to analyze what is the specific problem that causes the volume to be larger?
It turned out to be because of some property pages. Because the property page is mainly used in the development and design process, it may not be needed when it is finally compiled into exe or OCX.
Then optimize it when compiling, and it will also have a certain impact according to the volume or the running speed.
With these methods, the final size was reduced by a factor of two to more than 600 KB.
I spent a few hours studying it. If you directly import multiple files of the source code into the project, which file attributes will change? Control, the public property of the class becomes private.
My idea is. The application project under development maintains an automatic reference to the files in this directory and does not need to change other settings each time a new version is downloaded.
If different control developers can create a standard for everyone.
Some control groups contain multiple controls in one project, such as text boxes, buttons, tabs, and grid controls.
Someone may just need a text box or button that supports Unicode.
How do I keep just these two controls while deleting the other extraneous files?
I just thought of a good way The author who developed this component is most familiar with it.
Just delete some other extraneous files and then save as a project name in the same directory.
I'm writing a plug-in that will automatically bring these files into a new project.
Perhaps more than half of the users may prefer to become a stand-alone exe, because OCX requires registration and permissions.
Turn a control project into a Exe project template,You need to change the public properties of some classes or controls to private properties.Some other settings may be needed.
Then save these files with minor changes as *.-copy. CTL file name。
Because I used to test a project called exe or com DLL mode, often some files can not coexist with two projects.
Perhaps the simplest is to simply generate the OCX reference. Otherwise, it is really troublesome to add dozens of files to another new project.
It is mainly based on the fact that some control or component module projects are relatively large, with 5 to 10 or more than 20 source files.
At the same time, I would like to thank many individual developers for contributing free source code to develop more useful new controls.
And keep it updated for months to years,No matter what the return.
Because the control is very difficult to develop or change, and only the original author can implement these functions.
Yes, they are needed for the developer using the OCX to be able to set some properties, like Theme and others, and also there are tools there that can be handy, for example to move control from one tab to another, or to change the order of tabs.
I don't think so., the speed will be the same.
I'll repeat: 1.3 MB for today's standards, computers and OSs is a very small file. There is no problem at all, we are not in 1990.
There are not "extraneous files", all files are needed. If you don't need some functionality then delete the corresponding files, but that won't be for everybody, other people may not want to loose the related functionality.
PD: you can delete the pagNewTabTabs property page, that one may be not needed.
ok,thank you,Maybe user want to make the volume a little smaller, and the earliest version may be smaller.
If in the process of development. Save some older versions that are more stable.
Like control version 1.0, 2.0, 3.0.
Maybe 1.0 might only be 200KB. Version 2.0 reaches 500KB, and version 3.0 reaches one megabyte.
rc3.dll,rc5.dll,rc6.dll
The old version can be easily registered on a computer, (rc6 The new version can't register on a very small number of computers (most computers will be perfectly fine))
Some people need some simple tab control functions, and it is possible that his earliest version is enough to use.
RC6.DLL I found that 3 of my friends could not register successfully on their computers.
(By that I mean embedding the control source code to vb6 project. The problem of registration failure can be avoided.Of course, there is also a method of exemption from registration, which is also possible. It's just that some new users can't use it yet.
Some new versions of OCX, com, and DLL use more of the windows API, so they can cause, ah, registration failures on some older systems.
So keep some of the old versions, and there will be higher compatibility.)
Maybe the translation software didn't explain it clearly.
Some may be anti-virus software blocked, some may be the system non-administrator account permission is not enough.
I am saying that when compiling the project containing the control source code as EXE software, select the compilation option (to make the file size smaller) (to make the running speed faster).
It can also reduce the size of the EXE volume after compilation. Reduced from 1.3MB to only 640kb
NEWTAB.OCX 1.3MB
Compiled as an EXE, all files retained: 1.13MB, 40% larger than the minimum version
Retain only the most basic control functionality: 820KB(340KB less)
The optimized code size is 644kb, (Compile in the way of running speed first.)744KB
I have no ill will, originally is 2 words finished, the result replies so much. I'M SORRY
Excellent work, thanks for the update!
Hi Eduardo,
Quick question: when I disable the tabcontrol, the images used on the tabs with the Picture property are automatically greyed out. Is it possible to keep these the same as when the tabcontrol is enabled?
Thx,
Erwin
Update released.
Changed that behavior in the current version.
Now the bitmap pictures are grayed only when the particular tab is disabled but not when the whole control is disabled.
BTW: I also added a new property 'TabsEndFreeSpace': Returns/sets the size of an optional free space after the last tab (rightmost tab for the top orientation).
Hi Eduardo,
I’m afraid that I have to come back to you on #60 in the thread.
During testing I discovered that when buttons on the tab were clicked during the loading of the items in the listview, Windows buffered these, and started the code behind them either already during the loading, or afterwards. So I went through, and discovered a DoEvents statement in the listview processing that was there to allow the progress bar to be updated.
I cleaned up the code to make sure no DoEvents were around, I'll worry about showing the updates on the progress bar later, and installed your latest OCX.
Much to my sadness, clicking on the tab doesn’t refresh anything, until the listview is fully loaded.
This is the code I currently have:
I’ve tried also with adding tabMainForm.Redraw = True before the refresh statements. Didn’t make a difference.Code:Private Sub tabMainForm_Click(PreviousTab As Integer)
tabMainForm.Refresh
End Sub
Private Sub tabMainForm_TabSelChange()
tabMainForm.Refresh
'Actions depend on the tab that was selected
If tabMainForm.TabSel = 2 Then
‘Populate treeview and listview
End If
End Sub
Tested in the IDE, as well as compiled on Windows 10, but unfortunately all the same.
What do I do wrong?
Thanks,
Erwin
You told me that you didn't need to update the control:
I suggest you to test with the latest version, then tell me whether it is working as expected or not.
PS: It worked before because you had a DoEvents in your code, now that you don't have the DoEvents anymore, you'll need to update the control to the latest version for the .Refresh to properly work.
Hi Eduardo,
I did install and register the latest version of the OCX. Just double checked and this is what's in the vbp-file:
Object={66E63055-5A66-4C79-9327-4BC077858695}#3.2#0; NewTab01.ocx
I also confirm that it worked before as there was still a DoEvents in the code. (The code that fills the treecontrol and the listview calls several routines and functions, and one DoEvents was deep down in there, hence I missed that last time.) Now that this is gone, the tab is only painted when all code is finished.
Note that if I put a MsgBox statement in the Click event, nothing happens. However, if that statement is added as the first line in the TabSelChange event, the tab is painted. It then is even painted without the .Refresh
Regards,
Erwin
Just put the NewTabX.Refresh at the beginning of the TabSelChange event.
Did it work or not?
If no, what exactly is the issue?
That's where it is:
The issue is that I see that the tab is being selected (the text in the tab gets bold) but none of the controls on the tab are being displayed. The controls of the previously selected tab remain visible, and the controls on the newly selected tab are only displayed after the code in the TabSelChange event has finished processing.Code:Private Sub tabMainForm_TabSelChange()
tabMainForm.Refresh
'Actions depend on the tab that was selected
If tabMainForm.TabSel = 2 Then
‘Populate treeview and listview
End If
End Sub
In these cases it is better to add a Timer control, Interval 15 ms, Enabled = False at design time.
Then in the tab change event, if it is the tab where the long process must take place, set the timer Enabled = True.
Then move the long process to the timer. And of course set the timer to Enabled = False from its timer procedure too.
It is not a problem of the tab Control. The other controls paintings are not updated (what is normal anyway in such cases).
Try calling UpdateWindow API on the form's hWnd. This is effectively sending WM_PAINT out of order i.e. without waiting for other messages to dequeue (contrary to InvalidateWindow API which posts WM_PAINT at the end of the message queue).
This might not work if show/hide animations are involved which obviously cannot happen while TabSelChange event handler is stalling UI thread populating the list-view.
cheers,
</wqw>
In case no one else has encountered this, I downloaded the modded VBA6.DLL from GitHub and tried it on WIndows 7 Ultimate 64 Bit in Vb6 Service Pack 6. VB6 throws an error when it encounters DatePicker1.Format = dtpCustom. I don't get the error with the original DLL. From the screen shots I've seen, your tab control looks great and I might use it on a project that doesn't use a date picker.
Hi Eduardo,
This did the trick! 15ms seemed a bit too tight, so I settled for 100ms, and all seems to work great. Will do more testing in the upcoming days, but the results so far look very good.
Once again many thanks!!! Not only for a great tab-control, but also for your support in finding solutions to challenges that may only be sideways related to your control, if at all. It is greatly appreciated.
Thanks,
Erwin
Update released.
2023-11-28 Changed to OLE version 5.0.
2023-11-27 Added ntTabOrientationLeftHorizontal and ntTabOrientationRightHorizontal options to the TabOrientation property.
2023-11-22 Several minor bugs fixed.
Now the left and right orientation can show the captions horizontally.
Attachment 189396
Hello Eduardo!
Thank you for providing such an excellent tab control.
Can multiple forms be opened in the NewTab tab, and when a tab is selected, the corresponding form will be displayed on the tab. When the tab is closed, the form is automatically uninstalled (or when the form is uninstalled, the corresponding tab is automatically closed). When the size of a tab changes, the size of the form changes with the size of the tab.
If convenient, could you please add such an example in the presentation file.
Thank you very much!
Similar effects:
Attachment 189453
Interesting request. I'll consider it but I don't promise when I'll do it (or if ever).
To do it automatically I'll have to expand the TDIMode property from a boolean to an enum like ntTDINone, ntTDIControls and ntTDIForms.
And then, detect when a form is going to be shown modally or non-modally and place every non-modal form in a tab (with the SetParent API), and allow modal forms to display normally. Probably with a CBT hook.
Hello Eduardo!
Your reply has shown me the possibility and hope. Time is not a problem, you can do it at any convenient time for you. I hope to see the release of this example in the near future.
Thank you very much!
Hello Taishan!
Thank you for your reply.
Within a limited range of controls, it is possible to use Pic1, Pic2, and Pic3 to accommodate a limited number of controls (implemented by tab effects), or even place the control directly in the control's tab without Pic.
In actual business, we may have many forms, and we may need to open several different forms to comprehensively process the information of different forms to complete our work (sometimes, we may need to view several different forms at the same time, constantly switching between tabs), which is why we have the idea of "tab based forms".
There is no "tabbed form" feature in VB6, and it would be great if this feature could be achieved through tab controls.
Similar to the "tab form" effect in Access, as shown in the screenshot below:
Attachment 189462
Attachment 189463
I agree that to have the whole program with all the code and all the controls over an unique form, could be a mess for most programs.
I have it already "working".
I've already done the 90%, now I'm working in the other 90% ( Tom Cargill's rule).
You can use the a picture to contain the entire form, you can see this sample from elGuille https://www.elguille.info/vb/API/DockVBSetParent.htm.
The only problem is that the form that contains the NewTab control, can not be show as modal
Update released.
TDIMode now can be set to ntTDIModeForms. It works similar to an MDI form but tabbed.
Of course, the forms don't need to be MDIChild but normal.
There is a new sample project for testing this feature in the download.
Please test and report back.
Attachment 189490
I downloaded the latest version and found a small bug:
In the file NewTab.ctl the line 13763, method TDIPutFormIntoTab:
Set TabPicture(mTabs - 1) = LoadPicture("D:\Programas\Infotambo\Iconos e imagenes\Formularios\frmAnimales\1.bmp") ' CreatePicture(iIconHandle, vbPicTypeIcon)
Returns the error:
Run.time error '76'
Path not found: 'D:\Programas\Infotalambo\Iconos e imagenes\Formularios\frmAnimales\1.bmp'
I think it should be deleted.
Otherwise it seems to work correctly.
Now I'm trying to resolve a small incompatibility with my method to simulate Anchor in forms automatically
Everything works perfectly except post #107.
Add that, loading the form, it does not lose focus.
Eduardo, hello!
Thank you for implementing the "TabForm" feature so quickly. This has provided me with great help in my work. Thank you very much!
The feedback on the testing situation is as follows:
1. The same error occurred as # 107; As shown in the following figure:
Attachment 189499
2.When the value of Form.BorderStyle is set to 0-None, the form cannot be opened in TDIForms, but appears outside the form to open. I don't know if this is wrong; As shown in the following figure:
Attachment 189500
Attachment 189501
Hello Eduardo!
Test report:
1. Step 1) Click on the "Show Form1" form to load; Step 2) Click the "Minimize" button in the upper right corner of the form frmTDIFormsTest, and the error "Real time error 5: Invalid procedure call or parameter" will appear.
Attachment 189507
Attachment 189508
2. Click the button "Show Form0->BorderStyle=0" in the attachment, and the form will not be loaded into "TDI". When setting "Form. BorderStyle=0", the form cannot be loaded into "TDI". It must be set to a value other than 0 to load the form into "TDI". Please advise.
Attachment 189509
Attachment 189510
Thank you very much!
Update released.
Yes, thanks, that is fixed now.
That behavior is on purpose: borderless forms, toolwindow forms and modal forms are not tabbed (non made TDI-child) on purpose. If you want a form to be shown TDI, then it needs to have a BorderStyle 1, 2 or 3.
I added some explanation in Form4, that is a new form. Also showing a way to display forms normally (non-TDI), even when they have normal BorderStyle.
You're welcome.
Hello Eduardo!
Thank you for your careful explanation, which has given me a deeper understanding of the functions of the "TDI" form.
The NewTab TDI is now being used normally in my project. This has been very helpful to me.
Thank you very much!
btw, what is "TDI“ represent?
This is my first post on this forum. Please understand if there are language translation errors.
I would like to greet Mr. Eduardo, and thank him for his hard work. And related to this thread, there are several questions I want to ask :
1 - How do I arrange the text and icon to be in the middle of the CaptionBar (adjusting to the size of the CaptionBar)?
Attachment 189550
When the CaptionBar position is at the bottom (ssTabOrientationBottom), it seems like the text and icons don't look good.
Attachment 189551
2 - Is it possible to display custom tab shapes like image attachments?
Attachment 189552
Thanks for your answer.
Hopefully this time the images can be shown. Below, I will try to attach the images again using the Insert Image tag:
Attachment 189556
Attachment 189557
Attachment 189558
Please provide instructions on how to display the images if the images above do not appear.
Thank You.
Hello. This forum have a problem with attachments. Please edit the post and re-upload the attachments so I can see them.