|
Follow up:
I have gotten it to work when serializing as binary. I placed the following attribute on my setting of type Hashtable:
[global::System.Configuration.SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)]
I guess Hashtables can serialize out of the box in binary mode, but not xml.
R.Bischoff
Tengas un buen dia
-- modified at 11:28 Thursday 23rd March, 2006
|
|
|
|
|
Hello,
I just wondering what is the best way to relay certain information back to the parent window, from invoked dialog window?
I have MainWindow, that launches dialog:
Options optionsWindow = new Options(user);<br />
optionsWindow.ShowDialog(this);
In the options dialog the user can set to display toolbar, etc..
When the user clicks the Ok button to close options dialog, I want to update the toolbar status in the mainwindow. What would be the best way to do it.
For now I use:
>((MainWindow)Owner).UpdateToolBarStatus(currentUser.ToolBarVisible);<br />
|
|
|
|
|
There are several ways that actions in one window can notify the parent of what is happening. For example:
In your optionsWindow, you can have it raise events back to the parent that are specifically created by you. (example: UpdateOptionsEvent using an OptionsEventHandler in the MainWindow)
Another way is that you have the MainWindow register as a subscriber to the options :
Options optionsWindow = new Options(user);
optionsWindow.ShowToolBarStatusChecked+=this.StutusCheckEventHandler;
It all depends on if you want the parent to respond to specific, single events (checking a box) or continuous events (the options cause a process to run in the child that you reflect the status of in the MainWindow).
Hope this helps.
|
|
|
|
|
|
I have created an abstract class called "BASE", that will have 10-20 subclasses. In a config file I will have pairings of MessageIDs and subclass names. MessageID is a custom identifier for the message type. So my config will look like this:
1,TestApp.subClassSample
2,TestApp2.NewSubclass
3,TestApp2.OldSubClass
In pseudo-code, I want my code to work like this
BASE b = null;<br />
string classname = getMessageIdsClass(2) ;
b = new classname;
b.SomeFunctionInAbstractClass();<br />
b = new classname obviuosly is not valid. I can create a Type object based on the string, but can't figure out how to cast BASE to the subclass.
Any thoughts would be appreciated!
Greg
|
|
|
|
|
|
Yes that works for creating an object. But then how do I cast the object to a subBase or a subBase2 which I don't know at design time. My example below works, but in runtime, I am not going to know the actual object subBase. I will need to cast it from the string in the config file. That's where I get stuck.
<br />
BASE c = null;<br />
Type t = Type.GetType("mytest.subBase");<br />
object o = Activator.CreateInstance(t);<br />
c = o as subBase;<br />
"c = o as subBase" needs to be "c = o as "someString"" but I can't figure it out.
thanks for your response.
Greg
|
|
|
|
|
Presumably there is some shared functionality which is then implemented by the Concrete class (the ones defined in the config) so the abstract class (or interface) should be sufficient:
class MyBaseClass
{
abstract void DoSomething();
}
class MyConcreeteClass1 : MyBaseClass
{
override coid DoSomething()
{
Console.WriteLine("From 1");
}
}
class MyConcreeteClass2 : MyBaseClass
{
override coid DoSomething()
{
Console.WriteLine("From 2");
}
}
now, notice the only time I specify the class name is in a string - same as your config:
Type t1 = Type.GetType("MyConcreteClass1");<br />
Type t2 = Type.GetType("MyConcreteClass2");<br />
MyBaseClass o1 = (MyBaseClass)Activator.CreateInstance(t1);<br />
MyBaseClass o2 = (MyBaseClass)Activator.CreateInstance(t2);<br />
o1.DoSomething();<br />
o2.DoSomething();
-- modified at 10:48 Thursday 23rd March, 2006
|
|
|
|
|
Exactly. I'm kicking myself now. I don't know why I was trying to cast it!
thank you both for your quick responses!
greg
|
|
|
|
|
As far as i know it's not possible to make such a "dynamic cast".
Can't you create the object as instance of the subBase class needed?
In your example o will have type mytest.subBase so why cast to subBase afterwards.?
www.troschuetz.de
|
|
|
|
|
hello everybody in this forum.
iam currently implementing chat server application that must connect to the outside world from windows xp sp1 or sp2.
i tried to add my application ports programmatically to the internet connection firewall in windows xp sp1 but i couldn't cause i see the com file "hnetcfg.dll" in my windows operating system doesn't have "INetFwMgr" class that i must interlop to add the ports to the current running service of my application in the firewall.
i asked some friends and they told me it is impossible to add these ports cause your windows xp is SP1 not SP2 but what i see strange ???
is that hotmail messenger currently do that in my windows xp Sp1 ? when i try to connect to the internet it adds two UDP ports to the current dial up connection used to connect to the internet.
my question is :
i want to know how to add these ports in the windows xp if it is sp1 or sp2 as hotmail messenger does ?
is there any com file i can take from hotmail messenger for doing that ???
and if there is a com file for doing that ? if i interlopped that .Dll com into my application and i registered that com in the target pc that will run my application it will work or it needs msn messenger to be installed first (this is in case i took dll from the com files of the msn msgr).
how can i add these ports ? Please help me.
Human knowledge belongs to the world.
|
|
|
|
|
|
I have a requirement to create a hyperlink in Outlook using C#. The Hyperlink will point to some .exe file. When I create hyperlink manually in Outlook 2003, it executes the exe file on clicking it. Now I have to do this programmatically. How can it be done??
One more thing how can I pass arguments to this exe file. Any Idea??
|
|
|
|
|
|
Ya, I am talking about a hyperlink inside a composed email in outlook
|
|
|
|
|
Maybe this helps: http://forums.devshed.com/html-programming-1/adding-link-in-body-of-mailto-333922.html
|
|
|
|
|
i made control to open PPT application but i am getting a problem that when i close the form on which i am using that control the following error occurs
"Microsoft occurs a problem to close this application"
and after that a new ppt window is opened..
i Am defineing the following code to defien events....
wd.CommandBars.AdaptiveMenus = false;
wd.PresentationOpen += new ppt.EApplication_PresentationOpenEventHandler(OnOpenDoc);
wd.EApplication_Event_NewPresentation += new ppt.EApplication_NewPresentationEventHandler(OnNewDoc);
If anybody have any solution please let me know...
Thanks...
|
|
|
|
|
where is the code for closing your application?
This code always open a new application!
"wd.PresentationOpen += new ppt.EApplication_PresentationOpenEventHandler(OnOpenDoc);"
With the "+=" you open a new ppt without closing the old one!
best regard
Adiphe
"...all is simple, but there is always simpler ..."
|
|
|
|
|
hi Adiphe
thanks for response...
i am using this code for close but its giving me error i have mentioned the error in end..
wd.PresentationClose += new ppt.EApplication_PresentationCloseEventHandler(OnClose);
and the onClose function is
private void OnClose(ppt.Presentation pt, ref bool cancel)
{
if (!deactivateevents)
{
cancel = true;
}
}
I wrote this code for colse but its giving the following build error
"No overload for 'OnClose' matches delegate 'Microsoft.Office.Interop.PowerPoint.EApplication_PresentationCloseEventHandler'"
please tell me the solution
|
|
|
|
|
Hi
I want to know how to open an executable for reading
like those hexeditors out there
and how then i can jumb to specific offset and change it
any help please !!
Ahmad Shaban
|
|
|
|
|
Hi!
Try this code:
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);
BinaryReader br = new BinaryReader(fs);
BinaryWriter bw = new BinaryWriter(fs);
fs.Seek(123, SeekOrigin.Begin);
byte[] buf = br.ReadBytes(16);
for (int i=0; i<buf.Length; i++)
buf[i] ^= 128;
fs.Seek(123, SeekOrigin.Begin);
bw.Write(buf);
bw.Close();
MessageBox.Show("Congratulations, you have ruined '"+filePath+"'!");
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Requirement :
VC++ dll ==> Exports a class which contains few functions.
I need to create a C# Application that consumes the function in
VC++ dll.
Looking forward ur Help
for thendral
|
|
|
|
|
Hi there
use :
using System.Runtime.InteropServices;
and in the class (propably a static helper class)
[DllImport ("user32.dll")]
public static extern long DestroyWindow (long hWnd);
and from your program call :
MyStaticHelper.DestroyWindow (this.Handle);
Hope that helped
Nassos
GanDad
|
|
|
|
|
Add the dll into ur project,
add a reference to that dll,
Create an object of the class in the dll,
and call the methods of that class.
Regards,
Pramod
|
|
|
|
|
I suggest you read the question more carefully next before you give wrong advise.
|
|
|
|