Announcement

Collapse
No announcement yet.

Transparent background

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

  • Scott Turchin
    replied
    Wow, I had forgotten I posted that, I never did fix it, got distracted about 3 months ago and still haven't caught my breath, but I will fix this 2nite, thank you!

    Scott


    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    This my old training code + I added especially TextOut in %WM_PAINT
    Code:
       #Compile Exe
       #Dim All
       #Register None
       #Include "Win32Api.Inc"
    
       %ID_Label1 =  101
       %ID_Text1 = 201
       %ID_Button = 301
    
       CallBack Function DlgProc
          Dim hBrushDlg As Static Long, hBrush1 As Static Long
          Select Case CbMsg
             Case %WM_INITDIALOG
                hBrushDlg = CreateSolidBrush(%Yellow)
                hBrush1 =  CreateSolidBrush(%White)
             Case %WM_DESTROY
             DeleteObject hBrushDlg: DeleteObject hBrush1
          Case %WM_CTLCOLORDLG
             Function = hBrushDlg
          Case %WM_PAINT
             Dim ps As Paintstruct, rc As Rect, x As Long, y As Long
             BeginPaint CbHndl, ps
             Setbkmode ps.hDC, %TRANSPARENT
             Dialog Units CbHndl, 10, 20 To Pixels x, y
             SetTextColor ps.hDC, Rgb(128, 0, 0)
             textout ps.hDC, x, y, "Textout", 7
             EndPaint CbHndl, ps
          Case %WM_CTLCOLORSTATIC, %WM_CTLCOLOREDIT
             Select Case GetDlgCtrlId(CbLparam)
                Case %ID_Text1
                   SetTextColor CbWparam, %Blue
                   SetBkColor CbWparam, %White
                   Function = hBrush1
                Case %ID_Label1
                   SetBkMode CbWparam, %TRANSPARENT
                   SetTextColor CbWparam, Rgb(0, 128, 128)
                   Function = hBrushDlg
                Case %ID_BUTTON
                   SetBkMODE CbWparam, %Transparent
                   SetTextColor CbWparam, Rgb(0, 0, 128)
                   Function = hBrushDlg
                End Select
          End Select
       End Function
    
       Function PbMain
          Local hDlg As Long
          Dialog New 0 ,"Test",,, 105, 110, %WS_CLIPCHILDREN Or %WS_CLIPSIBLINGS _
             Or %WS_SYSMENU To hDlg
          Control Add Label, hDlg, %ID_Label1, "Transparent Label", 10, 5, 80, 10, %SS_RIGHT
          Control Add TextBox, hDlg, %ID_Text1,"1. Not nice" + $CRLF + "2. Colors, fonts" + $CRLF + "3. Pardon", 9, 35, 82, 30, %ES_WANTRETURN Or %ES_MULTILINE Or %ES_READONLY, %WS_EX_CLIENTEDGE
          Control Add Option, hDlg, %ID_Button, "Transparent option", 10, 70, 80, 15
          Dialog Show Modal hDlg, Call DlgProc
       End Function
    ------------------

    Leave a comment:


  • Mike Joseph
    replied
    I'm having problems getting this to work. I've got a Label on a window. I change the color of a portion of the window to white by changing the pen and brush and then using PaintRgn to color in the area. That works fine. But my label is still using the default gray background. Any ideas? I've tried using %TRANSPARENT style for both the window and the control as well as using %WS_EX_TRANSPARENT Nothing seem to do the trick.

    Here's what my WM_PAINT event looks like for the dialog.

    Code:
         CASE %WM_PAINT
                hDC = BeginPaint(g_hWizzard, ps)
                SelectObject hdc, hPen
                SelectObject hdc, hBrush
                PaintRgn hDC, hRegion
    
                setbkmode hDC, %TRANSPARENT
                ' output our text
                CONTROL SET TEXT g_hWizzard, %ctlLabel1, "Test"
                ' the above line changes the text, but the backround isnt transparent.
    
                ' the following line works though with transparency.
                textout hDC, 220, 20, "Testing", 7    
    
                ' select the original values into the DC
                SelectObject hDC, hPenSave
                SelectObject hDC, hBrushSave
    
                EndPaint g_hWizzard, ps
    -Mike


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

    Leave a comment:


  • Lance Edmonds
    replied
    In your dialog callback, draw the text during a %WM_PAINT event (Dont forget to set the background mode to %TRANSPARENT).

    Lance
    PowerBASIC Support

    Leave a comment:


  • Scott Turchin
    started a topic Transparent background

    Transparent background

    Code:
    Function SplashProc() As Long
      Dialog New 0, "",,, 325,146, %WS_POPUP Or %WS_DLGFRAME  To sDlg
      Control Add Image, sDlg, -1,"#1031",0,0,325,146
      Control Add Frame, sDlg, -2,"Licensed to",20, 55, 150, 35, %WS_EX_LEFT
      Control Add Label, sDlg, -3, wRegUser,    25, 65, 140, 10, %WS_EX_LEFT
      Control Add Label, sDlg, -4, wRegCompany, 25, 75, 140, 10, %WS_EX_LEFT
      Dialog Show Modal sDlg Call SplashScreen
    
    End Function

    I would like to make the label's background clear, transparent, etc, it's being put over top of a bitmap (image) and it looks kinda silly this way...

    Is there a window style for this or do I have to do the paint by numbers routine??

    Thanks,

    Scott

Working...
X