INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

How to determine Cancel was used with the printer prompt by mgagnon
Posted: 24 Jun 03

This function is similar to the SYS(1037) function, but it allows you to catch the lcStruct value that determines if the user used the Cancel button or the Print button:

Do setPrinterPrompt

#Define PD_ALLPAGES 0
#Define PD_RETURNDC 256
#Define PD_USEDEVMODECOPIESANDCOLLATE 262144 && 0x40000
#Define PD_RETURNDEFAULT 1024 && 0x400

Local lcStruct, hDc, lnFlags
lnFlags = PD_USEDEVMODECOPIESANDCOLLATE + PD_RETURNDC
lcStruct = num2dword(66) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(lnFlags) +;
    num2word(65535) +;
    num2word(65535) +;
    num2word(1) +;
    num2word(65535) +;
    num2word(1) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0) +;
    num2dword(0)
If PrintDlg (@lcStruct) <> 0
    hDc = buf2dword (Substr (lcStruct, 17, 4))
    = DeleteDC (hDc)
    Messagebox("The user chose the print button")
Else
    Messagebox("The user chose the cancel button.")
Endif

Function num2dword (lnValue)
#Define m0 256
#Define m1 65536
#Define m2 16777216
Local b0, b1, b2, b3
b3 = Int(lnValue/m2)
b2 = Int((lnValue - b3 * m2)/m1)
b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
b0 = Mod(lnValue, m0)
Return Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)

Function num2word (lnValue)
Return Chr(Mod(m.lnValue,256)) + Chr(Int(m.lnValue/256))

Function buf2dword (lcBuffer)
Return Asc(Substr(lcBuffer, 1,1)) + ;
    Asc(Substr(lcBuffer, 2,1)) * 256 +;
    Asc(Substr(lcBuffer, 3,1)) * 65536 +;
    Asc(Substr(lcBuffer, 4,1)) * 16777216

Procedure SetPrinterPrompt
Declare Integer DeleteDC In gdi32 Integer hdc
Declare Integer PrintDlg In comdlg32;
    STRING @ lppd



Some of this code came from Anatoliy Mogylevets

Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close