|
|
Comments and Discussions
|
|
 |

|
I've compiled this with Unicode defined, but the text displays very oddly. Does anyone have this converted to support multiple languages? I would love to have some suggestions or better yet, the code
Thanks
|
|
|
|

|
Has anyone tried it with VS 2010 ? It worked fine with VS 2008 and VS 2003.
When I try to run the sample in debug, it ASSERTs when the splitter gets created in CSplitterWnd::GetPane, here is the stack:
mfc100d.dll!CSplitterWnd::GetPane(int row, int col) Line 367 + 0x19 bytes C++
mfc100d.dll!CSplitterWnd::RecalcLayout() Line 1465 + 0x19 bytes C++
mfc100d.dll!CSplitterWnd::OnSize(unsigned int nType, int cx, int cy) Line 1215 C++
it fails because the line:
CWnd* pView = GetDlgItem(IdFromRowCol(row, col));
returns a NULL pointer for the view.
MS seems to have change how splitter windows work. Are more initializations needed ?
|
|
|
|

|
If in SDI is created the new document without saving the previous, the view isn't updated correctly. It is need to invalidate the view if it was reset.
void CCrystalTextView::UpdateView(CCrystalTextView *pSource, CUpdateContext *pContext, DWORD dwFlags, int nLineIndex )
{
if (dwFlags & UPDATE_RESET)
{
ResetView();
RecalcVertScrollBar();
RecalcHorzScrollBar();
Invalidate(TRUE);
return;
}
.....
|
|
|
|

|
Display chinese is not very good.
|
|
|
|

|
Yes.
I want to konow how to support the chinese words..
|
|
|
|

|
Hello,
I am using VC.net 2003 version 7.1.
I would like to know how I can add an
Edit box like control to the windows form
so that at run time the user will be able
to drag and drop images and print it.
Please help I am stuck with this problem
for many days.
Thanks.
Minad
|
|
|
|

|
When using "GetLineChars(int nLineIndex)" to get an empty column, it return a non-empty string. Is anyone has the same problem ? How to solve it?
|
|
|
|

|
use "GetLineLength" to get the real line length
|
|
|
|

|
Hi,
Can I base on your Crystal Edit source code to build up my own application
for commercial purpose ? My application is a bundle software for H/W. Not
a stand alone software package. Also, my application will be free download
for any user.
|
|
|
|

|
I like the look of this - but was unable to get it to compile in VC++.NET (VC++ Version 7, not 2005), there's no vcproj or dsp file. Any help?
CP McElhinney
|
|
|
|

|
You need to use "Sample.dsw" in Demo Project
|
|
|
|

|
I want to use this edit in my docking window without document,i can't insert this function
CCrystalTextBuffer *CMessageView::LocateTextBuffer()
{
CMessageDoc *pDoc = (CMessageDoc *) GetDocument();
return &pDoc->m_xTextBuffer;
}
Somebody please help me and thank you very much!
chihyuchen
|
|
|
|
|

|
I find it hard to add the column selection to the edit
|
|
|
|

|
Hi,
Is an OCX version of this control(activeX) is available. I want use this as an OCX in my VB6 application.
cheers,
Avins.
|
|
|
|

|
I find the length of a single line can't be more than 64k, how to solve it or avoid it?
|
|
|
|

|
I needed to use the editor as a control in a dialog for some of my application's needs to I borrowed the code from CHtmlCtrl from the MSDN article by Paul DiLascia which was about making CHtmlView into a control, and I added some changes to work with CCrystalEditView.
You can use this code to replace a CEdit control:
CDialog::OnInitDialog();
// Create the CrystalEdit control.
m_ScriptEditor.CreateFromControl( IDC_EDIT_SCRIPT, this );
// Attach it to the edit control.
m_ScriptEditor.AttachToBuffer( &m_ScriptBuffer );
and it will create a CCrystalEditControl at the same coordinates as the Edit control.
After that it works just like the normal control and does not require a MainFrame container.
CCrystalEditControl.h:
////////////////////////////////////////////////////////////////
// Microsoft Systems Journal -- December 1999
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
//
// MODIFIED for use with CrystalEditView. CMF 2004/08/13
#include
#include "../Basic/Editor/Crystal/CCrystalTextBuffer.h"
#include "../Basic/Editor/Crystal/CCrystalEditView.h"
class CCrystalEditControl : public CCrystalEditView {
public:
CCrystalEditControl() { }
~CCrystalEditControl() { }
BOOL CreateFromControl(UINT nID, CWnd* pParent);
// Normally, CHtmlView destroys itself in PostNcDestroy,
// but we don't want to do that for a control since a control
// is usually implemented as a stack object in a dialog.
//
virtual void PostNcDestroy() { }
// overrides to bypass MFC doc/view frame dependencies
afx_msg void OnDestroy();
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg);
// Override to get messages since Dialogs normally suck them up.
afx_msg UINT OnGetDlgCode();
DECLARE_MESSAGE_MAP();
DECLARE_DYNAMIC(CCrystalEditControl)
};
Here's the .cpp file:
////////////////////////////////////////////////////////////////
// Microsoft Systems Journal -- December 1999
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
//
#include "StdAfx.h"
#include "CrystalEditControl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define NO_CLASS_NAME NULL
#define NO_TITLE NULL
IMPLEMENT_DYNAMIC(CCrystalEditControl, CCrystalEditView)
BEGIN_MESSAGE_MAP(CCrystalEditControl, CCrystalEditView)
ON_WM_DESTROY()
ON_WM_MOUSEACTIVATE()
ON_WM_GETDLGCODE()
END_MESSAGE_MAP()
//////////////////
// Create control in same position as an existing control with the same ID.
BOOL CCrystalEditControl::CreateFromControl( UINT controlID, CWnd* parentWindow )
{
CEdit editControl;
CRect controlRect;
// Subclass the control at that id.
if (!editControl.SubclassDlgItem( controlID, parentWindow ) )
return FALSE;
// Get static control rect, convert to parent's client coords.
editControl.GetWindowRect(&controlRect);
parentWindow->ScreenToClient(&controlRect);
editControl.DestroyWindow();
// Create the CrystalEdit control (CCrystalEditView)
return Create( NO_CLASS_NAME, NO_TITLE, (WS_CHILD | WS_VISIBLE | WS_TABSTOP), controlRect,
parentWindow, controlID, NULL );
} // CCrystalEditControl::CreateFromControl
UINT CCrystalEditControl::OnGetDlgCode()
{
// We want all the keys.
return DLGC_WANTALLKEYS;
} // CCrystalEditControl::OnGetDlgCode
////////////////
// Override to avoid CView stuff that assumes a frame.
//
void CCrystalEditControl::OnDestroy()
{
// NOTE: This stuff was copied from CCrystalEditView::OnDestroy
// since we are skipping it and going right to the CWnd::OnDestroy
// because CCrystalEditView::OnDestroy calls CView::OnDestroy which
// doesn't work since it assumes it's in a frame window which it
// won't be as a control.
// Detach from our buffer.
DetachFromBuffer();
m_hAccel = NULL;
// Bypass CView doc/frame stuff
CWnd::OnDestroy();
for ( int I = 0; I < 4; I ++ )
{
if ( m_apFonts[I] != NULL )
{
m_apFonts[I]->DeleteObject();
delete m_apFonts[I];
m_apFonts[I] = NULL;
}
}
if ( m_pCacheBitmap != NULL )
{
delete m_pCacheBitmap;
m_pCacheBitmap = NULL;
}
} // CCrystalEditControl::OnDestroy
////////////////
// Override to avoid CView stuff that assumes a frame.
//
int CCrystalEditControl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
{
int result;
// bypass CView doc/frame stuff
result = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, msg);
// re-activate this view
CView::OnActivateView(TRUE, this, this);
// Return the result.
return result;
} // CCrystalEditControl::OnMouseActivate
Let me know if you have problems or find bugs.
- Curtis
|
|
|
|

