|
The CP Anonymous bug bites again
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
|
|
|
|
|
Does it matter how large the .exe file gets? I used to program in DOS and the eventual .exe size was a big consideration. If it doesn't matter with Windows and .NET then embedding them is the way to go. For ease of use.
EvilDingo
|
|
|
|
|
Can somebody explain me, how i can copy the content from a ListView row into a database or into an array.
Many thanks
Kind Regards
|
|
|
|
|
Hi There,
I hope somebody can give me some good advices:
I need to use an existing Programming Interface which is available whether as a 'COM object dll' or' 2 C++ header files' under .NET.
I used the COM object, this works quite nice in VB.NET and as well in C#, using the System.Runtime.InteropServices.TypeLibConverter class.
In fact everything will be done automatically and i can use my Interface like in the unmanaged world, great!
The main problem is, I develop an application on a PocketPC, under the .NET Compact Framwork.
Since this System.Runtime.InteropServices.TypeLibConverter class does not exist under the .NET CF, i need to use the C++ interface, but this gives me headache.
So far I found out the following:
1)use (unmanaged) C++ Code in the managed world of .NET
2)use the built-in .NET runtime interop facilities to talk directly to the existing code.
3)wrap the code using the managed extensions to C++.
4)rewrite the code in a .NET language.
I wanted to go in direction 4) originally, but I'm no longer sure what makes really sense on this one...
My interface is consisting of 3 header files. 2 of them are simply describing enumerations and structs.
The third one consists of helper classes in C++ which are easing the use of this interface a lot.
I assume that when I would go the wrapping way, that I would only need to wrap the classes I directly touch from my App in c#?
If yes then I woud need to wrap only 2 classes?
What way to go would be the best, wrapping interop, rewrite?
But how would I do that best? Could somebody give me an idea how to do that?
Thanks a lot,
stonee
Attached the sample classes:
<br />
<br />
Class1 to wrap:<br />
<br />
#define DATA_PACKET &Data.DataPacket, sizeof(Data.DataPacket)<br />
<br />
class Command<br />
<br />
{<br />
<br />
public:<br />
<br />
CESAPICommand() {TRACE(_T("CESAPICommand()\n"));}<br />
<br />
<br />
virtual bool SendPacket(void* PacketStart, long PacketSize) <br />
<br />
{ <br />
<br />
TRACE(_T("Virtual SendPacket() called!\n"));<br />
<br />
<br />
return false; <br />
<br />
};<br />
<br />
<br />
<br />
bool inline Init() {CInit Data; return SendPacket(DATA_PACKET);}<br />
<br />
<br />
<br />
<br />
bool inline SetBox(double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2)<br />
<br />
{CSetBox Data(dX1, dY1, dZ1, dX2, dY2, dZ2); return SendPacket(DATA_PACKET);}<br />
<br />
<br />
};<br />
<br />
<br />
<br />
Class2 to wrap:<br />
<br />
<br />
class Receive<br />
<br />
{<br />
<br />
public:<br />
<br />
Receive() {TRACE(_T("Receive()\n"));}<br />
<br />
protected:<br />
<br />
<br />
<br />
bool ReceiveData(void* packetStart, long packetSize) <br />
<br />
{ <br />
<br />
<br />
if (packetStart && packetSize > 0)<br />
<br />
return ProcessData(packetStart, packetSize); <br />
<br />
else<br />
<br />
return false;<br />
<br />
};<br />
<br />
protected:<br />
<br />
virtual void OnInitializeAnswer() {TRACE(_T("virtual OnInitializeAnswer() call\n"));}<br />
<br />
virtual void OnGetBoxAnswer(const BoxRegionDataT& boxRegionData) {TRACE(_T("virtual OnGetBoxRegionParamsAnswer() call\n"));}<br />
<br />
<br />
<br />
protected:<br />
<br />
<br />
<br />
<br />
<br />
virtual bool ProcessData(void *pDataArrived, long lBytes)<br />
<br />
{<br />
<br />
<br />
<br />
PacketHeaderT *pData = (PacketHeaderT*)pDataArrived;<br />
<br />
<br />
if (pData->lPacketSize != lBytes)<br />
<br />
{<br />
<br />
TRACE2("PacketSize (%ld) differs from TotalBytes (%ld) !\n", pData->lPacketSize, lBytes);<br />
<br />
return false;
<br />
}
<br />
switch (pData->type)<br />
<br />
{<br />
<br />
case ES_DT_Command:
<br />
{<br />
<br />
<br />
<br />
<br />
<br />
OnCommandAnswer(*(BasicCommandRT *)pData);
<br />
<br />
BasicCommandRT *pData2 = (BasicCommandRT *)pData;<br />
<br />
<br />
if (pData2->status != ES_RS_AllOK)<br />
<br />
return true;
<br />
<br />
<br />
switch (pData2->command)<br />
<br />
{<br />
<br />
case ES_C_ExitApplication:<br />
<br />
OnExitApplicationAnswer();<br />
<br />
break;<br />
<br />
<br />
case ES_C_GetSystemStatus:<br />
<br />
OnGetSystemStatusAnswer(((GetSystemStatusRT*)pDataArrived)->lastResultStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->trackerProcessorStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->laserStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->admStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->esVersionNumber,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->weatherMonitorStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->lFlagsValue,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->lTrackerSerialNumber);<br />
<br />
break;<br />
<br />
<br />
<br />
<br />
<br />
case Init<br />
<br />
OnInitializeAnswer();<br />
<br />
break;<br />
<br />
<br />
<br />
case ES_C_GetReflectors:<br />
<br />
OnGetReflectorsAnswer(((GetReflectorsRT*)pDataArrived)->iTotalReflectors,<br />
<br />
((GetReflectorsRT*)pDataArrived)->iInternalReflectorId,<br />
<br />
((GetReflectorsRT*)pDataArrived)->targetType,<br />
<br />
((GetReflectorsRT*)pDataArrived)->dSurfaceOffset,<br />
<br />
((GetReflectorsRT*)pDataArrived)->cReflectorName);<br />
<br />
break;<br />
<br />
<br />
<br />
TRACE(_T("Unexpected data received (ignored)\n"));<br />
<br />
break;<br />
<br />
}
<br />
return true;<br />
<br />
}
<br />
};
|
|
|
|
|
Hi,
I have been trying to save images as gifs, but I am dissatisfied with the results. The colors are reduced drastically, even if I have specified a highquality pixelformat. I tried changing all kinds of variables such as CompositingMode, SmoothingMode, InterpolationMode, COmpositingQuality etc. Nothing works. However, when I save the image as a jpg, then the color reduction is not as drastic.
I am starting to suspect that the color reduction occurs when the bitmap is saved, in which case the problem most likely has to do with the Gif compression and any settings you can pass to the codec.
Does anyone know how you specify the gif compression when using the Save Method? Where can I read about the compression alternatives? I have already managed to see all my codecs and their properties, but it is of no use to me.
<br />
<%@ Import Namespace="System" %><br />
<%@ Import Namespace="System.IO" %><br />
<%@ Import Namespace="System.Collections" %><br />
<%@ Import Namespace="System.ComponentModel" %><br />
<%@ Import Namespace="System.Data" %><br />
<%@ Import Namespace="System.Drawing" %><br />
<%@ Import Namespace="System.Drawing.Drawing2D" %><br />
<%@ Import Namespace="System.Drawing.Imaging" %><br />
<%@ Import Namespace="System.Drawing.Text" %><br />
<script language="C#" runat="server"><br />
<br />
static PrivateFontCollection pf; <br />
<br />
static void InitPF(string path) <br />
{<br />
pf = new PrivateFontCollection();<br />
string[] ttfs = Directory.GetFiles(path, "*.ttf");<br />
<br />
for (int i = 0; i<ttfs.Length; i++){<br />
pf.AddFontFile(ttfs[i]);<br />
}<br />
}<br />
<br />
public static FontFamily[] GetFonts(string path)<br />
{<br />
if (pf == null) InitPF(path);<br />
return (FontFamily[]) pf.Families.Clone();<br />
}<br />
<br />
void Page_Load(Object sender, EventArgs e)<br />
{<br />
<br />
FontFamily[] pf = GetFonts(Server.MapPath(""));<br />
<br />
<br />
<br />
const int width = 300, height = 41;<br />
Bitmap objBitmap = new Bitmap(width, height, PixelFormat.Format64bppArgb);<br />
Graphics objGraphics = Graphics.FromImage(objBitmap);<br />
<br />
<br />
<br />
<br />
<br />
objGraphics.FillRectangle(new SolidBrush( Color.White ), 0, 0, width, height);<br />
<br />
Bitmap objTile = new Bitmap(Server.MapPath(Request.ApplicationPath) + "\\uploads\\title_tile.gif");<br />
objGraphics.DrawImage(objTile, 0, 0, objTile.Width, objTile.Height);<br />
<br />
<br />
String adPitch = "gif compression";<br />
<br />
int count = 0;<br />
string familyNameAndStyle;<br />
<br />
count = pf.Length;<br />
<br />
<br />
StringFormat stringFormat = new StringFormat();<br />
<br />
if(pf[count - 1].IsStyleAvailable(FontStyle.Regular))<br />
{<br />
myLabel.Text = objBitmap.PixelFormat + "<br>";<br />
myLabel.Text += pf.ToString() + "<br>";<br />
myLabel.Text += pf[count - 1].Name + "<br>";<br />
myLabel.Text += pf.Length + "<br>";<br />
<br />
<br />
Font regFont = new Font(<br />
pf[count - 1],<br />
16);<br />
<br />
<br />
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;<br />
objGraphics.DrawString(adPitch, regFont, new SolidBrush(Color.FromArgb(255, 0, 51, 102)), <br />
new Rectangle(24, 0, width, height), stringFormat);<br />
regFont.Dispose();<br />
}<br />
else{<br />
myLabel.Text = "Not found"<br />
}<br />
<br />
<br />
objBitmap.Save(Server.MapPath(Request.ApplicationPath) + "\\uploads\\banner.gif", ImageFormat.GIf);<br />
objGraphics.Dispose();<br />
objBitmap.Dispose();<br />
}<br />
<br />
</script><br />
<br />
<br />
<asp:label id="myLabel" runat="server" /><br />
Regards,
Christian Toivola
|
|
|
|
|
|
Is there a way to force the display of a notifyicon tooltip? I want the tooltip to be displayed without the user actually hovering over the taskbar icon.
|
|
|
|
|
Check this link out.
Though it deals with the problem in C++ and MFC, just check if it is of some help.
http://msdn.microsoft.com/msdnmag/issues/02/11/cqa/

|
|
|
|
|
Hi,
I have a rather strange problem with RichTextBox controls.
My form has 2 RichTextBox controls and a TreeView. During the runtime, I'll be writing data to both the RichTextBox controls for every 100 m.sec. During this process after some time, which is not always the same, I get the following exception :
System.NullReferenceException: Object reference not set to an instance of an object. at.....
Moreover, even when I right click on the control for popup menu also, it gives the exception. I want to scroll to the end of the control so that the recently added text is visbile. So, I do this in the Text_Changed event :
this.rtxtSECS2Log.Focus();
this.rtxtSECS1Log.ScrollToCaret();
I get the exception even if I comment the above lines and run.
Can any one pull me out of this.
Regards.
Srinivas.
|
|
|
|
|
1. How to create a object in specific server in c#
Eg – in vb createobject(“name”,”server”)
2. Is there any technology in .Net to replace com+
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
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/
|
|
|
|
|