EX_DDT_Splitbutton_01 - 64bit/fail - undefined reference to `GetDpiForSystem@0'

Started by hajubu, August 10, 2025, 05:51:14 PM

Previous topic - Next topic

hajubu

hi, just a little hick-up : testing just various 32/64er compilings of the samples.
Found : 32bit runs fine , 64bit fails when trying to add an icon to the title bar
( Loadfromfile and also Copyfromresource ):
location : DIM cx AS LONG = 16 * GetDpiForSystem \ 96
GetDpiForSystem is not resolved   as it is missing.

Solution ( temporarily for test) :
' // Patch (1) use :: #include "my_getDpiFunc.inc"
' // in EX_DDT_SplitButton_0x.bas just below 'USING AfxNova"
' // purpose ::
' // patch for missing 32bit - unreferenced GetDpiForSystem

' // found private function AfxGetDpiForSystem()
' //  in AFX2/AfxCtlProc2.inc
' //  made a copy as 'PRIVATE FUNCTION GetDpiForSystem () AS UINT!'
' //  and used below in 'FUNCTION wWinMain'
' //  after :line: DIM hSplitButton AS HWND = ControlAdd("BUTTON".....
' //  as Patch (2) #include "my_new_getDpi.inc" to replace the "One-Liner"
'//
' // Patch (2) use :: #include "my_new_getDpi.inc"
' // for the "One-Liner" ::
   ' // Calculate an appropriate icon size
   ' // to be replaced :: --> :: DIM cx AS LONG = 16 * GetDpiForSystem \ 96
   ' // next lines replaces the one-liner

PATCH(1)
#ifdef __fb_64BIT__
    dim _test_cx as LONG = (16 * GetDpiForSystem \ 96)
    dim as string  msgcx,msgti
    msgcx = !"64BIT and Not 32Bit@"+str(GetDpiForSystem)+!"_DPI \n  cx = 16 * GetDpiForSystem  / 96 ="+str(_test_cx)
    msgti = !"Message@32bit AfxNova adapted"
    MsgBox msgcx, 64, msgti
#else
  PRIVATE FUNCTION GetDpiForSystem () AS UINT
     DIM pLib AS ANY PTR = DyLibLoad("user32.dll")
     IF pLib = NULL THEN RETURN 0
     DIM pGetDpiForSystem AS FUNCTION () AS UINT
     pGetDpiForSystem = DyLibSymbol(pLib, "GetDpiForSystem")
     IF pGetDpiForSystem THEN FUNCTION = pGetDpiForSystem()
     DyLibFree(pLib)
 END FUNCTION
 
     DIM _test_cx AS LONG = 16 * GetDpiForSystem() \ 96
     dim as string  msgcx,msgti
     msgcx = !"32BIT and/or  64Bit@"+str(GetDpiForSystem())+!"_DPI \n  cx = 16 * GetDpiForSystem() / 96 ="+str(_test_cx)[code]
     msgti = !"Message@32bit AfxNova adapted"
     MsgBox  msgcx, 48, msgti
#endif
[/code]

PATCH(2) - replaces the "ONE-Liner"
   #ifdef __fb_64bit__
        DIM cx AS LONG = 16 * GetDpiForSystem \ 96
        dim as string  msgcx,msgti
        msgcx = !"64BIT and Not 32Bit@"+str(GetDpiForSystem)+!"_DPI \n  cx = 16 * GetDpiForSystem  / 96 ="+str(cx)
        msgti = !"Message@32bit AfxNova adapted"
        MsgBox hDlg, msgcx, 64, msgti
   #else
        DIM cx AS LONG = 16 * GetDpiForSystem() \ 96
        dim as string  msgcx,msgti
        msgcx = !"32BIT and/or  64Bit@"+str(GetDpiForSystem())+!"_DPI \n  cx = 16 * GetDpiForSystem() / 96 ="+str(cx)
        msgti = !"Message@32bit AfxNova adapted"
        MsgBox hDlg,  msgcx, 48, msgti
   #endif

As I believe there is a liitle more to do , as just my small patch solution.
P.S: the AfxCtlProc2.inc does not fit in the AfxNova without changes.
b.r. Hajubu

José Roca

P.S: the AfxCtlProc2.inc does not fit in the AfxNova without changes.

Please don't mix old include files with the right ones. The only valid files are in https://github.com/JoseRoca/AfxNova

The import libraries for user32.dll that come with the compiler are broken. They haven't been updated in 10 years.

I'm attaching the correct ones for both 32 and 64 bit.


Overwrite with them the ones in

Tiko/toolchains/FreeBASIC-1.10.1-winlibs-gcc-9.3.0/Lib/Win32
Tiko/toolchains/FreeBASIC-1.10.1-winlibs-gcc-9.3.0/Lib/Win64

P.S. Paul, I suggest that you include these new import libraries in your Tiko distribution.

José Roca

With updated import libraries and appropriate casting (forget DWORD, this is not 32-bit PowerBasic), the code will always be the same with 32 and 64 bit.

I already reported an issue in the FreeBasic GitHub repository: https://github.com/freebasic/fbc/issues/446

But I'm afraid that the only solution will be that Paul and I modify the broken or outdated libraries and distribute them with Tiko.

So far, I'm adding declarations missing in the FreeBasic headers in the file AfxExt.inc. Will make it easier to remove them if one day they update the headers and the import libraries.


hajubu

Hi Jose, Thank's for the fast solution.
 ( the odd library error did not came up til now . )
b.r. Hajubu

Paul Squires

Quote from: José Roca on August 10, 2025, 10:09:08 PMBut I'm afraid that the only solution will be that Paul and I modify the broken or outdated libraries and distribute them with Tiko.
You might need to remind me again in a couple of weeks. I'm currently on a train somewhere across the border of France and Germany. First time in Europe.
Paul Squires
PlanetSquires Software

José Roca