|
Hi,
I am planning to create a freeware java ide and wanted to use your Sorce code in my application. Can I use your application for this with out having any liscence problems?
Thanks
Sudhakar
|
|
|
|

|
Is there an easy way to make a line of text non-editable in the Crystal Edit?
|
|
|
|
|

|
Then why not tell everyone?
|
|
|
|

|
First of all thanks to Andrei Stcherbatchenko, This code works really nice and it helped us a lot.
But in some HP laptops, which have Israel locale there is some probelm.
problem description:-
---------------------
Suppose I have the following code
int i;//declaring a var
i=1;
Sometimes on the view it looks like below
int i;//declaring a var
i=1;i;//declaring a var
Some characters of the first line are copied to the second line.
If you know how to correct this please get to me.
Thanks in advance,
Rohan
|
|
|
|

|
Generating Code...
Linking...
msvcrtd.lib(crtexe.obj) : error LNK2001: unresolved external symbol _main
Debug/crysedit.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
crysedit.exe - 2 error(s), 0 warning(s)
What am I doing wrong
|
|
|
|

|
AssertValidTextPos Function can't pass!
Who can help me?
How I do it when without CDocument?
Thanks you!
Hello!
Hope all to be pleasure!
|
|
|
|

|
when I use Crystal Edit , it seems that the Tab make text location display error
can someone tell me how to solve it
|
|
|
|

