Group:  Microsoft Excel » microsoft.public.excel.sdk
Thread: Problems with xlfDialog

Problems with xlfDialog
Chris <chris[ at ]chrisbird.com> 11/20/2008 12:18:46 PM
I am writing an XLL add-in with a custom dialog - DLL builds fine and
gets loaded into Excel, however I am having problems with the dialog.
The dialog only seems to want to display 63 or 64 controls from the
[64][7] array that I have created.
I can see nothing wrong with the definitions, and if I move the
'Error' row further up in the array then a different row gives the
error.
Are there any limits on the number of controls that can be specified
within the array passed to xlfDialog?

Thanks,

Chris.
Re: Problems with xlfDialog
"Steve Dalton" <NOsteveSPAM(at)NOeigensysSPAM(dot)com> 11/23/2008 6:14:17 PM
Hi Chris

Have you tried creating the dialog using an XLM macro sheet and displaying
it using an XLM command macro? I know it's going back several steps in
Excel programming terms, but it might demonstrate whether or not the problem
is a hard limit on the number of rows that xlfDialogBox can process.

Regards

Steve Dalton


"Chris" <chris[ at ]chrisbird.com> wrote in message
news:48e4d6f6-e17a-45d8-9c9d-5214c99e9053[ at ]d23g2000yqc.googlegroups.com...
[Quoted Text]
>I am writing an XLL add-in with a custom dialog - DLL builds fine and
> gets loaded into Excel, however I am having problems with the dialog.
> The dialog only seems to want to display 63 or 64 controls from the
> [64][7] array that I have created.
> I can see nothing wrong with the definitions, and if I move the
> 'Error' row further up in the array then a different row gives the
> error.
> Are there any limits on the number of controls that can be specified
> within the array passed to xlfDialog?
>
> Thanks,
>
> Chris.


Re: Problems with xlfDialog
Chris <chris[ at ]chrisbird.com> 11/24/2008 9:06:29 AM
Hi Steve,

Thanks for your input - I was considering doing the same thing,
certainly worth a try.
In your book it demonstrates how to generate an Excel dialog from an
array - is it possible to do the opposite i.e. generate an array from
a dialog?
I am using Excel 2003.
Also, I have found several resource where people have managed to get
MFC DLLs to act as XLLs and display dialogs. I guess the approach
would be to use AFX_MANAGE_STATE to control resource location, create
a thread to act as a message handler, and create the dialog on the
thread - blocking the Excel API method until the dialog is terminated.
Do you know if this approach is possible and do I need to do perform
any periodic calls into the Excel API whilst awaiting return from the
MFC Dialog.
A requirement of the project is that it is written in C++ so I am
stuck with Excel API and cannot write the project using .NET
Framework.
You mention in your book that you only recommend the xlfDialog API
call for relatively simple Dialogs. Unfortunately, the dialog in
question is raather complex - could you give any recommendations on
the best way to implement a complex dialog?

Thanks,

Chris.


On Nov 23, 6:14 pm, "Steve Dalton" <NOsteveSPAM(at)NOeigensysSPAM(dot)
com> wrote:
[Quoted Text]
> Hi Chris
>
> Have you tried creating the dialog using an XLM macro sheet and displaying
> it using an XLM command macro?  I know it's going back several steps in
> Excel programming terms, but it might demonstrate whether or not the problem
> is a hard limit on the number of rows that xlfDialogBox can process.
>
> Regards
>
> Steve Dalton
>
> "Chris" <ch...[ at ]chrisbird.com> wrote in message
>
> news:48e4d6f6-e17a-45d8-9c9d-5214c99e9053[ at ]d23g2000yqc.googlegroups.com...
>
>
>
> >I am writing an XLL add-in with a custom dialog - DLL builds fine and
> > gets loaded into Excel, however I am having problems with the dialog.
> > The dialog only seems to want to display 63 or 64 controls from the
> > [64][7] array that I have created.
> > I can see nothing wrong with the definitions, and if I move the
> > 'Error' row further up in the array then a different row gives the
> > error.
> > Are there any limits on the number of controls that can be specified
> > within the array passed to xlfDialog?
>
> > Thanks,
>
> > Chris.- Hide quoted text -
>
> - Show quoted text -

