In normal circumstances there really isn't any difference as far as modal
vers modeless. If you look at demo project it is creating a modal dialog.
But you did mention some dlls. How and when do your dlls come into play?
dialog, and simply just store information.
we can recreate your problem and give a solution.
AliR.
Hello,
I have a dialog box that has Chris Maunder's MFC Grid control 2.26 on
it.
http://www.codeproject.com/KB/miscctrl/gridctrl.aspx
when I run the dialog box as a modal dialog box everything works well,
but when I created the modeless version of it, the custom grid didn't
respond correctly. To create the modeless version I first created an
array of the dialog class in the header file.
CGridHolderDLG *gridArray[50];
and in a function that I create the dialog I do this:
void showGrid(char *header,
long numberOfRows,
long numberOfColumns,
char **columns,
char **columnLabels,
long columnSortFlags[],
SdaiPrimitiveType columnPrimtypes[],
SdaiServerContext serverContextId)
{
// need for exporting this function
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// create a dialog box and fill it
numberOfGrids++;
// CGridHolderDLG myGrid;
/* myGrid.setHeader(header);
myGrid.setNumberOfRows(numberOfRows);
myGrid.setNumberofColumns(numberOfColumns);
myGrid.setColumns(columns);
myGrid.setColumnLables(columnLabels);
myGrid.setColumnSortFlags(columnSortFlags);
myGrid.setColumnPrimitypes(columnPrimtypes);
myGrid.setServerContext(serverContextId);
myGrid.setArrayNum(numberOfGrids);
*/
gridArray[numberOfGrids] = new CGridHolderDLG();
gridArray[numberOfGrids]->setHeader(header);
gridArray[numberOfGrids]->setNumberOfRows(numberOfRows);
gridArray[numberOfGrids]->setNumberofColumns(numberOfColumns);
gridArray[numberOfGrids]->setColumns(columns);
gridArray[numberOfGrids]->setColumnLables(columnLabels);
gridArray[numberOfGrids]->setColumnSortFlags(columnSortFlags);
gridArray[numberOfGrids]->setColumnPrimitypes(columnPrimtypes);
gridArray[numberOfGrids]->setServerContext(serverContextId);
gridArray[numberOfGrids]->setArrayNum(numberOfGrids);
// myGrid.DoModal();
gridArray[numberOfGrids]->Create(IDD_GRIDDIALOG);
gridArray[numberOfGrids]->ShowWindow(TRUE);
}
this is an exported function that is used to create the dialog box
from a C environment. the problem is that in this method
typedef void(*FnPtrT)(char*);
void CGridHolderDLG::OnGridDblClick(NMHDR *pNotifyStruct, LRESULT* /
*pResult*/)
{
NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNotifyStruct;
// Can we do it?
if (!IsValid(pItem->iRow, pItem->iColumn))
return;
if (pItem->iRow != 0 && (myColumnPrimitypes[pItem->iColumn - 1] ==
sdaiINSTANCE || myColumnPrimitypes[pItem->iColumn - 1] == sdaiAGGR)) {
CGridCellBase* pCell = m_Grid.GetCell(pItem->iRow, pItem-
iColumn);
if (pCell) { // if cell exist check for column type
if (myColumnPrimitypes[pItem->iColumn - 1] == sdaiINSTANCE)
{ //if instance call showInstanceCallFromGridDLL()
FnPtrT FnPtr = (FnPtrT)::GetProcAddress(GetModuleHandle
(NULL), "showInstanceCallFromGridDLL");
if(FnPtr)
(*FnPtr)((char *)pCell->GetText());
} else if (myColumnPrimitypes[pItem->iColumn - 1] ==
sdaiAGGR) { //if aggragate call showInstanceCallFromGridDLL()
FnPtrT FnPtr = (FnPtrT)::GetProcAddress(GetModuleHandle
(NULL), "showAggrCallFromGridDLL");
if(FnPtr)
(*FnPtr)((char *)pCell->GetText());
}
}
}
}
which calls a function outside of the the DLL, the
if (pItem->iRow != 0 && (myColumnPrimitypes[pItem->iColumn - 1] ==
sdaiINSTANCE || myColumnPrimitypes[pItem->iColumn - 1] == sdaiAGGR))
{
statement does not work, the second part is always false. and the
settings for the actual grid changes in the modeless version. e.g. all
cell become editable.
is there some kind of a setting one should do when working with custom
controls and modeless dialog boxes? or is the array doing something
that it shouldn't do.
thanks
ehsan