[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
PHYSICALWIDTH = 110
PHYSICALHEIGHT = 111
PHYSICALOFFSETX = 112
PHYSICALOFFSETY = 113
SCALINGFACTORX = 114
SCALINGFACTORY = 115
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Thanks gforseth :D You gave me a clue and with a little more digging I found the rest of the constants in wingdi.h file.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Thanks gforseth :D You gave me a clue and with a little more digging I found the rest of the constants in wingdi.h file.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Thanks gforseth :D You gave me a clue and with a little more digging I found the rest of the constants in wingdi.h file.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Great!
Why don't you tell us what you are using it for, perhaps you will give the spark, so more users come up with additional ideas.
Gisle
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Originally posted by gforseth
Why don't you tell us what you are using it for, perhaps you will give the spark, so more users come up with additional ideas.
Gisle
Hello Gisle,
Sorry this has taken a little while.
I want my program to format Documents to fit the printable area of a printer. GetDeviceCaps API gives me all the parameters to calculate the printable area. There is even a VB example in MSDN Library titled "HOWTO: Use GetDeviceCaps to Determine Margins on a Page". I have translated necessary code to COBOL and it works well.
There is only one problem - getting the hDC (Device Context Handle) for a Printer WITHOUT displaying the printer dialog. GetDeviceCaps needs this handle. I can get the hDC by using ShowPrint() method of Comdlg32.ocx. However, I need the hDC of the Windows Default Printer without displaying the printer dialog. VB gives it with the Printer object - Printer.hDC.
Do you or anyone in the community know of a Windows API that will provide me with a hDC for the Default Printer?
I tried to call "CreateDC" API in GDI32.DLL but COBOL gives an error "CreateDC: program not found or inaccessible". MSDN says it is an SDK function and to use the GDI32 library. Am I missing something?
Code I am using is:
Set Environment "DLL_CONVENTION" To "1"
Call "gdi32.dll"
Call "CreateDC"
Using by Reference
NULL WINPRINT-NAME NULL NULL
Returning PRINTER-hDC
where WINPRINT-NAME is null terminated and PRINTER-hDC is PIC 9(9) COMP-5
Any help would be appreciated.
Thank you.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
First of all, you send strings a bit odd.
When sending WINPRINT-NAME in the example above, you should do the following:
INSPECT WINPRINT-NAME REPLACING TRAILING SPACES BY LOW-VALUES.
And when calling, this is the proper syntax:
CALL "CreateDC" USING BY REFERENCE WINPRINT-NAME
GIVING .....
Now, having said that, when you work on a printers device context, it means the printer has to have been opened. This because the properties of a printers device context depends on the settings you either apply yourself, via the setup, or by the spooler configuration.
Thus, in order to use GetDeviceCaps properly, you should first open the printer.
Example:
identification division.
program-id. deviceinfo.
environment division.
input-output section.
file-control.
select spool assign to print "-p spooler"
organization is line sequential.
data division.
file section.
fd spool.
01 spool-satz pic x(80).
working-storage section.
77 H-ACU-SPOOLER-DC PIC 9(9) COMP-5 EXTERNAL.
77 FunctionNumber PIC 9(9) COMP-5.
88 PHYSICALOFFSETX VALUE 112.
77 WS-PHYSICALOFFSETX PIC 9(9) COMP-5.
procedure division.
main-logic.
set environment "DLL-CONVENTION" TO 1.
call "gdi32.dll".
open output spool. | default printer
set physicaloffsetx to true.
call "GetDeviceCaps" using
BY VALUE H-ACU-SPOOLER-DC
BY VALUE FunctionNumber
GIVING WS-PHYSICALOFFSETX.
close spool.
cancel "gdi32.dll".
stop run.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
First of all, you send strings a bit odd.
When sending WINPRINT-NAME in the example above, you should do the following:
INSPECT WINPRINT-NAME REPLACING TRAILING SPACES BY LOW-VALUES.
And when calling, this is the proper syntax:
CALL "CreateDC" USING BY REFERENCE WINPRINT-NAME
GIVING .....
Now, having said that, when you work on a printers device context, it means the printer has to have been opened. This because the properties of a printers device context depends on the settings you either apply yourself, via the setup, or by the spooler configuration.
Thus, in order to use GetDeviceCaps properly, you should first open the printer.
Example:
identification division.
program-id. deviceinfo.
environment division.
input-output section.
file-control.
select spool assign to print "-p spooler"
organization is line sequential.
data division.
file section.
fd spool.
01 spool-satz pic x(80).
working-storage section.
77 H-ACU-SPOOLER-DC PIC 9(9) COMP-5 EXTERNAL.
77 FunctionNumber PIC 9(9) COMP-5.
88 PHYSICALOFFSETX VALUE 112.
77 WS-PHYSICALOFFSETX PIC 9(9) COMP-5.
procedure division.
main-logic.
set environment "DLL-CONVENTION" TO 1.
call "gdi32.dll".
open output spool. | default printer
set physicaloffsetx to true.
call "GetDeviceCaps" using
BY VALUE H-ACU-SPOOLER-DC
BY VALUE FunctionNumber
GIVING WS-PHYSICALOFFSETX.
close spool.
cancel "gdi32.dll".
stop run.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
First of all, you send strings a bit odd.
When sending WINPRINT-NAME in the example above, you should do the following:
INSPECT WINPRINT-NAME REPLACING TRAILING SPACES BY LOW-VALUES.
And when calling, this is the proper syntax:
CALL "CreateDC" USING BY REFERENCE WINPRINT-NAME
GIVING .....
Now, having said that, when you work on a printers device context, it means the printer has to have been opened. This because the properties of a printers device context depends on the settings you either apply yourself, via the setup, or by the spooler configuration.
Thus, in order to use GetDeviceCaps properly, you should first open the printer.
Example:
identification division.
program-id. deviceinfo.
environment division.
input-output section.
file-control.
select spool assign to print "-p spooler"
organization is line sequential.
data division.
file section.
fd spool.
01 spool-satz pic x(80).
working-storage section.
77 H-ACU-SPOOLER-DC PIC 9(9) COMP-5 EXTERNAL.
77 FunctionNumber PIC 9(9) COMP-5.
88 PHYSICALOFFSETX VALUE 112.
77 WS-PHYSICALOFFSETX PIC 9(9) COMP-5.
procedure division.
main-logic.
set environment "DLL-CONVENTION" TO 1.
call "gdi32.dll".
open output spool. | default printer
set physicaloffsetx to true.
call "GetDeviceCaps" using
BY VALUE H-ACU-SPOOLER-DC
BY VALUE FunctionNumber
GIVING WS-PHYSICALOFFSETX.
close spool.
cancel "gdi32.dll".
stop run.
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Thank you for sharing the above code. Very Interesting and illuminating too. How does the runtime know to set H-ACU-SPOOLER-DC to the Windows Printer Handle when the Open statement is executed? Is this a non-documented feature? An explanation would be very much appreciated....
As for CALL "CreateDC" .... Changing the code as you suggested has not helped yet. My problem was and still is that the runtime is not finding the function in gdi32.dll giving an error "CreateDC: Program missing or inaccessible".
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
H-ACU-SPOOLER-DC is a runtime EXTERNAL variable. What you do here is simply declaring a variable that is inside the runtime, I must confess that I am not sure to what extent we have documented this, probably not.
As for the failure of calling CreateDC. This is probably because it is a unicode enabled function. Which means you have to suffix an A when you call:
CALL "CreateDCA"
Now, your next Q will be why the 'A'. That and lots of other questions will be answered in San Diego on January 19th. :-)
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Enlightening stuff......
a) Does H-ACU-SPOOLER-DC take up any system resources that need releasing or does the runtime free the memory on "CANCEL program" statement?
b) Are there more hidden runtime variables that would make life easier for us? Even a crude list would do for a start.
c) CreateDC is a unicode enabled function and by making a call to "CreateDCA" it gives me exactly what I was looking for before I knew about H-ACU-SPOOLER-DC! Of course H-ACU-SPOOLER-DC is lot easier.
d) As for San Deago... my hope is that you might consider running an Advanced Windows API Programming in UK soon.
Thank you again
:)
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Enlightening stuff......
a) Does H-ACU-SPOOLER-DC take up any system resources that need releasing or does the runtime free the memory on "CANCEL program" statement?
b) Are there more hidden runtime variables that would make life easier for us? Even a crude list would do for a start.
c) CreateDC is a unicode enabled function and by making a call to "CreateDCA" it gives me exactly what I was looking for before I knew about H-ACU-SPOOLER-DC! Of course H-ACU-SPOOLER-DC is lot easier.
d) As for San Deago... my hope is that you might consider running an Advanced Windows API Programming in UK soon.
Thank you again
:)
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Enlightening stuff......
a) Does H-ACU-SPOOLER-DC take up any system resources that need releasing or does the runtime free the memory on "CANCEL program" statement?
b) Are there more hidden runtime variables that would make life easier for us? Even a crude list would do for a start.
c) CreateDC is a unicode enabled function and by making a call to "CreateDCA" it gives me exactly what I was looking for before I knew about H-ACU-SPOOLER-DC! Of course H-ACU-SPOOLER-DC is lot easier.
d) As for San Deago... my hope is that you might consider running an Advanced Windows API Programming in UK soon.
Thank you again
:)
[Migrated content. Thread originally posted on 30 October 2003]
Can someone help me to write COBOL code to tap into GetDeviceCaps function in Gdi32.lib. I am interested in receving items PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, SCALINGFACTORX and SCALINGFACTORY. I can provide the hDC handle to the printer, what I am unsure is how to receive the items I need.
Thanks
;)
Originally posted by SRFish
a) Does H-ACU-SPOOLER-DC take up any system resources that need releasing or does the runtime free the memory on "CANCEL program" statement?
No. It is all contained by the runtime. In fact, you should consider this variable a 'READ ONLY'. Never modify it.
Originally posted by SRFish
b) Are there more hidden runtime variables that would make life easier for us? Even a crude list would do for a start.
There are more, but not as useful. This is another bait for the session in San Diego :-)
Originally posted by SRFish
d) As for San Deago... my hope is that you might consider running an Advanced Windows API Programming in UK soon.
You should talk to your account manager at the UK office, if there is a demand, the training will be held.