Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

How to create a Basic4ppc library

Reply
 
LinkBack Thread Tools Display Modes
  #121 (permalink)  
Old 05-17-2011, 08:28 PM
Knows the basics
 
Join Date: Aug 2010
Location: Russia
Posts: 64
Default

Please, help me with events...

I created C# DLL with simple class for testing event:
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace EventHandlersTest
{
    public delegate void MyEventHandler();
        
    public class MyEvent
    {
        public event MyEventHandler SomeEvent;

        public void OnSomeEvent()
        {
            
if (SomeEvent != null)
                SomeEvent();
        }

        public void Test(
int X)
        {
                
if (X == 10)
                    OnSomeEvent();
        }
    }
}
B4PPC code:
(ME - MyEvent.dll)
Code:
Sub App_Start
   Form1.Show
   ME.New1
End Sub

Sub Button1_Click
  ME.Test(
10)
End Sub

Sub ME_OnSomeEvent
  
Msgbox("SomeEvent!")
End Sub
But, if I clicked on Button1, event OnSomeEvent doesn't work.
How to correct?
Reply With Quote
  #122 (permalink)  
Old 05-18-2011, 06:23 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

See how it is done in the example in the first post: http://www.basic4ppc.com/forum/code-...c-library.html
Reply With Quote
  #123 (permalink)  
Old 05-18-2011, 04:51 PM
Knows the basics
 
Join Date: Aug 2010
Location: Russia
Posts: 64
Default

Erel, unfortunately, still it is not clear... In an example, event is anchored to already available event of ScrollBar, but in my case, event is required for the self class. I tried various variants, but I receive either an error, or event doesn't work in B4PPC...
I will be grateful, if somebody helps with example on a C #.
Reply With Quote
  #124 (permalink)  
Old 05-18-2011, 06:08 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Like this I think. Compare it to the ScrollBar code.

Code:
namespace EventHandlersTest
{
         // at runtime tells Basic4ppc what event has occurred
        private 
object[] SomeEventEventObject;

 
        // at compile times identifies the event 
to Basic4ppc
        // at runtime Basic4ppc sets this 
to its event handler
       public event EventHandler SomeEvent; 

      
        public class MyEvent
        {
            SomeEventEventObject = new 
object[] { this, "SomeEvent" };
        }

        public void OnSomeEvent()
        {
            
if (SomeEvent != null)
                SomeEvent();
        }

        public void Test(
int X)
        {
                
if (X == 10)
                    OnSomeEvent();
        }
    }
}
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #125 (permalink)  
Old 05-18-2011, 07:33 PM
Knows the basics
 
Join Date: Aug 2010
Location: Russia
Posts: 64
Default

agraham, Your example isn't compiled (~4 errors)
My project (VS 2008) in attach.
Attached Files
File Type: zip EventHandlersTEst.zip (16.1 KB, 7 views)
Reply With Quote
  #126 (permalink)  
Old 05-18-2011, 08:14 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Sorry, I knocked it up from memory without testing it, but it's really not complicated.

Code:
    public class MyEvent
{
    private 
object[] SomeEventEventObject;
    public event EventHandler SomeEvent;

   public MyEvent()
    {
         SomeEventEventObject = new 
object[] { this, "SomeEvent" };
    }

    public void OnSomeEvent()
    {
        
if (SomeEvent != null)
            SomeEvent(SomeEventEventObject, 
null); 
    }

    public void Test(
int X)
    {
        
if (X == 10)
            OnSomeEvent();
    } 

}
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #127 (permalink)  
Old 05-19-2011, 05:27 PM
Knows the basics
 
Join Date: Aug 2010
Location: Russia
Posts: 64
Thumbs up

agraham, many thanks!
All perfectly works! All problems was here -
Code:
SomeEvent(SomeEventEventObject, null);
I did a call SomeEvent() without arguments...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use basic4ppc to create a Bluetooth middleware solution? Olav Questions (Windows Mobile) 1 09-22-2008 11:21 AM
How to create a new appointment willisgt Questions (Windows Mobile) 2 05-15-2008 08:21 PM
how to create a database ? gjoisa Questions (Windows Mobile) 27 02-14-2008 05:38 PM
Can you help me create B4P lib? conf Questions (Windows Mobile) 7 08-20-2007 07:41 PM
Table create with no data tvrman Questions (Windows Mobile) 4 06-25-2007 08:46 PM


All times are GMT. The time now is 10:14 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0