Jump to content

Error on exist with Metro UDF


gahhon
 Share

Recommended Posts

The original UDF is Metro UDF v5.1

Recently, I have added new function to handle similar like SplashTextOn

Func _Metro_SplashTextScreen($Flag, $Title = "", $Text = "", $mWidth = 600, $Fontsize = 11, $ParentGUI = "")
    Local $msgbDPI = _HighDPICheck()
    Local $SplashScreen_Form
    $iMsg = $Text

    If $Flag = 1 Then
        If $HIGHDPI_SUPPORT Then
            $mWidth = Round($mWidth * $gDPI)
        Else
            $Fontsize = ($Fontsize / $Font_DPI_Ratio)
        EndIf

        Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI))
        Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI)
        $SplashScreen_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI)

        GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000)
        GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30))
        GUICtrlSetColor(-1, $FontThemeColor)
        _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5)
        $iLableID = GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, "", $LabelSize[3], -1, 0x00100000)
        GUICtrlSetBkColor(-1, $GUIThemeColor)
        GUICtrlSetColor(-1, $FontThemeColor)
        GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5)

        GUISetState(@SW_SHOW)
        Return SetError(1, 0, "")
    ElseIf $Flag = 0 Then
        _Metro_GUIDelete($SplashScreen_Form)
        Return SetError(1, 0, "")
    Else
        Return SetError(0, "", "Error: Invalid flag value")
    EndIf
EndFunc   ;==>_Metro_SplashTextScreen

Then I call it from my main application I got error display when exited. It didn't got any impact to the result, but just wondering why it show this error.
This error only appear when my main application trigger this function, but not from my test application to trigger this function.

Test application at here: Test Application

image.thumb.png.ae8de3003f6f13d9ac531f682465394b.png

This is the function code where trigger the error.

image.png.2672663abb432f5243b77cc70fe75e05.png

Func _iMExit()
    For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1
        _Metro_GUIDelete($iGUI_LIST[$i_HR][0])
    Next
    DllCallbackFree($m_hDll)
    _GDIPlus_Shutdown()
EndFunc   ;==>_iMExit

.......

Func _Metro_GUIDelete($GUI)
    GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted
    _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010)
    GUIDelete($GUI)

    ;Remove from Global GUI List
    Local $CLEANED_GUI_LIST[0]
    For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1
        If $iGUI_LIST[$i_HR][0] <> $GUI Then
            ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16]
            For $i_Hx = 0 To 11 Step +1
                $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx]
            Next
        EndIf
    Next
    $iGUI_LIST = $CLEANED_GUI_LIST

;~  _ReduceMemory()
EndFunc   ;==>_Metro_GUIDelete

Any idea what is going on?

Because before this, I also got create another input function just for password purpose. (Duplicate & similar to _Metro_InputBox)
But it didn't got any error display on console when exited.

Edited by gahhon
Link to comment
Share on other sites

Probably the problem is in the first code that you posted. You're declaring the LOCAL var "$SplashScreen_Form", so you enter in a if-condition, if the flag is "1" you create the GUI, elseif you're deleting it!?! why? you didin't created anything, why are you deleting? You maybe thought use this function more than once, but when you declare a local variable you lose the id value of the _Metro_CreateGUI, you should store it in a global var.

Edited by x_bennY
Link to comment
Share on other sites

5 minutes ago, x_bennY said:

Probably the problem is in the first code that you posted. You're declaring the LOCAL var "$SplashScreen_Form", so you enter in a if-condition, if the flag is "1" you create the GUI, elseif you're deleting it!?! why? you didin't created anything, why are you deleting?

You got the point. I should declare the $SplashScreen_Form as GLOBAL instead.
Now the issue is fixed. Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...