Support Forums > WinFBX - Windows Framework for FreeBASIC

CWindow v. 1.0 for Free Basic

(1/1)

Josť Roca:
The class is finished. I have added support for accelerators and MDI, and have removed any dependency other than the standard Windows API headers. Support for RichEdit controls will be done in a separate class.

Works both with 32 & 64-bit, and supports Unicode and High DPI. I have tried to make it as lightweight as possible since Free Basic has not dead code removal.

Paul Squires:
Awesome!  I will use your CWindow class when I redesign Firefly's code generator. Firefly for PB already uses your class but now I can also have it in FB. Sweet! :)

Josť Roca:
I haven't used any of the extra bytes, just one property to store the class pointer. Therefore, the class should be easy to extend (haven't yet tried this feature).

There is not purpose to have both ansi and unicode versions, because the unicode version will work even if you send ansi messages (Windows detects it and does the conversion), whereas the ansi version does not work with unicode.

I checked this with Bob some time ago, and there was no way to display Russian or Greek characters, for example, in a control created with the "A" functions. This is why DDT is now Unicode aware.

I have explicitily used the W in the names of the API functions in case somebody does not #define unicode. Does work perfectly except for a warning with the LoadCursorW function. If I cast it to LPCWSTR, the warning disappears if I use FB 64-bit, but persists if I use FB 32-bit. It is like if the 32-bit compiler does a check with the "A" version of the function despite using explicitily the "W" one. Strange.

Josť Roca:
WARNING: I have reuploaded the file. When adding support for MDI, I inadvertently wrapped the pWindow variable between the #ifdef USEMDI/#endif.

So, instead of


--- Code: ---#ifdef USEMDI
   ' // Note: I have needed to use HANDLE instead of HWND; otherwise, the compiler
   ' // gives error 14: Branch crossing local variable definition. Don't know why?
   STATIC pWindow AS CWindow PTR
   STATIC hwndClient AS HANDLE    ' // Handle of the MDI client window
   DIM    hwndActive AS HANDLE    ' // Active window
   DIM    hMdi AS HANDLE          ' // MDI child window handle
   ' // MDI client window handle
   IF hwndClient = NULL AND pWindow <> NULL THEN hwndClient = pWindow->hwndClient
#endif

--- End code ---

it must be:


--- Code: ---   STATIC pWindow AS CWindow PTR
#ifdef USEMDI
   ' // Note: I have needed to use HANDLE instead of HWND; otherwise, the compiler
   ' // gives error 14: Branch crossing local variable definition. Don't know why.
   STATIC hwndClient AS HANDLE    ' // Handle of the MDI client window
   DIM    hwndActive AS HANDLE    ' // Active window
   DIM    hMdi AS HANDLE          ' // MDI child window handle
   ' // MDI client window handle
   IF hwndClient = NULL AND pWindow <> NULL THEN hwndClient = pWindow->hwndClient
#endif

--- End code ---

Sorry for the inconvenience.

Navigation

[0] Message Index

Go to full version