Skip to main content
gamedev.net
🔒 Locked

Close Window

Started by ratha Sep 24, 2010 at 2:29 AM 0 replies 850+ views
Original Post
ratha
ratha
Hi!
I 've created an Input Box(a modal window with edit box, OK&CANCEL buttons), if an image is clicked. I've to close this window if OK or CANCEL button is clicked. I've removed the window,inside the click event of these buttons.

My problem is, if I visit the menu page second time and click the image, the Input Box window doesn't open.

This is my code:

if(m_pCreateProfileImage->getRelativePosition().isPointInside(m_MousePos)) {  if(m_pInput == NULL)  {   m_pInput = pManager->getGUIEnvironment()->addWindow(recti(100,100,400,250),true,L"Create a New Profile",0,ID_WINDOW_INPUT);   m_pEdit = pManager->getGUIEnvironment()->addEditBox(L"Enter",recti(30,50,250,80),true,m_pInput,ID_EDIT_BOX);   m_pEdit->setMax(10);   m_pBtnOK = pManager->getGUIEnvironment()->addButton(recti(20,90,100,120),m_pInput,ID_BUTTON_OK, L"OK", L"Click to create Profile");   m_pBtnCancel = pManager->getGUIEnvironment()->addButton(recti(120,90,200,120),m_pInput,ID_BUTTON_CANCEL,L"Cancel",L"");  } }

I've checked for m_pInput == NULL why because I'm creating this Input Box on clicking an image. So an input box will be created on each click otherwise.

Here is the event handler:
 if(event.GUIEvent.EventType == EGET_BUTTON_CLICKED) {  s32 id = event.GUIEvent.Caller->getID();    switch(id)  {   case ID_BUTTON_OK:   {    if(str.size() > 0)	{	 //sprintf_s(query,512,"UPDATE profile SET name=(%s)",str.c_str());	 printf("%S \n",str.c_str());	 m_pInput->remove();	}	break;	//return true;   }   case ID_BUTTON_CANCEL:	   m_pInput->remove();	   break;	   //return false;  }  //return false; }

What to do to open the window on second visit also?
Endurion
Endurion
It would help alot to see what all those functions you have there are doing?
Is this your own wrapper about Win32 (as it seems)?

The proper call to close a modal dialog is to call EndDialog.


Your problem might be that you don't seem to set m_pInput to NULL once you're closing the dialog. So the next time the first code snippet is called it won't enter the dialog creation code. A few steps with the debugger should show if that happens.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Topic Locked

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

Sign in to reply to this topic.