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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modeless Dialog using .net

Status
Not open for further replies.

minifiredragon

Programmer
Jun 29, 2003
68
US
Ok, I am looking for how to get to the settings for a dialog box I created so I can change it from modal to modeless. I was looking through the property window and didn't see it there.

I am calling the dialog like such:

dlgTimeLeft.DoModal();

I am assuming that doesn't force it as a modal box, but can change settings in the setup section.

I am using Visual C++ .net 2003, and I am still not fully familar with it.
 
Taken from MSDN:
----------------------------------------------------------
To create a modal dialog box, construct an object on the stack using the constructor for your derived dialog class and then call DoModal to create the dialog window and its controls. If you wish to create a modeless dialog, call Create in the constructor of your dialog class.

You can also create a template in memory by using aDLGTEMPLATE data structure as described in the Win32 SDK documentation. After you construct a CDialog object, call CreateIndirect to create a modeless dialog box, or call InitModalIndirect and DoModal to create a modal dialog box.
-----------------------------------------------------------

Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
I did all that, and it opens and closes the dialog box very very fast.

here is the call:

CTimeLeft dlgTimeLeft;
TimeRemaining(str_validratio,
str_validamount);
dlgTimeLeft.str_TimeLeft =
str_TimeRemaining;
dlgTimeLeft.Create(IDD_TIME_LEFT, this);
dlgTimeLeft.ShowWindow(SW_SHOW);

here is the place it is called from:

void CICClientDlg::OnRecieve(void)
{
char *pBuf = new char[1025];
int iBufSize = 1024;
int iRcvd;
CString strRecvd;

//recieve message
iRcvd = m_sConnectSocket.Receive(pBuf, iBufSize);
//did we recieve anything?


if (iRcvd == SOCKET_ERROR) ----->

***Removed working code***

<-----

else
{
str_validinfo = strRecvd;
SeperateInfo(str_validinfo); //used to seperate account info
CTimeLeft dlgTimeLeft;
TimeRemaining(str_validratio, str_validamount);
dlgTimeLeft.str_TimeLeft = str_TimeRemaining;

dlgTimeLeft.Create(IDD_TIME_LEFT, this);
dlgTimeLeft.ShowWindow(SW_SHOW);


}
}
 
try creating the dialog in memory using the new operator instead of on the stack.

(in the CWnd class derive pDlgTimeLeft and intialize to NULL)


pDlgTimeLeft = new CTimeLeft();
TimeRemaining(str_validratio,
str_validamount);
pDlgTimeLeft->str_TimeLeft =
str_TimeRemaining;
pDlgTimeLeft->Create(IDD_TIME_LEFT, this);
pDlgTimeLeft->ShowWindow(SW_SHOW);

here is the place it is called from:

void CICClientDlg::OnRecieve(void)
{
char *pBuf = new char[1025];
int iBufSize = 1024;
int iRcvd;
CString strRecvd;

//recieve message
iRcvd = m_sConnectSocket.Receive(pBuf, iBufSize);
//did we recieve anything?


if (iRcvd == SOCKET_ERROR) ----->

***Removed working code***

<-----

else
{
str_validinfo = strRecvd;
SeperateInfo(str_validinfo); //used to seperate account info
pDlgTimeLeft = new CTimeLeft();
TimeRemaining(str_validratio, str_validamount);
pDlgTimeLeft->str_TimeLeft = str_TimeRemaining;

pDlgTimeLeft->Create(IDD_TIME_LEFT, this);
pDlgTimeLeft->ShowWindow(SW_SHOW);


}
}

I'm new also so take this suggestion for what is worth. Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top