Announcement

Collapse
No announcement yet.

Stange Thing On Graphic Copy

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

  • Stange Thing On Graphic Copy

    I have a small program that read from clipboard buffer to a graphic window, code as below.

    LOCAL GraphicWindow AS DWORD
    LOCAL GraphicHandle AS DWORD , x AS LONG

    CLIPBOARD GET BITMAP GraphicHandle, x
    GRAPHIC WINDOW "Graphic window", 0, 0 , 800, 600 TO GraphicWindow
    GRAPHIC ATTACH GraphicWindow, 0
    GRAPHIC COPY GraphicHandle, 0
    SLEEP 5000

    The program work fine in debug mode, but the graphic window shows nothing when it is run in compiled mode.

    Help is deeply appreciated !

    Regards.

    Kunhock

  • #2
    Deleted as Dave (below) found the answer.

    =================================
    "He who has a 'why' to live,
    can bear with almost any 'how'."
    Friedrich Nietzsche (1844-1900)
    =================================
    Last edited by Gösta H. Lovgren-2; 14 Apr 2009, 03:56 PM. Reason: Unnecessary and JPW
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

    Comment


    • #3
      There does seem to be something odd going on here.
      Try this test code (with something on the clipboard eg from Alt-Print Scrn)..
      Code:
      #Dim All 
      #INCLUDE "WIN32API.INC"
       
      FUNCTION PBMAIN()
       LOCAL X AS LONG                      ' Note different arrangements below
       LOCAL GraphicWindow AS DWORD
       LOCAL GraphicHandle AS DWORD
       
        CLIPBOARD GET BITMAP GraphicHandle, x
        GRAPHIC WINDOW "Graphic window", 0, 0 , 800, 600 TO GraphicWindow
        GRAPHIC ATTACH GraphicWindow, 0
        GRAPHIC COPY GraphicHandle, 0
       
        GRAPHIC ATTACH GraphicHandle, 0
        GRAPHIC BITMAP END
       
        SLEEP 5000
       
      END FUNCTION
      '------------------/PBMain
      #IF 0
       LOCAL X AS LONG                      ' OK
       LOCAL GraphicWindow AS DWORD
       LOCAL GraphicHandle AS DWORD
       
       
       LOCAL GraphicWindow AS DWORD         ' Not OK
       LOCAL GraphicHandle AS DWORD
       LOCAL X AS LONG
       
       
       LOCAL GraphicWindow AS DWORD         ' OK   !
       STATIC GraphicHandle AS DWORD
       LOCAL X AS LONG
      #ENDIF
      I get different results just by repositioning the declaration of the 'X' variable. Using STATIC for the Bitmap handle also has some effect !!??
      All variants work when run in debug mode.
      Rgds, Dave

      Comment


      • #4
        Thanks ..

        Thanks ..you saved my life ..

        I like the static declaration. But .. still wonder why the pointer run away ..

        Regards.

        Kunhock

        Comment


        • #5
          Did you try adding #Register None before the declares? Can they be defined in any order with this added?
          Scott Slater
          Summit Computer Networks, Inc.
          www.summitcn.com

          Comment


          • #6
            Good catch Scott. Indeed it does seem that the problem occurs when GraphicHandle is assigned as a register variable (unless told otherwise PB automatically classifies the first two integer variables as Register variables).

            The 'cure' is to ensure that..
            1. #Register None is applied. or
            2. There are at least two other integer variables assigned ahead of GraphicHandle (at present only two integer variables are automatically classified as register variables - "may change in the future"). or
            3. Declare GraphicHandle as a Static (or Global) variable.
            Rgds, Dave

            Comment

            Working...
            X