Ejemplo n.º 1
0
HDC CBufferedPaint::Begin(HDC hdc,const RECT *pRect,bool fErase)
{
	if (!BufferedPaintInitializer.IsInitialized())
		return NULL;

	if (m_hPaintBuffer!=NULL) {
		if (!End(false))
			return NULL;
	}

#ifdef WIN_XP_SUPPORT
	auto pBeginBufferedPaint=
		GET_LIBRARY_FUNCTION(BufferedPaintInitializer.m_hThemeLib,BeginBufferedPaint);
	if (pBeginBufferedPaint==NULL)
		return NULL;
#endif

	BP_PAINTPARAMS Params={sizeof(BP_PAINTPARAMS),0,NULL,NULL};
	if (fErase)
		Params.dwFlags|=BPPF_ERASE;
	HDC hdcBuffer;
	m_hPaintBuffer=
#ifdef WIN_XP_SUPPORT
		pBeginBufferedPaint
#else
		::BeginBufferedPaint
#endif
			(hdc,pRect,BPBF_TOPDOWNDIB,&Params,&hdcBuffer);
	if (m_hPaintBuffer==NULL)
		return NULL;
	return hdcBuffer;
}
Ejemplo n.º 2
0
	~CBufferedPaintInitializer()
	{
		if (m_hThemeLib!=NULL) {
			auto pBufferedPaintUnInit=GET_LIBRARY_FUNCTION(m_hThemeLib,BufferedPaintUnInit);
			if (pBufferedPaintUnInit!=NULL)
				pBufferedPaintUnInit();
			::FreeLibrary(m_hThemeLib);
		}
	}
