Skip to content

Commit 6b9a953

Browse files
committed
version update
Removed reference to MS Forms library and added MS Forms enums Modified setting control BorderStyle property to more closely respect UserForm special effects
1 parent e7e50c5 commit 6b9a953

12 files changed

+120
-19
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The resulting imported form and code may have to be tweaked in **twinBASIC** to
1313

1414
**MS Forms controls not yet supported**: TabStrip, and MultiPage.
1515

16-
**Extract Image Resources Option**: User can optionally extract and save to file all image resources (mouse icons and picture bitmaps) that are embedded in each UserForm for later use as a **twinBASIC** resource.
16+
**Extract Image Resources Option**: User can optionally extract and save to file all image resources (mouse icons and picture bitmaps) that are embedded in each UserForm for later use in **twinBASIC** Resources.
1717

1818
<img src="https://github.com/GCuser99/VBA-UserForm-to-twinBASIC/blob/main/images/nested_controls.png" alt="NestedControls" width=95% height=95%>
1919

@@ -27,7 +27,7 @@ The resulting imported form and code may have to be tweaked in **twinBASIC** to
2727
## Quick How-To-Use
2828

2929
1) Make sure to close all MS Office applications.
30-
2) Run the included tBUserformConverterSetup.exe Inno installer.
30+
2) Download and run the tBUserformConverterSetup.exe Inno installer.
3131
3) Open an MS Office document that contains UserForm(s) to be converted.
3232
4) Open the Visual Basic for Application IDE.
3333
5) You should see the "twinBASIC Tools" menu item on the far right of the main menu bar.

dist/tBUserFormConverter_win32.dll

4 KB
Binary file not shown.

dist/tBUserFormConverter_win64.dll

4.5 KB
Binary file not shown.

dist/tBUserformConverterSetup.exe

1.18 KB
Binary file not shown.

images/nested_controls.png

2.78 KB
Loading

src/Sources/About.twin

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Class About
55

66
Sub New()
77
lblInfo.Caption = "Author: GCUser99" & vbCrLf & _
8-
"Version: v2.5" & vbCrLf & _
8+
"Version: v2.6" & vbCrLf & _
99
"Description: A VBIDE add-in (complied with twinBASIC) that converts VBA UserForms for use in twinBASIC."
1010
lblWebsite.Caption = "https://github.com/GCuser99/VBA-UserForm-to-twinBASIC"
1111
Set Me.Icon = GetImageFromResources("transparent.ico", "IMAGES")

src/Sources/FormProcessing.twin

+115-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
' ==========================================================================
2-
' tBUserFormConverter v2.5
2+
' tBUserFormConverter v2.6
33
'
44
' A VBIDE add-in (complied with twinBASIC) that converts VBA UserForms for use in twinBASIC.
55
'
@@ -33,6 +33,84 @@
3333
' ==========================================================================
3434

3535
Module FormProcessing
36+
37+
'---------------------------------------------------------------------
38+
' MS Forms Enums
39+
'---------------------------------------------------------------------
40+
Private Enum fmMousePointer
41+
fmMousePointerDefault = 0 ' &H00000000&
42+
fmMousePointerArrow = 1 ' &H00000001&
43+
fmMousePointerCross = 2 ' &H00000002&
44+
fmMousePointerIBeam = 3 ' &H00000003&
45+
fmMousePointerSizeNESW = 6 ' &H00000006&
46+
fmMousePointerSizeNS = 7 ' &H00000007&
47+
fmMousePointerSizeNWSE = 8 ' &H00000008&
48+
fmMousePointerSizeWE = 9 ' &H00000009&
49+
fmMousePointerUpArrow = 10 ' &H0000000A&
50+
fmMousePointerHourGlass = 11 ' &H0000000B&
51+
fmMousePointerNoDrop = 12 ' &H0000000C&
52+
fmMousePointerAppStarting = 13 ' &H0000000D&
53+
fmMousePointerHelp = 14 ' &H0000000E&
54+
fmMousePointerSizeAll = 15 ' &H0000000F&
55+
fmMousePointerCustom = 99 ' &H00000063&
56+
End Enum
57+
58+
Private Enum fmScrollBars
59+
fmScrollBarsNone = 0 ' &H00000000&
60+
fmScrollBarsHorizontal = 1 ' &H00000001&
61+
fmScrollBarsVertical = 2 ' &H00000002&
62+
fmScrollBarsBoth = 3 ' &H00000003&
63+
End Enum
64+
65+
Private Enum fmBorderStyle
66+
fmBorderStyleNone = 0 ' &H00000000&
67+
fmBorderStyleSingle = 1 ' &H00000001&
68+
End Enum
69+
70+
Private Enum fmTextAlign
71+
fmTextAlignLeft = 1 ' &H00000001&
72+
fmTextAlignCenter = 2 ' &H00000002&
73+
fmTextAlignRight = 3 ' &H00000003&
74+
End Enum
75+
76+
Private Enum fmBackStyle
77+
fmBackStyleTransparent = 0 ' &H00000000&
78+
fmBackStyleOpaque = 1 ' &H00000001&
79+
End Enum
80+
81+
Private Enum fmOrientation
82+
fmOrientationAuto = -1 ' &HFFFFFFFF&
83+
fmOrientationVertical = 0 ' &H00000000&
84+
fmOrientationHorizontal = 1 ' &H00000001&
85+
End Enum
86+
87+
Private Enum fmMultiSelect
88+
fmMultiSelectSingle = 0 ' &H00000000&
89+
fmMultiSelectMulti = 1 ' &H00000001&
90+
fmMultiSelectExtended = 2 ' &H00000002&
91+
End Enum
92+
93+
Private Enum fmListStyle
94+
fmListStylePlain = 0 ' &H00000000&
95+
fmListStyleOption = 1 ' &H00000001&
96+
End Enum
97+
98+
Enum fmSpecialEffect
99+
fmSpecialEffectFlat = 0 ' &H00000000&
100+
fmSpecialEffectRaised = 1 ' &H00000001&
101+
fmSpecialEffectSunken = 2 ' &H00000002&
102+
fmSpecialEffectEtched = 3 ' &H00000003&
103+
fmSpecialEffectBump = 6 ' &H00000006&
104+
End Enum
105+
106+
Private Enum fmStyle
107+
fmStyleDropDownCombo = 0 ' &H00000000&
108+
fmStyleDropDownList = 2 ' &H00000002&
109+
End Enum
110+
111+
'---------------------------------------------------------------------
112+
' Public Forms Processing (called by Menu entries)
113+
'---------------------------------------------------------------------
36114

