|
The A is almost always going to be 255, and therefore be irrelevant. Color doesn't HAVE an A. The alpha tells you how strongly the color is blended with the background. So if it's 255, you can ignore it. If it's not, I guess you can scale the values according to how they'd draw over white or black, if you really want to.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yeah... that's right.
If you set A to 255, then you will see always the color.
If you set A to 0, then you cannot see the color.
To take only the RGB value, just do this:
int onlyRGB = Color.Red.ToArgb() & 0x00FFFFFF;
|
|
|
|
|
Hi guys,
I need some help! Is there a way to run a store procedure or a .SQL file when running a setup of an application designed in Visual C#. I have already created a windows installer setup in Visual studio and I have an SQL file that I would like to run during installation.
Please help!
sasa
|
|
|
|
|
I don't think you can do it from an MSI. Your SQL script can't be executed, it doesn't know what to connect to, for a start. You could write an exe that runs as a post install step and runs the script on the DB that I assume you know will be there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I know it can be done, look at the ASPX Starter Kits. I just don't know how they do it, never looked into it. Probably with the MSI SDK, not Studio.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Thank you Christian for your answer. I appreciate you taking the time on this. I will probably run the sql statement in manual setup.
sasa
|
|
|
|
|
hi all,
i dont want my exe to start more than once if it's started before.
let's say i start my program and minimize it to taskbar.
if i click on its exe again, it first should check whether it was started before or not. if started before, just maximize it again. if not started before, then should start my application...
how can i do this ?
help me please.
thanks in advance, bye.
|
|
|
|
|
I usually use something like this:
Process[] sameProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
if(sameProcesses.Length == 1)
{
}
else
{
}
|
|
|
|
|
|
Hi,
I'm trying to create some code to enter a new record into a dataset that was filled from a database that has an autoincremented field. I need to create a unique number to insert into that field in the dataset.
I've already come accross some examples on how to do this that appear complicated - at least to me they are
Surely there is a simple was to retrieve the value of a datasets field eg
variableA = datasetName.tableName.rowNumber.filedName.value
Using the above I could read each row and incrementing variableA until such time as variableA was the highest number in the autoincremented field.
If there is an easier way to generate a unique number to use in the dataset then please let me know BUT I would also like to know the easiest way to read a dataset's specified row value.
TIA
Glen Harvy
|
|
|
|
|
Are you just needing the number to insert into the dataset or are you wanting to update the database with the new record?
|
|
|
|
|
Hi,
I just need to ascertain the value contained within field in the row. I can ascertain the row and even identify it with a SELECT but how can you just get one value from the whole record easily?
Thanks,
Glen Harvy
|
|
|
|
|
Is that record always going to be in the same column of the grid? (I assume yes)
|
|
|
|
|
Does it matter?
Glen Harvy
|
|
|
|
|
Bit of an odd one here. I have the following string:
4e554c4c00
Which is a HEX representation of
NULL
I need to convert that intial string into it human readable format, does anybody know of any framework methods/classes to do this? If not can anybody think of an elegant/quick solution?
I was initially thinking of string parsing, however this portion of code will be called 100's of times a second and parsing string is fairly heavy.
-- modified at 9:17 Thursday 13th July, 2006
EDIT :
Here is a chunk of code that works, however I have a few concerns about speed
string raw = "4e554c4c00";
raw = "556e6b6e6f776e204576656e742025545241504944252e00";
string[] rawParts = new string[raw.Length / 2];
int rawPos = 0;
int partsPos = 0;
while(rawPos < raw.Length)
{
rawParts[partsPos] = raw.Substring(rawPos, 2);
partsPos++;
rawPos++;
rawPos++;
}
string humanReadable = string.Empty;
for(int partsLoop=0; partsLoop<rawParts.Length - 1; partsLoop++)
{
char charPart = Convert.ToChar(
Int32.Parse(rawParts[partsLoop],
System.Globalization.NumberStyles.HexNumber));
humanReadable += charPart.ToString();
}
Console.WriteLine(humanReadable);
if the first value of the string "raw" is used "NULL" is output by the final Console.WriteLine. if the second value of the string is used "Unknown Event %TRAPID%." is output.
-- modified at 9:23 Thursday 13th July, 2006
|
|
|
|
|
MrEyes wrote: I need to convert that intial string into it human readable format
What do you mean by human readable? What do you want it to say? Do you just want your hex string replaced with "null"? In that case:
string humanReadable = inputString.Replace("4e554c4c00","NULL");
|
|
|
|
|
Unfortunatly that wont work, 4e554c4c00 is just one example. The application that generates these string could have encoded anything at all so I need to dynamically translate it
|
|
|
|
|
|
As an example:
4e554c4c00
breaks down to (ignoring the 00 termination)
4e
55
4c
4c
Which are the hex values for
N
U
L
L
This is based on standard hex codes (http://www.lookuptables.com/[^])
As mention earlier I was considering using something like Replace() however this code will be called many times and this might be a little too slow
|
|
|
|
|
See this:
byte[] b = new byte[4] {0x4e, 0x55, 0x4c, 0x4c};
string s = System.Text.Encoding.ASCII.GetString(b);
The result is "NULL". First you must change your "4e554c4c" into byte array.
static string HexToString(string input)
{
byte[] b = new byte[input.Length / 2];
for(int i = 0; i < input.Length; i+=2)
b[i / 2] = byte.Parse(input.Substring(i, 2), NumberStyles.HexNumber);
return System.Text.Encoding.ASCII.GetString(b);
}
|
|
|
|
|
stancrm wrote: First you must change your "4e554c4c" into byte array.
And therein lies the issue, I need something quick - if you look at my modified first post I have added the hacky method I am using at the moment.
|
|
|
|
|
See my message again. I have added the function to change 4e554c4c to NULL.
I think that is the fastest way.
|
|
|
|
|
Thats great, considerably better than my loop and loop attempt
I have only made one amendment and that is to remove the trailing terminator:
public static string HexToString(string input)
{
input = input.Substring(0, input.Length - 2);
byte[] b = new byte[input.Length / 2];
for(int i = 0; i < input.Length; i+=2)
{
b[i / 2] = byte.Parse(input.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
}
return System.Text.Encoding.ASCII.GetString(b);
}
|
|
|
|
|
Here's my entry (no need to prepare the data as a byte array):
private static string HexToText(string hex)
{
string result = string.Empty;
for (Int32 i = 0; i < hex.Length; i += 2)
result += (char)byte.Parse(hex.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
return result;
}
Share and enjoy.
Sean
|
|
|
|
|
This is getting shorter and shorter
Anybody got a one liner?
Time to start doing some timings
|
|
|
|