fafalone / windevlib Goto Github PK
View Code? Open in Web Editor NEWWindows Development Library for twinBASIC
License: Creative Commons Zero v1.0 Universal
Windows Development Library for twinBASIC
License: Creative Commons Zero v1.0 Universal
Hi,
I am very new to tB and cannot find Package Manger
in the tB IDE.
Can you please guide me through the process?
Or better still can you please prepare a shot document showing how to install and add ShellLib to a project in tB.
Regards,
I've confirmed that the 32- and 64-bit versions have different call signatures by using both in tB (and of course they are not interchangeable). The 32-bit version requires a Long array of dimension 2 (Colors(0) and Colors(1)).
#If Win64 Then
Private Declare PtrSafe Function GdipGetLineColors Lib "gdiplus" (ByVal brush As LongPtr, color1 As Long, color2 As Long) As GpStatus
#Else
Private Declare Function GdipGetLineColors Lib "gdiPlus" (ByVal brush As Long, Colors As Any) As GpStatus
#End If
Thx!
The OnCurrentDesktop
parameter should be ByRef, not ByVal.
Missing Alias "LoadLibraryW"
Will be fixed in update later tonight or tomorrow.
Is this restriction necessary? For example, if I want to return an ITypeInfo from a function in a dll I call from VBA, will I be able to with this flag?
This was due to the SHOWWINDOW enum being moved; they're only not ambiguous when in the same module. I was in the middle of 10 things so an update is taking a while. For a temp workaround, fully qualify it with tbShellLib.slAPI.ShowWindow.
The GetImage function takes a ByVal SIZE; in x64 this is done with 2x ByVal Long, but on x64 must be a single ByVal LongLong (CopyMemory to read it in/out).
The following updated definition will appear in future versions but the code in this repo is not yet updated:
[ InterfaceId ("bcc18b79-ba16-442f-80c4-8a59c30c463b") ]
Interface IShellItemImageFactory Extends stdole.iunknown
#If Win64 Then
Sub GetImage(ByVal cxy As LongLong, ByVal flags As SIIGBF, phbm As LongPtr)
#Else
Sub GetImage(ByVal cx As Long, ByVal cy As Long, ByVal flags As SIIGBF, phbm As LongPtr)
#End If
End Interface
Up until twinBASIC Beta 132, there was no option to not have an interface inherit from something, so the definition in the current version will not work.
If you have Beta 132, the following definition will fix it and will be applied in the next version:
[ InterfaceId ("00000000-0000-0000-C000-000000000046") ]
Interface IUnknownUnrestricted Extends Nothing
Sub QueryInterface(riid As UUID, ppvObject As any)
Sub AddRef()
Sub Release()
End Interface
dwStackSize
should be LongPtr
to match original SIZE_T
. This does not impact x64 function calls if it's 0.
Return should be LongPtr
to match original HANDLE
.
A zero got truncated (should be &H00080000
) but this is extremely rarely used so a fix will wait for the next update.
Jon, just now starting to use your WinDevLib for vb6-to-tB project conversion. This helps a lot but still a very tedious process!
Anyway, I'm currently using WinDevLib 7.7.370.0 and ran across possible mis-declarations for two GDI-Plus functions.
These are the current declarations your wdGDPI.twin module:
Public Declare PtrSafe Function GdipFillClosedCurve2 Lib "gdiplus" (ByVal Graphics As LongPtr, ByVal brush As LongPtr, Points As POINTF, ByVal count As Long, ByVal fillMode As GpFillMode) As GpStatus
Public Declare PtrSafe Function GdipFillClosedCurve2I Lib "gdiplus" (ByVal Graphics As LongPtr, ByVal brush As LongPtr, Points As POINT, ByVal count As Long, ByVal fillMode As GpFillMode) As GpStatus
which I believe might be missing the "tension" argument:
Public Declare PtrSafe Function GdipFillClosedCurve2 Lib "gdiplus" (ByVal Graphics As LongPtr, ByVal brush As LongPtr, Points As POINTF, ByVal count As Long, ByVal tension As Single, ByVal fillMode As GpFillMode) As GpStatus
Public Declare PtrSafe Function GdipFillClosedCurve2I Lib "gdiplus" (ByVal Graphics As LongPtr, ByVal brush As LongPtr, Points As POINT, ByVal count As Long, ByVal tension As Single, ByVal fillMode As GpFillMode) As GpStatus
Can you take a look? Thx!
Edit: I'm on Windows 11 if that matters
The first argument "Graphics" should be LongPtr type instead of Long I think. Here is what is currently in WDL:
Public Declare PtrSafe Function GdipDrawImagePointsRect Lib "gdiplus" (ByVal Graphics As Long, ByVal Image As LongPtr, points As POINTF, ByVal count As Long, ByVal srcx As Single, ByVal srcy As Single, ByVal srcwidth As Single, ByVal srcheight As Single, ByVal srcUnit As GpUnit, Optional ByVal imageAttributes As LongPtr = 0, Optional ByVal callback As LongPtr = 0, Optional callbackData As Any) As GpStatus
Public Declare PtrSafe Function GdipDrawImagePointsRectI Lib "gdiplus" (ByVal Graphics As Long, ByVal Image As LongPtr, dstpoints As POINT, ByVal count As Long, ByVal srcx As Long, ByVal srcy As Long, ByVal srcwidth As Long, ByVal srcheight As Long, ByVal srcUnit As GpUnit, Optional ByVal imageAttributes As LongPtr = 0, Optional ByVal callback As LongPtr = 0, Optional callbackData As Any) As GpStatus
This should return LongPtr I believe (it is PVOID)
Also I wonder how you would feel about 2 (or 3) improvements to make this more idiomatic:
In my code, I have declared this as
Sub GetDocumentation(ByVal memid As MEMID, Optional ByRef pBstrName As String, Optional ByRef pBstrDocString As String = vbNullString, Optional ByRef pdwHelpContext As Long, Optional ByRef pBstrHelpFile As String)
with 2 changes: The Optional arguments, since these are optional from the API point of view. You can specify default of =vbNullString
and =NULL_PTR
or =0
if needed
Second change is I do
Public Enum MEMID
[_]
End Enum
This does a sort of typedef for DWORD types which improves readability IMO
3rd change is I rename parameters to for example
Sub GetDocumentation(ByVal memid As MEMID, Optional ByRef outName As String, ...)
Since ByRef pBstrName
to me is
ByRef
and p
both mean kinda the same thing, doubling up makes me expect to get a pointer to a string out, not just a stringoutParam
prefix is good from a VBA consumer point of view to make it clear. Attributes may be better in future tB.I think this may be a harder sell as it is backwards incompatible for your library interface. However in my experience when I declare the APIs this way it makes me much less likely to need to look at the MSDN documentation. But it's still easy to look up online even if I've renamed the params, the function name is the same and the order of params is the same. Maybe for version 3.x of your package.
Missing an alias, should be
Public Declare PtrSafe Function SysReAllocStringW Lib "oleaut32" Alias "SysReAllocString" (ByVal pBSTR As LongPtr, Optional ByVal pszStrPtr As LongPtr) As Long
These currently have an incorrect 3rd parameter and should instead be:
Public Declare PtrSafe Function SHGetPathFromIDList Lib "shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As LongPtr, ByVal pszPath As String) As Long
Public Declare PtrSafe Function SHGetPathFromIDListW Lib "shell32" (ByVal pidl As LongPtr, ByVal pszPath As LongPtr) As Long
I just updated the package so it might be a few days until this is fixed... the OPENFILENAME, OPENFILENAMEA,
and OPENFILENAMEW
UDTs all have 2 members that should be a String/LongPtr
but are set as Long
.
The following definitions are correct:
Public Type OPENFILENAMEA
lStructSize As Long
hwndOwner As LongPtr
hInstance As LongPtr
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As OFNFlags
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As LongPtr
lpfnHook As LongPtr
lpTemplateName As String
pvReserved As LongPtr
dwReserved As Long
FlagsEx As OFNFlagsEx
End Type
Public Type OPENFILENAMEW
lStructSize As Long
hwndOwner As LongPtr
hInstance As LongPtr
lpstrFilter As LongPtr
lpstrCustomFilter As LongPtr
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As LongPtr
nMaxFile As Long
lpstrFileTitle As LongPtr
nMaxFileTitle As Long
lpstrInitialDir As LongPtr
lpstrTitle As LongPtr
Flags As OFNFlags
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As LongPtr
lCustData As LongPtr
lpfnHook As LongPtr
lpTemplateName As LongPtr
pvReserved As LongPtr
dwReserved As Long
FlagsEx As OFNFlagsEx
End Type
Public Type OPENFILENAME
lStructSize As Long
hwndOwner As LongPtr
hInstance As LongPtr
lpstrFilter As LongPtr
lpstrCustomFilter As LongPtr
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As LongPtr
nMaxFile As Long
lpstrFileTitle As LongPtr
nMaxFileTitle As Long
lpstrInitialDir As LongPtr
lpstrTitle As LongPtr
Flags As OFNFlags
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As LongPtr
lCustData As LongPtr
lpfnHook As LongPtr
lpTemplateName As LongPtr
pvReserved As LongPtr
dwReserved As Long
FlagsEx As OFNFlagsEx
End Type
This bug carried over from oleexp; the 2nd argument should be ByVal, not ByRef. You can use CreateTypeLib2 as a workaround until the next update if this impacts you.
Public Const MAX_COLUMN_NAME_LEN = 80
Public Type CM_COLUMNINFO
cbSize As Long ' size in bytes of struct
dwMask As CM_MASK ' CM_MASK
dwState As CM_STATE ' CM_STATE
uWidth As Long ' CM_MASK_WIDTH, for SetColumnInfo it can be a CM_SET_WIDTH_VALUE
uDefaultWidth As Long ' CM_MASK_DEFAULTWIDTH
uIdealWidth As Long ' CM_MASK_IDEALWIDTH
wszName(0 To (MAX_COLUMN_NAME_LEN - 1)) As Byte
End Type
should be
Public Const MAX_COLUMN_NAME_LEN = 80
Public Type CM_COLUMNINFO
cbSize As Long ' size in bytes of struct
dwMask As CM_MASK ' CM_MASK
dwState As CM_STATE ' CM_STATE
uWidth As CM_SET_WIDTH_VALUE ' CM_MASK_WIDTH, for SetColumnInfo it can be a CM_SET_WIDTH_VALUE
uDefaultWidth As Long ' CM_MASK_DEFAULTWIDTH
uIdealWidth As Long ' CM_MASK_IDEALWIDTH
wszName(0 To (MAX_COLUMN_NAME_LEN - 1)) As Integer
End Type
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.