Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
C++
void CEverDlg::OnButton1() 
{
straw dlg;

if(dlg.DoModal() == IDOK)
{
	

MessageBox("dfdfd","dfdfd",MB_OK);

}
}


Ok..let me clear things up..i made it easy but accaully I have a FTP CLIENT with a a list control of the files on the server. the user right clicks the list control and selects "EDIT THE HTML FILE" from a context menu.

its in testing mode...the modal dialog has a button that im testing with a messagebox. but the messagebox only pops up when the the dialog is closed.

I can not put the code in the dialog its self because some varibles wouldn't work.such as hIConnect that gets on in the other cpp file ..so there is no way of putting the code in the cpp file
Posted
Updated 16-Jul-13 5:14am
v8
Comments
nv3 16-Jul-13 10:50am    
You need to show your code, particularly the part in which you process the IDOK command and where you open the message box.
[no name] 16-Jul-13 10:51am    
"ideas whey this is doing this?", sure plenty of ideas but without seeing your code for what you have done, can't say for sure.
terry mobley 16-Jul-13 10:55am    
void CEverDlg::OnButton1()
{
straw dlg;

if(dlg.DoModal() == IDOK)
{


MessageBox("dfdfd","dfdfd",MB_OK);

}
}
terry mobley 16-Jul-13 11:15am    
Ok..let me clear things up..i made it easy but accaully I have a FTP CLIENT with a a list control of the files on the server. the user right clicks the list control and selects "EDIT THE HTML FILE" from a context menu.

its in testing mode...the modal dialog has a button that im testing with a messagebox. but the messagebox only pops up when the the dialog is closed.

I can not put the code in the dialog its self because some varibles wouldn't work.such as hIConnect that gets on in the other cpp file ..so there is no way of putting the code in the cpp file

You must show the message box from within the OnOK() handler of your straw dialog box:
C++
void straw::OnOK()
{
    MessageBox("dfdfd","dfdfd",MB_OK);
    CDialog::OnOK();
}

When you now press the OK button in the straw dialog, the message box is shown and the straw dialog is closed after closing the message box.
 
Share this answer
 
Comments
H.Brydon 16-Jul-13 11:10am    
Exactly. +5...
terry mobley 16-Jul-13 11:34am    
But what if I have a HINTERNET variable that cannot go into the straw dialog because it is in the other cpp file?...
Jochen Arndt 16-Jul-13 11:41am    
Then add a member variable of type HINTERNET to the straw dialog and set it before calling DoModal().
terry mobley 16-Jul-13 11:46am    
this would cause me to have to make a new connection or reconnect
with this code
hIConnect = InternetConnect(hInternet,w_host123, w_port123,
w_user123, w_pass123, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);

I would have to make a new connection

is there a way around this?
Jochen Arndt 16-Jul-13 12:01pm    
I don't know about your program flow. But when the connection is no longer present when showing the message box from within OnOK(), it is also no more present when showing it afterwards when DoModal() returns.

Or do you need the connection handle? Then pass this to the dialog box (or both if both are required).

EDIT:
If you need access to multiple members of the calling dialog, you can also pass a pointer to the dialog and access the members from within your straw dialog.
oK GOT IT TO WORK

just played around with the classes in the classview and added a windows message handle of the button now it works..
 
Share this answer
 
v2
Comments
H.Brydon 16-Jul-13 13:43pm    
Don't be surprised if you see a downvote storm here. You seem to have ignored Solution #1 which from what I see has the closest to correct answer for you. You asked more questions in the Solution #1 comments. You posted a Solution #2 which does not describe a solution and marked it as the preferred answer. That is neither accurate nor courteous treatment for people trying to help you.

You're probably not going to get much more help here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900