Announcement

Collapse
No announcement yet.

SD card or USB stick

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

  • I started to run debug and compile then animate to trace where the bug is ... it is taking some time

    Comment


    • It is still running in animation mode , so it means that the program couldn't handle a long Disk Label as in

      VolumeLabel AS STRING * 40 'ex CF_1GB

      inside EjectDrive_SDK_API_A.inc

      there could be some array dimensioning problem which caused the program to crash.

      Maybe you need to test on DVD with a long label and find out?

      Comment


      • Got this debug error message

        Code:
        Begin Debug at 6:01:26 AM on 09/10/2019
        Break on error 105:
        Not a valid PowerBASIC error code. Possible memory corruption.

        the error's location is on this line
        Code:
         TheArray(giArrayIndex).VolumeLabel = UCASE$(zVolumeLabel)

        Comment


        • Did you see my extended post in #140?

          Comment


          • Can't find Error 105 in the PB help documentation ?

            Probably error due to this below statement that crashes out?

            Code:
             GetVolumeInformationA TRIM$(RTRIM$(TheArray(giArrayIndex).DriveLetter, CHR$(0))) + "\", zVolumeLabel, 39, 0, 0, 0, "", 0

            Comment


            • this will also need to be changed...


              Code:
               
              LOCAL zVolumeLabel AS ASCIIZ * 20

              to this...

              Code:
               
              LOCAL zVolumeLabel AS ASCIIZ * 40
              and this...
              Code:
              GetVolumeInformationA TRIM$(RTRIM$(TheArray(giArrayIndex).DriveLetter, CHR$(0))) + "\", zVolumeLabel, 39, 0, 0, 0, "", 0
              to this...

              Code:
              GetVolumeInformationA TRIM$(RTRIM$(TheArray(giArrayIndex).DriveLetter, CHR$(0))) + "\", zVolumeLabel, 50, 0, 0, 0, "", 0

              Comment


              • Thank you Jim
                It works now with all the above changes in post #140 and #146 --- I'm able to select and eject the DVD drive


                Comment


                • Tim,
                  Sweet! Good deal. I knew we could fix it.

                  Comment


                  • Probably you would need to change the width of the dialog as it truncates the drive labels being display

                    Click image for larger version

