<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум Guardant &mdash; Помощь c non-Static CallBack]]></title>
	<link rel="self" href="https://forum.guardant.ru/feed/atom/topic/917" />
	<updated>2020-12-22T07:19:01Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.guardant.ru/topic/917/</id>
		<entry>
			<title type="html"><![CDATA[Re: Помощь c non-Static CallBack]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/4441/#p4441" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>aurusoft пишет:</cite><blockquote><p>Коллеги, может кому-то пригодится!</p><p>Вопрос решили по нестатической функции класса!</p><p>std::function&lt;void(HANDLE, int)&gt; _callback_prot;<br />extern &quot;C&quot; void _wrapper(HANDLE h, int v)<br />{<br />&nbsp; &nbsp;_callback_prot(h, v);<br />}<br />Class A{<br />&nbsp; &nbsp; // Dongle Notification CallBack routine<br />&nbsp; &nbsp;&nbsp; virtual void OnDongleCallback(&nbsp; &nbsp; HANDLE hGrd,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int nGrdNotifyMessage<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; } <br />&nbsp; &nbsp; bool RegisterCallback(void){<br />&nbsp; &nbsp; &nbsp; &nbsp;_callback_prot = std::bind(&amp;A::OnDongleCallback, this, _1, _2);<br />&nbsp; &nbsp; grdResult = ::GrdRegisterDongleNotification(grdHandle, _wrapper);<br />&nbsp; &nbsp; }<br />};</p><p>Всё работает!</p><p>Предлагаю включить в примеры работы на С++!</p><p>С уважением,<br />aurusoft@mail.ru</p></blockquote></div><p>Благодарим за обратную связь!</p>]]></content>
			<author>
				<name><![CDATA[Тимофей Ершов]]></name>
				<uri>https://forum.guardant.ru/user/1116/</uri>
			</author>
			<updated>2020-12-22T07:19:01Z</updated>
			<id>https://forum.guardant.ru/post/4441/#p4441</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помощь c non-Static CallBack]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/4440/#p4440" />
			<content type="html"><![CDATA[<p>Коллеги, может кому-то пригодится!</p><p>Вопрос решили по нестатической функции класса!</p><p>std::function&lt;void(HANDLE, int)&gt; _callback_prot;<br />extern &quot;C&quot; void _wrapper(HANDLE h, int v)<br />{<br />&nbsp; &nbsp;_callback_prot(h, v);<br />}<br />Class A{<br />&nbsp; &nbsp; // Dongle Notification CallBack routine<br />&nbsp; &nbsp;&nbsp; virtual void OnDongleCallback(&nbsp; &nbsp; HANDLE hGrd,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int nGrdNotifyMessage<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; } <br />&nbsp; &nbsp; bool RegisterCallback(void){<br />&nbsp; &nbsp; &nbsp; &nbsp;_callback_prot = std::bind(&amp;A::OnDongleCallback, this, _1, _2);<br />&nbsp; &nbsp; grdResult = ::GrdRegisterDongleNotification(grdHandle, _wrapper);<br />&nbsp; &nbsp; }<br />};</p><p>Всё работает!</p><p>Предлагаю включить в примеры работы на С++!</p><p>С уважением,<br />aurusoft@mail.ru</p>]]></content>
			<author>
				<name><![CDATA[aurusoft]]></name>
				<uri>https://forum.guardant.ru/user/1913/</uri>
			</author>
			<updated>2020-12-21T14:16:52Z</updated>
			<id>https://forum.guardant.ru/post/4440/#p4440</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помощь c non-Static CallBack]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/4439/#p4439" />
			<content type="html"><![CDATA[<p>Здравствуйте.</p><p>Спасибо за оперативный ответ!</p><p>Принято!</p><p>С уважением...</p>]]></content>
			<author>
				<name><![CDATA[aurusoft]]></name>
				<uri>https://forum.guardant.ru/user/1913/</uri>
			</author>
			<updated>2020-12-18T12:06:33Z</updated>
			<id>https://forum.guardant.ru/post/4439/#p4439</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помощь c non-Static CallBack]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/4438/#p4438" />
			<content type="html"><![CDATA[<p>Добрый день. У нас таких примеров нет (<a href="https://dev.guardant.ru/display/KB/0017">Рекомендации по работе с примерами</a>). Но похожие примеры можно найти в открытых источниках, например, <a href="https://stackoverflow.com/questions/3725425/class-method-as-winapi-callback">здесь</a>.</p>]]></content>
			<author>
				<name><![CDATA[Тимофей Ершов]]></name>
				<uri>https://forum.guardant.ru/user/1116/</uri>
			</author>
			<updated>2020-12-18T11:55:57Z</updated>
			<id>https://forum.guardant.ru/post/4438/#p4438</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Помощь c non-Static CallBack]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/4437/#p4437" />
			<content type="html"><![CDATA[<p>Здравствуйте.</p><p>Подробно:<br />Используем С++ (Win 10)</p><p>Имеется класс работы с Dongle. После переопределения функции и её описания в классе<br />Class A{<br />&nbsp; &nbsp; typedef void (A::*CallbackFun)(HANDLE, int);<br />&nbsp; &nbsp; void&nbsp; &nbsp;_OnDongleCallback( HANDLE hGrd,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Handle to Guardant protected container<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; int nGrdNotifyMessage<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; // Dongle notification message. See GrdNotifyMessage_XXX definition<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; } <br />&nbsp; &nbsp; bool RegisterCallback(){<br />&nbsp; &nbsp; &nbsp; &nbsp;CallbackFun _CallbackFun = &amp;A::_OnDongleCallback;<br />&nbsp; &nbsp; &nbsp; &nbsp; //_grdHandle - ключ корректный <br />&nbsp; &nbsp; &nbsp; &nbsp;_grdResult = ::GrdRegisterDongleNotification(_grdHandle, reinterpret_cast&lt;GrdDongleNotifyCallBack*&gt;(&amp;_CallbackFun) );<br />&nbsp; &nbsp; &nbsp; &nbsp; //_grdResult - Ошибок нет<br />&nbsp; &nbsp; }<br />}</p><p>Код отрабатывается хорошо. Но при изъятии ключа - происходит Exception!</p><p>Есть ли пример использования не СТАТИЧНОЙ CallBack функции класса при регистрации в GrdRegisterDongleNotification(...)?</p><p>Заранее благодарен...</p>]]></content>
			<author>
				<name><![CDATA[aurusoft]]></name>
				<uri>https://forum.guardant.ru/user/1913/</uri>
			</author>
			<updated>2020-12-17T17:09:29Z</updated>
			<id>https://forum.guardant.ru/post/4437/#p4437</id>
		</entry>
</feed>
