OVH Cloud OVH Cloud

[VC++] imprimer le contenu d'un richtextcontrol ?

9 réponses
Avatar
joanmcq
Comment fait-on pour imprimer le contenu d'un richtextcontrol ?

ps: j'utilise vc++ 6.0

9 réponses

Avatar
Christian ASTOR
joanmcq a écrit:

Comment fait-on pour imprimer le contenu d'un richtextcontrol ?



EM_FORMATRANGE
Avatar
joanmcq
Christian ASTOR a écrit :

joanmcq a écrit:

Comment fait-on pour imprimer le contenu d'un richtextcontrol ?




EM_FORMATRANGE




Je débute en vc++, alors merci de détailler un peu plus.
Vous n'avez pas un exemple de code source (pas trop compliqué), svp ?

j'ai chercher sur google, mais la pluspart des exemples sont en visual
basic.
Avatar
Manuel Leclerc
joanmcq a écrit :

Je débute en vc++, alors merci de détailler
un peu plus. Vous n'avez pas un exemple de code
source (pas trop compliqué), svp ?

j'ai chercher sur google, mais [...]



Ton application est-elle une application
purement "Win32" où utilises-tu les MFC ?

--
> DES FOUS. DES PORCS SAUVAGES FOUS !
Calmévoo.


NON !
ILS M'ONT BOUFFE MES TUYAUX !
Avatar
joanmcq
Manuel Leclerc a écrit :

joanmcq a écrit :


Je débute en vc++, alors merci de détailler
un peu plus. Vous n'avez pas un exemple de code
source (pas trop compliqué), svp ?

j'ai chercher sur google, mais [...]




Ton application est-elle une application
purement "Win32" où utilises-tu les MFC ?



Elle utilse les MFC.
Avatar
Manuel Leclerc
joanmcq a écrit :

Manuel Leclerc a écrit :

> Ton application est-elle une application
> purement "Win32" où utilises-tu les MFC ?

Elle utilise les MFC.



Un peu de doc sur le RichEdit:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_printing_in_rich_edit_controls.asp

Tu vas retrouver là la piste que t'as suggérée Christian, ainsi
que des exemples de code.

Avec Google et les mots clés RichEdit MFC Print etc. tu vas
tomber sur CodeProject et CodeGuru. Je te laisse fouiller.

Je crois que les choses peuvent être assez différentes suivant
que ton RichEdit est tout seul comme un grand (CRichEdit), ou
bien si c'est en fait une view (CRichEditView). Dans ce dernier
cas tu peux aussi utiliser l'infrastructure d'impression des MFC.
Voir sur ce dernier point :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Printing.asp

Ha oui, j'oubliais : bon courage !

--
ladobas vatous vouniké
--griskov
Avatar
joanmcq
Manuel Leclerc a écrit :

joanmcq a écrit :


Manuel Leclerc a écrit :


Ton application est-elle une application
purement "Win32" où utilises-tu les MFC ?



Elle utilise les MFC.




Un peu de doc sur le RichEdit:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_printing_in_rich_edit_controls.asp

Tu vas retrouver là la piste que t'as suggérée Christian, ainsi
que des exemples de code.

Avec Google et les mots clés RichEdit MFC Print etc. tu vas
tomber sur CodeProject et CodeGuru. Je te laisse fouiller.

Je crois que les choses peuvent être assez différentes suivant
que ton RichEdit est tout seul comme un grand (CRichEdit), ou
bien si c'est en fait une view (CRichEditView). Dans ce dernier
cas tu peux aussi utiliser l'infrastructure d'impression des MFC.
Voir sur ce dernier point :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Printing.asp

Ha oui, j'oubliais : bon courage !



Il s'agit d'un cRichText et non d'un richedit.

Apparement ce n'est pas la même chose puisque j'ai téléchargé un exemple
avec richedit (http://www.codeproject.com/printing/richeditprint.asp),
mais il utilise la fonction SetTargetDevice() qui n'existe pas dans la
classe crichtext.
Avatar
Manuel Leclerc
joanmcq a écrit :

Il s'agit d'un cRichText et non d'un richedit.



C'est bizare, j'ai l'impression qu'il n'y a
pas de classe CRichText dans les MFC. Tu peux
préciser un peu de quoi tu parles ?

--
<morganj> 0 is false and 1 is true, correct?
<alec_eso> 1, morganj
<morganj> bastard.
Avatar
joanmcq
Manuel Leclerc a écrit :

joanmcq a écrit :


Il s'agit d'un cRichText et non d'un richedit.




C'est bizare, j'ai l'impression qu'il n'y a
pas de classe CRichText dans les MFC. Tu peux
préciser un peu de quoi tu parles ?



Sur l'interface du projet, j'ai un control qui sert a afficher du texte
en format rtf. Lorsque je clique sur propriété, j'ai ceci: "Microsoft
Rich Textbox Control, version 6.0".
La variable menbre correspondante est déclarée comme ceci:
CRichText m_DefText;

Dans crichtext.h j'ai trouvé la déclaration de la classe crichtext:

class CRichText : public CWnd
{
protected:
DECLARE_DYNCREATE(CRichText) // macro de control dynamique de type
dans les classes dérivées de Cobject
public:
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0x3b7c8860, 0xd78f, 0x101b, { 0xb9, 0xb5, 0x4, 0x2, 0x1c, 0x0,
0x94, 0x2 } };
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect,
pParentWnd, nID); }

BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect,
pParentWnd, nID,
pPersist, bStorage, bstrLicKey); }

// Attributes
public:

// Operations
public:
long GetAppearance();
void SetAppearance(long nNewValue);
unsigned long GetBackColor();
void SetBackColor(unsigned long newValue);
long GetBorderStyle();
void SetBorderStyle(long nNewValue);
float GetBulletIndent();
void SetBulletIndent(float newValue);
BOOL GetDisableNoScroll();
void SetDisableNoScroll(BOOL bNewValue);
BOOL GetEnabled();
void SetEnabled(BOOL bNewValue);
CString GetFileName();
void SetFileName(LPCTSTR lpszNewValue);
COleFont GetFont();
void SetRefFont(LPDISPATCH newValue);
BOOL GetHideSelection();
void SetHideSelection(BOOL bNewValue);
long GetHwnd();
void SetHwnd(long nNewValue);
BOOL GetLocked();
void SetLocked(BOOL bNewValue);
long GetMaxLength();
void SetMaxLength(long nNewValue);
CPicture GetMouseIcon();
void SetMouseIcon(LPDISPATCH newValue);
void SetRefMouseIcon(LPDISPATCH newValue);
long GetMousePointer();
void SetMousePointer(long nNewValue);
BOOL GetMultiLine();
void SetMultiLine(BOOL bNewValue);
float GetRightMargin();
void SetRightMargin(float newValue);
long GetScrollBars();
void SetScrollBars(long nNewValue);
VARIANT GetSelAlignment();
void SetSelAlignment(const VARIANT& newValue);
VARIANT GetSelBold();
void SetSelBold(const VARIANT& newValue);
VARIANT GetSelBullet();
void SetSelBullet(const VARIANT& newValue);
VARIANT GetSelCharOffset();
void SetSelCharOffset(const VARIANT& newValue);
VARIANT GetSelColor();
void SetSelColor(const VARIANT& newValue);
VARIANT GetSelFontName();
void SetSelFontName(const VARIANT& newValue);
VARIANT GetSelFontSize();
void SetSelFontSize(const VARIANT& newValue);
VARIANT GetSelHangingIndent();
void SetSelHangingIndent(const VARIANT& newValue);
VARIANT GetSelIndent();
void SetSelIndent(const VARIANT& newValue);
VARIANT GetSelItalic();
void SetSelItalic(const VARIANT& newValue);
long GetSelLength();
void SetSelLength(long nNewValue);
VARIANT GetSelProtected();
void SetSelProtected(const VARIANT& newValue);
VARIANT GetSelRightIndent();
void SetSelRightIndent(const VARIANT& newValue);
CString GetSelRTF();
void SetSelRTF(LPCTSTR lpszNewValue);
long GetSelStart();
void SetSelStart(long nNewValue);
VARIANT GetSelStrikeThru();
void SetSelStrikeThru(const VARIANT& newValue);
VARIANT GetSelTabCount();
void SetSelTabCount(const VARIANT& newValue);
CString GetSelText();
void SetSelText(LPCTSTR lpszNewValue);
VARIANT GetSelUnderline();
void SetSelUnderline(const VARIANT& newValue);
CString GetText();
void SetText(LPCTSTR lpszNewValue);
CString GetTextRTF();
void SetTextRTF(LPCTSTR lpszNewValue);
COLEObjects GetOLEObjects();
BOOL GetAutoVerbMenu();
void SetAutoVerbMenu(BOOL bNewValue);
long GetOLEDragMode();
void SetOLEDragMode(long nNewValue);
long GetOLEDropMode();
void SetOLEDropMode(long nNewValue);
long Find(LPCTSTR bstrString, const VARIANT& vStart, const VARIANT&
vEnd, const VARIANT& vOptions);
long GetLineFromChar(long lChar);
void LoadFile(LPCTSTR bstrFilename, const VARIANT& vFileType);
void Refresh();
void SaveFile(LPCTSTR bstrFilename, const VARIANT& vFlags);
void SelPrint(long lHDC);
VARIANT GetSelTabs(short sElement);
void SetSelTabs(short sElement, const VARIANT& newValue);
void Span(LPCTSTR bstrCharacterSet, const VARIANT& vForward, const
VARIANT& vNegate);
void UpTo(LPCTSTR bstrCharacterSet, const VARIANT& vForward, const
VARIANT& vNegate);
void OLEDrag();
};

Je pense qu'on doit pouvoir imprimer avec la fonction selprint mais je
ne sais pas comment faire.
Avatar
Manuel Leclerc
joanmcq a écrit :

Manuel Leclerc a écrit :

> C'est bizare, j'ai l'impression qu'il n'y a
> pas de classe CRichText dans les MFC. Tu peux
> préciser un peu de quoi tu parles ?

[...]

"Microsoft Rich Textbox Control, version 6.0".

[...]

void SelPrint(long lHDC);



Je crois que ton contrôle est un ActiveX, et non
pas un contrôle MFC au sens propre. D'après ce que
j'ai compris, il s'utilise surtout dans un environnement
Visual Basic.

Ceci dit, si tu utilises la CommonDialog "Print", tu devrais
pouvoir récupérer un "HDC" et le fournir à la méthode SelPrint.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_MFC_CPrintDialog.asp

--
The GPFS guys tell me that the "gpl" in the RPM name
means "GPFS Portability Layer".
--Paul E. McKenney