Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nacho

Problems with GUI implementation

This topic is 5793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!

Share this post


Link to post
Share on other sites
Advertisement
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;

Share this post


Link to post
Share on other sites
The condition for that for loop is 'i < iTotalControls'.

[edited by - Ignacio Liverotti on August 12, 2002 2:28:48 PM]

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!