Skip to main content
gamedev.net
🔒 Locked

Problems with GUI implementation

Started by Nacho Aug 11, 2002 at 5:58 PM 3 replies 250+ views
Original Post
Nacho
Nacho
Hi! I´m coding a GUI with DirectX and I´m having a little trouble with the list of windows. Ok, here´s the situation: I´ve got an ABC called CWindow. Up to this moment there are two classes that derive from it and override its only pure virtual method Render, these are CButton and CGraph. Since I´m not the person who is actually designing the GUI, my teammate who is in charge of that gives me a bunch of bitmaps and a text file that has all the information to build the GUI (total number of controls, size and position for every window, name of the associated bitmap, etc.) Since I don´t know at compile-time neither how many windows will I have to allocate room for nor which class are them (Button ,Graph, etc.) I use the following approach: I declare a pointer to a pointer to a CWindow inside WinMain and I pass it to the LoadGUI function like this: CWindow **lpWindow = NULL; int iTotalControls; // It is validated inside LoadGUI(). LoadGUI(hWnd,lpDD,lpWindow,iTotalControls); // lpDD is a valid DDraw4 object. The most important snippets inside LoadGUI() are: if(NULL==(lpFile = fopen("GUI2.txt","r"))) return INIT_FAILED; fscanf(lpFile,"Total Controls: %d\n\n",&iTotalControls); lpWindow = new CWindow*[iTotalControls]; for(iLoop=0;iLoop; delete [] lpWindow; lpWindow = NULL; The program crashes in this part of the code. I´m completely sure about that because I commented out this snippet and the program worked and exited fine. What do you think I should do? Thanks in advance!!
Nacho
Nacho
Looking at your answer I realized that my message got messed when I posted it. Here´s the shutdown snippet again:

for(i=0;
ii++)
delete [] lpWindow;

delete [] lpWindow;
lpWindow = NULL;
Nacho
Nacho
The condition for that for loop is 'i < iTotalControls'.

[edited by - Ignacio Liverotti on August 12, 2002 2:28:48 PM]
Nacho
Nacho
I´ve found the mistake! There is an array of offscreen surfaces inside CWindow and I forgot to release them before deleting the CWindow pointers. Thanks for your help Kylotan!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.