471,327 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

RTF widget and undo disabling (sometimes only)

Hi,

I have successfully created a class derived from the RTF widget that can
syntax highlight XML as fast as you type :-)

The only problem I have is that if the user does an 'undo' then syntax
highlighting is undone. Is it possible to disable the undo stack during
specific operations ?

Jim
Dec 6 '05 #1
4 2394
Jim,

You can override the WndProc method on your control and then handle the
EM_UNDO message (I believe you are using an RichTextBox). You can decide
whether to process this or not.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Random Task" <Ra****@Task.be> wrote in message
news:tr*******************@news20.bellglobal.com.. .
Hi,

I have successfully created a class derived from the RTF widget that can
syntax highlight XML as fast as you type :-)

The only problem I have is that if the user does an 'undo' then syntax
highlighting is undone. Is it possible to disable the undo stack during
specific operations ?

Jim

Dec 6 '05 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Jim,

You can override the WndProc method on your control and then handle the
EM_UNDO message (I believe you are using an RichTextBox). You can decide
whether to process this or not.

Hope this helps.

I am a newbie to having to write code at this level ... I just tried the
below code and it looks like I can't overide this on the RickTextBox ...

Is there something else i should be trying?

And thanks very much ... everyone normally ignores this question

Jim

public class MyHighlightable: RichTextBox
{
public bool ishighlighting;
public MyHighlightable(): base()
{
}

/*
RichTextBoxSyntaxHighligher.cs(29):
'Zeligsoft.Helpers.MyHighlightable.WndProc(ref
Zeligsoft.Helpers.Message)': no suitable method found to
override
*/
protected override void WndProc(ref Message message)
{
switch (message.Msg)
{
case (int)Msgs.EM_UNDO:
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
default:
{
base.WndProc(ref message);
}
}
}

}
Dec 6 '05 #3
Ooops ... some one created a "Message" class in namespace ...

My bad ...
Jim

Random Task wrote:
Nicholas Paldino [.NET/C# MVP] wrote:
Jim,

You can override the WndProc method on your control and then
handle the EM_UNDO message (I believe you are using an RichTextBox).
You can decide whether to process this or not.

Hope this helps.

I am a newbie to having to write code at this level ... I just tried the
below code and it looks like I can't overide this on the RickTextBox ...

Is there something else i should be trying?

And thanks very much ... everyone normally ignores this question

Jim

public class MyHighlightable: RichTextBox
{
public bool ishighlighting;
public MyHighlightable(): base()
{
}

/*
RichTextBoxSyntaxHighligher.cs(29):
'Zeligsoft.Helpers.MyHighlightable.WndProc(ref
Zeligsoft.Helpers.Message)': no suitable method found to
override
*/
protected override void WndProc(ref Message message)
{
switch (message.Msg)
{
case (int)Msgs.EM_UNDO:
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
default:
{
base.WndProc(ref message);
}
}
}

}

Dec 7 '05 #4
Nicholas Paldino [.NET/C# MVP] wrote:
Jim,

You can override the WndProc method on your control and then handle the
EM_UNDO message (I believe you are using an RichTextBox). You can decide
whether to process this or not.

Hope this helps.


Thanks for the help ... unfortunately it still doesn't work ... it
appears there is no "disable undo queue" that i can call during the
period of time where i highlight the code in the RTF ... my boss
unfortunately wont let me simply disable undo in the editor :-)

Maybe there are some other ideas ... but like I said your the first to
even offer a suggestion on this :-)

Cheers,
Jim

ps here's the code i tried to catch events ...
/// <summary>
///
/// </summary>
public class MyHighlightableRTF: RichTextBox
{
public bool ishighlighting;

public MyHighlightableRTF(): base()
{

}

protected override void WndProc(ref System.Windows.Forms.Message message)
{
switch (message.Msg)
{
case (int) 0x0304://EM_UNDO:
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
case (int) 0x00C7:
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
};
case (int) 0x00C6: //EM_CANUNDO 0x00C6
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
case (int) 0x0114://WM_HSCROLL
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
case 0x0115: //(int)WM_VSCROLL
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
case 0x00CD: //EM_EMPTYUNDOBUFFER
{
if (ishighlighting)
{
return;
}
else
{
base.WndProc(ref message);
}
break;
}
default:
{
base.WndProc(ref message);
break;
}
}
}

}
Dec 7 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Enigman O'Maly | last post: by
3 posts views Thread by Phil Schmidt | last post: by
reply views Thread by John Benson | last post: by
2 posts views Thread by Leslie | last post: by
5 posts views Thread by Woody Splawn | last post: by
1 post views Thread by Jeremy | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.