create an event in internal queue
BlitzMax Forums/MaxGUI Module/create an event in internal queue
| ||
Hi I wonder if its possable to add my own events to the waitevent queue from within c. im currently writing a ftp client and have listbox item drag and drop between 2 listboxs and would like to add these events and hwnd pointers to the maxgui queue anyone done this or now if its possable without hacking maxgui mod? thanks kev |
| ||
Hi, try this: Test-File.bmx: Strict Framework brl.blitz Import brl.eventqueue 'You can see that it only needs the eventqueue module, 'the maxgui is actually not needed Import "Test-File.c" AddHook EmitEventHook , Func 'Add a hook to show that the events can also be 'received by using hooks CallCStuff 'go straight into c WaitEvent 'let's get an event from the queue WriteStdout "Event received by queue: " + CurrentEvent.ToString ( ) + "~n" Function Func:Object ( id , data:Object , context:Object ) WriteStdout "Event received by hooks: " + data.ToString ( ) + "~n" Return data EndFunction Extern Function CallCStuff ( ) EndExternTest-File.c: #define EVENT_GADGETACTION 0x2001 #define BBNULL &bbNullObject extern void * bbNullObject ; void * brl_event_CreateEvent ( int id , void * source , int data , int mods , int x , int y , void * extra ) ; void brl_event_EmitEvent ( void * event ) ; void CallCStuff ( ) { brl_event_EmitEvent ( brl_event_CreateEvent ( EVENT_GADGETACTION , BBNULL , 13 , 15 , 7 , 4 , BBNULL ) ) ; //I'm using some random numbers in the event's fields to show that there're really carried with }(I'm not the best c-programmer, I know... but it works) Of course you can post an event directly to the queue by calling PostEvent, however I suggest to use EmitEvent instead, which will post it to the queue as well, but also allows users using the hook-system to get these events. If it runs successfully, it should give this output: Building Test-File Compiling:Test-File.c Compiling:Test-File.bmx flat assembler version 1.66 3 passes, 2125 bytes. Linking:Test-File.debug.exe Executing:Test-File.debug.exe Event received by hooks: GadgetAction: data=13, mods=15, x=7, y=4, extra="" Event received by queue: GadgetAction: data=13, mods=15, x=7, y=4, extra="" Process completeI hope I could help you. |
| ||
thanks Fabian, this works like i hoped :) thanks again kev |