|
Naveen R wrote: try the below code. It just remove the WM_QUIT message.
is there any relation between ExitInstance and WM_QUIT message!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
When I saw his question, I started investigating the problem. I tried calling DoModal for a dialog. Inside the DoModal function i found that the message loop returned immediately.this was because it had a WM_QUIT message in the message queue. I think the WM_QUIT message that gets posted when we close a dialog resides in the queue.
nave
|
|
|
|
|
See if MSDN article Q138681 is of any help.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
MFC Dialog Based Applications generally act up in the following way:
1) Initialize MFC
2) Call InitInstance. Create and show the dialog box here, if it's a modal dialog box application
3) The dialog box terminates
4) InitInstance returns FALSE.
5) Call ExitInstance.
6) Terminate.
When a Dialog Box application's ExitInstance is running, the application's message pump is shut down already, and the application is preparing to terminate. Calling MessageBox will order the box to be a child of the desktop window, and will freeze the desktop while the box is being shown. This is generally a bad idea, since your application is outrightly blocking the desktop for the sake of displaying it's own message.
Put the MessageBox call to somewhere else. Anywhere but ExitInstance should do quite fine.. Perhaps right after the dialog terminates in InitInstance, but before InitInstance returns FALSE ?
- Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Antti Keskinen wrote: When a Dialog Box application's ExitInstance is running, the application's message pump is shut down already
When u call DOModal for a dialog, it creates a message pumps there. So u can't say the message pump is shutdown or like that...
Antti Keskinen wrote: Calling MessageBox will order the box to be a child of the desktop window, and will freeze the desktop
never. U can't freeze the Desktop
nave
|
|
|
|
|
The DoModal dialog can create the message queue for the dialog window, but the thread's message pump (CWinApp::Run) no longer executes when ExitInstance is running. This means that only modal dialogs are available. If you create a modeless dialog during ExitInstance, problems are guaranteed.
Regardless of this detail, I still consider it a bad idea to create message boxes in ExitInstance. I consider it bad coding. Like reserving memory in an object's destructor. It's a sign of bad design
Didn't know about the desktop window though. Thought it would behave just like any other window in the system. But now I know better then, thanks for clarifying
- Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Antti Keskinen wrote: If you create a modeless dialog during ExitInstance, problems are guaranteed.
Even if u try to show a Modal window, it will not work( After all, message box is a modal window or latest block the code)
Antti Keskinen wrote: I still consider it a bad idea to create message boxes in ExitInstance
I too dont recomment showing a message box in the existinstance.
nave
|
|
|
|
|
Hi,
I have a structure ...
typedef struct
{
CString progId;
IEFCMainForm * pIForm;
}NODEDATA;
char buf[200];
// The structure is initialized
NODEDATA *nd=new NODEDATA;
nd->progId = _T("EFCSkinView.EFCForm.1 ") ;
sprintf(buf,"%s",nd->progId);
nd->pIForm=NULL;
if (nd->pIForm == NULL)
{
CLSID clsid;
wchar_t lszProgID[200];
mbstowcs(lszProgID,buf/*nd->progId*/,nd->progId.GetLength());
lszProgID[nd->progId.GetLength()]=0;
CLSIDFromProgID(_T("EFCSkinView.EFCForm.1 "),&clsid);
HRESULT hr=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,IID_IEFCMainForm,(void**)&(nd->pIForm));
// Iam unable to get clsid ,iam getting GUID_NULL for clsid eventhough iam getting correct progid
if(FAILED(hr))
{
CString str=_T("Failed to Create ");
AfxMessageBox(str+nd->progId);
return;
}
Any suggetions would be helpful
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
narayanagvs wrote: CLSIDFromProgID(_T("EFCSkinView.EFCForm.1 "),&clsid);
check Registry under HKEY_CLASS_ROOTS , is your EFCSkinView exist there, my suggestion would be go for version independent id for EFCSkinView Libaray by using EFCSkinView.EFCForm instead EFCSkinView.EFCForm.1
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
I am using VC++ .NET(8 Version) to build a Dialog based application, however, my
application allows user to input command arguments from the Command prompt
window.
I want to write some help message when user enters "Some.exe /?" at the command prompt. How can I write text to the command prompt window if user enters the above arguments?(Some.exe /?)
Thanks in advance.
|
|
|
|
|
when u start a dialog based application from the command line, the moment u press enter a new process is created. So the new process dont have any relation with the console. But in a console based application, both the console and the new application exists in same process. Better u output the help string in a messagebox( check the regsvr32.exe application. It shows the help in message box )
nave
|
|
|
|
|
Thanks for the Reply.
Is there any way to get the HANDLE of the console where we are executing our Dlg Based Appln. I have read about AllocConsole() and GetStdHandle() but could not corelate with my problem. Plz Help
|
|
|
|
|
zxc89 wrote: Is there any way to get the HANDLE of the console
sorry i dont know. Even if there is a way what u gone do if i immediately close the console after pressing enter?
nave
|
|
|
|
|
|
hi DavidCrow,
In both of the link u give the parent application have to redirect the child applications stdout. This is not possible in his case since the parent applicaton is command prompt. He is searching for a way to redirect the output from the child process itself.
nave
|
|
|
|
|
Can anyone Help.I had tried different ways but i coulnot succeed.
|
|
|
|
|
I received the value from one class. now i need send this value to the socket at another class. how do retrieve this value from different class?
void CIPConfig::OnBnClickedButton2()
{
int level, comm;
...........
level = atoi(v_level);
comm = atoi(v_comm);
temp.Format("%d", level);
sIOSetting = temp;
temp.Format("%2d", comm);
sIOSetting+=temp;
}
now i need send sIOSetting to socket in CConfigurationView.
how do i do it?
|
|
|
|
|
u need to keep 1) a pointer of CConfigurationView in the CIPConfig class or
2) a pointer of CIPConfig in the CConfigurationView class.
nave
|
|
|
|
|
/////////////////////In IPConfig.cpp //////////////////////////////
void CIPConfig::OnBnClickedButton2()
{
CConfigurationView *pView = theApp.GetConfigureView();
int level, comm;
CString sIOSetting ="", temp;
........
level = atoi(v_level);
comm = atoi(v_comm);
temp.Format("%d", level);
sIOSetting = temp;
temp.Format("%2d", comm);
sIOSetting+=temp;
return pView->SendConfig(sIOSetting, _IO_SETTING);
}
/////////////////////////In configureationView.cpp//////////////////////
BOOL CConfigurationView::SendConfig(int nCode)
{
CString str;
str.Format("6x1%2d", nCode);
send(conn,str,5,0);
}
is it correct?
|
|
|
|
|
yijia_24 wrote: SendConfig(sIOSetting, _IO_SETTING);
but in the SendConfig function u wrote it take only one parameter. What about the sIOSetting?Dont u want to send that string data?the function should be modified as follows.
BOOL CConfigurationView::SendConfig(CString sIOSetting, int nCode)
{
....
// Send the sIOSetting
}
Everything else is ok.
nave
|
|
|
|
|
yijia_24 wrote: BOOL CConfigurationView::SendConfig(int nCode)
{
CString str;
str.Format("6x1%2d", nCode);
send(conn,str,5,0);
}
missing string argument.. and use const CString& in function argument!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
Hi,
I have been doing an application on Dialogbar.I have added some controls to it.But,My problem is that,the Buttons are appearing as if they are disabled when i run the application.How can i overcome this problem.
Thanks in advance,
Radhika.
|
|
|
|
|
radhika28 wrote: as if they are disabled when i run the application
EnableWindow()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: EnableWindow()
he he he
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
radhika28 wrote: I have been doing an application on Dialogbar.I have added some controls to it.But,My problem is that,the Buttons are appearing as if they are disabled when i run the application.How can i overcome this problem.
You should provide event handlers for these buttons, else it will appear disabled.
|
|
|
|