|
1. delete getdocument() in main tab view;
2. add getdocument() in child tab view(Only add one);
Try it!
Good Luck
Hello!
Hope all to be pleasure!
|
|
|
|

|
Hello,
I am trying to use the Crystal Edit code to implement a syntax coloring editor in my MFC app. I am having problems when I try to add text, like several lines of text, in response to user button presses. Depending on what button the user presses, text lines of various lengths will be inserted at the cursor position, or the line immediately following the current cursor position. This needs to work in an empty file/buffer or in a previously edited file.
The following code:
.
.
.
CPoint curpos = GetCursorPos();
GetDocument()->m_xTextBuffer.InsertText(this,curpos.x,curpos.y,"Test1",a, b);
GetDocument()->m_xTextBuffer.InsertText(this,curpos.x+1,curpos.y,"Test2",a, b);
GetDocument()->m_xTextBuffer.InsertText(this,curpos.x+2,curpos.y,"Test3",a, b);
curpos.x += 3;
SetCursorPos(curpos);
.
.
.
Asserts here: ASSERT(nLine >= 0 && nLine < m_aLines.GetSize());
in this function in CCrystalTextBuffer.cpp
BOOL PBTextBuffer::InternalInsertText(PBTextView *pSource, int nLine, int nPos, LPCTSTR pszText, int &nEndLine, int &nEndChar)
{
ASSERT(m_bInit); // Text buffer not yet initialized.
// You must call InitNew() or LoadFromFile() first!
ASSERT(nLine >= 0 && nLine < m_aLines.GetSize());
ASSERT(nLine >= 0);
ASSERT(nPos >= 0 && nPos <= m_aLines[nLine].m_nLength);
if (m_bReadOnly)
return FALSE;
From what it looks like, CrystalEdit is not designed to grow dynamically, or at least not without the user typing. If I go to the view a make space for the text with the spacebar, it seems to work. Has anyone used this code in this manner? Am I doing something wrong? Is there a fix for this? Please Help....
Doug
Doug
|
|
|
|

|
Solution is very simple. I tried the following and worked fine:
On the user action response function add the following lines:
int nEndChar;
CPoint pt;
pt = GetCursorPos();
GetDocument()->m_xTextBuffer.InsertText(this, pt.x, pt.y,
"if (a == b)\r\n"
"{\r\n"
" // Do whatever\r\n"
" //...\r\n"
"} // end of if",
nEndLine, nEndChar);;
pt.x += sizeof("} // end of if") - 1;
pt.y += 4;
SetCursorPos(pt);
|
|
|
|

|
Displaying bugs when i use the system default font; my codes:
CSampleDoc::CSampleDoc() : m_xTextBuffer(this)
{
// TODO: add one-time construction code here
// Initialize LOGFONT structure
/*
memset(&m_lf, 0, sizeof(m_lf));
m_lf.lfWeight = FW_NORMAL;
m_lf.lfCharSet = ANSI_CHARSET;
m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
m_lf.lfQuality = DEFAULT_QUALITY;
m_lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
strcpy(m_lf.lfFaceName, "Courier");
*/
::GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &m_lf);
}
int CCrystalTextView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
/*
memset(&m_lfBaseFont, 0, sizeof(m_lfBaseFont));
lstrcpy(m_lfBaseFont.lfFaceName, _T("FixedSys"));
m_lfBaseFont.lfHeight = 0;
m_lfBaseFont.lfWeight = FW_NORMAL;
m_lfBaseFont.lfItalic = FALSE;
m_lfBaseFont.lfCharSet = DEFAULT_CHARSET;
m_lfBaseFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
m_lfBaseFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
m_lfBaseFont.lfQuality = DEFAULT_QUALITY;
m_lfBaseFont.lfPitchAndFamily = DEFAULT_PITCH;
*/
::GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &m_lfBaseFont);
...
}
help me!
img src="/script/Forums/Images/smiley_cry.gif" align="top" alt="Cry | :((" />
|
|
|
|

