Glen,
AppendMenu is a windows API function in the VOWin32ApiLibrary.
This function expects a PSZ as last parameter.
You are (Willie is) passing in an array element.
To "satisfy" the compiler this Array element needs to be converted from a USUAL (array elements are untyped) to a PSZ. Of course that will only work when the array contains strings.
The compiler does not know what AppendMenu is doing with the PSZ. It could be making a copy of it, but it could also store the address of the PSZ and hold on to it. For that reason it cannot compile this into a call of String2Psz() since the PSZs allocated by that function will be automatically freed when the calling function ends.
For that reason the compiler creates an instance of the PSZ type and simply does not free that type.
Something like:
Code: Select all
AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), PSZ{ (STRING) SELF:aMonthsbyName})
The PSZ type allocates a block of static memory and converts the string from Unicode to Ansi and stores this Ansi string in the static memory.
If you know that AppendMenu does not hold on to the PSZ but makes a copy (which it does) then you should change the code to:
Code: Select all
AppendMenu( hMenu, MF_STRING, ID_MONTH1 + (DWORD)(i-1), String2Psz(SELF:aMonthsbyName))
Robert