|
It gets them for sure, but users can't access mainframe when modal dialog is displayed - the main window is disabled.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
|
Well? And if, should I? The alternative is to check the length of the list I need to process.
|
|
|
|
|
This compiles w/o error:
void main()
{
char* p = new char[0];
} As for whether you should do this, without knowing your code I would say no. If someone asks me to allocate 0, I'd treat it as an error or no-op, depending on the situation.
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
According to section 5.3.3 of the ARM - yes!
Dale Thompson
|
|
|
|
|
|
The Annotated C++ Reference Manual, it was considered the official definition of the C++ language before the ANSI/ISO standard was approved.
|
|
|
|
|
Yes, the standard says that you can allocate a 0 byte array, and that this will be at least 1 unit of storage (on PC's this is one byte) So that it's address may be taken. It's not recommended that you actually DO anything with it though.
|
|
|
|
|
Hello,
Please read the following code.This is for an MDI project in VC++5.
I use this particular method to make MDI documents and windows.
How can I name the frames that I create using this method?
//This is the iitialization.
pDiagramTemplate = new CMultiDocTemplate(
IDR_DIAGRAMTYPE,
RUNTIME_CLASS(CDiagramDoc),
RUNTIME_CLASS(CDiagramChildFrame),
RUNTIME_CLASS(CDiagramView));
//This is for displaying the new frame.
CDiagramChildFrame *pdiagramframe = new CDiagramChildFrame;
CDiagramDoc *pdiagramdoc = new CDiagramDoc;
CDocTemplate *pTemplate = pDiagramTemplate;
CFrameWnd *pframe = pTemplate->CreateNewFrame(pdiagramdoc,pdiagramframe);
pTemplate->InitialUpdateFrame(pframe,pdiagramdoc);
Everything works but I want to name the frames like 1,2,3 etc.as they are created
using THIS PARTICULAR METHOD.Please help me.I need it very very urgently.
Thanx.
Joey Tribbiani.
|
|
|
|
|
What's the relationship between new frame and existing docs? Is this a new window showing new document, or new window for document already associated with other frame windows?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
A 3rd party's client app is written in MicroFocus Cobol. My 32 bit DLL exports "int __stdcall DisplayNoGridDlg(HWND hWnd)" which displays a modal dialog. At least it does when called by my C++ test client. When the 3rd party runs their Cobol app it doesn't work.
Debug displays at both sides of the interface show that the value of the handle parameter being sent by the Cobol client is not the same as the value being received so my DLL, which does an IsWindow check, simpy sends back an error.
Is there a trick to getting Cobol and C++ to understand where the interface is in memory?
|
|
|
|
|
This looks like calling convention conflict. The calling convention has impact on the stack layout - and your HWND doesn't get through. I know nothing about MicroFocus Cobol, so can't advice in detail. Check the MF Cobol docs for interfacing to foreign DLLs.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Ta.
Turns out this is a human interface problem. The 3rd party was passing my DLL a pointer to a HWND not a HWND. Apparently pointer params are the default for MF Cobol.
Jim
|
|
|
|
|
Hi,
I like to know if this is the right way to count the number of open documents in MDI :
int i=1;
CWinApp* pApp = AfxGetApp();
POSITION posTemplate = pApp->GetFirstDocTemplatePosition();
while (posTemplate)
{
posTemplate = pApp->GetFirstDocTemplatePosition();
i++;
}
thanks
Ehsan Behboudi
|
|
|
|
|
This will count the document templates, not the document themselves, and only if you replace GetFirstDocTemplatePosition with GetNextDocTemplate inside the while(...) loop.
With a doctemplate, you can count the documents using CDocTemplate::GetFirstDocPosition/GetNextDoc. You'll have two nested loops - outer loop for iterating over templates and inner loop for documents.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
thanks for your help,
I have a small question. How can I cast the pDoc pointer so I could have access to the data of the corresponding document.
int i=0;
int nDocCount = 0;
CWinApp* pApp = AfxGetApp();
POSITION posTemplate = pApp->GetFirstDocTemplatePosition();
while (posTemplate)
{
CDocTemplate *pDocTemplate=pApp->GetNextDocTemplate(posTemplate);
if(NULL!=pDocTemplate)
{
POSITION posDoc = pDocTemplate->GetFirstDocPosition();
while(posDoc)
{
CDocument *pDoc = pDocTemplate->GetNextDoc(posDoc);
////////////////////////////////////////////////////
//I need another pointer to the data of the corresponding doc, or i have to cast pDoc. How can I do that.
///////////////////////////////
if(NULL!=pDoc)
nDocCount++;
}
}
i++;
}
TRACE("%d",nDocCount);
Thanks
Ehsan Behboudi
|
|
|
|
|
How can I cast the pDoc pointer so I could have access to the data of the corresponding document
Try this...
CDocument *pDoc = pDocTemplate->GetNextDoc(posDoc);
CMyDocument *pMyDoc = (CMyDoc *)pDoc;
... or this:
CDocument *pDoc = pDocTemplate->GetNextDoc(posDoc);
CMyDocument *pMyDoc = static_cast<CMyDocument *>(pDoc);
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I've created a splitted window. And I want my left part of the window to be not less than 150 pixels by X axis. How can I do this?
With the best regards, Vitaly.
|
|
|
|
|
Use CSplitterWnd::SetColumnInfo/SetRowInfo. They have a parameter that controls the minimum pane size.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
No, it isn't work the way I need. If I reduce the column width less than cxMin value - it's width will be set to 0. But I need it to be set to the cxMin. At this moment I'm trying to make a child class for CSplitterWnd and correct the width in RecalcLayout().
With the best regards, Vitaly.
|
|
|
|
|
yeah! it works
With the best regards, Vitaly.
|
|
|
|
|
I see - user can drag the splitter to hide a column. RecalcLayout looks very ugly - maybe it's better to hack into OnMouseMove?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Do you find this ugly?
void CVertSplitter::RecalcLayout() {
CSplitterWnd::RecalcLayout();
int cur, min;
GetColumnInfo(0, cur, min);
if (cur < min) {
SetColumnInfo(0, min, min);
CSplitterWnd::RecalcLayout();
}
}
With the best regards, Vitaly.
|
|
|
|
|
Mea culpa. I didn't realize that RecalcLayout is virtual and you'll have to take the source of CSplitterWnd and make substantial changes.
Cheers,
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I need to run an application from screen saver. When screen saver exists I use this code to launch application.
STARTUPINFO si;
PROCESS_INFORMATION ProcessInformation;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = _T("WinSta0\\Default");
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.dwFlags = 0;;
si.wShowWindow = SW_SHOW;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
if (::CreateProcess(lpApplicationName, lpszCmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &si, &ProcessInformation))
{
::CloseHandle(ProcessInformation.hProcess);
::CloseHandle(ProcessInformation.hThread);
}
But problem is, this code launch application successfully on Win NT, but I can'tsee launched application on desktop of Win 2k. Another important thing is that when I shutdown my Win 2k system then while shuting down I can see that launched application. I don't know on which desktop this Win 2k launch application.
Please help me in his problem, as I m not getting any idea, as the code is working fine on NT, but is creating problem on Win 2k.
Please help me.
Waiting for reply!
Thanx.
I m really about this Win2k behaviour.
|
|
|
|