2 * Copyright 2002 Dmitry Timoshkov for CodeWeavers
3 * Copyright 2005 Maarten Lankhorst
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(avicap
);
33 static HINSTANCE avicap_instance
;
34 static unixlib_handle_t unix_handle
;
36 static const WCHAR class_name
[] = L
"wine_avicap_class";
38 static LRESULT CALLBACK
avicap_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
43 if (msg
>= WM_CAP_START
&& msg
<= WM_CAP_END
)
44 FIXME("Unhandled message %#x.\n", msg
);
45 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
49 static void register_class(void)
53 .cbSize
= sizeof(WNDCLASSEXW
),
54 .lpfnWndProc
= avicap_wndproc
,
55 .hInstance
= avicap_instance
,
56 .hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
),
57 .hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1),
58 .lpszClassName
= class_name
,
61 if (!RegisterClassExW(&class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS
)
62 ERR("Failed to register class, error %lu.\n", GetLastError());
65 static void unregister_class(void)
67 if (!UnregisterClassW(class_name
, avicap_instance
) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST
)
68 ERR("Failed to unregister class, error %lu.\n", GetLastError());
71 /***********************************************************************
72 * capCreateCaptureWindowW (AVICAP32.@)
74 HWND VFWAPI
capCreateCaptureWindowW(const WCHAR
*window_name
, DWORD style
,
75 int x
, int y
, int width
, int height
, HWND parent
, int id
)
77 TRACE("window_name %s, style %#lx, x %d, y %d, width %d, height %d, parent %p, id %#x.\n",
78 debugstr_w(window_name
), style
, x
, y
, width
, height
, parent
, id
);
80 return CreateWindowW(class_name
, window_name
, style
, x
, y
, width
, height
, parent
, NULL
, avicap_instance
, NULL
);
83 /***********************************************************************
84 * capCreateCaptureWindowA (AVICAP32.@)
86 HWND VFWAPI
capCreateCaptureWindowA(const char *window_name
, DWORD style
,
87 int x
, int y
, int width
, int height
, HWND parent
, int id
)
93 RtlCreateUnicodeStringFromAsciiz(&nameW
, window_name
);
97 window
= capCreateCaptureWindowW(nameW
.Buffer
, style
, x
, y
, width
, height
, parent
, id
);
98 RtlFreeUnicodeString(&nameW
);
103 /***********************************************************************
104 * capGetDriverDescriptionA (AVICAP32.@)
106 BOOL VFWAPI
capGetDriverDescriptionA(WORD wDriverIndex
, LPSTR lpszName
,
107 INT cbName
, LPSTR lpszVer
, INT cbVer
)
110 WCHAR devname
[CAP_DESC_MAX
], devver
[CAP_DESC_MAX
];
111 TRACE("--> capGetDriverDescriptionW\n");
112 retval
= capGetDriverDescriptionW(wDriverIndex
, devname
, CAP_DESC_MAX
, devver
, CAP_DESC_MAX
);
114 WideCharToMultiByte(CP_ACP
, 0, devname
, -1, lpszName
, cbName
, NULL
, NULL
);
115 WideCharToMultiByte(CP_ACP
, 0, devver
, -1, lpszVer
, cbVer
, NULL
, NULL
);
120 /***********************************************************************
121 * capGetDriverDescriptionW (AVICAP32.@)
123 BOOL VFWAPI
capGetDriverDescriptionW(WORD index
, WCHAR
*name
, int name_len
, WCHAR
*version
, int version_len
)
125 struct get_device_desc_params params
;
127 params
.index
= index
;
128 if (!unix_handle
|| __wine_unix_call(unix_handle
, unix_get_device_desc
, ¶ms
))
131 TRACE("Found device name %s, version %s.\n", debugstr_w(params
.name
), debugstr_w(params
.version
));
132 lstrcpynW(name
, params
.name
, name_len
);
133 lstrcpynW(version
, params
.version
, version_len
);
137 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
141 case DLL_PROCESS_ATTACH
:
142 NtQueryVirtualMemory(GetCurrentProcess(), instance
,
143 MemoryWineUnixFuncs
, &unix_handle
, sizeof(unix_handle
), NULL
);
144 DisableThreadLibraryCalls(instance
);
146 avicap_instance
= instance
;
149 case DLL_PROCESS_DETACH
: