Gijs Vermeulen : avicap32: Partially implement capCreateCaptureWindowW.
Alexandre Julliard
julliard at winehq.org
Thu Sep 2 15:45:30 CDT 2021
Module: wine
Branch: master
Commit: b755d58b13e7c5b61ba7c78b9402b2c919d57b58
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b755d58b13e7c5b61ba7c78b9402b2c919d57b58
Author: Gijs Vermeulen <gijsvrm at gmail.com>
Date: Wed Sep 1 15:56:47 2021 -0500
avicap32: Partially implement capCreateCaptureWindowW.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38011
Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/avicap32/Makefile.in | 1 +
dlls/avicap32/avicap32_main.c | 76 ++++++++++++++++++++++++++++++++++---------
2 files changed, 61 insertions(+), 16 deletions(-)
diff --git a/dlls/avicap32/Makefile.in b/dlls/avicap32/Makefile.in
index a899a6207b0..b74c4726e8b 100644
--- a/dlls/avicap32/Makefile.in
+++ b/dlls/avicap32/Makefile.in
@@ -1,5 +1,6 @@
MODULE = avicap32.dll
IMPORTLIB = avicap32
+IMPORTS = user32
EXTRALIBS = -Wl,--subsystem,unixlib
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/avicap32/avicap32_main.c b/dlls/avicap32/avicap32_main.c
index d4608138d8b..3ce9d5240b8 100644
--- a/dlls/avicap32/avicap32_main.c
+++ b/dlls/avicap32/avicap32_main.c
@@ -30,37 +30,74 @@
WINE_DEFAULT_DEBUG_CHANNEL(avicap);
+static HINSTANCE avicap_instance;
static unixlib_handle_t unix_handle;
+static const WCHAR class_name[] = L"wine_avicap_class";
+
+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 =
+ {
+ .cbSize = sizeof(WNDCLASSEXW),
+ .lpfnWndProc = avicap_wndproc,
+ .hInstance = avicap_instance,
+ .hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW),
+ .hbrBackground = (HBRUSH)(COLOR_BTNFACE+1),
+ .lpszClassName = class_name,
+ };
+
+ if (!RegisterClassExW(&class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
+ ERR("Failed to register class, error %u.\n", GetLastError());
+}
+
+static void unregister_class(void)
+{
+ if (!UnregisterClassW(class_name, avicap_instance) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST)
+ ERR("Failed to unregister class, error %u.\n", GetLastError());
+}
+
/***********************************************************************
* 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 parent, 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;
+ TRACE("window_name %s, style %#x, x %d, y %d, width %d, height %d, parent %p, id %#x.\n",
+ debugstr_w(window_name), style, x, y, width, height, parent, id);
+
+ return CreateWindowW(class_name, window_name, style, x, y, width, height, parent, NULL, avicap_instance, 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 parent, int id)
+{
+ UNICODE_STRING nameW;
+ HWND window;
- if (lpszWindowName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszWindowName);
- else nameW.Buffer = NULL;
+ if (window_name)
+ RtlCreateUnicodeStringFromAsciiz(&nameW, window_name);
+ else
+ nameW.Buffer = NULL;
- retW = capCreateCaptureWindowW(nameW.Buffer, dwStyle, x, y, nWidth, nHeight,
- hWnd, nID);
+ window = capCreateCaptureWindowW(nameW.Buffer, style, x, y, width, height, parent, id);
RtlFreeUnicodeString(&nameW);
- return retW;
+ return window;
}
/***********************************************************************
@@ -105,6 +142,13 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
NtQueryVirtualMemory(GetCurrentProcess(), instance,
MemoryWineUnixFuncs, &unix_handle, sizeof(unix_handle), NULL);
DisableThreadLibraryCalls(instance);
+ register_class();
+ avicap_instance = instance;
+ break;
+
+ case DLL_PROCESS_DETACH:
+ if (!reserved)
+ unregister_class();
break;
}
More information about the wine-cvs
mailing list