Ejemplo n.º 3
0
bool CBufferedPaint::SetAlpha(BYTE Alpha)
{
	if (m_hPaintBuffer==NULL)
		return false;
#ifdef WIN_XP_SUPPORT
	auto pBufferedPaintSetAlpha=
		GET_LIBRARY_FUNCTION(BufferedPaintInitializer.m_hThemeLib,BufferedPaintSetAlpha);
	if (pBufferedPaintSetAlpha==NULL)
		return false;
	return pBufferedPaintSetAlpha(m_hPaintBuffer,NULL,Alpha)==S_OK;
#else
	return ::BufferedPaintSetAlpha(m_hPaintBuffer,NULL,Alpha)==S_OK;
#endif
}
Ejemplo n.º 4
0
bool CBufferedPaint::Clear(const RECT *pRect)
{
	if (m_hPaintBuffer==NULL)
		return false;
#ifdef WIN_XP_SUPPORT
	auto pBufferedPaintClear=
		GET_LIBRARY_FUNCTION(BufferedPaintInitializer.m_hThemeLib,BufferedPaintClear);
	if (pBufferedPaintClear==NULL)
		return false;
	return pBufferedPaintClear(m_hPaintBuffer,pRect)==S_OK;
#else
	return ::BufferedPaintClear(m_hPaintBuffer,pRect)==S_OK;
#endif
}
Ejemplo n.º 5
0
bool CDirectWriteSystem::Initialize()
{
	if (m_hD2DLib == nullptr) {
		m_hD2DLib = Util::LoadSystemLibrary(TEXT("d2d1.dll"));
		if (m_hD2DLib == nullptr)
			return false;
	}

	if (m_hDWriteLib == nullptr) {
		m_hDWriteLib = Util::LoadSystemLibrary(TEXT("dwrite.dll"));
		if (m_hDWriteLib == nullptr)
			return false;
	}

	if (m_pD2DFactory == nullptr) {
		typedef HRESULT (WINAPI *D2D1CreateFactoryFunc)(
			D2D1_FACTORY_TYPE factoryType,
			REFIID riid,
			const D2D1_FACTORY_OPTIONS *pFactoryOptions,
			void **ppIFactory);
		D2D1CreateFactoryFunc pD2D1CreateFactory =
			reinterpret_cast<D2D1CreateFactoryFunc>(::GetProcAddress(m_hD2DLib, "D2D1CreateFactory"));
		if (pD2D1CreateFactory == nullptr)
			return false;
		HRESULT hr = pD2D1CreateFactory(
			D2D1_FACTORY_TYPE_SINGLE_THREADED,
			__uuidof(ID2D1Factory),
			nullptr,
			reinterpret_cast<void**>(&m_pD2DFactory));
		if (FAILED(hr))
			return false;
	}

	if (m_pDWriteFactory == nullptr) {
		auto pDWriteCreateFactory =
			GET_LIBRARY_FUNCTION(m_hDWriteLib, DWriteCreateFactory);
		if (pDWriteCreateFactory == nullptr)
			return false;
		HRESULT hr = pDWriteCreateFactory(
			DWRITE_FACTORY_TYPE_SHARED,
			__uuidof(IDWriteFactory),
			reinterpret_cast<IUnknown**>(&m_pDWriteFactory));
		if (FAILED(hr))
			return false;
	}

	return true;
}
Ejemplo n.º 6
0
// コンポジションが有効か取得する
bool CAeroGlass::IsEnabled()
{
	BOOL fEnabled;

#ifdef WIN_XP_SUPPORT
	if (!LoadDwmLib())
		return false;

	auto pIsCompositionEnabled=GET_LIBRARY_FUNCTION(m_hDwmLib,DwmIsCompositionEnabled);

	return pIsCompositionEnabled!=NULL
		&& pIsCompositionEnabled(&fEnabled)==S_OK && fEnabled;
#else
	return ::DwmIsCompositionEnabled(&fEnabled)==S_OK && fEnabled;
#endif
}
Ejemplo n.º 7
0
bool CBufferedPaint::End(bool fUpdate)
{
	if (m_hPaintBuffer!=NULL) {
#ifdef WIN_XP_SUPPORT
		auto pEndBufferedPaint=
			GET_LIBRARY_FUNCTION(BufferedPaintInitializer.m_hThemeLib,EndBufferedPaint);
		if (pEndBufferedPaint==NULL)
			return false;
		pEndBufferedPaint(m_hPaintBuffer,fUpdate);
#else
		::EndBufferedPaint(m_hPaintBuffer,fUpdate);
#endif
		m_hPaintBuffer=NULL;
	}
	return true;
}
Ejemplo n.º 8
0
// フレームの描画を無効にする
bool CAeroGlass::EnableNcRendering(HWND hwnd,bool fEnable)
{
	DWMNCRENDERINGPOLICY ncrp=fEnable?DWMNCRP_USEWINDOWSTYLE:DWMNCRP_DISABLED;

#ifdef WIN_XP_SUPPORT
	if (!LoadDwmLib())
		return false;

	auto pSetWindowAttribute=GET_LIBRARY_FUNCTION(m_hDwmLib,DwmSetWindowAttribute);
	if (pSetWindowAttribute==NULL)
		return false;

	return pSetWindowAttribute(hwnd,DWMWA_NCRENDERING_POLICY,&ncrp,sizeof(ncrp))==S_OK;
#else
	return ::DwmSetWindowAttribute(hwnd,DWMWA_NCRENDERING_POLICY,&ncrp,sizeof(ncrp))==S_OK;
#endif
}
Ejemplo n.º 9
0
	bool Initialize()
	{
		if (m_hThemeLib==NULL) {
			if (!Util::OS::IsWindowsVistaOrLater())
				return false;
			m_hThemeLib=Util::LoadSystemLibrary(TEXT("uxtheme.dll"));
			if (m_hThemeLib!=NULL) {
				auto pBufferedPaintInit=GET_LIBRARY_FUNCTION(m_hThemeLib,BufferedPaintInit);
				if (pBufferedPaintInit==NULL
						|| pBufferedPaintInit()!=S_OK) {
					TRACE(TEXT("BufferedPaintInit() Failed\n"));
					::FreeLibrary(m_hThemeLib);
					m_hThemeLib=NULL;
					return false;
				}
			}
		}
		return true;
	}