|
CrystalEdit can't be used with proportional (variable) font.
|
|
|
|

|
Hi,
I am creating a CCrystalEditView in a child of a CSplitterWnd. Everything works fine except for one thing: if the document has more text lines than the view, the scrollbars don't show up unless you deliberately resize the view. If you start with a new file and type in lines until you reach the bottom of the view, scrollbar(s) should appear after when you add the last line. Or if you load a long file, scrollbars should appear. They don't appear, unless you manually resize the view. After that they stay around and work correctly. There is a comment in the source code, in CCrystalTextView::PreCreateWindow()
if (pParentWnd == NULL || ! pParentWnd->IsKindOf(RUNTIME_CLASS(CSplitterWnd)))
{
// View must always create its own scrollbars,
// if only it's not used within splitter
cs.style |= (WS_HSCROLL | WS_VSCROLL);
}
it looks related to this.
I'd appreciate any help.
Regards
C Newell.
|
|
|
|
|

|
/* ////comment here*/
is ok....
|
|
|
|

|
the moveleft and moveright methods are not versatile enough for there many wide charsets, when press left arrow or right arrow button, the caret should move 2 ansi char width.
|
|
|
|

|
I also have a problem with Japanese. Reading from a file seems ok, but writing in Japanese displays wierd stuff. (same kinda problem)
Did you (or someone else) ever convert this to use wide-character strings?
Apart from that - Great Stuff!
|
|
|
|

|
To show my language(Korean) I modifed all the features with regards to mouse and keyboard input to check if it's between DBCS characters, and it's working very well now.
If your project is based on multi-byte character set, please check DBCS, and if your project is based on UNICODE, you can use IME events..
modified 24 Aug '12 - 2:24.
|
|
|
|

|
What special precautions should I take when working with MDI...?
I've got everything working great inside an SDI, but something is wrong when I use it with MDI
What could I be doing wrong...?
Thanks again
I'm drinking triples, seeing double and acting single
|
|
|
|

|
HAve programmed an Editor and I need to save the hole text from the View in a String . How can I get the hole Text?!
GetWindowText doesnt work
thx anyway
|
|
|
|
|

|
I've successfully moved all resources from demo project into mine and everything compiled fine, and seems to be working properly.
However now i'd like to remove the search dialog and some of the resources, is this possible? Which ones are safe to remove?
Thanks
|
|
|
|

|
hello,Hockey.
I meet the problem like you. I make a MFC EXTENTION DLL project with author's source code modified. It works but with error in"
ASSERT(m_hAccel == NULL);m_hAccel = ::LoadAccelerators(GetResourceHandle(), MAKEINTRESOURCE(IDR_DEFAULT_ACCEL));ASSERT(m_hAccel != NULL);"
It seems My exe lost the IDR_DEFAULT_ACCEL.
Why i can't get the resource in the DLL?
|
|
|
|

|
It is temporarily solved with the RC file in author's class src included in my dll project rc file.
|
|
|
|

|
In your implementation you are not accounting for one, admittedly rather obscure, language feature of C++: trigraphs. I discovered this within a construct according to this thread's title:
// multi-line double slash comment ??/
trigraph should be converted during preprocessing to '\' character
Even though multi-line comments should be avoided to begin with and most contemporary compilers do issue a warning even at low warning levels, I thought you might be interested to know, since you have already put quite a bit of effort into parsing comments correctly.
Let me know what you think, if it's worth a thought or just too far out to be considered as a future addition.
Regards,
.f
|
|
|
|

|
testing/*testing*///testing
The last word testing SHOULD be a comment, but it isn't.
Adam Clauss
cabadam@tamu.edu
|
|
|
|

|
Hi,
Thanks to Andrei Stcherbatchenko for this wonderful code. I was wondering if any one knows how to add the support for any other language say japanese?
What are the steps invloved.
Thanks,
Ashu
|
|
|
|

|
I'm guessing you need to convert it to wide-character strings. Apart from that, I dont really know.
If you did solve this problem, can you let me know? (It'll make my life a bit easier )
Sam.
|
|
|
|

|
There is a highlighting problem when you click Find Next in the Find-Replace box if you want to find just 1 caracter. How can i fix that ?
|
|
|
|

|
I'm having some trouble with the print preview while using this class. The font for editor has been set to Courier New, but on machine with WIN2K or lower, the print preview shows the text in Arial. It works fine in XP. I'm setting the font for the print preview (and for print, which shows the right font, btw) in OnBeginPrinting. Has anyone expirianced this or have any ideas on how to fix it? Thanks!
|
|
|
|

|
First thanks to Andrei Stcherbatchenko for this nice and useful piece of code!
I've found a small bug that was ennoying me for quite a long time as it was only occuring in Release Unicode build.
The CCrystalTextBuffer::SaveToFile convert the text buffer to Ascii before writing it to the file. To convert the string the T2A is used; it expects a zero-terminated wide-string and the text buffer lines are not zero-terminated.
It works most of the times as a double-00 can be found somewhere in memory after the string unless the string is near the end of the process memory leading to an access violation.
Here is a quick (and a little dirty) fix:
Replace the lines:
if (! ::WriteFile(hTempFile, T2A(m_aLines[nLine].m_pcLine), nLength, &dwWrittenBytes, NULL))
__leave;
by:
#ifndef _UNICODE
if (! ::WriteFile(hTempFile, T2A(m_aLines[nLine].m_pcLine), nLength, &dwWrittenBytes, NULL))
__leave;
#else
LPSTR lpa = (LPSTR)alloca( nLength + 1 );
WideCharToMultiByte( CP_ACP, 0, m_aLines[nLine].m_pcLine, nLength, lpa, nLength, NULL, NULL );
if (! ::WriteFile(hTempFile, lpa, nLength, &dwWrittenBytes, NULL))
__leave;
#endif
You will notice that all the lines of the text buffer will be alloca-ated and freed only on procedure exit.
That was already the case before but this time allocation is, at least, done with the real size of the string!
Pierre MEINDRE
|
|
|
|

|
Is it possible to use more just 4-bit (16 colours) in the toolbar?
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
A set of classes that provide an expandable framework for the syntax coloring text editor.
| Type | Article |
| Licence | |
| First Posted | 30 Jan 2000 |
| Views | 474,243 |
| Bookmarked | 220 times |
|
|