mfc >> Custom window attributes

by TF » Tue, 25 Jan 2005 02:12:59 GMT

I am attempting to set my main window (MFC generated) with certain
attributes. Here is the list.

1. Borderless
2. No title/caption bar
3. No resize
4. No taskbar button

So far, I have the border down to almost nothing, but as soon as it is
resized, it appears (once the scrollbars appear).

TF




Similar Threads

1. custom events in custom controls not appear in properties window - CSharp/C#

2. How to use Custom Attribute on ASSEMBLY level

In my project, I need to use custom attribute on all assemblies. This
attribute will implement some non-functional code and I want to use it
on assembly level(AttributeTargets is Assembly).

I add code "[assembly: CallTracing()]" in file AssemblyInfo.cs. But it
seem that it didn't work. I don't know why.

CODE AS BELOW:

TestAttribute.cs+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
using System;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Activation;

namespace AOP.Experiment
{
	internal class CallTracingAspect : IMessageSink
	{
		private IMessageSink m_next;
		private String m_typeAndName ;

		internal CallTracingAspect(IMessageSink next)
		{
			// Cache the next sink in the chain
			m_next = next;
		}

		public IMessageSink NextSink
		{
			get
			{
				return m_next;
			}
		}

		public IMessage SyncProcessMessage(IMessage msg)
		{
			Preprocess(msg);
			IMessage returnMethod = m_next.SyncProcessMessage(msg);
			PostProcess(msg, returnMethod);
			return returnMethod;
		}

		public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink
replySink)
		{
			throw new InvalidOperationException() ;
		}

		public static string ContextName
		{
			get
			{
				return "CallContext" ;
			}
		}
		private void Preprocess(IMessage msg)
		{
			if (!(msg is IMethodMessage)) return;

			IMethodMessage call = msg as IMethodMessage;
			Type t = Type.GetType(call.TypeName) ;
			m_typeAndName = t.Name + "." + call.MethodName ;
			Console.Write("calltrace PreProcessing: " + m_typeAndName + "(");

			for (int i = 0; i < call.ArgCount; ++i)
			{
				if (i > 0) Console.Write(", ");
				Console.Write(call.GetArgName(i) + "= " + call.GetArg(i));
			}
			Console.WriteLine(")");

			// set us up in the callContext
			call.LogicalCallContext.SetData(ContextName, this);
		}

		private void PostProcess(IMessage msg, IMessage msgReturn)
		{
			// We only want to process method return calls
			if (!(msg is IMethodMessage) ||
				!(msgReturn is IMethodReturnMessage)) return;

			IMethodReturnMessage retMsg = (IMethodReturnMessage)msgReturn;
			Console.Write("calltrace PostProcessing: ");
			Exception e = retMsg.Exception;
			if (e != null)
			{
				Console.WriteLine("Exception was thrown: " + e);
				return;
			}

			// Loop through all the [out] parameters
			Console.Write(m_typeAndName + "(");
			if (retMsg.OutArgCount > 0)
			{
				Console.Write("out parameters[");
				for (int i = 0; i < retMsg.OutArgCount; ++i )
				{
					if (i > 0) Console.Write(", ");
					Console.Write(retMsg.GetOutArgName(i) + "= " +
						retMsg.GetOutArg(i));
				}
				Console.Write("]");
			}
			if (retMsg.ReturnValue.GetType() != typeof(void))
				Console.Write("returned [" + retMsg.ReturnValue + "]");

			Console.WriteLine(")");
		}
	}

	public class CallTracingProperty : IContextProperty,
IContributeServerContextSink
	{
		public IMessageSink GetServerContextSink(IMessageSink next)
		{
			Console.WriteLine("***In CallTracingProperty's GetObjectSink***");
			Console.WriteLine("Next Message Sink is " + next.GetType());
			return new CallTracingAspect(next);
		}
		public bool IsNewContextOK( Context newCtx )
		{
			return true ;
		}
		public void Freeze(Context newContext)
		{
		}
		public string Name
		{
			get
			{
				return "CallTracingProperty";
			}
		}
	}

	[AttributeUsage(AttributeTargets.Assembly)]
	public class CallTracingAttribute : ContextAttribute
	{
		public CallTracingAttribute() : base("CallTracing") {}

		public override void
GetPropertiesForNewContext(IConstructionCallMessage ccm)
		{
			ccm.ContextProperties.Add(new CallTracingProperty());
			Console.WriteLine("CallTracingAttribute has been created for new
context");
		}
	}
}


TestClass.cs+++++++++++++++++++++++++++++++++++++++++++++++++
using System;

namespace AOP.Experiment
{
	public class cTestClass:ContextBoundObject
	{
		public cTestClass()
		{
			Console.WriteLine("TestClass ctor()");
		}

		public override string ToString()
		{
			return "Test Class";
		}

	}
}

TestClass.csssemblyInfo.cs+++++++++++++++++++++++++++++++++++++

using System.Reflection;
using System.Runtime.CompilerServices;
using AOP.Experiment;

[assembly: CallTracing()]

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

TestManager.cs+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
using System;
using System.Reflection;

namespace AOP.Experiment
{
	class cTestManager
	{
		[STAThread]
		static void Main(string[] args)
		{
			Assembly TestAssembly;
			cTestClass TestClass;
			try
			{
				Console.WriteLine("dd");
				TestAssembly =
Assembly.LoadFrom("E:\\DR\\Module\\Debug\\TestClass.dll");
				Console.WriteLine(TestAssembly.GetName().ToString());
				TestClass =
(cTestClass)TestAssembly.CreateInstance("AOP.Experiment.cTestClass");
				Console.WriteLine(TestClass.ToString());

			}
			catch(Exception e)
			{
				Console.WriteLine(e.ToString());
			}

			Console.ReadLine();
		}
	}
}

3. Custom Attribute trouble - CSharp/C#

4. generating C# classes from XSD with Custom Attributes..

Hi All

I am trying to generate classes from XSD which looks like this

namespace WindowsFormsApplication1.Something.Some
{
    public class Address
    {

        public Address()
        {
        }


        [FormMapper("TextBox2")]

        public string StreetAddress { get; set; }
        [FormMapper("TextBox3")]
        public string UnitNumber { get; set; }
        [FormMapper("TextBox4")]
        public string City { get; set; }
        [FormMapper("TextBox5")]
        public string State { get; set; }
        [FormMapper("TextBox6")]
        public string zip { get; set; }

    }
}




How do i represent the FormMapper Attribute in the xsd.

Please Help and thanks

5. Custom attribute ? - CSharp/C#

6. Keeping the order of custom attributes

7. Using a custom attribute in aspx pages - CSharp/C#

8. Custom Attributes - Are they implicitly inherited by subclasses?


public class ClassA
{
 [MyCoolAttribute]
 private string  _FieldName;   
    public string  FieldName
    {
      get { return _FieldName; }
    }
}

public class ClassB: ClassA
{
 // [MyCoolAttribute] 
 // Must be explicity typed in attribute or implicit in 
 // the base class?
 private string  _FieldName;   
    public string  FieldName
    {
      get { return _FieldName; }
    }
}
    
If ClassA implments a custom attribute on one of it's members, do
derived classes automatically get that attribute or must it be
explicitly added?

Thank you,

-- 
Warm Regards,
Lee

"Upon further investigation it appears that your software is missing
just one thing.  It definitely needs more cow bell..."