Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

catch events from dynamic controls

4 views
Skip to first unread message

Stan Sager

unread,
Mar 10, 2010, 12:11:29 PM3/10/10
to
Hi everyone,
I am tasked with designing a form that would display checkboxes based
on some dynamic information items that we pull from a different source
(basically the information is not static and not coded in the form).
Because of this, we do not know the names of these checkboxes and how
many of them we need in the form. But the thing is that I need to be
able to fire an event when any of these dynamic controls are clicked.
Now I know, if the events were static, (lets say the button would be
called "staticname", I would be able to design a sub and call it sub
staticname_Click, and it would be fired as soon as such checkbox is
clicked. But I do not have such ability because the names of these
checkboxes are dynamic. So the question that I have, how would I
accomplish this "onClick" function for each of these checkboxes if the
code is dynamic. Here is an example of my code (follows):
sub Item_Open()
dim objPage, Frame1 'Declare controls
dim variable_array(3) 'Declare variable array
dim checkbox_array(3) 'places to store checkboxes array
dim i 'counter variable


variable_array(0)="variable_checkbox1" 'variable contents of the
array, contents are not known"
variable_array(1)="variable_checkbox2"
variable_array(2)="variable_checkbox3"
variable_array(3)="variable_checkbox4"
Set objPage = Item.GetInspector.ModifiedFormPages("Message")
Set Frame1 = objPage.Controls("Frame1")

''loop and add checkbox controls to the Frame1 from the
variable_array.
''Store them in the checkbox_array
for i = 0 to ubound(variable_array)
set checkbox_array(i)=Frame1.Controls.Add( "Forms.Checkbox.
1",variable_array(i) )
checkbox_array(i).Caption=variable_array(i)
checkbox_array(i).Alignment = 1
checkbox_array(i).AutoSize=true
checkbox_array(i).Left=50
checkbox_array(i).Top=(i+1)*checkbox_array(i).Height
next
end sub

I sincerely appreciate your help,

Stan

Ken Slovak - [MVP - Outlook]

unread,
Mar 10, 2010, 1:57:11 PM3/10/10
to
That's never going to work in Outlook form code. You can do similar things
with arrays of checkboxes with Windows Forms or things like that but not
with Outlook forms and form code. Use a listbox with checkboxes or a similar
control that fires only 1 event that you can code for.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stan Sager" <sag...@gmail.com> wrote in message
news:292e83b2-39d5-4e29...@v20g2000yqv.googlegroups.com...

Stan Sager

unread,
Mar 10, 2010, 2:51:55 PM3/10/10
to
Perhaps you could give me some ideas on how to accomplish what I am
trying to accomplish.

A form is to send one specific message to number of people, that are
chosen within a form. The types of people are derived by looking into
the addressbook. It looks at a specific distribution list, and for
each nested distribution list it creates a tab within a MultiTab
control, and for each person -- a checkbox with its name. So we do not
know how many tabs and listbox or checkboxes we are going to use. So
is there perhaps any way to trap such signal to evaluate if any
changes were present from a parent MultiTab control (or frame?)

Stan


On Mar 10, 1:57 pm, "Ken Slovak - [MVP - Outlook]"


<kenslo...@mvps.org> wrote:
> That's never going to work in Outlook form code. You can do similar things
> with arrays of checkboxes with Windows Forms or things like that but not
> with Outlook forms and form code. Use a listbox with checkboxes or a similar
> control that fires only 1 event that you can code for.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
>

> "Stan Sager" <sage...@gmail.com> wrote in message

Ken Slovak - [MVP - Outlook]

unread,
Mar 11, 2010, 9:52:22 AM3/11/10
to
You can't do what you want to do with Outlook forms. You need to redesign
your architecture. You have to hard-code any event handlers in Outlook form
code. Also, I'd be very wary of creating too many tabs on that multitab
control. When you add too many controls in an Outlook form it becomes
completely unstable and may even crash Outlook in addition to the form.

What I would do is use a listbox or other control that can have its list
modified at runtime and that can show checkboxes. An alternative would be a
grid control. However, any controls used in an Outlook from won't fire
almost any of their events and may crash the form. Outlook forms are just
not very robust for what you want to do.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.

Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stan Sager" <sag...@gmail.com> wrote in message

news:b91024c3-6a3b-4b76...@15g2000yqi.googlegroups.com...

Stan Sager

unread,
Mar 11, 2010, 4:12:46 PM3/11/10
to
Thank you Ken fory our advise and help.

Frankly I am both surprised and disappointed that Microsoft decided to
implement such poor API, terrible version of vbscript and gimped
controls. And also that with the new versions of the Office they did
not bother to update their code for the better.

Anyways, thank you very much for your help.

Stan

On Mar 11, 9:52 am, "Ken Slovak - [MVP - Outlook]"


<kenslo...@mvps.org> wrote:
> You can't do what you want to do with Outlook forms. You need to redesign
> your architecture. You have to hard-code any event handlers in Outlook form
> code. Also, I'd be very wary of creating too many tabs on that multitab
> control. When you add too many controls in an Outlook form it becomes
> completely unstable and may even crash Outlook in addition to the form.
>
> What I would do is use a listbox or other control that can have its list
> modified at runtime and that can show checkboxes. An alternative would be a
> grid control. However, any controls used in an Outlook from won't fire
> almost any of their events and may crash the form. Outlook forms are just
> not very robust for what you want to do.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.

> Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
>

> "Stan Sager" <sage...@gmail.com> wrote in message

Ken Slovak - [MVP - Outlook]

unread,
Mar 12, 2010, 9:17:03 AM3/12/10
to
Forms really haven't changed all that much since before Outlook was
released. MS never put much development effort there, and custom forms just
aren't very robust. Since the technology hasn't changed since before 1997 no
more modern things have been added except where absolutely necessary.

The development efforts have gone into COM addins and recently into Form
Regions. Both are far more robust and modern. Using addins I can do exactly
what you are looking to do, just not on forms or with form code. I'd be
using Windows Forms called from a button I'd add to the toolbars or ribbons.

I only make use of custom forms where they are absolutely necessary, where a
custom UI must be displayed in an Outlook form. If any alternative means of
displaying a desired UI is possible I'd use that rather than custom forms.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.

Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stan Sager" <sag...@gmail.com> wrote in message

news:78a71f29-110d-45e1...@b30g2000yqd.googlegroups.com...

Stan Sager

unread,
Mar 15, 2010, 11:00:41 AM3/15/10
to
Ken, forgive me my ignorance, I'm quite a newbie when it comes to the
Outlook programming. When you are creating these custom UI via
alternative means (as you described, COM addins or form regions), is
it possible to deploy them across Exchange (as we do forms)? If yes,
would you recommend any particular reading material on how to
accomplish that?

Thanks,

Stan

On Mar 12, 10:17 am, "Ken Slovak - [MVP - Outlook]"


<kenslo...@mvps.org> wrote:
> Forms really haven't changed all that much since before Outlook was
> released. MS never put much development effort there, and custom forms just
> aren't very robust. Since the technology hasn't changed since before 1997 no
> more modern things have been added except where absolutely necessary.
>
> The development efforts have gone into COM addins and recently into Form
> Regions. Both are far more robust and modern. Using addins I can do exactly
> what you are looking to do, just not on forms or with form code. I'd be
> using Windows Forms called from a button I'd add to the toolbars or ribbons.
>
> I only make use of custom forms where they are absolutely necessary, where a
> custom UI must be displayed in an Outlook form. If any alternative means of
> displaying a desired UI is possible I'd use that rather than custom forms.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.

> Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
>

> "Stan Sager" <sage...@gmail.com> wrote in message

Ken Slovak - [MVP - Outlook]

unread,
Mar 15, 2010, 12:49:40 PM3/15/10
to
Yes, you can deploy COM addins to all your users, they just have to be
installed on each desktop where you want the addins to run. Normally, addins
are installed using Windows Installer programs (msi's and setup.exe's).

I'm not sure what you want to read about this, installation is just from any
installer. If you want to find out more about COM addins in general you can
look at the material at www.outlookcode.com on COM addins to start with.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.

Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stan Sager" <sag...@gmail.com> wrote in message

news:b5f1ebd5-41f4-4b30...@z35g2000yqd.googlegroups.com...

0 new messages