Name:	New disp.png
Views:	82
Size:	21.2 KB
ID:	785710

                    Comment


                    • Probably you may need to change your drive change program too, accommodating these longer length label changes?

                      https://forum.powerbasic.com/forum/u...4-drive-change

                      Comment



                      • See, I said it would look ugly.

                        I see you missed a step in #135
                        To make the displayed information look cleaner now that the volume label is expanded change this:

                        Code:
                        zText = $CRLF & PARSE$(LVData(@dis.itemID), $TAB, COLx + 1) & $TAB & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 2) & $CRLF & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 5)
                        to this...

                        Code:
                        zText = $CRLF & MID$(PARSE$(LVData(@dis.itemID), $TAB, COLx + 1), 1, 35) & $CRLF & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 2)

                        Now change this:
                        Code:
                                          zText = $CRLF & MID$(PARSE$(LVData(@dis.itemID), $TAB, COLx + 1), 1, 35) & $CRLF & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 2)
                        to this:

                        Code:
                                          zText = $CRLF & MID$(PARSE$(LVData(@dis.itemID), $TAB, COLx + 1), 1, 22) & $CRLF & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                  PARSE$(LVData(@dis.itemID), $TAB, COLx + 2)
                        Yes Tim, I already changed it. I'll release an update version for both soon. DriveChange 6.1 and EjectDrive 1.1

                        Comment


                        • If this was a single-line rather than a multi-line then we could limit the length to the ListView cell. Like this:


                          Change this...
                          Code:
                                            IF (ListviewColumn.fmt AND %LVCFMT_CENTER) THEN                              'Is text centered, at left, or at right
                                              DrawTextA(@dis.hDC, zText, LEN(zText), ColumnRect, %DT_CENTER) ' OR _         'Text is centered
                                                       '%DT_VCENTER OR %DT_END_ELLIPSIS OR %DT_SINGLELINE)
                                            ELSEIF (ListviewColumn.fmt AND %LVCFMT_RIGHT) THEN
                                              DrawTextA(@dis.hDC, zText, LEN(zText), ColumnRect, %DT_RIGHT) ' OR _          'Text is right aligned
                                                       '%DT_VCENTER OR %DT_END_ELLIPSIS OR %DT_SINGLELINE)
                                            ELSE
                                              DrawTextA(@dis.hDC, zText, LEN(zText), ColumnRect, %DT_LEFT) ' OR _           'Text is left aligned
                                                       '%DT_VCENTER OR %DT_END_ELLIPSIS OR %DT_SINGLELINE)
                          to this...

                          Code:
                                            IF (ListviewColumn.fmt AND %LVCFMT_CENTER) THEN                              'Is text centered, at left, or at right
                                              DrawTextA(@dis.hDC, zText, LEN(zText), ColumnRect, %DT_CENTER OR _         'Text is centered
                                                       %DT_END_ELLIPSIS) '%DT_VCENTER OR %DT_SINGLELINE)
                                            ELSEIF (ListviewColumn.fmt AND %LVCFMT_RIGHT) THEN
                                              DrawTextA(@dis.hDC, zText, LEN(zText), ColumnRect, %DT_RIGHT OR _          'Text is right aligned
                                                       %DT_END_ELLIPSIS) '%DT_VCENTER OR %DT_SINGLELINE)
                                            ELSE
                                              DrawTextA(@dis.hDC, zText, LEN(zText), ColumnRect, %DT_LEFT OR _           'Text is left aligned
                                                       %DT_END_ELLIPSIS) '%DT_VCENTER OR %DT_SINGLELINE)

                          Which will change the extended DriveLabel into a segment followed by an ellipsis.

                          Note:
                          DriveChange was already using the ellipsis flag on its single-line cell.

                          Since this is a multi-line instead of a single-line cell the %DT_END_ELLIPSIS flag is not considered when drawing the text so
                          it looks like keeping the limit at 22 is the best method.


                          Code:
                                            zText = $CRLF & MID$(PARSE$(LVData(@dis.itemID), $TAB, COLx + 1), 1, 22) & $CRLF & _
                                                    PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                    PARSE$(LVData(@dis.itemID), $TAB, COLx + 2)
                          This would emulate the 22 character limit...

                          Code:
                                            IF LEN(zText) > 22 THEN
                                                zText = $CRLF & MID$(PARSE$(LVData(@dis.itemID), $TAB, COLx + 1), 1, 22) & "..." & $CRLF & _    'text limited to 40 characters
                                                        PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                        PARSE$(LVData(@dis.itemID), $TAB, COLx + 2)
                                            ELSE
                                                zText = $CRLF & MID$(PARSE$(LVData(@dis.itemID), $TAB, COLx + 1), 1, 22) & $CRLF & _    'text limited to 40 characters
                                                        PARSE$(LVData(@dis.itemID), $TAB, COLx + 3) & $TAB & _
                                                        PARSE$(LVData(@dis.itemID), $TAB, COLx + 2)
                                            END IF
                          Of course if 22 is still too long then replace the 22 with 17.

                          Let me know what fits for you.
                          To be on the safe side I'm just going to set it at 17 for the new version.

                          Tim,
                          Thank you for bringing it to my attention.
                          Last edited by Jim Fritts; 9 Oct 2019, 11:30 AM.

                          Comment


                          • Thank you Jim
                            I'm using 22

                            Comment


                            • All,
                              I fixed DoubleClickIt, DetermineIfDriveIsRemovable, and EjectDrive routines.
                              Array boundaries are now honored.

                              These are the new routines...

                              Code:
                              '________________________________________________________________________________
                              '
                              '   SUB DoubleClickIt
                              '________________________________________________________________________________
                              
                              SUB DoubleClickIt
                                  LOCAL iIndex      AS LONG
                                  LOCAL szLinkText  AS STRING
                              
                                  iIndex = SendMessageA(hListView, %LVM_GETNEXTITEM, -1, %LVNI_SELECTED)
                                  '? str$(iIndex)
                              
                                  IF iIndex <= UBOUND(LVData()) AND iIndex >= LBOUND(LVData()) THEN
                                      szLinkText = MID$(LVData(iIndex), 1, 2) & "\"
                                      szLinkText = $DQ + szLinkText + $DQ
                                      ShellExecuteA %HWND_DESKTOP, "open", BYCOPY szLinkText, "", "", %SW_NORMAL
                                  ELSE
                                      EnableWindow GetDlgItem(hWndMain, %ID_ButtonEject), %FALSE
                                  END IF
                              
                              END SUB
                              '________________________________________________________________________________
                              '
                              '   SUB DetermineIfDriveIsRemovable
                              '________________________________________________________________________________
                              
                              SUB DetermineIfDriveIsRemovable
                                  LOCAL iIndex      AS LONG
                                  LOCAL sLinkText   AS STRING
                              
                                  iIndex = SendMessageA(hListView, %LVM_GETNEXTITEM, -1, %LVNI_SELECTED)
                                  '? str$(iIndex)
                              
                                  IF iIndex <= UBOUND(LVData()) AND iIndex >= LBOUND(LVData()) THEN
                                      sLinkText = LVData(iIndex)
                                      IF TRIM$(sLinkText) <> "" THEN
                                          IF INSTR(sLinkText, "Removable") OR INSTR(sLinkText, "CD-ROM") THEN
                                              EnableWindow GetDlgItem(hWndMain, %ID_ButtonEject), %TRUE
                                          ELSE
                                              EnableWindow GetDlgItem(hWndMain, %ID_ButtonEject), %FALSE
                                          END IF
                                      END IF
                                  ELSE
                                      EnableWindow GetDlgItem(hWndMain, %ID_ButtonEject), %FALSE
                                  END IF
                              END SUB
                              '________________________________________________________________________________
                              '
                              '   SUB EjectDrive
                              '________________________________________________________________________________
                              
                              SUB EjectDrive
                                  LOCAL iIndex      AS LONG
                                  LOCAL sLinkText   AS STRING
                              
                                  iIndex = SendMessageA(hListView, %LVM_GETNEXTITEM, -1, %LVNI_SELECTED)
                                  '? str$(iIndex)
                              
                                  IF iIndex <= UBOUND(LVData()) AND iIndex >= LBOUND(LVData()) THEN
                                      sLinkText = MID$(LVData(iIndex), 1, 1)
                                      '? sLinkText
                                      IF TRIM$(sLinkText) <> "" THEN
                                          CALL EjectVolume(sLinkText)
                                          CALL EjectionMessage(0)
                              
                                          EnableWindow GetDlgItem(hWndMain, %ID_ButtonEject), %FALSE
                                          ListViewItem.iItem = 0
                                          'Select Item:
                                          ListView_SetItemState(hListView, -1, 0, %LVIS_SELECTED) ' // deselect all items
                              
                                      END IF
                                  END IF
                              END SUB
                              Note: More changes
                              Last edited by Jim Fritts; 9 Oct 2019, 02:50 PM.

                              Comment


                              • Updated EjectDrive and DriveChange together.

                                Comment


                                • Thank you very much Jim
                                  These programs comes in very handy, appreciate your tremendous efforts in developing such programs

                                  Comment


                                  • Tim,
                                    Glad I could help.

                                    Comment


                                    • All,
                                      A new look is coming soon.

                                      Click image for larger version  Name:	New Bitmap Image.jpg Views:	0 Size:	70.4 KB ID:	785773

                                      First time I've seen this in a listview control on this forum.

                                      With the exception of Patrice here.

                                      Here is the code segment that makes it possible...
                                      Code:
                                      '_________________________________________________________________
                                      '
                                      '   SUB  DrawGradientLV
                                      '_________________________________________________________________
                                      
                                      SUB DrawGradientLV(BYVAL hDC AS DWORD, ItemRect AS RECT)
                                         LOCAL rectFill   AS RECT
                                         LOCAL fStep      AS SINGLE
                                         LOCAL hBrushGrad AS DWORD
                                         LOCAL lOnBand    AS LONG
                                         LOCAL Temp&
                                         LOCAL iItem      AS LONG
                                      
                                         'Put gradient on each item
                                         FOR iItem = ItemRect.nTop TO ItemRect.nBottom + 1
                                             INCR lOnBand
                                      
                                             SetRect _
                                                 rectFill  _
                                               , ItemRect.nLeft      _
                                               , iItem               _
                                               , ItemRect.nRight + 1 _
                                               , iItem + 1
                                      
                                             Temp& = RGB((94 - lOnBand), (245 - lOnBand), (251 - lOnBand))  'LIGHT BLUE
                                             hBrushGrad = CreateSolidBrush(Temp&)
                                             Fillrect hDC, rectFill, hBrushGrad   'draw line across rectangle
                                             DeleteObject hBrushGrad
                                         NEXT
                                      
                                      END SUB
                                      Last edited by Jim Fritts; 11 Oct 2019, 12:03 PM.

                                      Comment


                                      • Bundled code here.

                                        Comment


                                        • Very nice background color, I tried using your DrawGradientLV() routine in an ordinary DDT Listview but was not successful

                                          However , the Drive change ( DriveChange_SDK.exe ) program's background is just too dark

                                          Comment

                                          Working...
                                          X