Announcement

Collapse
No announcement yet.

Graphic Bitmap Load problem

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

  • Graphic Bitmap Load problem

    Hello,

    I am trying to use GRAPHIC BITMAP LOAD. Whatever I try, I keep on getting "Cannot write to memory" exception failure at program end.
    Code:
         Graphic Bitmap Load "CHECK", 13, 13 To hBmpCheck
         XPrint Stretch hBmpCheck, 0 , (0,0) - (12,12) To (x+1*ppcmx, y+1*ppcmy) - (x+1*ppcmx + 60, y+1*ppcmy + 60)
         Graphic Bitmap Load "NOCHECK", 13, 13 To hBmpUnCheck
         XPrint Stretch hBmpUnCheck, 0 , (0,0) - (12,12) To (x+2*ppcmx, y+2*ppcmy) - (x+2*ppcmx + 60, y+2*ppcmy + 60)
    The graphics are only used for printing to a printer, so they are not attached to any window.
    For use of GRAPHIC BITMAP END I need to do GRAPHIC ATTACH, but I have no graphic windows. Everything works fine, but the failure on exit doesn't look very nice...
    Tried CloseHandle on hBmpCheck and hBmpUnCheck, with no results.
    How should I close the Bitmaps?
    Regards,
    Peter

  • #2
    Peter,
    the manual says:
    To close a bitmap, select it with the GRAPHIC ATTACH statement, then execute GRAPHIC BITMAP END.
    Paul.

    Comment


    • #3
      Are you doing this?

      GRAPHIC BITMAP LOAD TO hBmp
      ...
      GRAPHIC ATTACH hBmp
      GRAPHIC BITMAP END

      Graphic Attach "Selects the graphic target (Window, Control or Bitmap)"

      hee hee - like Paul said
      Rgds, Dave

      Comment


      • #4
        I read that, but it's very unclear to me. Both parameters are specified as the same? And I do not have a graphic window.
        Do I have to create a Graphic window, just to be able to delete the bitmaps?
        (It would have been easier if you just could do "GRAPHIC BITMAP END hBitmap")
        Syntax
        GRAPHIC ATTACH hWin???, id& [, REDRAW]

        hWin???
        graphic window, bitmap, or control to be used with statements.

        id&
        Handle of the graphic window, control, or bitmap to be used with GRAPHIC statements.
        Regards,
        Peter

        Comment


        • #5
          Peter,
          you don't need a window. The ATTACH statement just determines which bitmap you want to refer to in future graphic operations. That bitmap can be in memory (hidden) or in a window (visible)
          GRAPHIC ATTACH statement
          Purpose
          Select the graphic target (window or bitmap ) on which future drawing operations will take place.
          Paul.

          Comment


          • #6
            Paul,

            GRAPHIC ATTACH needs 2 parameters; what should I specify If I do not have a graphic window? (ByVal 0?)
            Regards,
            Peter

            Comment


            • #7
              Peter,
              the manual says of the second parameter:
              Reserved for future implementation. Must be zero (0) for a GRAPHIC WINDOW or BITMAP
              Paul.

              Comment


              • #8
                The first parameter is the handle. The second is the unique control identifier assigned with the CONTROL ADD GRAPHIC statement. id& must be 0 for a GRAPHIC WINDOW or GRAPHIC BITMAP.

                Best...

                Bob Zale
                PowerBASIC Inc.

                Comment


                • #9
                  Ah, thanks,

                  Then it's clear to me. The above quote of the helpfile incorrectly says that the second parameter is a Handle... (error in helpfile)
                  Last edited by Peter Lameijn; 20 Nov 2008, 09:40 AM.
                  Regards,
                  Peter

                  Comment


                  • #10
                    I still get access violation directly after "GRAPHIC BITMAP LOAD". The debugger says:
                    Code:
                    HEAP[Alarm_test.exe]: 
                    Heap block at 0013D000 modified at 0013D028 past requested size of 20<0A>
                    HEAP[Alarm_test.exe]: 
                    Invalid Address specified to RtlSizeHeap( 130000, 13d008 )<0A>
                    I am sure the bitmap size is specified OK. (Mono bitmap 13x13 pixels)
                    Regards,
                    Peter

                    Comment


                    • #11
                      Need to deliver application tomorrow, so I made a quick work-around.
                      I needed two bitmaps with a checked and an un-checked checkbox to print.
                      Made them with line drawing . Maybe useful to others too:
                      Code:
                      Sub CheckedBox(ByVal X As Long, ByVal Y As Long, ByVal Checked As Long)
                        XPrint Width 3
                        XPrint Line (x,y) - (x+36,y)
                        XPrint Line (x,y) - (x,y+36)
                        XPrint Line (x,y+36) - (x+36,y+36)
                        XPrint Line (x+36,y) - (x+36,y+36)
                      
                        If Checked Then
                          XPrint Line (x+6,y+18) - (x+6,y+30)
                          XPrint Line (x+9,y+15) - (x+9,y+30)
                          XPrint Line (x+12,y+24) - (x+27,y+9)
                          XPrint Line (x+12,y+27) - (x+30,y+9)
                        End If
                        XPrint Width 1
                      End Sub
                      Regards,
                      Peter

                      Comment

                      Working...
                      X