Announcement

Collapse
No announcement yet.

adding a image to a image box

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

  • adding a image to a image box

    I am writing a program that takes the Acc teams and their mascots and you have to match them together. but i want to have the program display the mascots image in a image box when the user is correct. i have converted all my images to bitmaps and i am not sure how to get it to display them. plaese help.
    Last edited by David Sherwood; 23 Apr 2009, 10:25 AM.

  • #2
    Hi David;

    Here's a quick and dirty demo that shows how to display a BMP in a graphic box.
    Code:
    '====================================================================
    '
    '  Image.bas for PowerBASIC Compiler for Windows
    '
    '  Display an BMP image.
    '
    '====================================================================
    #COMPILER PBWIN 9
    #COMPILE EXE
    '--------------------------------------------------------------------
    %IDC_GRAPHIC1  = 111
    '--------------------------------------------------------------------
    
    
    '********************************************************************
    FUNCTION PBMAIN () AS LONG
    '--------------------------------------------------------------------
    ' Program entrance
    '--------------------------------------------------------------------
      LOCAL hDlg    AS DWORD
      LOCAL DX      AS DWORD
      LOCAL DY      AS DWORD
      LOCAL GX      AS DWORD
      LOCAL GY      AS DWORD
    
      DIALOG NEW PIXELS, 0, "Image Display",,, 800, 600, _
                         %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
                         
      DIALOG GET SIZE hDlg TO DX, DY
      '------------------------------------------------------------------
      
      GX = INT((DX - 700) /2)
      GY = INT((DY - 412) /2)
      CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1,"", GX, GY, 700, 326
      GRAPHIC ATTACH hDlg, %IDC_GRAPHIC1
      GRAPHIC CLEAR RGB(0, 0, 0)
      '------------------------------------------------------------------
      
      GRAPHIC RENDER "Pontiac Solstice5.bmp", (0, 0)- (700, 326)
      '------------------------------------------------------------------
      
      DIALOG SHOW MODAL hDlg CALL DlgProc
    
    END FUNCTION
    
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgProc() AS LONG
    '--------------------------------------------------------------------
    ' Main dialog callback procedure
    '--------------------------------------------------------------------
    
      SELECT CASE CB.MSG
      CASE %WM_COMMAND
          SELECT CASE CB.CTL
          CASE %IDCANCEL
              IF CB.CTLMSG = %BN_CLICKED THEN
                  DIALOG END CB.HNDL
              END IF
    
          END SELECT
    
      END SELECT
    
    END FUNCTION
    Attached Files

    Comment

    Working...
    X