Re: is there a difference between a custom control on a modal dialog
box and a modeless dialog box.
On Sep 14, 6:22 pm, "AliR" <A...@online.nospam> wrote:
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 dial=
og.
But you did mention some dlls. How and when do your dlls come into play?
Also is ShowGrid a global function or a method of a class?
Also I'm assuming that the setXXXX methods that you are calling before th=
e
create is called in ShowGrid, don't actually manipulate any controls on t=
he
dialog, and simply just store information.
Anyway, if you give more details on how your program is laid out then may=
be
we can recreate your problem and give a solution.
AliR.
"bachegool" <esadegh...@gmail.com> wrote in message
news:e2d57d69-4f76-41c8-b6c4-fe676b87f160@h30g2000vbr.googlegroups.com...
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 numberOf=
Rows,
Columns,
s,
Labels,
rtFlags[],
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] == sd=
aiINSTANCE)
{ //if instance call showInstanceCallFromGridDLL()
FnPtrT FnPtr = (FnPtrT)::GetProcAddress(GetMod=
uleHandle
(NULL), "showInstanceCallFromGridDLL");
if(FnPtr)
(*FnPtr)((char *)pCell->GetText());
} else if (myColumnPrimitypes[pItem->iColumn - 1] =
==
sdaiAGGR) { //if aggragate call showInstanceCallFromGridDLL()
FnPtrT FnPtr = (FnPtrT)::GetProcAddress(Ge=
tModuleHandle
(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] == sdaiA=
GGR))
{
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
The code in the mail is the DLL. The showGrid is the exported
function, I did this to avoid changing the Grid library that I am
using and it's much easier. the setXXX belong to the dialog that holds
the grid. The problem is that for some reason my private variables are
being rewritten after the grid is displayed. so when I use gridArray
[numberOfGrids]->setColumnPrimitypes(columnPrimtypes); the
"columnPrimtypes" and "myColumnPrimitypes" are correct, but after this
when I'm using the grid it is written over.
ehsna