Re: Problems with xlfDialog
Chris <chris[ at ]chrisbird.com> 11/24/2008 10:57:44 AM
Hi Steve,

Creating a dialog using a macro and Excel worksheet definitions as
outlined in Chapter 9 of your book also seems to fail - when around 64
items are added to the dialog. I will research this further, but it
does appear to be a rather frustrating limitation.

Chris.

On Nov 24, 9:06 am, Chris <ch...[ at ]chrisbird.com> wrote:
[Quoted Text]
> Hi Steve,
>
> Thanks for your input - I was considering doing the same thing,
> certainly worth a try.
> In your book it demonstrates how to generate an Excel dialog from an
> array - is it possible to do the opposite i.e. generate an array from
> a dialog?
> I am using Excel 2003.
> Also, I have found several resource where people have managed to get
> MFC DLLs to act as XLLs and display dialogs. I guess the approach
> would be to use AFX_MANAGE_STATE to control resource location, create
> a thread to act as a message handler, and create the dialog on the
> thread - blocking the Excel API method until the dialog is terminated.
> Do you know if this approach is possible and do I need to do perform
> any periodic calls into the Excel API whilst awaiting return from the
> MFC Dialog.
> A requirement of the project is that it is written in C++ so I am
> stuck with Excel API and cannot write the project using .NET
> Framework.
> You mention in your book that you only recommend the xlfDialog API
> call for relatively simple Dialogs. Unfortunately, the dialog in
> question is raather complex - could you give any recommendations on
> the best way to implement a complex dialog?
>
> Thanks,
>
> Chris.
>
> On Nov 23, 6:14 pm, "Steve Dalton" <NOsteveSPAM(at)NOeigensysSPAM(dot)
>
>
>
> com> wrote:
> > Hi Chris
>
> > Have you tried creating the dialog using an XLM macro sheet and displaying
> > it using an XLM command macro?  I know it's going back several steps in
> > Excel programming terms, but it might demonstrate whether or not the problem
> > is a hard limit on the number of rows that xlfDialogBox can process.
>
> > Regards
>
> > Steve Dalton
>
> > "Chris" <ch...[ at ]chrisbird.com> wrote in message
>
> >news:48e4d6f6-e17a-45d8-9c9d-5214c99e9053[ at ]d23g2000yqc.googlegroups.com....
>
> > >I am writing an XLL add-in with a custom dialog - DLL builds fine and
> > > gets loaded into Excel, however I am having problems with the dialog.
> > > The dialog only seems to want to display 63 or 64 controls from the
> > > [64][7] array that I have created.
> > > I can see nothing wrong with the definitions, and if I move the
> > > 'Error' row further up in the array then a different row gives the
> > > error.
> > > Are there any limits on the number of controls that can be specified
> > > within the array passed to xlfDialog?
>
> > > Thanks,
>
> > > Chris.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Re: Problems with xlfDialog
Chris <chris[ at ]chrisbird.com> 11/24/2008 12:24:51 PM
Okay,

I have managed to get MFC to display a dialog from within a XLL - this
required a little hacking.
I guess the question is whether or not this is a safe approach or not.

Step 1. Create MFC DLL
Step 2. Add XLL support files
Step 3. Modify the CWinApp derived class to include a static accessor
to the current CWinApp derived instance, which is set in
InitInstance , i.e

// static
CMyXLLWinApp &CMyXLLWinApp::pthis_;

