Hi,
I'm trying to retrieve the printer device context handle with the sample code below with no results, and I'm not able to figure out where I'm wrong.
$include "windows.inc"
int prhdc=0,test=0,res=0
CONST BUTTON_1 = 1
DIALOG d1
CREATEDIALOG d1,0,0,300,202,0x80C80080,0,"Printer test",&d1_handler
CONTROL d1,@BUTTON,"Push me...",74,73,152,56,0x50000000,BUTTON_1
res = DOMODAL d1
end
SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
test = Printer(d1)
if test <> 0
messagebox d1,"Ok!","Result"
/*
prhdc = d1.m_hPrintDC
PlayWithPrinter(prhdc...)
_DeleteDc(prhdc)
*/
else
messagebox d1,"Problem!","Result"
endif
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB
sub Printer(dialog d),int
int result=0
PRINTDLG pd
_RtlZeroMemory(pd,len(PRINTDLG))
pd.lStructSize = len(PRINTDLG)
pd.hWndOwner = d.hWnd
pd.hDevMode = NULL
pd.hDevNames = NULL
pd.Flags = PD_ALLPAGES|PD_RETURNDC
pd.nFromPage = 1
pd.nToPage = 1
pd.nMinPage = 1
pd.nMaxPage = 1
pd.nCopies = 1
result = _PrintDlg(pd)
if result <> 0
d.m_hPrintDC = pd.hdc :' stores the printer device context handle
endif
return result
END sub
Can someone help me?
Thanks!
Sergio
Ok, the problem is solved if I use the Sapero's include windowssdk.inc (but I'm not able to understand the reason...) ???
$include "windowssdk.inc"
int prhdc=0,test=0,res=0
CONST BUTTON_1 = 1
DIALOG d1
CREATEDIALOG d1,0,0,300,202,0x80C80080,0,"Printer test",&d1_handler
CONTROL d1,@BUTTON,"Push me...",74,73,152,56,0x50000000,BUTTON_1
res = DOMODAL d1
end
SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
test = Printer(d1)
if test <> 0
messagebox d1,"Ok!","Result"
/*
prhdc = d1.m_hPrintDC
PlayWithPrinter(prhdc...)
_DeleteDc(prhdc)
*/
else
messagebox d1,"Problem!","Result"
endif
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB
sub Printer(dialog d),int
uint result=0
PRINTDLG pd
RtlZeroMemory(pd,len(PRINTDLG))
pd.lStructSize = len(PRINTDLG)
pd.hWndOwner = d.hWnd
pd.hDevMode = NULL
pd.hDevNames = NULL
pd.Flags = PD_ALLPAGES|PD_RETURNDC
pd.nFromPage = 1
pd.nToPage = 1
pd.nMinPage = 1
pd.nMaxPage = 1
pd.nCopies = 1
result = PrintDlg(pd)
if result <> 0
d.m_hPrintDC = pd.hdc :' stores the printer device context handle
endif
return result
END sub
bye
Sergio