Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Can "InitializeComponent()" info be captured

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Smith - 07 Jul 2006 16:28 GMT
Hi there,

Don't know if I picked the correct NGs or not but maybe someone can steer me
in the right direction. Does anyone know if a class exists to capture the
same info now wrapped in "InitializeComponent()". I want to capture all form
details for a given form at design time (properties and controls) but I
can't find anyway to do it. Note that reading a form's ".resx" files won't
do either (it's only good for localized forms but in any case, it doesn't
always provide complete info). Thanks very much.
Nicholas Paldino [.NET/C# MVP] - 08 Jul 2006 18:09 GMT
Larry,

   At design time, you should hook into the designer.  I would recommend
creating a component/control that you place on your form/control, and then
traversing the designer heiarchy (there is an object/interface model
specifically for this).

   Check out the article in MSDN mag titled "Building Windows Forms
Controls and Components with Rich Design-Time Features", located at (watch
for line wrap):

http://msdn.microsoft.com/msdnmag/issues/03/04/Design-TimeControls/default.aspx

   It has a section on the interfaces implemented by controls at design
time, and how you can access services of the designer and other information
about other components in the designer.  Of course, it will probably involve
a good deal of reflection ony your part as well, unless you know what you
are looking for specifically.

   Hope this helps.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi there,
>
[quoted text clipped - 5 lines]
> won't do either (it's only good for localized forms but in any case, it
> doesn't always provide complete info). Thanks very much.
Larry Smith - 09 Jul 2006 16:46 GMT
> Larry,
>
[quoted text clipped - 14 lines]
> probably involve a good deal of reflection ony your part as well, unless
> you know what you are looking for specifically.

Thanks very much. I'll look into it. It seems however that there's no (easy)
way for developers to extract a form from a project after the fact. Unlike
in raw Windows programming for instance, where an entire dialog can be
extracted from its ".res" file (or even it's corresponding ".rc" source
file) , no analogue seems to exist in .NET. A simple collection class
exposing all forms in a project (their properties and controls) is all
that's required. I'm surprised that this doesn't already exist but have
already suggested it to MSFT product feedback. Anyway, thanks again.
Stoitcho Goutsev (100) - 11 Jul 2006 14:20 GMT
Larry,

You can always load already compiled assembly reflect on it, find all public
forms and/or user controls, create the object and then go through their
Controls collections. This will give you pretty good information on the
structure of the forms and user controls in an assembly.

Signature

HTH
Stoitcho Goutsev (100)

>> Larry,
>>
[quoted text clipped - 23 lines]
> that's required. I'm surprised that this doesn't already exist but have
> already suggested it to MSFT product feedback. Anyway, thanks again.
Larry Smith - 11 Jul 2006 14:37 GMT
> Larry,
>
> You can always load already compiled assembly reflect on it, find all
> public forms and/or user controls, create the object and then go through
> their Controls collections. This will give you pretty good information on
> the structure of the forms and user controls in an assembly.

Thanks for the reply. Unfortunately it's not so simple :)
This app will be running on unknown 3rd-party developer machines. Therefore,
if the programmer adds any code immediately after the call to
"InitializeComponent()" (to initialize the form normally) then:

1) It may not run on the developer's machine where this is all taking place
(if the code depends on resources found in the actual release environment)
2) I can't allow this code to run anyway since I have no idea what it does
(therefore subject to failure, potentially very slow or even dangerous,
etc.)
3) I only want to capture the basic form without initializing its controls
in anyway (granted, if any controls or properties are manually added/changed
then I have a problem)

Anyway, thanks again.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.