Re: Need help in calling VBX/OCX from Developer/2000 forms 4.5

From: Tim McConechy <tmcconec_at_gulf.uvic.ca>
Date: 1997/11/27
Message-ID: <347DC4A8.6622F3EC_at_gulf.uvic.ca>#1/1


Here is a bit of code to use an VBX.
This particular one is for a barcode.vbx that reads a barcode so ista little complicated
Comments are marked with a **********comment************* 1) In layout edit add a VBX to the form.

   Right click it and insert object. Find your OCX control. 2)Add a button.
3) Put code like belo on the when button pressed.

declare
**You need this handle function and the status pls_intergers which are returned from the ocx calls******
  bar_handle ole2.obj_type;
  tiff_handle ole2.obj_type;
  status pls_integer;
  bmHandle pls_integer;
  ax11_dpix pls_integer;
  ax11_dpiy pls_integer;
begin
--Here I open up two OCX my block is called scan and the two ocx's are
--barcode reader and tiff_reader

  bar_handle := forms_ole.get_interface_pointer('scan.barcode_reader');   tiff_handle := forms_ole.get_interface_pointer('scan.tiff_reader');

  • open a TIFF file for input
    --set property sets the property readfile name specific to the control
    --see your controls help file there should be one
    --for a list of methods and properties
    ole2.set_property(tiff_handle, 'ReadFileName', 'c:\temp\scan.tif');
    --Here I envoke the method
    status := ole2.invoke_num(tiff_handle, 'ReadTiff');
    --status returns a value from the pcx see its help file again
    if status != 0 then message('file reading ERROR!'); end if;

 --another example
  bmHandle := ole2.get_num_property(tiff_handle, 'ReadBitmap');   if bmHandle = 0 then
    message('open a TIFF file first!');
  else
--just obtain the return value from a property. this one returns an
integer

    ax11_dpix := ole2.get_num_property(tiff_handle, 'ReadDpiX');     ax11_dpiy := ole2.get_num_property(tiff_handle, 'ReadDpiY');
--setting a whole bunch of properties

    ole2.set_property(bar_handle, 'Bitmap', bmHandle);
    ole2.set_property(bar_handle, 'DpiX', ax11_dpix);
    ole2.set_property(bar_handle, 'DpiY', ax11_dpiy);
    ole2.set_property(bar_handle, 'ReadMultipleEnable', 0);
    ole2.set_property(bar_handle, 'ReadTypeCode128', 0);
    ole2.set_property(bar_handle, 'ReadTypeCode39', -1);
    ole2.set_property(bar_handle, 'ReadTypeEan13', 0);
    ole2.set_property(bar_handle, 'ReadTypeEan8', 0);
    ole2.set_property(bar_handle, 'ReadTypeUpca',0);
    ole2.set_property(bar_handle, 'ReadTypeUpce', 0);
    ole2.set_property(bar_handle, 'ReadTypeI2of5',0);
    ole2.set_property(bar_handle, 'ReadDirLeftToRight', -1);
    ole2.set_property(bar_handle, 'ReadDirRightToLeft', -1);
    ole2.set_property(bar_handle, 'ReadDirTopToBottom', -1);
    ole2.set_property(bar_handle, 'ReadDirSkewed', -1);
    ole2.set_property(bar_handle, 'ReadGranularity', 9);
    ole2.set_property(bar_handle, 'ReadMinLength', 9);

  • scan the whole image ole2.set_property(bar_handle, 'ReadSizeX', 0); ole2.set_property(bar_handle, 'ReadSizeY', 0);
  • start reading the barcode status := ole2.invoke_num(bar_handle, 'ReadBarcode'); if status = 0 then :scan.code := ole2.get_char_property(bar_handle, 'ReadOutString'); end if; end if;

end;

**Your will probably be simple.
To summarize:
declare handlers based on return values to OCX calles decare ole2_objects
set properties (if you try to set them using right click on the form they don't get saved and need to be reentered at runtime.) invoke the methods....

See the help file for more. on calender ocx

I didn't see a help file for mine on NT but if you right click on the control you can get some properties. By their name you will have to find the methods yourself.

Hope some of this helps! Received on Thu Nov 27 1997 - 00:00:00 CET

Original text of this message