Author Topic: RichTextBox derived class generates memory protection error  (Read 2016 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
RichTextBox derived class generates memory protection error
« on: March 27, 2009, 09:57:24 AM »
Ok, so I found myself in need of a custom control, and since I couldn't find anything that allowed me to do what I wanted, I decided to build one. What I wanted was a treeview inside a regular document, and since I couldn't find anything that would allow me to do that, I decided to build one.

Everything was going along fine ... I created my control using 2 richtextbox components, one above and one below the treeview (sized appropriately). I even made the richtextbox controls resize according to content so the parent control could scroll it properly. But I needed a little more in the way of text formatting, and as such, I added a justified text setting (fitted margin to margin). Now whenever I load a rich text document that is fit justified, it shows correctly ... except ...

Since adding the justified setting, I am constantly getting memory protection errors saying that the control is trying to read or write to protected memory, and this is before I even compile it (while it is still in the designer).

So, I thought that I would try the class in a different project just to be sure, and it doesn't generate an error when added to a different project. However, on another development computer, I couldn't even load the class without generating hundreds of errors about private variables with public members .. so I changed everything to public on my custom structs.

I am at a loss, but the weird thing is that it compiles fine and runs fine, but as soon as I view the control in the IDE, the error is generated or right after compiling the project the error is generated and I have to terminate the process the hard way.

Maybe someone here can take a look at the class and tell me what I need to do to fix it .. or if it is even in that control at all ... that is where the IDE says it originates though.

The file is actually a VB.net file, but the forum doesn't allow .vb files to be uploaded, so I changed it to .cls .. you will need to rename it to open it.

One more thing ... I also use option strict on, and there are no IDE errors in that regard.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie