Salut,
Je viens de réussir à imprimer uen edit box(grace aux sources de ce site), mais le problème c'est que tous les mots s'affichent à la suite ...
J'aimerai bien savoir comment imprimer sur plusieurs ligne comme le texte apparait à l'écran.
Voila mon code pour imprimer :
HDC hDCmem;
DOCINFO di;
PRINTDLG prd;
// Appelle une Common Dialog Box d'impression.
prd.lStructSize = sizeof(PRINTDLG);
prd.hDevMode = (HANDLE) NULL;
prd.hDevNames = (HANDLE) NULL;
prd.Flags = PD_RETURNDC;
prd.hwndOwner = Dlg;
prd.hDC = (HDC) NULL;
prd.nFromPage = 1;
prd.nToPage = 1;
prd.nMinPage = 0;
prd.nMaxPage = 0;
prd.nCopies = 1;
prd.hInstance = NULL;
prd.lCustData = 0L;
prd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL;
prd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL;
prd.lpPrintTemplateName = (LPSTR) NULL;
prd.lpSetupTemplateName = (LPSTR) NULL;
prd.hPrintTemplate = (HANDLE) NULL;
prd.hSetupTemplate = (HANDLE) NULL;
PrintDlg(&prd);
// Créer un contexte de périphérique pour l'imprimante.
hDCmem = CreateCompatibleDC(prd.hDC);
memset( &di, 0, sizeof( DOCINFO ) );
di.cbSize = sizeof( DOCINFO );
di.lpszDocName = "Sample Document";
// Imprimer le contenu de l'Edit Box sur l'imprimante.
hEdit = GetDlgItem(Dlg, IDC_EDIT);
DWORD TextLength;
TextLength = GetWindowTextLength(hEdit);
if(TextLength > 0)
{
LPSTR buffer;
buffer = LPSTR(GlobalAlloc(GPTR, TextLength + 1));
if(buffer != NULL)
{
if(GetWindowText(hEdit, buffer, TextLength + 1))
{
if ( StartDoc( prd.hDC, &di ) > 0 )
{
StartPage( prd.hDC );
TextOut( prd.hDC, 10, 10,
buffer, TextLength);
EndPage( prd.hDC );
EndDoc( prd.hDC );
Merci d'avance.