FuncPtr1 J/Direct Sample

This sample is located in \Samples\JDirect\Funcptr1.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

This sample shows how to use the com.ms.dll.Callback class to simulate function pointers in Java.

To create a function pointer in Java

  1. Write a class that derives from com.ms.dll.Callback.

  2. Implement a public method named callback (all lowercase).

    The callback method must be non-static, accept only integers as parameters, and return a value that has the integer, boolean, char, short, or void data type.

  3. Create an instance of your new class, and then pass it as the function pointer argument.

Using the Sample

To run the sample

Run Go.bat in the \Samples\JDirect\Funcptr1 directory.

Key Project Files

FuncPtr1.java

This class contains the following two classes:

Different calls to EnumWindows are likely to use different child classes, but they all derive from EnumWindowsProc. Therefore, they can use the common declaration of EnumWindows, which is prototyped to accept an EnumWindowsProc.

Technologies Demonstrated

Microsoft J/Direct

This sample shows how to:

© 1999 Microsoft Corporation. All rights reserved. Terms of use.