37115
Public Sub ExportUserForm(activeVBProject As VBProject)
38116
Dim ctl As Object
@@ -439,6 +517,10 @@ Module FormProcessing
439517
End If
440518
End Function
441519

520+
'---------------------------------------------------------------------
521+
' Private Support Procedures
522+
'---------------------------------------------------------------------
523+
442524
'sort controls in order of descendancy - must process parent controls before their descendants!
443525
Private Function SortControls(frm As Object, ByVal dialogName As String) As Collection
444526
Dim sorted As New Collection
@@ -594,7 +676,12 @@ Module FormProcessing
594676
tbControl.Item("AutoSize") = ctl.AutoSize
595677

596678
If ctl.BackStyle = fmBackStyleTransparent Then tbControl.Item("BackStyle") = "vbBFTransparent"
597-
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
679+
680+
If ctl.SpecialEffect = fmSpecialEffectFlat Then
681+
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
682+
Else
683+
tbControl.Item("BorderStyle") = "vbFixedSingleBorder"
684+
End If
598685

599686
'tbControl.Item("HelpContextID") = ctl.HelpContextID
600687
tbControl.Item("ToolTipText") = ctl.ControlTipText
@@ -717,7 +804,11 @@ Module FormProcessing
717804
tbControl.Item("Alignment") = "vbRightJustify"
718805
End Select
719806

720-
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
807+
If ctl.SpecialEffect = fmSpecialEffectFlat Then
808+
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
809+
Else
810+
tbControl.Item("BorderStyle") = "vbFixedSingleBorder"
811+
End If
721812

722813
tbControl.Item("VisualStyles") = useVisualStyles
723814
If use3DAppearance Then tbControl.Item("Appearance") = vbAppear3d Else tbControl.Item("Appearance") = vbAppearFlat
@@ -753,9 +844,19 @@ Module FormProcessing
753844
If useVBAFont Then SetFontProperties tbControl, ctl
754845
tbControl.Item("BackColor") = ctl.BackColor
755846
tbControl.Item("ForeColor") = ctl.ForeColor
756-
If ctl.Caption = "" Then
847+
848+
'If ctl.Caption = "" Then
849+
' tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
850+
'End If
851+
852+
If ctl.SpecialEffect = fmSpecialEffectFlat Then
757853
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
854+
Else
855+
tbControl.Item("BorderStyle") = "vbFixedSingleBorder"
758856
End If
857+
858+
859+
759860
tbControl.Item("Caption") = ctl.Caption
760861
tbControl.Item("VisualStyles") = useVisualStyles
761862
If use3DAppearance Then tbControl.Item("Appearance") = vbAppear3d Else tbControl.Item("Appearance") = vbAppearFlat
@@ -850,7 +951,11 @@ Module FormProcessing
850951
tbControl.Item("TabIndex") = ctl.TabIndex
851952
tbControl.Item("TabStop") = ctl.TabStop
852953

853-
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
954+
If ctl.SpecialEffect = fmSpecialEffectFlat Then
955+
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
956+
Else
957+
tbControl.Item("BorderStyle") = "vbFixedSingleBorder"
958+
End If
854959

855960
'tb is vbComboDropdown,vbComboSimple,vbComboDropdownList
856961
Select Case ctl.Style
@@ -916,7 +1021,11 @@ Module FormProcessing
9161021
tbControl.Item("Style") = "vbListBoxCheckBox"
9171022
End Select
9181023

919-
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
1024+
If ctl.SpecialEffect = fmSpecialEffectFlat Then
1025+
tbControl.Item("BorderStyle") = IIf(ctl.BorderStyle = fmBorderStyleNone, "vbNoBorder", "vbFixedSingleBorder")
1026+
Else
1027+
tbControl.Item("BorderStyle") = "vbFixedSingleBorder"
1028+
End If
9201029

9211030
tbControl.Item("IntegralHeight") = ctl.IntegralHeight
9221031
tbControl.Item("Columns") = ctl.ColumnCount - 1 '?

src/Sources/ImageProcessing.twin

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
' ==========================================================================
2-
' tBUserFormConverter v2.5
2+
' tBUserFormConverter v2.6
33
'
44
' A VBIDE add-in (complied with twinBASIC) that converts VBA UserForms for use in twinBASIC.
55
'

src/Sources/MyModule.twin

-9
This file was deleted.

src/tbUserFormConverter.twinproj

672 Bytes
Binary file not shown.

test/dlgAllMSControls.frm

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Attribute VB_GlobalNameSpace = False
1313
Attribute VB_Creatable = False
1414
Attribute VB_PredeclaredId = True
1515
Attribute VB_Exposed = False
16+
1617
Private Sub CheckBox1_Click()
1718
If CheckBox1.Value Then
1819
TextBox1.Enabled = True

test/dlgAllMSControls.frx

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)