Ejemplo n.º 10
0
// クライアント領域を透けさせる
bool CAeroGlass::ApplyAeroGlass(HWND hwnd,const RECT *pRect)
{
	if (!IsEnabled())
		return false;

#ifdef WIN_XP_SUPPORT
	auto pExtendFrame=GET_LIBRARY_FUNCTION(m_hDwmLib,DwmExtendFrameIntoClientArea);
	if (pExtendFrame==NULL)
		return false;
#endif

	MARGINS Margins;

	Margins.cxLeftWidth=pRect->left;
	Margins.cxRightWidth=pRect->right;
	Margins.cyTopHeight=pRect->top;
	Margins.cyBottomHeight=pRect->bottom;

#ifdef WIN_XP_SUPPORT
	return pExtendFrame(hwnd,&Margins)==S_OK;
#else
	return ::DwmExtendFrameIntoClientArea(hwnd,&Margins)==S_OK;
#endif
}
Ejemplo n.º 11
0
int InitialiseOPAL()
{
  OpalMessage   command;
  OpalMessage * response;
  unsigned      version;


  if ((hDLL = OPEN_LIBRARY(OPAL_DLL)) == NULL) {
    fprintf(stderr, "Could not file %s\n", OPAL_DLL);
    return 0;
  }

  InitialiseFunction  = (OpalInitialiseFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_INITIALISE_FUNCTION  );
  ShutDownFunction    = (OpalShutDownFunction   )GET_LIBRARY_FUNCTION(hDLL, OPAL_SHUTDOWN_FUNCTION    );
  GetMessageFunction  = (OpalGetMessageFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_GET_MESSAGE_FUNCTION );
  SendMessageFunction = (OpalSendMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_SEND_MESSAGE_FUNCTION);
  FreeMessageFunction = (OpalFreeMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_FREE_MESSAGE_FUNCTION);

  if (InitialiseFunction  == NULL ||
      ShutDownFunction    == NULL ||
      GetMessageFunction  == NULL ||
      SendMessageFunction == NULL ||
      FreeMessageFunction == NULL) {
    fputs("OPAL.DLL is invalid\n", stderr);
    return 0;
  }


  ///////////////////////////////////////////////
  // Initialisation

#if LOCAL_MEDIA
  #define LOCAL_PREFIX OPAL_PREFIX_LOCAL
#else
  #define LOCAL_PREFIX OPAL_PREFIX_PCSS
#endif

  version = OPAL_C_API_VERSION;
  if ((hOPAL = InitialiseFunction(&version,
                                  OPAL_PREFIX_H323  " "
                                  OPAL_PREFIX_SIP   " "
                                  OPAL_PREFIX_IAX2  " "
                                  LOCAL_PREFIX
                                  " TraceLevel=4")) == NULL) {
    fputs("Could not initialise OPAL\n", stderr);
    return 0;
  }


  // General options
  memset(&command, 0, sizeof(command));
  command.m_type = OpalCmdSetGeneralParameters;
  //command.m_param.m_general.m_audioRecordDevice = "Camera Microphone (2- Logitech";
  command.m_param.m_general.m_autoRxMedia = command.m_param.m_general.m_autoTxMedia = "audio";

#if LOCAL_MEDIA
  command.m_param.m_general.m_mediaReadData = MyReadMediaData;
  command.m_param.m_general.m_mediaWriteData = MyWriteMediaData;
  command.m_param.m_general.m_mediaDataHeader = OpalMediaDataPayloadOnly;
#endif

  if ((response = MySendCommand(&command, "Could not set general options")) == NULL)
    return 0;

  FreeMessageFunction(response);

  // Options across all protocols
  memset(&command, 0, sizeof(command));
  command.m_type = OpalCmdSetProtocolParameters;

  command.m_param.m_protocol.m_name = "robertj";
  command.m_param.m_protocol.m_displayName = "Robert Jongbloed";
  command.m_param.m_protocol.m_interfaceAddresses = "*";

  if ((response = MySendCommand(&command, "Could not set protocol options")) == NULL)
    return 0;

  FreeMessageFunction(response);

  return 1;
}
Ejemplo n.º 12
0
int InitialiseOPAL()
{
    OpalMessage   command;
    OpalMessage * response;
    unsigned      version;


    if ((hDLL = OPEN_LIBRARY(OPAL_DLL)) == NULL) {
        fprintf(stderr, "Could not file %s\n", OPAL_DLL);
        return 0;
    }

    InitialiseFunction  = (OpalInitialiseFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_INITIALISE_FUNCTION  );
    ShutDownFunction    = (OpalShutDownFunction   )GET_LIBRARY_FUNCTION(hDLL, OPAL_SHUTDOWN_FUNCTION    );
    GetMessageFunction  = (OpalGetMessageFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_GET_MESSAGE_FUNCTION );
    SendMessageFunction = (OpalSendMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_SEND_MESSAGE_FUNCTION);
    FreeMessageFunction = (OpalFreeMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_FREE_MESSAGE_FUNCTION);

    if (InitialiseFunction  == NULL ||
            ShutDownFunction    == NULL ||
            GetMessageFunction  == NULL ||
            SendMessageFunction == NULL ||
            FreeMessageFunction == NULL) {
        fputs("OPAL.DLL is invalid\n", stderr);
        return 0;
    }


    ///////////////////////////////////////////////
    // Initialisation

    version = OPAL_C_API_VERSION;
    if ((hOPAL = InitialiseFunction(&version, "pc h323 sip TraceLevel=4")) == NULL) {
        fputs("Could not initialise OPAL\n", stderr);
        return 0;
    }


    // General options
    memset(&command, 0, sizeof(command));
    command.m_type = OpalCmdSetGeneralParameters;

    if ((response = MySendCommand(&command, "Could not set general options")) == NULL)
        return 0;

    FreeMessageFunction(response);

    // Options across all protocols
    memset(&command, 0, sizeof(command));
    command.m_type = OpalCmdSetProtocolParameters;

    command.m_param.m_protocol.m_name = "robertj";
    command.m_param.m_protocol.m_displayName = "Robert Jongbloed";
    command.m_param.m_protocol.m_interfaceAddresses = "*";

    if ((response = MySendCommand(&command, "Could not set protocol options")) == NULL)
        return 0;

    FreeMessageFunction(response);

    return 1;
}
Ejemplo n.º 13
0
Archivo: main.c Proyecto: VVer/opal
int InitialiseOPAL()
{
  OpalMessage   command;
  OpalMessage * response;
  unsigned      version;

  static const char OPALOptions[] = OPAL_PREFIX_H323  " "
                                    OPAL_PREFIX_SIP   " "
                                    OPAL_PREFIX_IAX2  " "
#if LOCAL_MEDIA
                                    OPAL_PREFIX_LOCAL
#else
                                    OPAL_PREFIX_PCSS
#endif
                                                      " "
                                    OPAL_PREFIX_IVR
                                    " TraceLevel=4 TraceFile=debugstream";


  if ((hDLL = OPEN_LIBRARY(OPAL_DLL)) == NULL) {
    fprintf(stderr, "Could not file %s\n", OPAL_DLL);
    return 0;
  }

  InitialiseFunction  = (OpalInitialiseFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_INITIALISE_FUNCTION  );
  ShutDownFunction    = (OpalShutDownFunction   )GET_LIBRARY_FUNCTION(hDLL, OPAL_SHUTDOWN_FUNCTION    );
  GetMessageFunction  = (OpalGetMessageFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_GET_MESSAGE_FUNCTION );
  SendMessageFunction = (OpalSendMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_SEND_MESSAGE_FUNCTION);
  FreeMessageFunction = (OpalFreeMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_FREE_MESSAGE_FUNCTION);

  if (InitialiseFunction  == NULL ||
      ShutDownFunction    == NULL ||
      GetMessageFunction  == NULL ||
      SendMessageFunction == NULL ||
      FreeMessageFunction == NULL) {
    fputs("OPAL.DLL is invalid\n", stderr);
    return 0;
  }


  ///////////////////////////////////////////////
  // Initialisation

  version = OPAL_C_API_VERSION;
  if ((hOPAL = InitialiseFunction(&version, OPALOptions)) == NULL) {
    fputs("Could not initialise OPAL\n", stderr);
    return 0;
  }

#if 0
  // Test shut down and re-initialisation
  ShutDownFunction(hOPAL);
  if ((hOPAL = InitialiseFunction(&version, OPALOptions)) == NULL) {
    fputs("Could not re-initialise OPAL\n", stderr);
    return 0;
  }
#endif


  // General options
  memset(&command, 0, sizeof(command));
  command.m_type = OpalCmdSetGeneralParameters;
  //command.m_param.m_general.m_audioRecordDevice = "Camera Microphone (2- Logitech";
  command.m_param.m_general.m_autoRxMedia = command.m_param.m_general.m_autoTxMedia = "audio";
  command.m_param.m_general.m_stunServer = "stun.voxgratia.org";
  command.m_param.m_general.m_mediaMask = "RFC4175*";

#if LOCAL_MEDIA
  command.m_param.m_general.m_mediaReadData = MyReadMediaData;
  command.m_param.m_general.m_mediaWriteData = MyWriteMediaData;
  command.m_param.m_general.m_mediaDataHeader = OpalMediaDataPayloadOnly;
#endif

  if ((response = MySendCommand(&command, "Could not set general options")) == NULL)
    return 0;

  FreeMessageFunction(response);

  // Options across all protocols
  memset(&command, 0, sizeof(command));
  command.m_type = OpalCmdSetProtocolParameters;

  command.m_param.m_protocol.m_userName = "******";
  command.m_param.m_protocol.m_displayName = "Robert Jongbloed";
  command.m_param.m_protocol.m_interfaceAddresses = "*";

  if ((response = MySendCommand(&command, "Could not set protocol options")) == NULL)
    return 0;

  FreeMessageFunction(response);

  memset(&command, 0, sizeof(command));
  command.m_type = OpalCmdSetProtocolParameters;

  command.m_param.m_protocol.m_prefix = "sip";
  command.m_param.m_protocol.m_defaultOptions = "PRACK-Mode=0\nInitial-Offer=false";

  if ((response = MySendCommand(&command, "Could not set SIP options")) == NULL)
    return 0;

  FreeMessageFunction(response);

  return 1;
}