Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pch.h « sanear-dll « src « dll - github.com/mpc-hc/sanear.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2566298bf41f64782ced018fa5e187bd5a36db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include "../../../src/pch.h"

#include <Commctrl.h>
#include <VersionHelpers.h>

namespace SaneAudioRenderer
{
    template <class T, DWORD(T::*ThreadProc)() = &T::ThreadProc>
    unsigned CALLBACK StaticThreadProc(LPVOID p)
    {
        return (static_cast<T*>(p)->*ThreadProc)();
    }

    template <class T, LRESULT(T::*WindowProc)(HWND, UINT, WPARAM, LPARAM) = &T::WindowProc>
    LRESULT CALLBACK StaticWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        if (LONG_PTR userData = GetWindowLongPtr(hWnd, GWLP_USERDATA))
            return (reinterpret_cast<T*>(userData)->*WindowProc)(hWnd, msg, wParam, lParam);

        if (msg == WM_NCCREATE)
        {
            CREATESTRUCT* pCreateStruct = reinterpret_cast<CREATESTRUCT*>(lParam);
            SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pCreateStruct->lpCreateParams));
            return (static_cast<T*>(pCreateStruct->lpCreateParams)->*WindowProc)(hWnd, msg, wParam, lParam);
        }

        return DefWindowProc(hWnd, msg, wParam, lParam);
    }

    inline void RunMessageLoop()
    {
        MSG msg;
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
}

_COM_SMARTPTR_TYPEDEF(IFilterMapper2, __uuidof(IFilterMapper2));