Announcement

Collapse
No announcement yet.

Custom Window Background

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

  • Custom Window Background

    The SMTP.BAS example IN the .\SAMPLES\TCP directory sets a
    custom window background. The example works USING DDT.

    I am trying TO DO the same WITH classic programming method...
    WITH some problems :-(
    The following code IN the windows procedure sets the bitmap
    over the other controls.
    I am looking FOR a way TO understand & solve this problem.


    Franck.

    ....

    CASE %WM_PAINT
    hbitmap= LoadBitmap(gHInst,"BRUSH1")
    r=getobject(hbitmap,SIZEOF(bm),bm)
    hdc=getdc(hDlg)
    hmemdc=createcompatibledc(hdc)
    r=selectobject(hmemdc,hbitmap)
    r=getclientrect(hDlg,rect)
    IF getstretchbltmode(hdc)<>%STRETCH_DELETESCANS THEN _
    r=setstretchbltmode(hdc,%STRETCH_DELETESCANS)

    r=stretchblt(hdc,0,0,rect.nright,rect.nbottom, _
    hmemdc,0,0,bm.bmwidth,bm.bmheight,%SRCCOPY)

    r=deletedc(hmemdc)
    r=releasedc(hDlg,hdc)
    r=deleteobject(hbitmap)

  • #2
    A couple of notes for you:

    1. Add the style %WS_CLIPCHILDREN to the parent window style.
    2. Move the LoadBitmap() call to the %WM_INITDIALOG (or %WM_CREATE) handler, and use a STATIC variable to gold the handle - this should ease the performance hit during %WM_PAINT
    3. Extend #2 above to cover setting up the compatible DC... this should reduce the code in the %WM_PAINT handler to just the StretchBlt() call (and the appropriate BeginPaint() and EndPaint() calls.
    4. If you inplement #2 & #3, you'll also need to handle %WM_DESTORY in which you release all of the GDI handles so that your code cleans up correctly after itself.

    I hope this helps.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3

      Yes Lance this helps.

      It works perfect now !

      Thanks & Regards Franck

      ------------------

      Comment

      Working...
      X