bijender singh


{ City } gurgaon
< Country > india
* Profession *
User No # 15428
Total Questions Posted # 0
Total Answers Posted # 3

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 7
Users Marked my Answers as Wrong # 5
Questions / { bijender singh }
Questions Answers Category Views Company eMail




Answers / { bijender singh }

Question { 16332 }

How to create a Modeless Dialog?


Answer

1.First you write the CDialog ctor without any parameter.
2.Then create object of CDialog class & call the Create()
function.
3.After creating call the ShowWindow() function.
*Instead of ShowWindow() you can us the WS_VISIBLE in
dialog rc script file.

While deleting call the DestroyWindow() not EndDialog()
which is for Modal dialog.

Is This Answer Correct ?    0 Yes 3 No

Question { 15143 }

How can we create thread in MFC framework?


Answer

MFC support two type of thread : Worker Thread & UI thread.
There is an overloaded function called AfxBeginThread()for
creating threads in MFC but at APT level you can't
differentaite.
At implementation level you can find the difference:-

For worker thread:
AfxBeginThread(); It takes 6 parameters, first param as
address of thread controlling function(must),2nd as
parameter passed to threadfn(must),3'rd thread priority
level(optional), 4'th as stack size(Optional),5'th as
create_flag(optional),6'th security class(optional)etc.

For UI(User Interface) thread:
Derive a class from CWinThread;
class CMyThread:public CWinThread
{
.....
.....
.....
}
Override the InitInstance() function in this class.

Then use the function
AfxBeginThread()and pass the parameter in RUNTIME_CLASS
macro in this func.
i.e. AfxBeginThread(RUNTIME_CLASS(CMyThread));
It takes 5 parameters ...rest of last four params are same
as worker thread which are optional.

So in this you can create the Worker and User Interface
threads.

Is This Answer Correct ?    5 Yes 2 No


Question { 9698 }

Does the application have more than one object? If no, then
what is the reason?


Answer

No,one application can't have more than one object.
Because when we create the Application class object.It
calls WinMain() function & which calls AfxWinInit() to
register the window class, InitInstace() to start,show &
update the window.
Than calls the Run() function which call
CWinThread::MessagePump() for message loop.
Once it receive the WM_QUIT message it will call AfxWinTerm
() to cleanup & exit the application.

So once you create the Application object the Primary
thread will start which is called as UI Thread.
One program can have only one Main function which do all
the above mentioned job.
That's why we can create the one object only.

Is This Answer Correct ?    2 Yes 0 No