Any thing I should know about converting from fb 24 to fb 1.0 ?

General FreeBASIC programming questions.
Post Reply
lassar
Posts: 306
Joined: Jan 17, 2006 1:35

Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by lassar »

I am having problems trying to convert a program from fb 24 to fb 1.0

This program works perfectly in fb 24.

Do you have any tips on converting from fb 24 to fb 1.0

I am using the "FBLITE" dialect.

When my program is running, the mouse also tends to stay in the upper left had corner of the desktop.

Also clicking on the desktop start button, acts wacky. Menu flashes up and disappears.

I am using classic shell.

I did a debug version of this program, and took out every thing related to the mouse, and this annoying behavior stopped.
Last edited by lassar on Feb 12, 2016 23:59, edited 1 time in total.
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by fxm »

Have you tested your program by compiling under fbc 0.24 with option '-exx' (which adds some code for error checking at runtime) before running it, to see if there is not a hidden bug that would show only with fbc 1.05 (due to different data mapping in memory)?
lassar
Posts: 306
Joined: Jan 17, 2006 1:35

Re: Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by lassar »

Yes I have tested it with fbc 0.24 with option '-exx with "on error" checking.
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by fxm »

Could you extract of your big program (I suppose) a shorter code which demonstrates the problem?
lassar
Posts: 306
Joined: Jan 17, 2006 1:35

Re: Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by lassar »

The program is 4992 lines long.

I have tried shorter code. Been unable to reproduce problem in shorter code.

Problem only appears in windowed mode.

The mouse only acts wacky in windowed mode.

I am looking for tips and tricks for getting it to work in FBC 1.05
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by dkl »

Hmm, it's hard to say, there have been many changes since 0.24, just check the changelog.txt...

but here I've looked through what should be most relevant, assuming the program compiles fine with 1.05 and assuming we're talking about Windows:

- ubound() on empty array now returns -1 instead of 0 (lbound() is still 0)!
- Byval As String behaviour changed (it now does what it says, but can break existing code that relies on it behaving as Byref As Zstring)

- FB supports 64bit now, but it's better stick to 32bit for now in case of an older program that wasn't checked for 64bit porting issues yet
- calling overloaded functions behaviour was changed (it was improved, but could still break existing code)
- Redim with explicit type now prefers redim'ming existing local arrays instead of creating new ones, that could break existing code
- With/End With blocks now have a scope, in -lang fb at least
- LBound/UBound( array, 0 ) now returns 1 and the dimension count, it is no longer the same as LBound/UBound( array, 1 )
lassar
Posts: 306
Joined: Jan 17, 2006 1:35

Re: Any thing I should know about converting from fb 24 to fb 1.0 ?

Post by lassar »

Since the problem only occurs in windowed mode, here is the full mode & window mode code.

The code works perfectly in full screen mode.

Code: Select all


WindowTitle "RadioTelephone Tutor"

IF FullScreen% = 1 THEN
    SCREENRES 640,480,32,,&H01 OR AltEnter& OR GFX_HIGH_PRIORITY
    VideoPtr = SCREENPTR
    IF VideoPtr = 0 THEN
        FullScreen% = 0
        IF ResolutionOn& THEN ChangeBack& = ChangeScreenResolution&()
        IF HideTaskBarFlag& THEN HideTaskBar
        IF HideDeskTopFlag& THEN HideDeskTop
        SCREENRES 640,480,32,,&H00 OR AltEnter& OR GFX_HIGH_PRIORITY
    END IF
ELSE
    IF ResolutionOn& THEN ChangeBack& = ChangeScreenResolution&()
    PostMessage FindWindow("Shell_TrayWnd", BYVAL 0), WM_COMMAND, MAKELONG(415, 0), 0 'bring up windows desktop
    IF HideTaskBarFlag& THEN HideTaskBar
    IF HideDeskTopFlag& THEN HideDeskTop
    DIM rc AS RECT
    SystemParametersInfo SPI_GETWORKAREA, 0, BYVAL VARPTR(rc), 0
    CaptionHeight& = GetSystemMetrics(SM_CYSMCAPTION)
    BorderHeight& = GetSystemMetrics(SM_CYBORDER)
    XScreenWidth& = rc.Right - rc.Left
    YScreenHeight& = rc.Bottom - rc.Top
    WindowHeight& = 480 + CaptionHeight& + BorderHeight& * 2
    SCREENRES 640,480,32,,&H00 OR AltEnter& OR GFX_HIGH_PRIORITY
    IF XScreenWidth& > 640 AND YScreenHeight& > WindowHeight& THEN
        SCREENCONTROL SET_WINDOW_POS, rc.Left + (XScreenWidth& -640)\2, rc.Top + (YScreenHeight& - WindowHeight&)\2
    END IF
