Re: Space characters is CEdit.
Have you tried what Jonathan was suggesting. It is very simple:
#pragma once
// CReplaceEdit
class CReplaceEdit : public CEdit
{
DECLARE_DYNAMIC(CReplaceEdit)
public:
CReplaceEdit();
virtual ~CReplaceEdit();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnEnUpdate();
void GetWindowText(CString &rString);
private:
TCHAR m_FromChar;
TCHAR m_ToChar;
};
// ReplaceEdit.cpp : implementation file
//
#include "stdafx.h"
#include "ReplaceEdit.h"
// CReplaceEdit
IMPLEMENT_DYNAMIC(CReplaceEdit, CEdit)
CReplaceEdit::CReplaceEdit()
: m_FromChar(' ') //replace all spaces with
, m_ToChar('_') //underscore char
{
}
CReplaceEdit::~CReplaceEdit()
{
}
BEGIN_MESSAGE_MAP(CReplaceEdit, CEdit)
ON_CONTROL_REFLECT(EN_UPDATE, OnEnUpdate)
END_MESSAGE_MAP()
// CReplaceEdit message handlers
void CReplaceEdit::OnEnUpdate()
{
DWORD dwPos = GetSel() & 0xFFFF; // The current cursor position
CString Text;
CEdit::GetWindowText(Text);
if (Text.Replace(m_FromChar,m_ToChar) > 0)
{
CEdit::SetWindowText(Text);
SetSel(dwPos, dwPos, FALSE); // Just to not confuse the user ;-)
}
}
void CReplaceEdit::GetWindowText(CString &rString)
{
CEdit::GetWindowText(rString);
rString.Replace(m_ToChar,m_FromChar);
}
AliR.
"Paco" <paco_beams@gmail.com> wrote in message
news:gCgGi.2635$ZA5.2077@nlpi068.nbdc.sbc.com...
I can't do what you are saying. A common entry I expect program users to
use is just one space character, nothing else. Or maybe two space
characters, nothing else. If that's the only entry then you can't see them
by just looking at the entry box.
"David Ching" <dc@remove-this.dcsoft.com> wrote in message
news:V%9Gi.26615$eY.26188@newssvr13.news.prodigy.net...
"Paco" <paco_beams@gmail.com> wrote in message
news:GS%Fi.2565$ZA5.2028@nlpi068.nbdc.sbc.com...
Another way might be by using a custom font that was a normal looking
font except for the space character. It could be a gray box for a space
or maybe something like what I have used when I'm writing in a notebook.
When I want to specify a space I write along the bottom of the line what
looks like a square bracket, but horizontal instead of vertical.
I would just change the edit box font to a non-proportional font like
"Courier New" so that the space is easier to see.
-- David