Click here to Skip to main content
15,888,286 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: a little help? with an idea [modified] Pin
steve2028614-Nov-07 8:14
steve2028614-Nov-07 8:14 
QuestionPseudoRandom functions in C++ Pin
bigdenny20013-Nov-07 7:32
bigdenny20013-Nov-07 7:32 
AnswerRe: PseudoRandom functions in C++ Pin
jhwurmbach13-Nov-07 7:54
jhwurmbach13-Nov-07 7:54 
AnswerRe: PseudoRandom functions in C++ Pin
Nathan Addy13-Nov-07 8:39
Nathan Addy13-Nov-07 8:39 
GeneralRe: PseudoRandom functions in C++ Pin
bigdenny20013-Nov-07 8:59
bigdenny20013-Nov-07 8:59 
GeneralRe: PseudoRandom functions in C++ Pin
Nelek13-Nov-07 22:28
protectorNelek13-Nov-07 22:28 
AnswerRe: PseudoRandom functions in C++ Pin
cp987613-Nov-07 10:05
cp987613-Nov-07 10:05 
QuestionProblem during running multiple instance of an MFC application Pin
Chirag_kalra13-Nov-07 7:30
Chirag_kalra13-Nov-07 7:30 
Hi

I'm facing some problem in standard MFC application. In my application, I'm able to run only 3 instances of my application simultaneously.That is, I'm able to open only three login screens at the same time, but I dont want this limitaton. I'm currently working in Windows XP. However, when I ran my application in Windows NT, only 4 instances can be run at a time.

When I tried to open it fourth time in Windows XP, it is failing at the following line of code.

//winfrm.cpp

BOOL CFrameWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
LPCTSTR lpszMenuName,
DWORD dwExStyle,
CCreateContext* pContext)
{
HMENU hMenu = NULL;
if (lpszMenuName != NULL)
{
// load in a menu that will get destroyed when window gets destroyed
HINSTANCE hInst = AfxFindResourceHandle(lpszMenuName, RT_MENU);
if ((hMenu = ::LoadMenu(hInst, lpszMenuName)) == NULL)
{
TRACE(traceAppMsg, 0, "Warning: failed to load menu for CFrameWnd.\n");
PostNcDestroy(); // perhaps delete the C++ object
return FALSE;
}}

m_strTitle = lpszWindowName; // save title for later

if (!CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle,
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
pParentWnd->GetSafeHwnd(), hMenu, (LPVOID)pContext))
{
TRACE(traceAppMsg, 0, "Warning: failed to create CFrameWnd.\n");
if (hMenu != NULL)
DestroyMenu(hMenu);
return FALSE;
}

return TRUE;
}

Also, I have the following thing in my code:

//Inside ::InitInstance



if (pDocTemplate = new CMultiDocTemplate(IDR_mdiflsTYPE,

RUNTIME_CLASS(CmdiflsDoc),

RUNTIME_CLASS(CChildFrame), // custom MDI child frame

RUNTIME_CLASS(CmdiflsView) ) != NULL)

cout<<"Successful"

else

cout<<"Failure"

I am creating such 140 CMULTIDOCTEMPLATE (using new) objects for different menus.

Somebody suggested me why above function is failed might be due to the following reason:-
If you call the constructor(above Doctemplate) so many times, without freeing, then you probably reach a maximum space of Windows handles, if the constructor loads menu and other resources. That’s why next resource-allocation functions fails. Can you confirm that you really create and keep so many objects?
So to check resource allocation/storage limitation problem, I applied logs as shown above and I got 140 "Successful" messages when I ran 4th instance.
One more thing is that when I lessen the number of these doc templates to around 50, I am able to start 6-7 instances of my application.
So could anybody suggest me how to ensure if this much objects are successfully created?
Is there any better way to ensure if it is a resource allocation/ storage limitation problem? If yes. how can I overcome this?

Thanks in advance!








Chirag Kalra

AnswerRe: Problem during running multiple instance of an MFC application Pin
Bram van Kampen13-Nov-07 13:41
Bram van Kampen13-Nov-07 13:41 
AnswerRe: Problem during running multiple instance of an MFC application Pin
Nelek13-Nov-07 22:21
protectorNelek13-Nov-07 22:21 
AnswerRe: Problem during running multiple instance of an MFC application Pin
Priyank Bolia25-May-08 21:39
Priyank Bolia25-May-08 21:39 
Questionidispatch concepts not understood Pin
prithaa13-Nov-07 7:05
prithaa13-Nov-07 7:05 
AnswerRe: idispatch concepts not understood Pin
led mike13-Nov-07 7:12
led mike13-Nov-07 7:12 
GeneralRe: idispatch concepts not understood Pin
Jim Crafton13-Nov-07 7:16
Jim Crafton13-Nov-07 7:16 
AnswerRe: idispatch concepts not understood Pin
Jim Crafton13-Nov-07 7:16
Jim Crafton13-Nov-07 7:16 
GeneralRe: idispatch concepts not understood Pin
prithaa13-Nov-07 7:30
prithaa13-Nov-07 7:30 
GeneralRe: idispatch concepts not understood Pin
led mike13-Nov-07 7:57
led mike13-Nov-07 7:57 
GeneralRe: idispatch concepts not understood Pin
bob1697213-Nov-07 16:16
bob1697213-Nov-07 16:16 
QuestionSending data - TCP connection Pin
bigdenny20013-Nov-07 7:00
bigdenny20013-Nov-07 7:00 
AnswerRe: Sending data - TCP connection Pin
Jim Crafton13-Nov-07 7:10
Jim Crafton13-Nov-07 7:10 
GeneralRe: Sending data - TCP connection Pin
led mike13-Nov-07 7:16
led mike13-Nov-07 7:16 
GeneralRe: Sending data - TCP connection Pin
Jim Crafton13-Nov-07 7:22
Jim Crafton13-Nov-07 7:22 
GeneralRe: Sending data - TCP connection Pin
led mike13-Nov-07 8:24
led mike13-Nov-07 8:24 
AnswerRe: Sending data - TCP connection Pin
led mike13-Nov-07 7:11
led mike13-Nov-07 7:11 
GeneralRe: Sending data - TCP connection Pin
bigdenny20013-Nov-07 8:01
bigdenny20013-Nov-07 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.