|
Gaurika Wijeratne wrote:
Is there any technology in .Net to replace com+
Check out the System.EnterpriseServices namespace
Gaurika Wijeratne wrote:
1. How to create a object in specific server in c#
Eg – in vb createobject(“name”,”server”)
Check out System.Remoting, it can be compared with that of DCOM.
Cheers,
Kannan
|
|
|
|
|
I am already using System.EnterpriseServices namespace
I have also registered the assembly in com+
I just want to create a object in the com+ server, from another machine..
Thanks
Gauirka.
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
ok, i need some help in this matter, and i cant seem to find a solution online
heres the scenario
i created a usercontrol
now, i added in a label and a picture box into it (docked both left)
so now the usercontrol is effectively hidden from the view
so, from the form that i add this control into, i want to create a Click event, referring to when the user clicks the control. i cant get it to work as the usercontrol.click event never fires due to the fact that i cant click directly on the usercontrol (its clicking on either the label or picture box)
now, im gonna use this user control in a lot of forms, and i dont want my only solution to be duplicating the code
uc.label1.click += new eventhandler(clicked);
uc.picturebox1.click += new eventhandler(clicked);
is there any way for me to merge the 2 events into 1?
something like declaring a public event inside the user control then linking it to both controls?
or is there an event type that allows me to specify if any of the child controls are clicked, a certain event will happen
bear in mind that i cannot put the event handler code inside the user control itself, it has to be in the form that calls it
appreciate any help you guys can give me on this matter
|
|
|
|
|
mtrx wrote:
bear in mind that i cannot put the event handler code inside the user control itself, it has to be in the form that calls it
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
i mean this
if i have a label inside the user control, i dont want the event handler to be inside the user control also.
i need it to be something like this
class form1
{
public form1()
{
UserControl1 uc = new UserControl1();
uc.Click += new EventHandler(OnClick); // clicking the usercontrol
}
private void OnClick(object sender, EventArgs e)
{
// do event stuff
}
}
i dont want the user control to have the event handler
class UserControl1
{
public UserControl1
{
label1.click += new EventHandler(OnClick);
}
private void OnClick(object sender, EventArgs e)
{
// do event stuff
}
}
my reasoning is because i have several items inside the usercontrol, and im gonna use this user control in a lot of forms, i dont want to be doing several event handlers for each item in the control everytime i want to use it
|
|
|
|
|
Easy peasy..!!!
in your user control add click event handlers for each of the controls you want to pass the event for... and point them both at a single handler, then in that single handler you call the user controls OnClick()....
<br />
private void SomethingClicked(object sender, EventArgs e)<br />
{<br />
OnClick(e);<br />
}<br />
then in your form you can just handle the one click event...
<br />
us.Click += new EventHandler(OnClick);
HTH
Shaun
|
|
|
|
|
HI. I'm just learning c# and need a little help with events.
(the following scenario is just an example...hopefully to simplify)
Lets say I have a custom control called Cars which has three states: drive, park and reverse
Now let's say i have a racetrack control that can contain any number of Cars controls, but does not NEED to know anything about those Cars, like their state or even how many of them there are.
Lets add a button to the racetrack control called Go.
When the user clicks Go, I would like an event to be fired that all the Cars can hear and process accordingly. (The ones in park ignore it, those in reverse start moving backwards, those in drive move forward...)
I would also like the Cars controls to be able to fire their own custom events (like HornHonked...) that can be heard by anything, like other Cars, the racetrack, or other controls (pedestrians, pigeons...).
I don't know how events work in C# .NET, so I'm not sure where to start. I came across Instrumentation, but don't know if this is appropriate for such a task. I don't know if I can use existing events somehow, or inherit from events or just create my own. I don't know how you tell parents and children what to listen for and how to make sure they hear it.
I thought there might be a better solution than:
User hits the Go button. In Go_OnClick(), the racetrack iterates through a collection of Cars controls (updated as Cars are added to, removed from the racetrack) and calls a Cars.Go() method.
Like I said, I'm just learning C# from scratch, so I'm not aware of all the features. Sorry about the dumb Cars stuff, it just seemed like an easy example.
Thnaks,
Tym!
|
|
|
|
|
so typical, as soon as i posted, i made some headway in my search. I think I have some options:
- have my custom child controls subscribe to the OnClick event of the Go button on the parent Racetrack control. So, when the onclick event is fired, all Cars controls who subscribe will receive the mesasge. This, however, ties the parent and child controls together, ie, I couldn't plop the Cars controls into, say, a driveway control, without, at a minimum, having the driveway control send an identical OnClick event...
- have the parent control publish a custom event that the child controls can subscribe to, and fire this event when the go button is clicked, or as necessary. this has the same problem as above, a new container/parent control must publish the same event
- this would be wonderful, but not sure if it's legal. in the namespace of the Cars control, but not in the Cars class itself, publish a custom event:
<br />
public event EventHandler GoEvent;<br />
then, in the parent control, fire the event when necessary, as in the OnClick event of the Go button:
<br />
if( GoEvent != null )
and, in the Cars control Class, subscribe to the event:
<br />
CarsNamespace.GoEvent += new EventHandler(OnGoEvent);<br />
Then when a Cars control receives a GoEvent, it will call OnGoEvent().
So, that is what I'd like, but it seems like just throwing it in the namespace like that wouldn't be enough, or is it?
I feel like I am close, but just barely missing something. Like, would I need to declare the GoEvent in the parent??
ok, sorry if you read this far and want the last 3 minutes of your life back... but I just found a little more out and it seems that the namespace thing is a bust, but the second method looks like the way it really works. And my "fix" for the problem of tying the parent to the child would apparently be to create a kind of CarsManager class that handles adding and removing cars, and publishes the events and the event would be triggered by a CarsManager method call. Sorry to make you suffer through my learning process. but, if i'm still missing something or if i made some bad choices, assumptions, I'll always listen to anything...
Thanks,
tym!
PS thanks to moredip who posted this stuff here.
|
|
|
|
|
I'm having a problem when generating a bitmap in memory. I have an image which I want to cut up and rearrange in memory.
When I cut the image up and .DrawImage to the bitmap in memory, it gets 'smudged'. Say the source image is 20px high, I create a 20px bitmap and .drawImage the bit of the source i'm interested in.
The dest image though is incorrect, the pasted sections are drawn at about 22px, even though I have checked, loads of times, the parameters passed to drawimage are correct (20).
Anybody had similar problems?
|
|
|
|
|
What you are describing is alignment problems, not anti-aliasing AA is applied to vector graphics such as fonts and lines, to get rid of the litle jagged edges.
The obvious thing to look for is whether the images proportions are not changing during the "copy" process. That could be one cause.
<a TITLE="See my user info" href=http:
|
|
|
|
|
The actual target image is still the right size, but the drawn areas are too high anfhence are stretched, even using DrawImageUnscaled
|
|
|
|
|
Hi!
I'd like to create an "id" class, i.e. a class which could hold any positive non-null integer, yet somehow semantically generated ids would be > 0, but 0 and -1 would have special meanings.
Basically something like that:
public class MyId: System.Int32
{
public const int kServer = 0;
public const int kBroadcast = -1;
}
Unfortunately that is not possible since System.Int32 is a struct and thus equivalent to a sealed class: I can't derive it.
Can anyone suggest another approach to this?
Maybe the class could just not derive from Int32 and just contain an Int32, generated to be unique from the constructor.
Thanks in advance, all ideas welcome.
R/
|
|
|
|
|
Containing a int32 is your best bet. If you'd like, you can write implicit conversions to and from int32, so you'd be able to write:
MyID id = 13;
or code like that.
|
|
|
|
|
I understand how to write an implicit conversion to in32, but I don't get how to write an implicit conversion from int32 to my class.
Currently I came up with something like that:
public struct MyId
{
public const int kServer = 0;
public const int kBroadcast = -1;
public override bool Equals(object obj)
{
return mId.Equals(obj);
}
public override string ToString()
{
return mId.ToString();
}
public override int GetHashCode()
{
return mId.GetHashCode();
}
public static implicit operator int(MyId id)
{
return id.mId;
}
private int mId;
}
The C# reference says operator = cannot be overloaded.
What I my missing so far?
Is it useful to overload GetHashCode/ToString/Equal?
TIA
R/
|
|
|
|
|
Funny, I could not find any reference to Stephen Toub in GotDotNet, yet I found a nice team page for Eric and his article on MSDN regarding operator overloading
Anyway, I am in the right direction when I say that:
- it's a C++-programmer reflex of mine to expect to be able to overload operator=()
- in the case above, I actually don't need such an operator=, what I need is an operator from int to MyId, such as:
public static implicit operator MyId(int id)
{
MyId v = new MyId; v.mId = id; return v;
}
R/
|
|
|
|
|
To "override" the = operator, all u need to do is an implicit cast
<a TITLE="See my user info" href=http:
|
|
|
|
|
Here's how you overload the conversion from int to your class:
public static implicit operator MyId(int id)
{
return new MyId(id);
}
|
|
|
|
|
As siad by Eric your best best is to make a continer class. Stephen Toub from MS has written an execellent (as all his stuff) utility for this. Search GotDotNet for stoub (his username).
<a TITLE="See my user info" href=http:
|
|
|
|
|
leppie wrote:
Search GotDotNet for stoub (his username).
I had to look on his blog just to find his username...it's toub...not stoub.
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
I am having a couple of problems setting form size at run-time.
First problem is when I first show the form, it sets the size of the form to 148x40 when I specify the width less than 148 or hight less than 40, they reset to 148 and 40 respectively.
It happens during handle creation time and I can't figure out where the form gets the 148x40 values. I happens somewhere in Control's constructor.
I tried overriding DefaultSize property but the size still defaults to 148x40 if I specify smaller dimentions.
The workaround I use is to force handle creation and then set the size of the form after.
Second problem is that when I set the height of the form and then show the form, the form adds extra height during handle creation time if I have a main menu specified.
Once again the workaround is to set the size after the handle has been created.
However I would like to know if I am missing something and if there is a better way of fixing these problems. Perhaps it is a bug in the form creation logic.
I wish I could see the source of the library so I knew what it was doing.
|
|
|
|
|
Did you look in the InitializeComponent method? That's where the forms designer does its initialization.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Yes, I did.
148x40 does not come from there.
|
|
|
|
|
Acidis wrote:
I wish I could see the source of the library so I knew what it was doing.
You can always use ILDasm to see the IL or use Anakrino or Reflector to decompile see C#, MC++, or VB.NET versions of the IL.
As to your specific problem I haven't seen that before, just doing a quick test I can resize my forms all the way down to 109w 28h which is the minimum size allowed by Windows. Depending on your Appearance settings, your minimum may differ.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
I might have missed a few details.
Here is the set up of my form. I call it ToolTipForm.
Properties that are different from default:
FormBorderStyle: None
AutoScale: False
Size: 100, 50
StartPosition: Manual
ShowInTaskbar: False
The form contains only one Lavel control.
Label properties:
BorderStyle: FixedSingle
TextAlign: MiddleCenter
UseMnemonic: False
Dock: Fill
Now, if you create a main form and add some way to display the ToolTipForm. USe the following code to show it:
<br />
ToolTipForm ttf = new ToolTipForm();<br />
ttf.Size = new Size(50, 18);<br />
ttf.Show();<br />
The first time you display this form (when it creates the handle) it will set the size of the form to 148x40 (in my case.)
Given the form set up, it should not do it.
If I set the Size property to 50, 18 after the Show() method, it sets the size to 50, 18 without any problems.
The reason I am using the form is because I need my tool tip to be displayed on top of my main window (form) so it is not clipped. I don't think the tooltip control is capable of doing it. And I was unable to make a control display as a top level window. Controls seem to require a parent.
As to decompiling, I am not sure how to do it. I have the Reflector but it does not allow me to decompile anything in the library. I am probably not understanding how to do it properly. Will have to look at it some more.
|
|
|
|
|
Acidis wrote:
I don't think the tooltip control is capable of doing it.
Using .NET 1.1 the ToolTip control isn't getting clipped by the child main window or by child windows. I don't know if this is something that changed between 1.0 and 1.1 though.
Acidis wrote:
I have the Reflector but it does not allow me to decompile anything in the library. I am probably not understanding how to do it properly. Will have to look at it some more.
A new version was released recently that added decompiling to the list of features. When you find a method you want to see the source to, you can press Enter to see the IL or Space to see the IL->C# or IL->VB.NET conversion.
http://www.aisto.com/roeder/dotnet[^]
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|