Solved

How do I print ActiveX type from .NET

Posted on 2009-05-06
4
809 Views
Last Modified: 2013-12-17
Ive written a program to dump out using .NET the objects in a crystal report.  This uses Crystals RDC ActiveX component.

Here is the problem.  When I dump an ActiveX object, I dont see the ActiveX type.  Here is what I see:

oFld.Field=System.__ComObject

Every Com object is seen as System.__ComObject.

How do I see the ActiveX type (which in this case might be IParameterField) of oFld.Field?

Im programming in C#.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using CRAXDDRT;

 

namespace Dumper

{

    class Dumper

    {

        static void Main(string[] args)

        {

            Application crApp = new Application();

            Report report;

            report = crApp.OpenReport("c:\\Reports\CurrentAdmissions.rpt", 0);

            ProcessReport(report);

        }

 

        static void ProcessReport(IReport report) {

            foreach (Section section in report.Sections)

            {

                Console.WriteLine("Section Name=" + section.Name);

                if (section.ReportObjects.Count != 0)

                {

                    foreach (Object item in section.ReportObjects)

                    {

                        if (item is ITextObject)

                        {

 

                            ITextObject oTxt = (ITextObject)item;

                            Console.WriteLine("oTxt.BackColor=" + oTxt.BackColor);

                            Console.WriteLine("oTxt.BorderColor = " + oTxt.BorderColor);

                            Console.WriteLine("oTxt.BottomLineStyle = " + oTxt.BottomLineStyle);

                            Console.WriteLine("oTxt.CanGrow = " + oTxt.CanGrow);

                            Console.WriteLine("oTxt.CharacterSpacing = " + oTxt.CharacterSpacing);

                            Console.WriteLine("oTxt.CloseAtPageBreak = " + oTxt.CloseAtPageBreak);

                            //Console.WriteLine("oTxt.ConditionFormula = " + oTxt.ConditionFormula(0));

                            Console.WriteLine("oTxt.CssClass = " + oTxt.CssClass);

                            //Console.WriteLine("oTxt.FieldElements = " + oTxt.FieldElements.);

                            Console.WriteLine("oTxt.FirstLineIndent = " + oTxt.FirstLineIndent);

                            Console.WriteLine("oTxt.Font = " + oTxt.Font);

                            Console.WriteLine("oTxt.HasDropShadow = " + oTxt.HasDropShadow);

                            Console.WriteLine("oTxt.Height = " + oTxt.Height);

                            Console.WriteLine("oTxt.HorAlignment = " + oTxt.HorAlignment);

                            Console.WriteLine("oTxt.HyperlinkText = " + oTxt.HyperlinkText);

                            Console.WriteLine("oTxt.HyperlinkType = " + oTxt.HyperlinkType);

                            Console.WriteLine("oTxt.KeepTogether = " + oTxt.KeepTogether);

                            Console.WriteLine("oTxt.Kind = " + oTxt.Kind);

                            Console.WriteLine("oTxt.Left = " + oTxt.Left);

                            Console.WriteLine("oTxt.LeftIndent = " + oTxt.LeftIndent);

                            Console.WriteLine("oTxt.LeftLineStyle = " + oTxt.LeftLineStyle);

                            Console.WriteLine("oTxt.LineSpacing = " + oTxt.LineSpacing);

                            Console.WriteLine("oTxt.LineSpacingType = " + oTxt.LineSpacingType);

                            Console.WriteLine("oTxt.MaxNumberOfLines = " + oTxt.MaxNumberOfLines);

                            Console.WriteLine("oTxt.Name = " + oTxt.Name);

                            Console.WriteLine("oTxt.RightIndent = " + oTxt.RightIndent);

                            Console.WriteLine("oTxt.RightLineStyle = " + oTxt.RightLineStyle);

                            Console.WriteLine("oTxt.Suppress = " + oTxt.Suppress);

                            Console.WriteLine("oTxt.SuppressIfDuplicated = " + oTxt.SuppressIfDuplicated);

                            Console.WriteLine("oTxt.Text = " + oTxt.Text);

                            Console.WriteLine("oTxt.TextColor = " + oTxt.TextColor);

                            Console.WriteLine("oTxt.TextRotationAngle = " + oTxt.TextRotationAngle);

                            Console.WriteLine("oTxt.Top = " + oTxt.Top);

                            Console.WriteLine("oTxt.TopLineStyle = " + oTxt.TopLineStyle);

                            Console.WriteLine("oTxt.Width = " + oTxt.Width);

                            Console.WriteLine("oTxt.FieldElements=" + oTxt.FieldElements);

 

 

                        }

                        else if (item is IFieldObject)

                        {

                            IFieldObject oFld = (IFieldObject)item;

                            Console.WriteLine("oFld.Name = " + oFld.Name);

                            Console.WriteLine("oFld.Value = " + oFld.Value);

                            Console.WriteLine("oFld.AmPmType = " + oFld.AmPmType);

                            Console.WriteLine("oFld.AmString = " + oFld.AmString);

                            Console.WriteLine("oFld.BackColor = " + oFld.BackColor);

                            Console.WriteLine("oFld.BooleanOutputType = " + oFld.BooleanOutputType);

                            Console.WriteLine("oFld.BorderColor = " + oFld.BorderColor);

                            Console.WriteLine("oFld.BottomLineStyle = " + oFld.BottomLineStyle);

                            Console.WriteLine("oFld.CanGrow = " + oFld.CanGrow);

                            Console.WriteLine("oFld.CharacterSpacing = " + oFld.CharacterSpacing);

                            Console.WriteLine("oFld.CloseAtPageBreak = " + oFld.CloseAtPageBreak);

                            //Console.WriteLine("oFld.ConditionFormula = " + oFld.ConditionFormula(??));

                            Console.WriteLine("oFld.CssClass = " + oFld.CssClass);

                            Console.WriteLine("oFld.CurrencyPositionType = " + oFld.CurrencyPositionType);

                            Console.WriteLine("oFld.CurrencySymbol = " + oFld.CurrencySymbol);

                            Console.WriteLine("oFld.CurrencySymbolType = " + oFld.CurrencySymbolType);

                            Console.WriteLine("oFld.DateCalendarType = " + oFld.DateCalendarType);

                            Console.WriteLine("oFld.DateEraType = " + oFld.DateEraType);

                            Console.WriteLine("oFld.DateFirstSeparator = " + oFld.DateFirstSeparator);

                            Console.WriteLine("oFld.DateOrder="+oFld.DateOrder);

                            Console.WriteLine("oFld.DatePrefixSeparator="+oFld.DatePrefixSeparator);

                            Console.WriteLine("oFld.DateSecondSeparator="+oFld.DateSecondSeparator);

                            Console.WriteLine("oFld.DateSuffixSeparator="+oFld.DateSuffixSeparator);

                            Console.WriteLine("oFld.DateWindowsDefaultType="+oFld.DateWindowsDefaultType);

                            Console.WriteLine("oFld.DayType="+oFld.DayType);

                            Console.WriteLine("oFld.DecimalPlaces="+oFld.DecimalPlaces);

                            Console.WriteLine("oFld.DecimalSymbol="+oFld.DecimalSymbol);

                            Console.WriteLine("oFld.DisplayReverseSign="+oFld.DisplayReverseSign);

                            Console.WriteLine("oFld.EnableTightHorizontal="+oFld.EnableTightHorizontal);

                            Console.WriteLine("oFld.FirstLineIndent="+oFld.FirstLineIndent);

                            Console.WriteLine("oFld.Font="+oFld.Font);

                            Console.WriteLine("oFld.HasDropShadow="+oFld.HasDropShadow);

                            Console.WriteLine("oFld.Height="+oFld.Height);

                            Console.WriteLine("oFld.HorAlignment="+oFld.HorAlignment);

                            Console.WriteLine("oFld.HourMinuteSeparator="+oFld.HourMinuteSeparator);

                            Console.WriteLine("oFld.HourType="+oFld.HourType);

                            Console.WriteLine("oFld.HyperlinkText="+oFld.HyperlinkText);

                            Console.WriteLine("oFld.HyperlinkType="+oFld.HyperlinkType);

                            Console.WriteLine("oFld.KeepTogether="+oFld.KeepTogether);

                            Console.WriteLine("oFld.Kind="+oFld.Kind);

                            Console.WriteLine("oFld.LeadingDayPosition="+oFld.LeadingDayPosition);

                            Console.WriteLine("oFld.LeadingDaySeparator="+oFld.LeadingDaySeparator);

                            Console.WriteLine("oFld.LeadingDayType="+oFld.LeadingDayType);

                            Console.WriteLine("oFld.Left="+oFld.Left);

                            Console.WriteLine("oFld.LeftIndent="+oFld.LeftIndent);

                            Console.WriteLine("oFld.LeftLineStyle="+oFld.LeftLineStyle);

                            Console.WriteLine("oFld.LineSpacing="+oFld.LineSpacing);

                            Console.WriteLine("oFld.LineSpacingType="+oFld.LineSpacingType);

                            Console.WriteLine("oFld.MaxNumberOfLines="+oFld.MaxNumberOfLines);

                            Console.WriteLine("oFld.MinuteSecondSeparator="+oFld.MinuteSecondSeparator);

                            Console.WriteLine("oFld.MinuteType="+oFld.MinuteType);

                            Console.WriteLine("oFld.MonthType="+oFld.MonthType);

                            Console.WriteLine("oFld.Name="+oFld.Name);

                            Console.WriteLine("oFld.NegativeType="+oFld.NegativeType);

                            Console.WriteLine("oFld.NextValue="+oFld.NextValue);

                            Console.WriteLine("oFld.PmString="+oFld.PmString);

                            Console.WriteLine("oFld.PreviousValue="+oFld.PreviousValue);

                            Console.WriteLine("oFld.RightIndent="+oFld.RightIndent);

                            Console.WriteLine("oFld.RightLineStyle="+oFld.RightLineStyle);

                            Console.WriteLine("oFld.RoundingType="+oFld.RoundingType);

                            Console.WriteLine("oFld.SecondType="+oFld.SecondType);

                            Console.WriteLine("oFld.Suppress="+oFld.Suppress);

                            Console.WriteLine("oFld.SuppressIfDuplicated="+oFld.SuppressIfDuplicated);

                            Console.WriteLine("oFld.SuppressIfZero="+oFld.SuppressIfZero);

                            Console.WriteLine("oFld.TextColor="+oFld.TextColor);

                            Console.WriteLine("oFld.TextFormat="+oFld.TextFormat);

                            Console.WriteLine("oFld.TextRotationAngle="+oFld.TextRotationAngle);

                            Console.WriteLine("oFld.ThousandsSeparators="+oFld.ThousandsSeparators);

                            Console.WriteLine("oFld.ThousandSymbol="+oFld.ThousandSymbol);

                            Console.WriteLine("oFld.TimeBase="+oFld.TimeBase);

                            Console.WriteLine("oFld.Top="+oFld.Top);

                            Console.WriteLine("oFld.TopLineStyle="+oFld.TopLineStyle);

                            Console.WriteLine("oFld.UseLeadingZero="+oFld.UseLeadingZero);

                            Console.WriteLine("oFld.UseOneSymbolPerPage="+oFld.UseOneSymbolPerPage);

                            Console.WriteLine("oFld.UseSystemDefaults="+oFld.UseSystemDefaults);

                            Console.WriteLine("oFld.Value="+oFld.Value);

                            Console.WriteLine("oFld.Width="+oFld.Width);

                            Console.WriteLine("oFld.YearType="+oFld.YearType);

                            Console.WriteLine("oFld.ZeroValueString="+oFld.ZeroValueString);

                            Console.WriteLine("oFld.Field=" + oFld.Field);

 

 

                        }

                        else if (item is ILineObject)

                        {

                            ILineObject oLine = (ILineObject)item;

                            Console.WriteLine("oLine.Bottom = " + oLine.Bottom);

                            //Console.WriteLine("oLine.ConditionFormula = " + oLine.ConditionFormula);

                            Console.WriteLine("oLine.CssClass = " + oLine.CssClass);

                            //Console.WriteLine("oLine.EndSection = " + oLine.EndSection. ' structure...);

                            Console.WriteLine("oLine.ExtendToBottomOfSection = " + oLine.ExtendToBottomOfSection);

                            Console.WriteLine("oLine.Kind = " + oLine.Kind);

                            Console.WriteLine("oLine.Left = " + oLine.Left);

                            Console.WriteLine("oLine.LineColor = " + oLine.LineColor);

                            Console.WriteLine("oLine.LineStyle = " + oLine.LineStyle);

                            Console.WriteLine("oLine.LineThickness = " + oLine.LineThickness);

                            Console.WriteLine("oLine.Name = " + oLine.Name);

                            Console.WriteLine("oLine.Right = " + oLine.Right);

                            Console.WriteLine("oLine.Suppress = " + oLine.Suppress);

                            Console.WriteLine("oLine.Top = " + oLine.Top);

 

                        }

                        else if (item is ICROleObject)

                        {

                        }

                        else if (item is ISubreportObject)

                        {

                            ISubreportObject oSubReport = (ISubreportObject)item;

                            Console.WriteLine("oSubReport = " + oSubReport.Name);

                            IReport sr = oSubReport.OpenSubreport();

                            ProcessReport(sr);

                        }

                        else

                        {

                            Console.WriteLine("Unimplemented type: " + item);

                        }

 

                    }

 

                }

 

 

            }

        }

    }

}

Open in new window

0
Comment
Question by:jslevinson
  • 2
  • 2
4 Comments
 

Author Comment

by:jslevinson
ID: 24319791
I've increased the value of the question.
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 24327299
This article is in VB rather than c#, but the same principles should apply:

http://msdn.microsoft.com/en-us/magazine/2009.01.basicinstincts.aspx
0
 

Author Closing Comment

by:jslevinson
ID: 31578465
I programmed a DLL in VB.NET with this solution.  So I did not have full C# solution but the solution works.  The C# code calls the VB.NET DLL to print out the type.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24330505
Cool, multi-language development in action!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This video shows how use content aware, what it’s used for, and when to use it over other tools.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now