Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic form problem.

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I have a problem:
I made one form, for a chat program I recently made, It attaches to a server, the server returns a list of online buddies. The user can click on a buddy in a list and the program will create a new instance of my single chat form, like so:

TChatForm *ChtForm /*ChatForm being the one form i created, to spawn multiple times*/

/*later on, in the OnClick function of the list box*/

/*makes a new chat form*/
ChtForm = new TChatForm(ChtForm);

/*names the form for the screen name of the buddy in the list*/
ChtForm->Name = ListBox1->Items->Strings;

ChtForm->Visible = true;



/*now i have lots of code in the ChatForm for sending and rich text, etc. My problem is that whenever i have anything saying 'TForm' in ChatForm, it raises an exception when the application terminates, for example, the below code is on my ChatForm's header, and is for catching when a form is in focus or not*/

protected:
void __fastcall WMFocus(TMessage &Message);

BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_SETFOCUS, TMessage, WMFocus)
MESSAGE_HANDLER(WM_KILLFOCUS, TMessage, WMFocus)
END_MESSAGE_MAP(TForm)

/*when the program terminates, it raises an exception on the line with 'TForm'. When I try to change it to TChatForm, it raises a Stack Overflow exception on startup. I have several lines with TForm, and I can't delete them, because I need most of the lines*/

Throug bug testing I know that it haas something to do with the way I create the chat form(s), but I don't have another way of doing it, and i dont know what to put in place of TForm that would fix the problem. I tried TCustomForm and TChatForm, TCustomForm does no difference. Does anyone know how to fix this stupid problem? I've been able to deal with it for a month now, but I have to get it out before I re-release the program. Cyprus
 
Well, once again, I've spoken too soon. Sorry! I fixed the problem just minuites after asking this question, and I tried so hard to come up with every possible solution I could think of to fix it before I asked! Cyprus
 
May I guess what the error is ?

ChtForm = new TChatForm(ChtForm);

I suppose this is the error : you make a new form where the parent is itself.
to my opinion this should be :
ChtForm = new TChatForm(Form1);
if Form1 is your parent form of course.



Wim Vanherp
Wim.Vanherp@myself.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top