From: Gijs Vermeulen Subject: [PATCH v2] avicap32: Partially implement capCreateCaptureWindowW. Message-Id: <20210831181745.186552-1-gijsvrm@gmail.com> Date: Tue, 31 Aug 2021 20:17:45 +0200 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38011 Signed-off-by: Gijs Vermeulen --- dlls/avicap32/Makefile.in | 1 + dlls/avicap32/avicap32_main.c | 91 ++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 17 deletions(-) diff --git a/dlls/avicap32/Makefile.in b/dlls/avicap32/Makefile.in index 8f5a1089d5c..f320a58f04b 100644 --- a/dlls/avicap32/Makefile.in +++ b/dlls/avicap32/Makefile.in @@ -1,4 +1,5 @@ MODULE = avicap32.dll IMPORTLIB = avicap32 +IMPORTS = user32 C_SRCS = avicap32_main.c diff --git a/dlls/avicap32/avicap32_main.c b/dlls/avicap32/avicap32_main.c index 9e2a99d4c7c..3a421f330f4 100644 --- a/dlls/avicap32/avicap32_main.c +++ b/dlls/avicap32/avicap32_main.c @@ -56,36 +56,75 @@ WINE_DEFAULT_DEBUG_CHANNEL(avicap); +static WCHAR class_nameW[] = {'W','i','n','e','A','v','i','C','a','p','C','l','a','s','s',0}; + +static LRESULT CALLBACK avicap_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch(msg) + { + default: + if (msg >= WM_CAP_START && msg <= WM_CAP_END) + FIXME("Unhandled message %#x\n", msg); + return DefWindowProcW(hwnd, msg, wparam, lparam); + } +} + +static void register_class(void) +{ + WNDCLASSEXW class; + + class.cbSize = sizeof(WNDCLASSEXW); + class.style = 0; + class.lpfnWndProc = avicap_wndproc; + class.cbClsExtra = 0; + class.cbWndExtra = 0; + class.hInstance = GetModuleHandleW(NULL); + class.hIcon = NULL; + class.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW); + class.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); + class.lpszMenuName = NULL; + class.lpszClassName = class_nameW; + class.hIconSm = NULL; + + if (!RegisterClassExW(&class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) + ERR("Failed to register class!\n"); +} + +static void unregister_class(HINSTANCE instance) +{ + if (!UnregisterClassW(class_nameW, instance) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST) + ERR("Failed to unregister class!\n"); +} /*********************************************************************** * capCreateCaptureWindowW (AVICAP32.@) */ -HWND VFWAPI capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x, - INT y, INT nWidth, INT nHeight, HWND hWnd, - INT nID) +HWND VFWAPI capCreateCaptureWindowW(const WCHAR *window_name, DWORD style, INT x, + INT y, INT width, INT height, HWND hWnd, INT id) { - FIXME("(%s, %08x, %08x, %08x, %08x, %08x, %p, %08x): stub\n", - debugstr_w(lpszWindowName), dwStyle, x, y, nWidth, nHeight, hWnd, nID); - return 0; + FIXME("(%s, %08x, %08x, %08x, %08x, %08x, %p, %08x): semi-stub\n", + debugstr_w(window_name), style, x, y, width, height, hWnd, id); + + return CreateWindowExW(style, class_nameW, window_name, style, x, y, width, height, + hWnd, NULL, GetModuleHandleW(NULL), NULL); } /*********************************************************************** * capCreateCaptureWindowA (AVICAP32.@) */ -HWND VFWAPI capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, INT x, - INT y, INT nWidth, INT nHeight, HWND hWnd, - INT nID) -{ UNICODE_STRING nameW; - HWND retW; +HWND VFWAPI capCreateCaptureWindowA(const char *window_name, DWORD style, INT x, + INT y, INT width, INT height, HWND hWnd, INT id) +{ UNICODE_STRING window_nameW; + HWND ret; - if (lpszWindowName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszWindowName); - else nameW.Buffer = NULL; + if (window_name) RtlCreateUnicodeStringFromAsciiz(&window_nameW, window_name); + else window_nameW.Buffer = NULL; - retW = capCreateCaptureWindowW(nameW.Buffer, dwStyle, x, y, nWidth, nHeight, - hWnd, nID); - RtlFreeUnicodeString(&nameW); + ret = capCreateCaptureWindowW(window_nameW.Buffer, style, x, y, width, height, + hWnd, id); + RtlFreeUnicodeString(&window_nameW); - return retW; + return ret; } #ifdef HAVE_LINUX_VIDEODEV2_H @@ -195,3 +234,21 @@ BOOL VFWAPI capGetDriverDescriptionW(WORD wDriverIndex, LPWSTR lpszName, TRACE("Version: %s - Name: %s\n", debugstr_w(lpszVer), debugstr_w(lpszName)); return TRUE; } + +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) +{ + TRACE("(%p %d %p)\n", instance, reason, reserved); + + switch(reason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(instance); + register_class(); + break; + case DLL_PROCESS_DETACH: + if (reserved) break; + unregister_class(instance); + } + + return TRUE; +} -- 2.33.0