Board index » cppbuilder » Error in EN_LINK Handling...
George P Boutwell
CBuilder Developer |
Error in EN_LINK Handling...2003-09-18 04:29:41 AM cppbuilder106 In an TRichEdit derived component that handled EN_LINK message, when handling the EN_LINK message I have the following code: if (Message.Msg == CN_NOTIFY) { TWMNotify* Msg = (TWMNotify*)&Message; if (Msg->NMHdr->code == EN_LINK) { TENLink* EnLink = reinterpret_cast<TENLink*>(Msg->NMHdr); if ((EnLink->msg == WM_LBUTTONDOWN) && (FLinkClicked)) { TTextRange TR; TR.chrg = EnLink->chrg; TR.lpstrText = new char[(TR.chrg.cpMax - TR.chrg.cpMin + 2)]; try { FLinkClicked(this, TR.chrg.cpMin, TR.chrg.cpMax, AnsiString(TR.lpstrText), FLinkObjects->GetItem(TR.chrg.cpMin, TR.lpstrText)); // FLinkObject returns a TObject* that was attached to the link } // End try __finally { delete [] TR.lpstrText; } // End catch } // End if } // End if } // End if // Default WndProc Handling inherited::WndProc(Message); This all seems find until in the program that uses this component I define an OnLinkClicked Event that does something like this: TMyObject* Object = reinterpret_cast<TMyObject*>(Obj); // TObject sent in by TMyRichEdit if (Object) { // Min == cpMin, Max == cpMax, Text = AnsiString(lptstrText) // The following line throws an EOutOfResources with message // 'RichEdit line insertion error' RichEdit1->Lines->Text = StuffString(CGVHARichEdit->Lines->Text, Min, (Max-Min), Object->ReplacementText); } I suppose I can see where the error is. It doesn't like me changing the RichEdit Text while I'm in the EN_LINK handler. Anyone seen this before and have a work around that might work? Thanks, George |