Thread: How do I convert the background of Edit Control to transparent in mFC VC++ ?

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    2

    How do I convert the background of Edit Control to transparent in mFC VC++ ?

    I am using one CStatic control with variable as "m_background" and ID as IDC_background. In this control, the video has been run on the click of the button. and there is second control Edit Control with variable as "m_edit" and ID as IDC_edit.This Edit Box is placed over static control. I want to show the text written in Edit Control on video while we play video on click of the button with transparent background color of EDit Control.
    But the problem is grey/white background has appeared for m_edit control while we play video. I want to show the text on the video with transparent background of the "m_edit" control while we play the video.
    I have attached the ScreHow do I convert the background of Edit Control to transparent in mFC VC++ ?-screenshot_r-png
    Please help !!
    Code:
    
    
    Code:
    BOOL CtestcodeDlg::OnInitDialog()//To set up the video in background and text above the video{
    
    
    
    
    m_background.ModifyStyle(0, WS_CLIPSIBLINGS);	
    
    
    m_edit.SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE|WS_EX_TRANSPARENT);
    
    
    
    
    	return TRUE;  // return TRUE  unless you set the focus to a control
    }
    
    
    
    
    HBRUSH CtestcodeDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)///To transparent the background of Edit box
    {
    HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
    HBRUSH m_default=CreateSolidBrush(RGB(0,0, 0));
    if(pWnd->GetDlgCtrlID() == IDC_edit)
    
    
    {
    pDC->SetTextColor(RGB(255,0,0));
    pDC->SetBkColor(TRANSPARENT);
    pDC->SetBkMode(TRANSPARENT);
    }
    return hbr;
    }
    
    
    
    
    void CtestcodeDlg::OnBnClickedButton1()////To run the video
    {
    my_instance = libvlc_new(0, NULL);
    my_media_file = libvlc_media_new_location(my_instance, "rtsp://BigBuckBunny_115k.mov");
    my_player = libvlc_media_player_new_from_media(my_media_file);
    my_event_manager = libvlc_media_player_event_manager(my_player);
    libvlc_media_player_play(my_player);
    libvlc_audio_set_track(my_player ,-1);
    libvlc_media_player_set_hwnd(my_player, m_background);
    Sleep(1000); 
    _beginthread(test, 0, NULL);
    libvlc_audio_set_track(my_player ,-1);
    
    
    
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,485
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. background of dialogbox transparent.. why?
    By Telmo Vaz in forum Windows Programming
    Replies: 1
    Last Post: 06-14-2013, 01:59 AM
  2. Transparent Background
    By C_ntua in forum C# Programming
    Replies: 4
    Last Post: 01-17-2010, 05:45 PM
  3. How to make a "transparent" User Control Background.
    By indigo0086 in forum C# Programming
    Replies: 2
    Last Post: 01-01-2008, 11:50 AM
  4. Transparent background
    By maxorator in forum Windows Programming
    Replies: 4
    Last Post: 11-02-2005, 08:02 PM
  5. Need to set EDIT background BLACK and EDIT text WHITE
    By Garfield in forum Windows Programming
    Replies: 3
    Last Post: 08-29-2003, 01:36 PM

Tags for this Thread