我正在使用一个CStatic控件,其变量为“ m_background”,ID为IDC_background。在此控件中,单击按钮即可运行视频。第二个控件是Edit Control,其变量为“ m_edit”,ID为IDC_edit。此Edit Box置于静态控件上。我要显示在视频上用Edit Control编写的文本,同时单击带有EDit Control透明背景色的按钮单击以播放视频。 但是问题是在我们播放视频时,m_edit控件出现了灰色/白色背景。我想在播放视频时在视频上显示带有“ m_edit”控件透明背景的文本。
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);
}
答案 0 :(得分:0)
尝试使用SetLayeredWindowAttributes函数以及您的bk颜色的crKey。
另外,我认为您代码中的pDC->SetBkColor(TRANSPARENT);
是一个错误,它将bk颜色设置为黑色。尝试在没有此调用的情况下运行。