|
Use the GDI+ GetPixel method
|
|
|
|
|
Hi...I'm trying to call an API, which takes a pointer to a structure that contains unions. I'm not sure how to build this in C#. Where I'm having difficulty is what to do for the unions and how setting a length for the character array. I know I'm going to have to use UNSAFE code for the dereferenced pointer.
I have enclosed the subset of the structure below...
typedef struct CCVUSER
{
SHORT TransactionType;
SHORT ProcessingMode;
PVOID pvBatch;
UCHAR uchErrorText1[255];
UCHAR uchErrorText2[255];
UCHAR uchSettingsPath[255];
union CCV
{
struct CreditCard
{
CHAR *CardInfo;
CHAR TransactionDate[4];
CHAR InvoiceNumber[10];
double CashBackAmount;
double TipAmount;
double Amount;
BYTE CustomerPresentFlag;
} CreditCard;
struct CheckApprovalRequest
{
CHAR IDType[2];
CHAR Number[26];
CHAR DateofBirth[6];
double Amount;
CHAR CheckSequenceNum[4];
} CheckApprovalRequest;
} CCV;
} CCVUSER;
Thanks for your help...
Glenn
Glenn
|
|
|
|
|
Here is a C style union in Csharp.
Out of the best Book I have read so far for .Net.
Essential .Net Volume 1.
[StructLayout( LayoutKind.Explicit )]
public struct Number
{
private enum NumType
{
Double,
Int64
}
[FieldOffset( 0 )]
double dblValue;
[FieldOffset( 0 )]
long lngValue;
[FieldOffset( 8 )]
NumType type;
public void Set( double value )
{
type = NumType.Double;
dblValue = value;
}
public void Set( long value )
{
type = NumType.Int64;
lngValue = value;
}
public double GetDouble()
{
if ( type == NumType.Double )
{
return dblValue;
}
return (double)lngValue;
}
public long GetLong()
{
if ( type == NumType.Int64 )
{
return lngValue;
}
return (long)dblValue;
}
}
Thank You
Bo Hunter
|
|
|
|
|
|
|
Create a new child form with transparent areas. Open these up when required.
|
|
|
|
|
Hello.
If a function like OnMouseMove is implemented in a derived class, without any message map info, this function gets called when the event occurs. How is the housekeeping done on this? One would think there is an overhead of calling all the event functions irrespective of wether it is implemented or not. Or is an optimization done at compile time?
Any useful links or explanations on this would be helpful.
Thanks in advance.
Regards,
Priyesh
|
|
|
|
|
Event handlers are basically a linkedlist of function pointers. The standard implementation will check whether the event handler is null, otherwise it will invoke each function pointer (delegate) in the eventhandler.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Does this mean that delegates and Onxxx functions use the same mechanism to deliver events?
|
|
|
|
|
Hello,
I've set up a site for my company which pulls content links from the database and binds them to a repeater which produces a list of linkbuttons with the text and link to the appropriate story. However, a great deal of importance has been attached to search engine placement and the ability of spiders to travel unimpeded throughout the site. Since a linkbutton does not produce a conventional url which can be followed by a spider, is there any piece of data that a linkbutton can produce allowing a spider to travel to the displayed link?
Thanks for any help you can provide.
|
|
|
|
|
I had the same problem with a Flash based menu. The best is to make some "invisible" links somewhere
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I have a question abount Socket Communication.
When Socket Connection was founded with Server and Client,Cliet send information to Server.Whether string array can be sent to Server.In the other hand,Whether object can be sent to Server.
When Server received the information,whether it can be convert to Array,or other object.
海纳百川,有容乃大
壁立千仞,无欲则刚
|
|
|
|
|
Objects have to be serializable (take a look at SerializableAttribute).
Arrays are serializable, if the elements are serializable.
You can send a serializable object/array through a socket by BinaryFormatter.Serialize(). The other side can read it by BinaryFormatter.Deserialize().
|
|
|
|
|
i want to run the sqlserver agent server,
in the code , that is run progress
|
|
|
|
|
I am trying to convert a routine from C to C#, that will scan over a character array converting the 1st character of every word to upper case. I mainly use this on peoples names.
In C it was very simple, I just loop over the characters and "AND"ed the byte with 0x20. In C# it wouldn't let me do that with strings, saying it was read only, so I tried copying it to a byte array, which kinda works.
I removed the 1st letter of each word logic to simplify the code. Now the code reads:
byte[] strout = new byte[255];
string workstr;
workstr = textBox1.Text;
for (int i = 0; i<textbox1.text.length; i++)
{
="" if="" (textbox1.text[i]=""> 0x60)
strout[i] = Convert.ToByte(workstr[i] & 0x20);
else
strout[i] = Convert.ToByte(workstr[i]);
}
textBox1.Text = Convert.ToString(strout);
What I am getting when trying to "AND" the 0x20 is just 0x20, it doesn't just turn off the bit. Also how do you convert the byte array back to a string? I have tried a couple of convert methods but haven't had much luck.
Thanks,
Glenn
|
|
|
|
|
When I pasted in the code the for loop got chopped off...its actually like this:
byte[] strout = new byte[255];
string workstr;
workstr = textBox1.Text;
for (int i = 0; i<workstr.length; i++)
{
="" if="" (textbox1.text[i]=""> 0x60)
strout[i] = Convert.ToByte(workstr[i] & 0x20);
else
strout[i] = Convert.ToByte(workstr[i]);
}
textBox1.Text = Convert.ToString(strout);
Glenn
|
|
|
|
|
Firstly, you can still do this with C# - convert the string to a char[] array using String.ToCharArray() , AND each char that needs it, then convert the char array back to a string using new String(chararray) . (It's not byte because .NET uses Unicode.)
Secondly, the AND 0x20 isn't needed, as you can use Char.ToUpper() .
"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
|
|
|
|
|
The simplest solution is to treat the string as a character array instead of a byte array. Here is a simple function that you can pass your line of text to. It simply looks to see if the current character is the first character in the array or if the previous character is a space and capitalizes the character accordingly.
string formatString(string input)
{
char[] result = input.ToCharArray();
for(int i=0; i <= result.Length; i++)
{
if ((i==0) || (result[i-1]==' '))
result[i] = char.ToUpper(result[i]);
}
return new string(result);
}
|
|
|
|
|
The i <= input.Length should be i < input.Length.
0 Based.
Thank You
Bo Hunter
|
|
|
|
|
|
Hi,
I have a treeview control in a form, which is bound to an imagelist control.
In this tree i have some node with some child node.My problem is when i click on any subnode then it's images will be replace with it's parent node picture or with any other things which you define in the SelectedImageIndex property.but i dont want to have selectedimagesindex property run when i click in any node, i just want to have it fix.
thanx,
best regards
sean
|
|
|
|
|
I have a string value in the registry that i'm trying to read into my app. I need this value to be read as an integer so i can use it in a custom function.
<br />
RegistryKey rk = Registry.Users;<br />
rk = rk.OpenSubKey(@".DEFAULT\CustomForm", false);<br />
int result = calculate(rk.GetValue("GRN1"),2);<br />
<br />
public int calculate(int x, int y)<br />
{<br />
int result = x * y;<br />
return result;<br />
}<br />
The rk.GetValue("GRN1") returns an Object Type, but how can i get it to return an Integer type. I get an 'Invalid Cast' error when i try to cast from a different 'domain' (as msdn calls it)....
int result = calculate((int)rk.GetValue("GRN1"),2);
so, how can i get an object value from the registry to convert to an integer?
Thanks for your help
.gonad.
|
|
|
|
|
Have you tried: Int32.Parse(rk.GetValue("GRN1"),2); ?
That might work.
|
|
|
|
|
Convert.ToInt32(rk.GetValue("GRN1")) should do the trick.
|
|
|
|
|
Hi, is there a way to turn rtf text into html? i.e. bold to <bold>
|
|
|
|