Commit 0aa0f689 authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

Win32: move controls from VLCFullScreenWnd to VLCControlsWnd class

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 344693cf
......@@ -30,437 +30,206 @@
#include "win32_fullscreen.h"
/////////////////////////////////
//VLCHolderWnd static members
HINSTANCE VLCHolderWnd::_hinstance = 0;
ATOM VLCHolderWnd::_holder_wndclass_atom = 0;
enum{
WM_TRY_SET_MOUSE_HOOK = WM_USER+1,
WM_MOUSE_EVENT_NOTIFY = WM_APP+1,
WM_MOUSE_EVENT_NOTIFY_SUCCESS = 0xFF
};
void VLCHolderWnd::RegisterWndClassName(HINSTANCE hInstance)
////////////////////////////////////////////////////////////////////////////////
//VLCControlsWnd members
////////////////////////////////////////////////////////////////////////////////
VLCControlsWnd*
VLCControlsWnd::CreateControlsWindow(HINSTANCE hInstance,
VLCWindowsManager* wm, HWND hWndParent)
{
//save hInstance for future use
_hinstance = hInstance;
WNDCLASS wClass;
if( ! GetClassInfo(_hinstance, getClassName(), &wClass) )
{
wClass.style = CS_DBLCLKS;
wClass.lpfnWndProc = VLCHolderClassWndProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
wClass.hInstance = _hinstance;
wClass.hIcon = NULL;
wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wClass.lpszMenuName = NULL;
wClass.lpszClassName = getClassName();
_holder_wndclass_atom = RegisterClass(&wClass);
}
else
{
_holder_wndclass_atom = 0;
}
}
void VLCHolderWnd::UnRegisterWndClassName()
{
if(0 != _holder_wndclass_atom){
UnregisterClass(MAKEINTATOM(_holder_wndclass_atom), _hinstance);
_holder_wndclass_atom = 0;
VLCControlsWnd* wnd = new VLCControlsWnd(hInstance, wm);
if( wnd && wnd->Create(hWndParent) ) {
return wnd;
}
}
VLCHolderWnd* VLCHolderWnd::CreateHolderWindow(HWND hParentWnd, VLCWindowsManager* WM)
{
HWND hWnd = CreateWindow(getClassName(),
TEXT("Holder Window"),
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE,
0, 0, 0, 0,
hParentWnd,
0,
VLCHolderWnd::_hinstance,
(LPVOID)WM
);
if(hWnd)
return reinterpret_cast<VLCHolderWnd*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
delete wnd;
return 0;
}
LRESULT CALLBACK VLCHolderWnd::VLCHolderClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
VLCControlsWnd::VLCControlsWnd(HINSTANCE hInstance, VLCWindowsManager* wm)
:VLCWnd(hInstance), _wm(wm),
hToolTipWnd(0), hFSButton(0), hPlayPauseButton(0),
hVideoPosScroll(0), hMuteButton(0), hVolumeSlider(0)
{
VLCHolderWnd* h_data = reinterpret_cast<VLCHolderWnd*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch( uMsg )
{
case WM_CREATE:{
CREATESTRUCT* CreateStruct = (CREATESTRUCT*)(lParam);
VLCWindowsManager* WM = (VLCWindowsManager*)CreateStruct->lpCreateParams;
h_data = new VLCHolderWnd(hWnd, WM);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(h_data));
RECT ParentClientRect;
GetClientRect(CreateStruct->hwndParent, &ParentClientRect);
MoveWindow(hWnd, 0, 0,
(ParentClientRect.right-ParentClientRect.left),
(ParentClientRect.bottom-ParentClientRect.top), FALSE);
break;
}
case WM_PAINT:{
PAINTSTRUCT PaintStruct;
HDC hDC = BeginPaint(hWnd, &PaintStruct);
RECT rect;
GetClientRect(hWnd, &rect);
int IconX = ((rect.right - rect.left) - GetSystemMetrics(SM_CXICON))/2;
int IconY = ((rect.bottom - rect.top) - GetSystemMetrics(SM_CYICON))/2;
DrawIcon(hDC, IconX, IconY, h_data->RC().hBackgroundIcon);
EndPaint(hWnd, &PaintStruct);
break;
}
case WM_NCDESTROY:
delete h_data;
SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
break;
case WM_TRY_SET_MOUSE_HOOK:{
h_data->MouseHook(true);
break;
}
case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:
h_data->_WindowsManager->OnMouseEvent(uMsg);
break;
case WM_MOUSE_EVENT_NOTIFY:{
h_data->_WindowsManager->OnMouseEvent(wParam);
return WM_MOUSE_EVENT_NOTIFY_SUCCESS;
}
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
};
void VLCHolderWnd::DestroyWindow()
{
LibVlcDetach();
if(_hWnd)
::DestroyWindow(_hWnd);
};
LRESULT CALLBACK VLCHolderWnd::MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
bool AllowReceiveMessage = true;
if(nCode >= 0){
switch(wParam){
case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:{
MOUSEHOOKSTRUCT* mhs = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam);
//try to find HolderWnd and notify it
HWND hNotifyWnd = mhs->hwnd;
LRESULT SMRes = ::SendMessage(hNotifyWnd, WM_MOUSE_EVENT_NOTIFY, wParam, 0);
while( hNotifyWnd && WM_MOUSE_EVENT_NOTIFY_SUCCESS != SMRes){
hNotifyWnd = GetParent(hNotifyWnd);
SMRes = ::SendMessage(hNotifyWnd, WM_MOUSE_EVENT_NOTIFY, wParam, 0);
}
AllowReceiveMessage = WM_MOUSEMOVE==wParam || (WM_MOUSE_EVENT_NOTIFY_SUCCESS != SMRes);
break;
}
}
}
LRESULT NHRes = CallNextHookEx(NULL, nCode, wParam, lParam);
if(AllowReceiveMessage)
return NHRes;
else
return 1;
}
void VLCHolderWnd::MouseHook(bool SetHook)
VLCControlsWnd::~VLCControlsWnd()
{
if(SetHook){
const HWND hChildWnd = GetWindow(getHWND(), GW_CHILD);
const DWORD WndThreadID = (hChildWnd) ? GetWindowThreadProcessId(hChildWnd, NULL) : 0;
if( _hMouseHook &&( !hChildWnd || WndThreadID != _MouseHookThreadId) ){
//unhook if something changed
MouseHook(false);
}
if(!_hMouseHook && hChildWnd && WndThreadID){
_MouseHookThreadId = WndThreadID;
_hMouseHook =
SetWindowsHookEx(WH_MOUSE, VLCHolderWnd::MouseHookProc,
NULL, WndThreadID);
}
}
else{
if(_hMouseHook){
UnhookWindowsHookEx(_hMouseHook);
_MouseHookThreadId=0;
_hMouseHook = 0;
}
if(hToolTipWnd){
::DestroyWindow(hToolTipWnd);
hToolTipWnd = 0;
}
}
//libvlc events arrives from separate thread
void VLCHolderWnd::OnLibVlcEvent(const libvlc_event_t* event)
bool VLCControlsWnd::Create(HWND hWndParent)
{
//We need set hook to catch doubleclicking (to switch to fullscreen and vice versa).
//But libvlc media window may not exist yet,
//and we don't know when it will be created, nor ThreadId of it.
//So we try catch events,
//(suppose wnd will be ever created),
//and then try set mouse hook.
const HWND hChildWnd = GetWindow(getHWND(), GW_CHILD);
const DWORD WndThreadID = (hChildWnd) ? GetWindowThreadProcessId(hChildWnd, NULL) : 0;
//if no hook, or window thread has changed
if(!_hMouseHook || (hChildWnd && WndThreadID != _MouseHookThreadId)){
//libvlc events arrives from separate thread,
//so we need post message to main thread, to notify it.
PostMessage(getHWND(), WM_TRY_SET_MOUSE_HOOK, 0, 0);
}
return VLCWnd::CreateEx(WS_EX_TOPMOST, TEXT("VLC Controls Window"),
WS_CHILD|WS_CLIPSIBLINGS,
0, 0, 0, 0, hWndParent, 0);
}
void VLCHolderWnd::LibVlcAttach()
void VLCControlsWnd::PreRegisterWindowClass(WNDCLASS* wc)
{
libvlc_media_player_set_hwnd(getMD(), getHWND());
}
wc->lpszClassName = TEXT("VLC Controls Class");
wc->hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
};
void VLCHolderWnd::LibVlcDetach()
void VLCControlsWnd::CreateToolTip()
{
libvlc_media_player_t* p_md = getMD();
if(p_md)
libvlc_media_player_set_hwnd(p_md, 0);
MouseHook(false);
}
/////////////////////////////////
//VLCFullScreenWnd static members
HINSTANCE VLCFullScreenWnd::_hinstance = 0;
ATOM VLCFullScreenWnd::_fullscreen_wndclass_atom = 0;
ATOM VLCFullScreenWnd::_fullscreen_controls_wndclass_atom = 0;
hToolTipWnd = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hWnd(),
NULL,
hInstance(),
NULL);
void VLCFullScreenWnd::RegisterWndClassName(HINSTANCE hInstance)
{
//save hInstance for future use
_hinstance = hInstance;
SetWindowPos(hToolTipWnd,
HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
WNDCLASS wClass;
memset(&wClass, 0 , sizeof(wClass));
if( ! GetClassInfo(_hinstance, getClassName(), &wClass) )
{
wClass.style = CS_NOCLOSE|CS_DBLCLKS;
wClass.lpfnWndProc = FSWndWindowProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
wClass.hInstance = _hinstance;
wClass.hIcon = NULL;
wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wClass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
wClass.lpszMenuName = NULL;
wClass.lpszClassName = getClassName();
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
ti.hwnd = hWnd();
ti.hinst = hInstance();
_fullscreen_wndclass_atom = RegisterClass(&wClass);
}
else
{
_fullscreen_wndclass_atom = 0;
}
TCHAR HintText[100];
RECT ActivateTTRect;
memset(&wClass, 0 , sizeof(wClass));
if( ! GetClassInfo(_hinstance, getControlsClassName(), &wClass) )
{
wClass.style = CS_NOCLOSE;
wClass.lpfnWndProc = FSControlsWndWindowProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
wClass.hInstance = _hinstance;
wClass.hIcon = NULL;
wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wClass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
wClass.lpszMenuName = NULL;
wClass.lpszClassName = getControlsClassName();
//end fullscreen button tooltip
GetWindowRect(hFSButton, &ActivateTTRect);
GetWindowText(hFSButton, HintText, sizeof(HintText));
ti.uId = (UINT_PTR)hFSButton;
ti.rect = ActivateTTRect;
ti.lpszText = HintText;
SendMessage(hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
_fullscreen_controls_wndclass_atom = RegisterClass(&wClass);
}
else
{
_fullscreen_controls_wndclass_atom = 0;
}
}
void VLCFullScreenWnd::UnRegisterWndClassName()
{
if(0 != _fullscreen_wndclass_atom){
UnregisterClass(MAKEINTATOM(_fullscreen_wndclass_atom), _hinstance);
_fullscreen_wndclass_atom = 0;
}
//play/pause button tooltip
GetWindowRect(hPlayPauseButton, &ActivateTTRect);
GetWindowText(hPlayPauseButton, HintText, sizeof(HintText));
ti.uId = (UINT_PTR)hPlayPauseButton;
ti.rect = ActivateTTRect;
ti.lpszText = HintText;
SendMessage(hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
if(0 != _fullscreen_controls_wndclass_atom){
UnregisterClass(MAKEINTATOM(_fullscreen_controls_wndclass_atom), _hinstance);
_fullscreen_controls_wndclass_atom = 0;
}
//mute button tooltip
GetWindowRect(hMuteButton, &ActivateTTRect);
GetWindowText(hMuteButton, HintText, sizeof(HintText));
ti.uId = (UINT_PTR)hMuteButton;
ti.rect = ActivateTTRect;
ti.lpszText = HintText;
SendMessage(hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
}
LRESULT CALLBACK VLCFullScreenWnd::FSWndWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT VLCControlsWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
VLCFullScreenWnd* fs_data = reinterpret_cast<VLCFullScreenWnd *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch( uMsg )
{
switch(uMsg){
case WM_CREATE:{
CREATESTRUCT* CreateStruct = (CREATESTRUCT*)(lParam);
VLCWindowsManager* WM = (VLCWindowsManager*)CreateStruct->lpCreateParams;
fs_data = new VLCFullScreenWnd(hWnd, WM);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(fs_data));
fs_data->hControlsWnd =
CreateWindow(fs_data->getControlsClassName(),
TEXT("VLC ActiveX Full Screen Controls Window"),
WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS,
0,
0,
0, 0,
hWnd,
0,
VLCFullScreenWnd::_hinstance,
(LPVOID) fs_data);
break;
}
case WM_NCDESTROY:
delete fs_data;
SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
break;
case WM_SHOWWINDOW:{
if(FALSE==wParam){ //hiding
break;
}
fs_data->NeedShowControls();
//simulate lParam for WM_SIZE
RECT ClientRect;
GetClientRect(hWnd, &ClientRect);
lParam = MAKELPARAM(ClientRect.right, ClientRect.bottom);
}
case WM_SIZE:{
if(fs_data->_WindowsManager->IsFullScreen()){
int new_client_width = LOWORD(lParam);
int new_client_height = HIWORD(lParam);
VLCHolderWnd* HolderWnd = fs_data->_WindowsManager->getHolderWnd();
SetWindowPos(HolderWnd->getHWND(), HWND_BOTTOM, 0, 0, new_client_width, new_client_height, SWP_NOACTIVATE|SWP_NOOWNERZORDER);
}
break;
}
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0L;
};
#define ID_FS_SWITCH_FS 1
#define ID_FS_PLAY_PAUSE 2
#define ID_FS_VIDEO_POS_SCROLL 3
#define ID_FS_MUTE 4
#define ID_FS_VOLUME 5
LRESULT CALLBACK VLCFullScreenWnd::FSControlsWndWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
VLCFullScreenWnd* fs_data = reinterpret_cast<VLCFullScreenWnd *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch( uMsg )
{
case WM_CREATE:{
CREATESTRUCT* CreateStruct = (CREATESTRUCT*)(lParam);
fs_data = (VLCFullScreenWnd*)CreateStruct->lpCreateParams;
const VLCViewResources& rc = fs_data->RC();
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(fs_data));
const int ControlsHeight = 21+2;
const int ControlsHeight = 21+3;
const int ButtonsWidth = ControlsHeight;
const int ControlsSpace = 5;
const int ScrollVOffset = (ControlsHeight-GetSystemMetrics(SM_CXHSCROLL))/2;
int HorizontalOffset = ControlsSpace;
int HorizontalOffset = xControlsSpace;
int ControlWidth = ButtonsWidth;
fs_data->hFSButton =
CreateWindow(TEXT("BUTTON"), TEXT("End Full Screen"), WS_CHILD|WS_VISIBLE|BS_BITMAP|BS_FLAT,
HorizontalOffset, ControlsSpace, ControlWidth, ControlsHeight, hWnd, (HMENU)ID_FS_SWITCH_FS, 0, 0);
SendMessage(fs_data->hFSButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)rc.hDeFullscreenBitmap);
HorizontalOffset+=ControlWidth+ControlsSpace;
ControlWidth = ButtonsWidth;
fs_data->hPlayPauseButton =
CreateWindow(TEXT("BUTTON"), TEXT("Play/Pause"), WS_CHILD|WS_VISIBLE|BS_BITMAP|BS_FLAT,
HorizontalOffset, ControlsSpace, ControlWidth, ControlsHeight, hWnd, (HMENU)ID_FS_PLAY_PAUSE, 0, 0);
SendMessage(fs_data->hPlayPauseButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)rc.hPauseBitmap);
HorizontalOffset+=ControlWidth+ControlsSpace;
hPlayPauseButton =
CreateWindow(TEXT("BUTTON"), TEXT("Play/Pause"),
WS_CHILD|WS_VISIBLE|BS_BITMAP|BS_FLAT,
HorizontalOffset, xControlsSpace,
ControlWidth, ControlsHeight, hWnd(),
(HMENU)ID_FS_PLAY_PAUSE, 0, 0);
SendMessage(hPlayPauseButton, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)RC().hPauseBitmap);
HorizontalOffset+=ControlWidth+xControlsSpace;
ControlWidth = 200;
int VideoPosControlHeight = 12;
fs_data->hVideoPosScroll =
CreateWindow(PROGRESS_CLASS, TEXT("Video Position"), WS_CHILD|WS_DISABLED|WS_VISIBLE|SBS_HORZ|SBS_TOPALIGN|PBS_SMOOTH,
HorizontalOffset, ControlsSpace+(ControlsHeight-VideoPosControlHeight)/2, ControlWidth, VideoPosControlHeight, hWnd, (HMENU)ID_FS_VIDEO_POS_SCROLL, 0, 0);
int VideoPosControlHeight = 10;
hVideoPosScroll =
CreateWindow(PROGRESS_CLASS, TEXT("Video Position"),
WS_CHILD|WS_DISABLED|WS_VISIBLE|SBS_HORZ|SBS_TOPALIGN|PBS_SMOOTH,
HorizontalOffset, xControlsSpace+(ControlsHeight-VideoPosControlHeight)/2,
ControlWidth, VideoPosControlHeight, hWnd(),
(HMENU)ID_FS_VIDEO_POS_SCROLL, 0, 0);
HMODULE hThModule = LoadLibrary(TEXT("UxTheme.dll"));
if(hThModule){
FARPROC proc = GetProcAddress(hThModule, "SetWindowTheme");
typedef HRESULT (WINAPI* SetWindowThemeProc)(HWND, LPCWSTR, LPCWSTR);
if(proc){
//SetWindowTheme(fs_data->hVideoPosScroll, L"", L"");
((SetWindowThemeProc)proc)(fs_data->hVideoPosScroll, L"", L"");
((SetWindowThemeProc)proc)(hVideoPosScroll, L"", L"");
}
FreeLibrary(hThModule);
}
HorizontalOffset+=ControlWidth+ControlsSpace;
HorizontalOffset+=ControlWidth+xControlsSpace;
ControlWidth = ButtonsWidth;
fs_data->hMuteButton =
CreateWindow(TEXT("BUTTON"), TEXT("Mute"), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX|BS_PUSHLIKE|BS_BITMAP, //BS_FLAT
HorizontalOffset, ControlsSpace, ControlWidth, ControlsHeight, hWnd, (HMENU)ID_FS_MUTE, 0, 0);
SendMessage(fs_data->hMuteButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)rc.hVolumeBitmap);
HorizontalOffset+=ControlWidth+ControlsSpace;
hMuteButton =
CreateWindow(TEXT("BUTTON"), TEXT("Mute"),
WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX|BS_PUSHLIKE|BS_BITMAP, //BS_FLAT
HorizontalOffset, xControlsSpace,
ControlWidth, ControlsHeight,
hWnd(), (HMENU)ID_FS_MUTE, 0, 0);
SendMessage(hMuteButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
(LPARAM)RC().hVolumeBitmap);
HorizontalOffset+=ControlWidth+xControlsSpace;
ControlWidth = 100;
fs_data->hVolumeSlider =
CreateWindow(TRACKBAR_CLASS, TEXT("Volume"), WS_CHILD|WS_VISIBLE|TBS_HORZ|TBS_BOTTOM|TBS_AUTOTICKS,
HorizontalOffset, ControlsSpace, ControlWidth, 21, hWnd, (HMENU)ID_FS_VOLUME, 0, 0);
HorizontalOffset+=ControlWidth+ControlsSpace;
SendMessage(fs_data->hVolumeSlider, TBM_SETRANGE, FALSE, (LPARAM) MAKELONG (0, 100));
SendMessage(fs_data->hVolumeSlider, TBM_SETTICFREQ, (WPARAM) 10, 0);
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOOWNERZORDER);
hVolumeSlider =
CreateWindow(TRACKBAR_CLASS, TEXT("Volume"),
WS_CHILD|WS_VISIBLE|TBS_HORZ|TBS_BOTTOM|TBS_AUTOTICKS,
HorizontalOffset, xControlsSpace,
ControlWidth, ControlsHeight - 4, hWnd(),
(HMENU)ID_FS_VOLUME, 0, 0);
HorizontalOffset+=ControlWidth+xControlsSpace;
SendMessage(hVolumeSlider, TBM_SETRANGE, FALSE, (LPARAM) MAKELONG (0, 100));
SendMessage(hVolumeSlider, TBM_SETTICFREQ, (WPARAM) 10, 0);
ControlWidth = ButtonsWidth;
hFSButton =
CreateWindow(TEXT("BUTTON"), TEXT("Toggle fullscreen"),
WS_CHILD|WS_VISIBLE|BS_BITMAP|BS_FLAT,
HorizontalOffset, xControlsSpace,
ControlWidth, ControlsHeight, hWnd(),
(HMENU)ID_FS_SWITCH_FS, 0, 0);
SendMessage(hFSButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
(LPARAM)RC().hDeFullscreenBitmap);
HorizontalOffset+=ControlWidth+xControlsSpace;
RECT rect;
GetClientRect(GetParent(hWnd()), &rect);
int ControlWndWidth = HorizontalOffset;
int ControlWndHeight = ControlsSpace+ControlsHeight+ControlsSpace;
SetWindowPos(hWnd, HWND_TOPMOST, (GetSystemMetrics(SM_CXSCREEN)-ControlWndWidth)/2, 0,
ControlWndWidth, ControlWndHeight, SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE);
int ControlWndHeight = xControlsSpace+ControlsHeight+xControlsSpace;
SetWindowPos(hWnd(), 0,
0, (rect.bottom - rect.top) - ControlWndWidth,
rect.right-rect.left, ControlWndHeight,
SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE);
//new message blinking timer
SetTimer(hWnd, 2, 500, NULL);
SetTimer(hWnd(), 2, 500, NULL);
fs_data->CreateToolTip();
CreateToolTip();
break;
}
case WM_SHOWWINDOW:{
if(FALSE!=wParam){ //showing
UpdateButtons();
}
break;
}
case WM_LBUTTONUP:{
POINT BtnUpPoint = {LOWORD(lParam), HIWORD(lParam)};
RECT VideoPosRect;
GetWindowRect(fs_data->hVideoPosScroll, &VideoPosRect);
ClientToScreen(hWnd, &BtnUpPoint);
GetWindowRect(hVideoPosScroll, &VideoPosRect);
ClientToScreen(hWnd(), &BtnUpPoint);
if(PtInRect(&VideoPosRect, BtnUpPoint)){
fs_data->SetVideoPos(float(BtnUpPoint.x-VideoPosRect.left)/(VideoPosRect.right-VideoPosRect.left));
SetVideoPos(float(BtnUpPoint.x-VideoPosRect.left)/(VideoPosRect.right-VideoPosRect.left));
}
break;
}
......@@ -470,30 +239,18 @@ LRESULT CALLBACK VLCFullScreenWnd::FSControlsWndWindowProc(HWND hWnd, UINT uMsg,
POINT MousePoint;
GetCursorPos(&MousePoint);
RECT ControlWndRect;
GetWindowRect(fs_data->hControlsWnd, &ControlWndRect);
if(PtInRect(&ControlWndRect, MousePoint)||GetCapture()==fs_data->hVolumeSlider){
GetWindowRect(hWnd(), &ControlWndRect);
if(PtInRect(&ControlWndRect, MousePoint)||GetCapture()==hVolumeSlider){
//do not allow control window to close while mouse is within
fs_data->NeedShowControls();
NeedShowControls();
}
else{
fs_data->NeedHideControls();
NeedHideControls();
}
break;
}
case 2:{
const VLCViewResources& rc = fs_data->RC();
LRESULT lResult = SendMessage(fs_data->hFSButton, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0);
if((HANDLE)lResult == rc.hDeFullscreenBitmap){
if(fs_data->_WindowsManager->getNewMessageFlag()){
SendMessage(fs_data->hFSButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)rc.hNewMessageBitmap);
//do not allow control window to close while there are new messages
fs_data->NeedShowControls();
}
}
else{
SendMessage(fs_data->hFSButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)rc.hDeFullscreenBitmap);
}
UpdateButtons();
break;
}
}
......@@ -501,7 +258,7 @@ LRESULT CALLBACK VLCFullScreenWnd::FSControlsWndWindowProc(HWND hWnd, UINT uMsg,
}
case WM_SETCURSOR:{
RECT VideoPosRect;
GetWindowRect(fs_data->hVideoPosScroll, &VideoPosRect);
GetWindowRect(hVideoPosScroll, &VideoPosRect);
DWORD dwMsgPos = GetMessagePos();
POINT MsgPosPoint = {LOWORD(dwMsgPos), HIWORD(dwMsgPos)};
if(PtInRect(&VideoPosRect, MsgPosPoint)){
......@@ -509,7 +266,7 @@ LRESULT CALLBACK VLCFullScreenWnd::FSControlsWndWindowProc(HWND hWnd, UINT uMsg,
return TRUE;
}