For Programmers: Free Programming Magazines  


Home > Archive > Cobol > November 2004 > Power Cobol and Windows API Routines









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Power Cobol and Windows API Routines
James Sugrue

2004-11-26, 3:55 pm

Does anyone have any examples on how to use the Windows API calls with
Fujitsu PowerCobol (6) ?

I want to use some GDI line drawing calls. LineTo etc.
Pete Dashwood

2004-11-26, 3:55 pm

Yes, I have some.

Before you start here are some suggestions:

1. Download a current API reference. (I use API Guide downloadable from:
http://www.allapi.net
2. Find out what part of windows your API call "lives in". (The document in
1 above will tell you this.)
3. Make sure you include the library containing these entry points into your
PowerCOBOL project. Note that Fujitsu do NOT provide a comprehensive set of
libraries. Some must be obtained by getting the Windows SDK.However,
libraries for most of the APIs you will use are provided by Fujitsu.

On checking, I find that the API you have requested is part of windows
GDI32.dll. This means you will need GDI32.lib included in your PowerCOBOL
project.(This is not provided by Fujitsu per se. You will probably need the
Windows SDK - downloadable for free from MS but it is over 100MB).

Here is the prototype in "VB speak":(You will need to "translate" this into
COBOL before using it...)

Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal
x As Long, ByVal y As Long) As Long

"hdc" is a device context, "x" is the x co-ordinate for the line end, "y" is
the y co-ordinate for the line end.

Check the PowerCOBOL sample code (I think there is an example API call in
it).

When you have some code of your own, post it here if you can't get it to
work. Or send me the PowerCOBOL project privately.


HTH,

Pete.
(top post no more below.)

"James Sugrue" <jamessugrue@xtra.co.nz> wrote in message
news:Kivod.9052$9A.208371@news.xtra.co.nz...
> Does anyone have any examples on how to use the Windows API calls with
> Fujitsu PowerCobol (6) ?
>
> I want to use some GDI line drawing calls. LineTo etc.
>




JerryMouse

2004-11-29, 3:55 pm

James Sugrue wrote:
> Does anyone have any examples on how to use the Windows API calls with
> Fujitsu PowerCobol (6) ?
>
> I want to use some GDI line drawing calls. LineTo etc.


Second what Pete says - it's pretty easy once you get the hang of it.

Watch out for proper casing - the API routines are positively anal about
that. You'll have to add a compile directive to your form. Double-click the
script to bring up "Properties" and add the following to "Compile" tab /
options:

"ALPHAL(WORD)" (no quotes)

otherwise calls to subprograms get folded to upper-case.

Here's an example to get the Windows directory:

01 The-Path-Name PIC X(256).
01 Path-Len Pic 9(9) Comp-5.

Move 255 To Path-Len
Call 'GetWindowsDirectoryA' With STDCALL Using
By Reference The-Path-Name
By Value Path-Len





Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com