I would like to publicly apologize to Dominic Mitchell for my recent negative comments.
I have a slightly different point of view about this project.
Even though the discussion on ActiveX controls is important, it is, in my opinion, a relatively
minor issue that can be tackled at a later date. It is minor, because ActiveX controls(the non-
intrinsic ones) are used as is. All you need is an OLE container and a good type library includes
generator.
I would first do the following if I were doing this project:
1) Install VisualBasic.
Bookmark the MSDN documentation for VisualBasic.
Nothing beats being able to see and test the properties of the controls you are trying to convert.
Just by looking at the VB objects, an experienced SDK programmer can deduce the SDK equivalents.
and quirks if any.
2) This is optioal. Get a proper type library browser.
The one that ships with PowerBASIC is useless in regards to the hierarchical organization of
objects, documentation, and references to external type libaries.
You have three options:
a) OleView by Microsoft
b) José's Type Library browser.
c) The standalone Type Library browser in Phoenix.
For example, if you were to generate BASIC include files for the TextBox object in VisualBasic
using the Phoenix standalone type library browser, you would get the following five files:
Events.bas - TextBox events
VB.inc - Visual Basic objects and procedures
VBRUN.inc - Visual Basic runtime objects and procedures
stdole.inc - OLE Automation
StdFormat.inc - Data Formatting Object Library
You would not know about the last three external references if you used the PowerBASIC browser.
If you have not done so yet, you should map the intrinsic controls in VisualBasic and the controls
in COMCTL32.OCX to their SDK equivalents. You want to map from VisualBasic to SDK to avoid limitations
imposed by proprietary systems such as DDT. You can then map from SDK to any proprietary or open system.
It is also much easier to discern whether to use the usually more restrictive but slightly more intuitive
form of a control creation statement over the generic form. For example, by looking at the SDK equivalent
properties for the VisualBasic TextBox object, it is easy to tell whether the control can be created using
the more intuitive statement
Code:
[b][color=fuchsia]CONTROL[/color][/b][color=fuchsia][/color] [b][color=fuchsia]ADD[/color][/b][color=fuchsia][/color] [b][color=fuchsia]TEXTBOX[/color][/b][color=fuchsia][/color]
Code:
[b][color=fuchsia]CONTROL[/color][/b][color=fuchsia][/color] [b][color=fuchsia]ADD[/color][/b][color=fuchsia][/color] [color=red]"[/color][color=red]Edit"[/color]
parameters of the CreateWindowEx function that the corresponding properties of the TextBox object map to.
Note: Dialog-based systems such as DDT do not support the Multiple Document Interface(MDI).
Note: In the table below, an embedded control is a child control that is created as the child of another
child control in order to make code that enhances the embedded control modular/reuseable.
Table 1. VisualBasic Object to SDK Equivalents
Code:
+---------------+-----------------+------------------------+--------------------+-----------------------------------------------------------+ | | | | | Default Window Styles | | Object | Window Type | API Function | Class Name |----------------------------------------+------------------| | | | | | Window | Extended | |===============|=================|========================|====================|========================================|==================| | Form | Top-level | | user-defined | WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_EX_WINDOWEDGE | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | App | | API functions | | | | | | | GetModuleFileName | | | | | | | Version resource | | | | | | | GetFileVersionInfo | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Screen | | API functions | | | | | | | GetWindowRect | | | | | | | GetDeviceCaps | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Clipboard | | API functions | | | | | | | OpenClipboard | | | | | | | SetClipboardData | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | PictureBox | Generic child | API functions | user-defined | WS_CHILD | WS_VISIBLE | | | | | GDI/GDI+ graphics | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Printer | | API functions | | | | | | | PrintDlgEx | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Label | Control | | Static | WS_CHILD | WS_GROUP | WS_VISIBLE | | | | | | | | SS_LEFT | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | TextBox | Control | | Edit | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | | | | | | ES_LEFT | ES_AUTOHSCROLL | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Frame | Control | | Button | WS_CHILD | WS_CKIPSIBLINGS | | | | | | | | WS_GROUP | WS_VISIBLE | | | | | | | | BS_GROUPBOX | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | CommandButton | Control | | Button | WS_CHILD | WS_TABSTOP | | | | | | | | BS_PUSHBUTTON | BS_CENTER | BS_VCENTER | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | CheckBox | Control | | Button | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | | | | | | | BS_AUTOCHECKBOX | BS_LEFT | BS_VCENTER | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | OptionButton | Control | | Button | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | | | | | | | BS_AUTORADIOBUTTON | BS_LEFT | | | | | | | | BS_VCENTER | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | ComboBox | Control | | Combobox | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | | | | | | WS_BORDER | WS_VSCROLL | | | | | | | | CS_DROPDOWN | CBS_HASSTRINGS | | | | | | | | CBS_SORT | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | ListBox | Control | | Listbox | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | | | | | | WS_BORDER | WS_VSCROLL | | | | | | | | LBS_HASSTRINGS | LBS_NOTIFY | LBS_SORT | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | HScrollBar | Control | | Scrollbar | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | | | | | | | SBS_HORZ | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | VScrollBar | Control | | Scrollbar | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | | | | | | | SBS_VERT | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Timer | | SetTimer | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | DriveListBox | Control | API functions | Combobox | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | | | | GetLogicalDriveStrings | (embedded)* | WS_BORDER | | | | | SHGetFileInfo | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|----------------- | | DirListBox | Control | API functions | Listbox | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | | | | FindFirstFile | (embedded)+ | WS_BORDER | WS_VSCROLL | | | | | SHGetFileInfo | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | FileListBox | Control | API functions | Listbox | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | | | | FindFirstFile | (embedded)* | WS_BORDER | WS_VSCROLL | | | | | SHGetFileInfo | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Menu | | Menu resource | | | | | | | LoadMenu | | | | | | | CreateMenu etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | MDIForm | Top-level | | user-defined | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_EX_WINDOWEDGE | | | | | | WS_VISIBLE | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Shape | | GDI graphics | | | | | | | Rectangle | | | | | | | Ellipse etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Line | | GDI graphics | | | | | | | LineTo etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Image | Control | | Static | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Data | | ADO RecordSet | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | OLE | OLE container | | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | UserControl | ActiveX control | Low-level COM | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | PropertyPage | Dialogs and | Property Sheet | #32770(dialog) | | | | | child controls | functions and | etc. | | | | | } messages | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | UserDocument | Insertable | Low-level COM | | | | | | object | | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Global | | API functions | | | | | | | EnumThreadWindows | | | | | | | EnumPrinters | | | | | | | LoadImage | | | | | | | LoadResource | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | CommonDialog | | GetOpenFileName | | | | | | | GetSaveFileName | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | RichTextBox | Control | | RichEdit50W | WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_EX_CLIENTEDGE | | | | | RichEdit20A | ES_AUTOHSCROLL | ES_LEFT | | | | | | | RichEdit | ES_MULTILINE | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | TabStrip | Control | | SysTabControl32 | WS_CHILD | WS_TABSTOP | WS_GROUP | | | | | | | | WS_CLIPSIBLINGS | WS_VISIBLE | | | | | | | | TCS_RAGGEDRIGHT | TCS_SINGLELINE | | | | | | | | TCS_TABS | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Toolbar | Control | | ToolbarWindow32 | WS_CHILD | WS_VISIBLE | | | | | | | CCS_TOP | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Statusbar | Control | | msctls_statusbar32 | WS_CHILD | WS_VISIBLE | | | | | | | | CCS_BOTTOM | SBARS_SIZEGRIP | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | ProgressBar | Control | | msctls_progress32 | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | WS_EX_CLIENTEDGE | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | TreeView | Control | | SysTreeView32 | WS_CHILD | WS_BORDER | WS_TABSTOP | | WS_EX_CLIENTEDGE | | | | | | WS_VISIBLE | | | | | | | | TVS_HASBUTTONS | TVS_HASLINES | | | | | | | | TVS_LINESATROOT | TVS_SHOWSELALWAYS | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | ListView | Control | | SysListView32 | WS_CHILD | WS_CLIPCHILDREN | | WS_EX_CLIENTEDGE | | | | | | WS_TABSTOP | WS_VISIBLE | | | | | | | | LVS_ALIGNTOP | LVS_AUTOARRANGE | | | | | | | | LVS_EDITLABELS | LVS_ICON | | | | | | | | LVS_SHAREIMAGELISTS | | | | | | | | LVS_SHOWSELALWAYS | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | ImageList | Control | API functions | | | | | | | ImageList_Create | | | | | | | etc. | | | | |---------------|-----------------|------------------------|--------------------|----------------------------------------|------------------| | Slider | Control | | msctls_trackbar32 | WS_CHILD | WS_TABSTOP | WS_VISIBLE | | | | | | | | TBS_AUTOTICKS | TBS_BOTTOM | TBS_HORZ | | +---------------+-----------------+------------------------+--------------------+----------------------------------------+------------------+
The second step is to create a table that maps the properties of each object in table 1 to SDK equivalents.
The majority of the properties will map to the parameters of the CreateWindowEx function and messges specific
to the SDK window class.
Table 2. TextBox Properties Map to SDK Equivalents
Code:
+-----------------+-------------------+---------------------------------------------------------------------------+--------------------+---------------------------------+ | | | CreateWindowEx Parameter | | | | | |--------------+-------------------------+-------------------+--------------| | | | Property | Values | Control | Window | Extended Window | Other | Message(s) | Function | | | | (dwStyle) | (dwStyle) | (dwExStyle) | | | | |=================|===================|==============|=========================|===================|==============|====================|=================================| | Alignment | Left Justify | ES_LEFT | | | | | | | | Right Justify | ES_RIGHT | | | | | | | | Center | ES_CENTER | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Appearance | 3D | | | WS_EX_CLIENTEDGE | | | | | | Flat | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | BackColor | | | | | | WM_CTLCOLOREDIT | | | | | | | | | WM_CTLCOLORSTATIC | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | BorderStyle | None | | | | | | | | | Fixed Single | | WS_BORDER | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | DataField | ADO Recordset | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | DataSource | ADO Recordset | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | DragIcon | OLE drag and drop | | | | | | DoDragDrop | | DragMode | | | | | | | IDataObject | | | | | | | | | IDropTarget | | | | | | | | | IDropSource | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Enabled | True | | | | | WM_ENABLE | EnableWindow | | | False | | WS_DISABLED | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Font | | | | | | WM_SETFONT | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | ForeColor | | | | | | WM_CTLCOLOREDIT | | | | | | | | | WM_CTLCOLORSTATIC | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Height | | | | | nHeight | | SetWindowPos | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | HelpContextID | | | | | |WM_HELP | HtmlHelp | | | | | | | | | WinHelp | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | HideSelection | True | | | | | | | | | False | ES_NOHIDESEL | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | Index | | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | Left | | | | | x | | SetWindowPos | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | LinkItem | DDE | | | | | | | | LinkMode | DDE | | | | | | | | LinkTimeOut | DDE | | | | | | | | LinkTopic | DDE | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | Locked | | ES_READONLY | | | | EM_SETREADONLY | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | MaxLength | | | | | | EM_SETLIMITTEXT | | | | | | | | | EM_GETLIMITTEXT | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | MouseIcon | | | | | | | LoadCursor, SetClassLong | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | MousePointer | Default | | | | | WM_SETCUSROR | LoadCursor, SetClassLong | | | Arrow | | | | | | | | | etc. | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | Multiline | True | ES_MULTILINE | | | | | | | | False | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | Name | | | | | hMenu | | | | | | | | | (Control ID) | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | PasswordChar | | ES_PASSWORD | | | | EM_SETPASSWORDCHAR | | | | | | | | | EM_GETPASSWORDCHAR | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | ScrollBars | None | | | | | | | | | Horizontal | | WS_HSCROLL | | | | | | | Vertical | | WS_VSCROLL | | | | | | | Both | | WS_HSCROLL | WS_VSCROLL | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | TabIndex | | | | | | | Z-order(order controls created) | | | | | | | | | SetWindowPos(to change z-order) | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|------------------------------------------------------| | TabStop | True | | WS_TABSTOP | | | | | | | False | | | | | | | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Tag | | | | | | | SetProp, GetProp | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Text | | | | | lpWindowname | WM_SETTEXT | SetWindowText | | | | | | | | WM_GETTEXT | GetWindowText | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Top | | | | | y | | SetWindowPos | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Visible | | | WS_VISIBLE | | | | ShowWindow | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | WhatsThisHelpID | | | | WS_EX_CONTEXTHELP | | WM_HELP | HtmlHelp, WinHelp | |-----------------|-------------------|--------------|-------------------------|-------------------|--------------|--------------------|---------------------------------| | Width | | | | | nWidth | | SetWindowPos | +-----------------+-------------------+--------------+-------------------------+-------------------+--------------+--------------------+---------------------------------+
Comment