Add support for CCSelect sound
Guy L. Albertelli
galberte at neo.lrun.com
Sun Sep 29 23:26:15 CDT 2002
While pawing through a native control relay trace for Listview, I saw that on a LButtonDown message selecting a item, the system
played a sound. Tracing back it is due to the Sounds Control Panel item "Select" which is stored in the registery under "CCSelect".
So I implemented it as a general interface for the common controls.
License: X11
Changelog:
Guy Albertelli <<galberte at neo.lrun.com>>
dlls/comctl32/comctl32.h commctrl.c
- Implement routine to do the Common Control Select sound.
-------------- next part --------------
Index: dlls/comctl32/comctl32.h
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/comctl32.h,v
retrieving revision 1.18
diff -u -r1.18 comctl32.h
--- dlls/comctl32/comctl32.h 17 Sep 2002 18:30:07 -0000 1.18
+++ dlls/comctl32/comctl32.h 30 Sep 2002 04:07:54 -0000
@@ -122,9 +122,13 @@
extern COMCTL32_SysColor comctl32_color;
+/* handles of dlls to unload when we detach */
+extern HMODULE COMCTL32_winmm; /* handle of WINMM.DLL if loaded */
+
/* Internal function */
HWND COMCTL32_CreateToolTip (HWND);
VOID COMCTL32_RefreshSysColors(void);
+VOID COMCTL32_PlayCCSelectSound(void);
INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
-------------- next part --------------
Index: dlls/comctl32/commctrl.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/commctrl.c,v
retrieving revision 1.55
diff -u -r1.55 commctrl.c
--- dlls/comctl32/commctrl.c 17 Sep 2002 01:35:09 -0000 1.55
+++ dlls/comctl32/commctrl.c 30 Sep 2002 04:04:25 -0000
@@ -29,6 +29,7 @@
#define NO_SHLWAPI_STREAM
#include "shlwapi.h"
#include "comctl32.h"
+#include "mmsystem.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
@@ -75,6 +76,11 @@
extern void UPDOWN_Unregister(void);
+static BOOL (WINAPI *pPlaySoundW)(LPCWSTR, HMODULE, DWORD);
+static UINT (WINAPI *pwaveOutGetNumDevs)(void);
+
+static HMODULE COMCTL32_winmm = 0; /* handle of WINMM.DLL if loaded */
+
HANDLE COMCTL32_hHeap = (HANDLE)NULL;
LPSTR COMCTL32_aSubclass = (LPSTR)NULL;
HMODULE COMCTL32_hModule = 0;
@@ -167,6 +173,9 @@
TREEVIEW_Unregister ();
UPDOWN_Unregister ();
+ /* unload DLLs loaded by this DLL */
+ if(COMCTL32_winmm) FreeLibrary(COMCTL32_winmm);
+
/* delete local pattern brush */
DeleteObject (COMCTL32_hPattern55AABrush);
COMCTL32_hPattern55AABrush = (HANDLE)NULL;
@@ -1071,4 +1080,48 @@
comctl32_color.clrActiveCaption = GetSysColor (COLOR_ACTIVECAPTION);
comctl32_color.clrInfoBk = GetSysColor (COLOR_INFOBK);
comctl32_color.clrInfoText = GetSysColor (COLOR_INFOTEXT);
+}
+
+
+/***********************************************************************
+ * COMCTL32_PlayCCSelectSound [NOT AN API]
+ *
+ * Invoked to play the sound associated with the CCSelect event.
+ *
+ * PARAMS
+ * none
+ *
+ * RETURNS
+ * none
+ */
+static const WCHAR CCSelect_path[] = {'A','p','p','E','v','e','n','t','s','\\',
+ 'S','c','h','e','m','e','s','\\',
+ 'A','p','p','s','\\',
+ '.','D','e','f','a','u','l','t','\\',
+ 'C','C','S','e','l','e','c','t','\\',
+ '.','c','u','r','r','e','n','t',0};
+
+VOID
+COMCTL32_PlayCCSelectSound(void)
+{
+ HMODULE hwinmm;
+ WCHAR value[260];
+ LONG value_size = 260;
+
+
+ if(!RegQueryValueW(HKEY_CURRENT_USER, CCSelect_path,
+ (LPWSTR)&value, &value_size)) return;
+
+ if (!value_size) return;
+
+ if (!(hwinmm = GetModuleHandleA("winmm.dll"))) {
+ hwinmm = LoadLibraryA("winmm.dll");
+ COMCTL32_winmm = hwinmm;
+ }
+ pwaveOutGetNumDevs = (void*)GetProcAddress(hwinmm, "waveOutGetNumDevs");
+ pPlaySoundW = (void*)GetProcAddress(hwinmm, "PlaySoundW");
+
+ if(!pwaveOutGetNumDevs()) return;
+
+ pPlaySoundW(value, 0, SND_FILENAME|SND_ASYNC);
}
More information about the wine-patches
mailing list