END IF



SUB HideTaskBar()
    DIM nhWnd AS HWND, ret AS LONG

    ' First, get the handle of the taskbar
    nhWnd = FindWindow("Shell_TrayWnd", "")

    ' Then hide the taskbar
    ret = ShowWindow(nhWnd, 0)   '%SW_HIDE = 0

END SUB

SUB ShowTaskBar()
    DIM nhWnd AS HWND, ret AS LONG

    ' First, get the handle of the taskbar
    nhWnd = FindWindow("Shell_TrayWnd", "")

    ' Then hide the taskbar
    ret = ShowWindow(nhWnd, 9)  '%SW_RESTORE = 9


END SUB

SUB HideDesktop()
    DIM hProgman AS HWND, hProgmanLv AS UINTEGER, szStr AS ZSTRING * 40

    hProgman      = FindWindow("ProgMan", BYVAL 0)
    hProgman      = GetWindow(hProgman, 5)  ' %GW_CHILD = 5
    hProgmanLv    = GetWindow(hProgman, 5)  ' %GW_CHILD = 5

    GetClassName hProgmanLv, szStr, 39
    InvalidateRect hProgmanLv, BYVAL 0, 1
    UpdateWindow hProgmanLv
    ShowWindow hProgmanLv, 0     '%SW_HIDE = 0
END SUB

SUB ShowDesktop()
    DIM hProgman AS HWND, hProgmanLv AS UINTEGER, szStr AS ZSTRING * 40

    hProgman      = FindWindow("ProgMan", BYVAL 0)
    hProgman      = GetWindow(hProgman, 5)  ' %GW_CHILD = 5
    hProgmanLv    = GetWindow(hProgman, 5)  ' %GW_CHILD = 5
    GetClassName hProgmanLv, szStr, 39
    ShowWindow hProgmanLv, 5                '%SW_SHOW = 5

    InvalidateRect hProgmanLv, BYVAL 0, 1
    UpdateWindow hProgmanLv
END SUB


FUNCTION ChangeScreenResolution&()
    '-------VERY IMPORTANT---------
    STATIC DevM AS DEVMODEW, DevMPtr AS ANY PTR
    DIM ModeNumber as UINTEGER
    DevMPtr = VARPTR(DevM)
    '------------------Change Adaptations----------------------
    ' Looks for current resolution
    DevM.dmSize = SIZEOF(DevM)
    ModeNumber = &HFFFFFFFF
    Result& = EnumDisplaySettings(BYVAL 0 , BYVAL ModeNumber, DevMPtr) '%ENUM_CURRENT_SETTINGS  = &HFFFFFFFF???

    DeskTopWidth% = DevM.dmPelsWidth
    DeskTopHeight% = DevM.dmPelsHeight
    DevM.dmBitsPerPel = 32

    DevM.dmFields = &H00080000 OR &H00100000&

    '%DM_PELSWIDTH        = &H00080000&
    '%DM_PELSHEIGHT       = &H00100000&

    IF DeskTopWidth% > 800 AND DeskTopHeight% > 600  THEN
        'Change res
        DevM.dmPelsWidth = 800
        DevM.dmPelsHeight = 600
        ChangeScreen% = ChangeDisplaySettings(DevMPtr, BYVAL &H00000002) ' %CDS_TEST = &H00000002

        '%DISP_CHANGE_FAILED      = -1
        '%DISP_CHANGE_BADMODE     = -2


        IF ChangeScreen% = -1 OR ChangeScreen% = -2 THEN
            IF DeskTopWidth% > 1024 AND DeskTopHeight% > 768  THEN
                DevM.dmPelsWidth = 1024
                DevM.dmPelsHeight = 768
                ChangeScreen% = ChangeDisplaySettings(DevMPtr, BYVAL &H00000002) ' %CDS_TEST = &H00000002
            END IF
        END IF

        IF ChangeScreen% = 0 THEN  ' %DISP_CHANGE_SUCCESSFUL = 0
            FUNCTION = ChangeDisplaySettings(DevMPtr, BYVAL &H00000004) '%CDS_FULLSCREEN = &H00000004
        END IF

    END IF
END FUNCTION

Post Reply