BOOL CMyXLLWinApp::InitInstance()
{
CWinApp::InitInstance*(l
if (CMyXLLWinApp::pthis_ != 0) // Consider threading issues?
{
pthis_ = this;
}
}

//static
CMyXLLWinApp &CMyXLLWinApp::GetMyInstance()
{
return CMyXLLWinApp::pthis_;
}

Step4: Display dialog

int __stdcall MyCmd(void)
{
#pragma EXPORT

AfxGetModuleState()->m_hCurrentResourceHandle = AfxGetModuleState()-
[Quoted Text]
>m_hCurrentInstanceHandle = CMyXLLWinApp::GetMyInstance().m_hInstance;
AfxGetModuleState()->m_pCurrentWinApp = &
(CMyXLLWinApp::GetMyInstance());
AFX_MANAGE_STATE(AfxGetModuleState());

HWND excel_wnd = get_xl_main_handle();
if (excel_wnd != 0)
{
CWnd parent;
if (0 != parent.Attach(excel_wnd))
{
try
{
MyCDialog dlg(&parent);
dlg.DoModal();
}
catch(...) // not nice
{
}
parent.Detach();
}
}
return 0;
}

Is this going to crash Excel or cause any unantipicated side-effects?

Chris Bird.

On Nov 24, 10:57 am, Chris <ch...[ at ]chrisbird.com> wrote:
> Hi Steve,
>
> Creating a dialog using a macro and Excel worksheet definitions as
> outlined in Chapter 9 of your book also seems to fail - when around 64
> items are added to the dialog. I will research this further, but it
> does appear to be a rather frustrating limitation.
>
> Chris.
>
> On Nov 24, 9:06 am, Chris <ch...[ at ]chrisbird.com> wrote:
>
>
>
> > Hi Steve,
>
> > Thanks for your input - I was considering doing the same thing,
> > certainly worth a try.
> > In your book it demonstrates how to generate an Excel dialog from an
> > array - is it possible to do the opposite i.e. generate an array from
> > a dialog?
> > I am using Excel 2003.
> > Also, I have found several resource where people have managed to get
> > MFC DLLs to act as XLLs and display dialogs. I guess the approach
> > would be to use AFX_MANAGE_STATE to control resource location, create
> > a thread to act as a message handler, and create the dialog on the
> > thread - blocking the Excel API method until the dialog is terminated.
> > Do you know if this approach is possible and do I need to do perform
> > any periodic calls into the Excel API whilst awaiting return from the
> > MFC Dialog.
> > A requirement of the project is that it is written in C++ so I am
> > stuck with Excel API and cannot write the project using .NET
> > Framework.
> > You mention in your book that you only recommend the xlfDialog API
> > call for relatively simple Dialogs. Unfortunately, the dialog in
> > question is raather complex - could you give any recommendations on
> > the best way to implement a complex dialog?
>
> > Thanks,
>
> > Chris.
>
> > On Nov 23, 6:14 pm, "Steve Dalton" <NOsteveSPAM(at)NOeigensysSPAM(dot)
>
> > com> wrote:
> > > Hi Chris
>
> > > Have you tried creating the dialog using an XLM macro sheet and displaying
> > > it using an XLM command macro?  I know it's going back several steps in
> > > Excel programming terms, but it might demonstrate whether or not the problem
> > > is a hard limit on the number of rows that xlfDialogBox can process.
>
> > > Regards
>
> > > Steve Dalton
>
> > > "Chris" <ch...[ at ]chrisbird.com> wrote in message
>
> > >news:48e4d6f6-e17a-45d8-9c9d-5214c99e9053[ at ]d23g2000yqc.googlegroups.com....
>
> > > >I am writing an XLL add-in with a custom dialog - DLL builds fine and
> > > > gets loaded into Excel, however I am having problems with the dialog.
> > > > The dialog only seems to want to display 63 or 64 controls from the
> > > > [64][7] array that I have created.
> > > > I can see nothing wrong with the definitions, and if I move the
> > > > 'Error' row further up in the array then a different row gives the
> > > > error.
> > > > Are there any limits on the number of controls that can be specified
> > > > within the array passed to xlfDialog?
>
> > > > Thanks,
>
> > > > Chris.- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Home | Search | Terms | Imprint
Newsgroups Reader