ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories >> Software >> Programming-Languages >> VC++
 
  MFC (122)  ATL (21)  COM-DCOM (30)  Win32API (19)  ActiveX (15)
  VC++-AllOther (55)
 


 

Back to Questions Page
 
Question
Hi All,
 I have created one MFC Dialog Based application.now if i am
running the application its working fine,instead of closing
he application i minimized the application,if i run the
application again,i am getting the Dialog.

I want to prevent the calling of application multiple times.
please give me the code and let me know in which method i
need to make changes.

Praveer
Rank Answer Posted By  
 Question Submitted By :: Praveer
This Interview Question Asked @   HP
I also faced this Question!!   © ALL Interview .com
Answer
if(NULL != ::CreateMutex(NULL, TRUE, 
_T("CSingleInstanceApp")))
{
	long dwError = ::GetLastError();
	if(dwError == ERROR_ALREADY_EXISTS)
		EndDialog(IDOK);	
}

Paste the above code snippet inside the "InitInstance" 
function.
 
0
Rajaram B
 
 
Answer
Hi,
      i wrote the code as you told still its not
working,here is my code,please have a look
/////////////////////////////////////////////////////////////
BOOL CDlgApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce
the size
	//  of your final executable, you should remove from the
following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a
shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC
statically
#endif


	if(NULL != ::CreateMutex(NULL, TRUE,_T("CSingleInstanceApp")))
	{
		long dwError = ::GetLastError();
		if(dwError == ERROR_ALREADY_EXISTS)
			EndDialog(NULL,IDOK);	
	}

	CDlgDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();

	
	

	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that
we exit the
	//  application, rather than start the application's
message pump.
	
	return FALSE;
}
////////////////////////////////
 
0
Praveer
 
 
Question
What is CALLBACK? How it work?
what is the advantage of CALLBACK,
please explain with an example

Rank Answer Posted By  
 Question Submitted By :: Praveer
I also faced this Question!!   © ALL Interview .com
Answer
•	callback function is a function that is called 
through a function pointer.
•	 pass the pointer (address) of a function as an 
argument to another, when that pointer is used to call the 
function it points to it is said that a call back is made.
     // 2.1 define a function pointer and initialize to NULL
int (*pt2Function)(float, char, char) = 
NULL;                        // C
int (TMyClass::*pt2Member)(float, char, char) = 
NULL;                // C++
int (TMyClass::*pt2ConstMember)(float, char, char) const = 
NULL;     // C++

•	 A callback function is a function that is passed 
to another function (in the form of a pointer to the 
callback function) so that the second function can
call it. This is simply of way of making the second 
function more flexible without the second function needing 
to know a lot of stuff

Uses:
•	A callback can be used for notifications
•	callback functions can be used for updates, sort of 
like hooking into another function. For example, consider a 
function that downloads files using http. Your application 
may want to display progress to the user. You could pass a 
callback function (display progress) into the download 
function so that it calls your display function everytime 
it reads from the socket. At least that is my 
understanding...
 
0
Zero Zero....
 
 
 
Question
what are the advantages of VC++ design environment
Rank Answer Posted By  
 Question Submitted By :: Jyothi N Swamy
I also faced this Question!!   © ALL Interview .com
Answer
By design environment if you mean by the IDE that MS 
provides then answer is quite simple. Visual Studio is one 
of the most sophisticated, powerful yet simple to use IDE 
for Windows programming.

Vikas
http://www.cppquestions.com/
 
0
V
 
 
Question
How WM_PAINT message gets called in MFC,please explain it .
a)Who calls the WM_PAINT message?
b)When it gets called?
c)how it comes to message queue?

Please Explain it
Rank Answer Posted By  
 Question Submitted By :: Praveer
I also faced this Question!!   © ALL Interview .com
Answer
a)The framework calls this member function 

b)This function get called, when Windows or an application 
makes a request to repaint a portion of an application's 
window.

c)
 
0
Sai
 
 
Answer
WM_Paint Message will be invoked by the system and not by 
any application.

This message is sent when updatewindow or RedrawWindow 
Function is called.

Dispactch Message Function dispatches the message , it gets 
the message from the GetMessage() or PeekMessage() 
Functions.
 
0
Vijay
 
 
Question
1)why we cant create more than one instance of the class
Derived from CWinApp
Rank Answer Posted By  
 Question Submitted By :: Praveer
I also faced this Question!!   © ALL Interview .com
Answer
You  theApp object is replace with new name;

Eg

CdlgtestApp theApp;
CdlgtestApp theApp3;  // now this is your applcation obj

CdlgtestApp theApp3;
CdlgtestApp theApp; // No effect
 
0
Narayan
 
 
Question
I have to DLL one is COM dll and another is normal DLL.
How I can identify which dll is normal DLL and which DLL is 
from COM DLL.
please give me some clear picture on these


Rank Answer Posted By  
 Question Submitted By :: Mohammed Shafi
I also faced this Question!!   © ALL Interview .com
Answer
make command on both dll 
regsvr("noramal dll") it will show message of some entry 
point error
regsvr("comdll")  it will register succesfully to window
 
0
Chetan
 
 
Question
Differ GetMessage, PostMessage & PeakMessage?
Rank Answer Posted By  
 Question Submitted By :: Td
This Interview Question Asked @   Symphony
I also faced this Question!!   © ALL Interview .com
Answer
PostMessage is used in Threading usually. to post a message
to Messaging Queue.


Get message is a blocking call it waits for the message
untill it recieve the message it was requiring 


Peak message doesnt wait for the message particually it is
looking it just look if the particular message is not in the
queue it returns.
 
0
Rao Naeem
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com