Announcement

Collapse
No announcement yet.

Recent Problem Appearing With old, working, programs.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Kerry,

    > What will happen to my PBCC programs that I sell?

    Nothing, just write them properly.
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

    Comment


    • #22
      You need to test your programs with both the 'Legacy console' and the new V2 console modes if they are to run in Windows 10.

      As Tim found. The new wiz 'LineWrap on console resize' feature introduced with V2, could be a real pain for your users.

      You might find that the console settings your app needs (or doesn't!) could be changed by the users preferences or by Microsoft's enforced 'Defaults' following an upgrade.

      One possible solutions could be to provide a 'myapp.lnk' shortcut file to launch your app. Console app shortcut files will override values values set in the user’s configured defaults.

      Another option (available since PBCC60) is to start the app without a console, set the appropriate registry keys and then create a new console with CON.NEW.
      The new console will take up Per-Console-application registry settings you have written rather than use those found in the Defaults (HKCU\Console).
      Rgds, Dave

      Comment


      • #23
        Originally posted by Dave Biggs View Post
        You need to test your programs with both the 'Legacy console' and the new V2 console modes if they are to run in Windows 10.

        As Tim found. The new wiz 'LineWrap on console resize' feature introduced with V2, could be a real pain for your users.

        You might find that the console settings your app needs (or doesn't!) could be changed by the users preferences or by Microsoft's enforced 'Defaults' following an upgrade.

        One possible solutions could be to provide a 'myapp.lnk' shortcut file to launch your app. Console app shortcut files will override values values set in the user’s configured defaults.

        Another option (available since PBCC60) is to start the app without a console, set the appropriate registry keys and then create a new console with CON.NEW.
        The new console will take up Per-Console-application registry settings you have written rather than use those found in the Defaults (HKCU\Console).
        Thanks, much more informative and useful that the preceding comment.

        Comment


        • #24
          For the curious, here's some test code that explores the second option proposed in post #22
          Code:
           '  Even with #CONSOLE OFF PBCC engine begins execution by loading data from HKCU\Console, for default console settings and
           '  from HKCU\Console\'FilePath_AppName.exe', if it exists, for previousy saved user settings.
           '  FreeConsole() clears that data so that it will be read again (after being modified within the App) during
           '  execution of Con.New  ***
          
          #Compiler PBCC 6                              ' PBCC6 required for CON.NEW method.
          #Compile Exe
          #Dim All
          #Break On
          #Console Off                                  ' No startup console shown
          #Include "win32api.inc"
          
          Function PBMain () As Long
           Local sSubKeys, sValueName As String
           Local lStat, lRet As Long
           Local dwData As Dword
          
            FreeConsole()                               ' Ensure fresh start for Con.New  ***
          
              sSubKeys = Exe.Full$                      ' app name used for Per-Console-application registry settings
          
              If Len(Environ$("PBDEBUG")) Then sSubKeys = "PB/CC Debugger"    ' PB IDE Debug mode
          
              Replace "\" With "_" In sSubKeys
              sSubKeys = "Console\" + sSubkeys
          
              ' Update Registry keys with required properties for our Console Window
              lStat = RegKeyCreate(%HKEY_CURRENT_USER, sSubKeys)        ' Create or re-open existing Registry Key
                Select Case As Long lStat
                  Case %REG_CREATED_NEW_KEY, %REG_OPENED_EXISTING_KEY   ' = 1 or 2
                    ' Set required properties (LineWrap setting for Win10 V2 console)
                    sValueName = "LineWrap" : dwData = Mak(Dword, 0, 0)   ' &h000000001 = 0n ~ aka Mak(Dword, 1, 0)
                    lRet = RegDataSetDword(%HKEY_CURRENT_USER, sSubKeys, sValueName, dwData)
          
                    sValueName = "ScreenBufferSize" : dwData = Mak(Dword, 100, 300)   ' &h012c0064
                    lRet = RegDataSetDword(%HKEY_CURRENT_USER, sSubKeys, sValueName, dwData)
          
                    sValueName = "WindowSize"       : dwData = Mak(Dword, 80, 40)     ' &h00280050
                    lRet = RegDataSetDword(%HKEY_CURRENT_USER, sSubKeys, sValueName, dwData)
          
                    sValueName = "WindowPosition"   : dwData = Mak(Dword, 10, 80)     ' &h0050000a
                    lRet = RegDataSetDword(%HKEY_CURRENT_USER, sSubKeys, sValueName, dwData)
          
                  Case Else
           '          ErrorMsg(GetLastError)    ' TBA
                    Exit Function
                End Select
          
              Con.New
              ? " Console startup test." : ?
              ? " Registry key: HKCU\" sSubKeys
              ? IIf$(lStat = %Reg_Created_New_Key, " Created", " Already existed")
              ?
              ? "App running with these Console properties:"
              ?
              lRet = RegDataGetDword(%HKEY_CURRENT_USER, sSubKeys, "LineWrap", dwData)
              Con.Print IIF$(dwData = &h00000001, "  LineWrap on",  "  LineWrap off")
              Con.Print "  Buffer Size", Con.Virtual.Col, Con.Virtual.Row
              Con.Print "  Screen Size", Con.Screen.Col,  Con.Screen.Row
              Con.Print "  Window Pos",  Con.Loc.X,       Con.Loc.Y
              ?
              ? "Any key to exit"
              WaitKey$("") ', 1000)
          End Function
          '------------------/PBMain
          
          ' Reg functions TT Pierre Bellisle
          '------------------------------------------------------------------------------
          
          FUNCTION RegDataGetDword(hMainKey AS DWORD, sKeyName AS STRING, _
                                   sValueName AS STRING, dwData AS DWORD) AS LONG
           'Set dwData. Return %ERROR_SUCCESS (0) if no error.
           LOCAL Retval AS LONG
           LOCAL hKey   AS DWORD
          
           Retval = RegOpenKeyEx(hMainKey, BYVAL STRPTR(sKeyName), BYVAL %Null, %KEY_READ, hKey)
           IF Retval = %ERROR_SUCCESS THEN
             Retval = RegQueryValueEx(hKey, BYVAL STRPTR(sValueName), BYVAL %Null, %REG_DWORD, BYVAL VARPTR(dwData), 4)
             RegCloseKey(hKey)
           END IF
           FUNCTION = Retval
          
          END FUNCTION
          '------------------------------------------------------------------------------
          
          Function RegDataSetDword(hMainKey As Dword, sKeyName As String, _
                                   sValueName As String, dwData As Dword) As Long
           'Create 'sValueName' if necessary, set DWORD data. Return %ERROR_SUCCESS(0) if no error.
           Local hKey   As Dword
           Local Retval As Long
          
            Retval = RegOpenKeyEx(hMainKey, ByVal StrPtr(sKeyName), ByVal %NULL, %KEY_ALL_ACCESS, hKey)
            If Retval = %ERROR_SUCCESS Then
              Retval = RegSetValueEx(hKey, ByVal StrPtr(sValueName), ByVal %NULL, %REG_DWORD, dwData, SizeOf(dwData))
              RegCloseKey(hKey)
            End If
           Function = Retval
          End Function
          '------------------------------------------------------------------------------
          
          Function RegKeyCreate(hMainKey As Dword, sKeyName As String) As Long
           'Create a Key if necessary. Return Disposition if no error.
           Local hKey As Dword
           Local Disposition As Long
          
            If RegCreateKeyEx(hMainKey, ByVal StrPtr(SKeyName), ByVal %NULL, "", _
                             %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, ByVal %NULL, hKey, Disposition) = %ERROR_SUCCESS Then
              RegCloseKey(hKey)
            End If
           Function = Disposition     ' 1 = new created. 2 = pre-existing
          End Function
          '------------------------------------------------------------------------------
          
          Function ErrorMsg (ByVal ErrorCode As Dword) As String
           Local szMsg As AsciiZ * 255
            FormatMessage %FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0, ErrorCode, 0, szMsg, SizeOf(szMsg), ByVal 0
           Function = Str$(ErrorCode) + " " + szMsg
          End Function
          '------------------/ErrorMsg
          
          
          #IF 0
           example:
           Registry key: HKCU\Console\C:_PBCC60_samples_AA Temp_ConsoleSize_LineWrapOff.exe
          #ENDIF
          Needs more work to deal with situation if app is started from within CMD window and if app is started from a shortcut .lnk
          Rgds, Dave

          Comment

          Working...
          X