Announcement

Collapse
No announcement yet.

Background BMP

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

  • Background BMP

    REF: /samples/internet/stmp/stmp.bas

    Shows a method to tile "stmp.bmp" over the dialog. If the dialog size during setup is changed as little as 10 units the tiling fails. Also, if the dialog size is then changed back to it's original size and the .BAS is recompiled, the tiling fails. Why?
    Walt Decker

  • #2
    Didn't see the problems that you described on my system XP Home SP2 when compiled with either PBwin804 or PBWin90.

    If you want to make a dialog with a background image resizeable try making these changes to SMTP.BAS..
    Code:
    CALLBACK FUNCTION DlgProc () AS LONG
     
        STATIC hBmp    AS LONG
        STATIC x       AS LONG
        STATIC y       AS LONG
     
        LOCAL  hBmpDC  AS LONG
        LOCAL  bmpfile AS ASCIIZ * %MAX_PATH
        LOCAL  bm AS BITMAP                                       ' <add
     
        SELECT CASE CBMSG
     
        CASE %WM_INITDIALOG
            CONTROL SET TEXT  CBHNDL, %IDC_SERVER, $mailhost
            CONTROL SET TEXT  CBHNDL, %IDC_FROM,   $mailfrom
            CONTROL SET FOCUS CBHNDL, %IDC_TO
     
     '        DIALOG GET CLIENT CBHNDL TO x, y                    ' Move (measured in %WM_SIZE)
     '        DIALOG UNITS CBHNDL, x, y TO PIXELS x, y            ' Move
     
            ' Load the bitmap from a file
            GetModuleFilename %NULL, bmpfile, SIZEOF(bmpfile)
            bmpfile = UCASE$(bmpfile)
            REPLACE ".EXE" WITH ".BMP" IN bmpfile
            hBmp = LoadImage(BYVAL %NULL, bmpfile, %IMAGE_BITMAP, x, y, %LR_LOADFROMFILE)
     
            FUNCTION = 1
     
        CASE %WM_SIZE                ' Windows is resized...      ' <add
            DIALOG REDRAW CBHNDL                                  ' <add
     
        CASE %WM_ERASEBKGND
            DIALOG GET CLIENT CBHNDL TO x, y                      ' Moved here
            DIALOG UNITS CBHNDL, x, y TO PIXELS x, y              ' Moved here
            ' Select the bitmap into a memory DC and transfer it to the dialog
            hBmpDC = CreateCompatibleDC(CBWPARAM)
            SelectObject hBmpDC, hBmp
            GetObject(hBmp, SIZEOF(bm), BYVAL VARPTR(bm))         ' <add, used to get current size of bitmap
            ' Change BitBlt to StretchBlt
            StretchBlt CBWPARAM, 0, 0, x, y, hBmpDC, 0, 0, bm.bmwidth, bm.bmheight, %SRCCOPY
            'BitBlt CBWPARAM, 0, 0, x, y, hBmpDC, 0, 0, %SRCCOPY  ' <not used
            DeleteDC hBmpDC
     
            FUNCTION = 1
     
        CASE %WM_DESTROY
            ' The dialog is being destroyed, so release the bitmap handle
            DeleteObject hBmp
     
        END SELECT
     
    END FUNCTION
     
    FUNCTION PBMAIN () AS LONG
     
        LOCAL hDlg AS DWORD
     
        DIALOG FONT "Arial", 10
        ' Add style  for resizing
        DIALOG NEW 0, "Simple Mail Transfer Protocol (SMTP)", ,, 365, 250, %WS_OVERLAPPEDWINDOW Or %WS_THICKFRAME, To hDlg
    Rgds, Dave

    Comment


    • #3
      Dave, perhaps I didn't explain it correctly. If, in PBMAIN, I change the dialog size from (365, 250) to (360, 270) and compile-run in the IDE the background is not tiled and the screen text is captured on the dialog background. If I then change the dialog size back to the original size and compile-run the same thing occurs. This leads me to think that:

      1. There is a problem with my display driver or CPU
      2. There is a problem with the PB9 compiler.
      Walt Decker

      Comment


      • #4
        Walt,
        Tha's what I thought you meant but din't see that in my tests (used PBEdit too). Background is adjusted to suit the dialog client area whatever size it's allocated in Dialog New..

        Might be aproblem with your display driver / pc?? You could try changing the display settings - different colour depths etc I suppose, if you don't have the chance to try a different pc?
        Rgds, Dave

        Comment

        Working...
        X