Tema: Re: Kaip sukurti iviki
Autorius: Kazius
Data: 2011-01-17 15:00:31
// Padariau su Visual Studio 2008, bet turetu veikti ir su Visual Studio 
2005

#include "stdafx.h"
#include <stdio.h>

[event_source(native)]
class CSource {
public:
   __event void MyEvent(int nValue);
};

[event_receiver(native)]
class CReceiver {
public:
   void MyHandler1(int nValue) {
    printf("New value: %d.\n", nValue);
   }

   void hookEvent(CSource* pSource) {
      __hook(&CSource::MyEvent, pSource, &CReceiver::MyHandler1);
   }

   void unhookEvent(CSource* pSource) {
      __unhook(&CSource::MyEvent, pSource, &CReceiver::MyHandler1);
   }
};

class SomeClass {
private:
 int _a;
 CSource source;
 CReceiver receiver;

public:
 SomeClass(int a) {
  receiver.hookEvent(&source);
  _a = a;
 }
 ~SomeClass() {
  receiver.unhookEvent(&source);
 }

 void AssignValueA(int a) {
  if (_a == a) return;

  _a = a;
  __raise source.MyEvent(a);
 }
};


int _tmain(int argc, _TCHAR* argv[])
{

 SomeClass* sc = new SomeClass(5);

 sc->AssignValueA(5);
 sc->AssignValueA(51);

 return 0;
}
"Valdas" <valdonas@super.lt> wrote in message 
news:ih1bmr$41l$1@trimpas.omnitel.net...
> Sveiki, reikalas ant Visual Studio 2005, yra kintamasis tarkim a, kaip 
> sukurti jam iviki, na tarkim ivikis pasileite a reiksme ?
>
> aciu
>