|
No, it's 255
But I've Got it, Thanks AnyWay
Like This:
Byte a;
bool Temp_Bool = (((a >> i) & 1) ==1 )?(true):(false);
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: bool Temp_Bool = (((a >> i) & 1) ==1 )?(true):(false);
Another case of the "x?true:false" antipattern...
bool Temp_Bool = (((a >> i) & 1) == 1);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi!
I have a C# program running with a 3rd party dll version 3.5... When I run it on another machine, having another program with same dll, but version 3.8, I have lots of troubles when the other application has started before then mine.
How can I force my application to load the dll version 3.5?
Thanks a lot
Life is not short... the problem is only how you organize yourself
|
|
|
|
|
You can set those options in the app.config. That said, there should be no interference between 2 version of a dll. What kind of problems do you have?
|
|
|
|
|
It's a little bit difficult: it's SAP :-S ...
SAP has an addon wich work in the directory \root ... under root you can find all the dlls used by this addon...
I'm programming an addon of the addon (called 1staddon) ... and by default all my dlls should reside in \root ... To avoid others addon to overwrite our dlls with the same name, we decided to put our dlls in \root\mydir ...
The problem is that 1staddon loads \root\a.dll and than calls my addon ... but my addon needs to use \root\mydir\a.dll, which is not loaded coz there is already \root\a.dll.
Life is not short... the problem is only how you organize yourself
|
|
|
|
|
This thing has totally stumped me. When I maximize the form, MouseUp event of the panel is firing. It happens only when I maximize the form by double clicking form border. The event is bound just with the panel. Can anyone help regarding this?
|
|
|
|
|
|
It's one of the controls present on my form.
|
|
|
|
|
hm..this is only true for me if the panel fills out the whole form.
you could set a flag on the form's SizeChanged event like this
bool resizing = false;
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
if (!resizing)
MessageBox.Show("MouseUp");
}
private void Form1_SizeChanged(object sender, EventArgs e)
{
resizing = true;
}
|
|
|
|
|
buchstaben wrote: private void Form1_SizeChanged(object sender, EventArgs e)
{
resizing = true;
}
And where do you ever set that false?
|
|
|
|
|
okay, but this spectaculous pimp would fix it..
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
if (!resizing)
MessageBox.Show("MouseUp");
else
resizing = false;
}
|
|
|
|
|
buchstaben wrote: okay, but this spectaculous pimp would fix it..
But it's still not right
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
if (!resizing)
MessageBox.Show("MouseUp");
resizing = false;
}
That should work tons better
|
|
|
|
|
I already have a lot of constants with me. I have managed to overcome the issue with those.
But I would like to know reason behind it.
|
|
|
|
|
Can anyone suggest a good way to tell if a file is a text file rather than a binary file? I want to search and replace some text in all text files but to ignore binary files.
Thanks
|
|
|
|
|
EXTENSION
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
The easiest is to check for new line characters.
Some binary may contains the newline character(s), in that case you will have to analyze the line a bit more. Obviously a very long line hints to binary.
Also check for control characters, those from 0 to 31 (i think), with a few exceptions of course.
Good luck
|
|
|
|
|
williammorrishooper wrote: I want to search and replace some text in all text files but to ignore binary files.
hm..not sure if it's worth the effort.
say you want replace "mystring1" with "mystring2". There would be no match in any of your binary files, wouldn't?
Or is it more a performance issue?
|
|
|
|
|
Not really, binary file can contain that series of text, no?
|
|
|
|
|
Hi,
I have a COM object that accept an array of integer.
HRESULT __stdcall CTestCOM::setValues(int* arr, int arrSize)
{
for(int i=0; i<arrSize; i++)
{
MyDebugTextOut("C:\\Temp\\TestCOM.txt", "arr[%d] = %d\n", i, arr[i]);
}
}
In my C# code:
int[] arrTest = new int[5];
for(int i=0; i<5; i++)
{
arrTest[i] = i;
}
TestCOM testCom = new TestCOM();
testCOM.setValues(ref arrTest[0]);
The result of my text out in x86 is correct:
arr[0] = 0
arr[1] = 1
arr[2] = 2
arr[3] = 3
arr[4] = 4
arr[5] = 5
But in my x64, it is wrong:
arr[0] = 0
arr[1] = -321451
arr[2] = -14537642
arr[3] = 0
arr[4] = 0
arr[5] = 0
I've checked the address of the array, in x86, it pass a same address from C# to COM object. But in x64, address of the array in the COM object is different from C# array.
Any idea why? If yes, is it possible to fix it?
Thanks
|
|
|
|
|
Although I do not know COM interop, there are a lot of things wrong here...
RYU^^ wrote: testCOM.setValues(ref arrTest[0]);
Why are you passing the reference to the first element in? A .NET array isn't just a int buffer! If you fixed it, then maybe you can use it. (does COM not require you to pass the length parameter too?)
RYU^^ wrote: arr[5] = 5
Your array length is only 5, so how can you read the 6th element?
|
|
|
|
|
Hi Leppie,
Thanks for the reply. The reason I pass the first element address because I want to manipulate the value in my COM object. It works fantastically in x86, but doesn't work in x64.
leppie wrote: (does COM not require you to pass the length parameter too?)
You were right, the length of the array must be passed in to the COM object. But in my case (not in this example), it is actually determine by another attribute that is set previously.
leppie wrote:
Your array length is only 5, so how can you read the 6th element?
Uppppsss... you were right again. It should be new int[6]. Sorry...
|
|
|
|
|
Before I begin, I'm a C#/.NET newbie. I'm completely familiar with C/C++ and using VS in that context, but you can probably expect me to have made very trivial errors.
Anyway...
I'm trying to implement a spell check into a tool I'm helping to develop -- I suppose the easiest way to do this would be to use the spell check from Word, so I don't have to duplicate any of its functionality.
I'm working in C#, but the article on this site for a VB.net version (http://www.codeproject.com/KB/office/SpellCheckUsingWord.aspx) helped to walk me through writing it up.
However, there are catches! Apparently, all of the tutorials I've checked out are using a different version of Office (11 instead of 12) which keeps me from compiling.
Here's my relevant code...
ApplicationClass WordApp = new ApplicationClass();
DocumentClass WordDoc = WordApp.Documents.Add();
WordApp.Visible = false;
String OldClipboardText = Clipboard.GetText();
Clipboard.SetDataObject(textBox1.Text);
WordDoc.Content.Paste();
WordDoc.Activate();
WordDoc.CheckSpelling();
WordDoc.Content.Copy();
if (Clipboard.GetDataObject.GetDataPresent(DataFormats.Text))
{
textBox1.Text = CType(Clipboard.GetDataObject.GetData(DataFormats.Text), String);
}
WordDoc.Saved = true;
WordDoc.Close();
WordApp.Quit();
Clipboard.SetDataObject(OldClipboardText);
and here's the compilation log:
------ Build started: Project: StupidSpellcheckSandboxApp, Configuration: Debug Any CPU ------
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(27,41): error CS1501: No overload for method 'Add' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(35,17): error CS1501: No overload for method 'CheckSpelling' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(38,31): error CS0119: 'System.Windows.Forms.Clipboard.GetDataObject()' is a 'method', which is not valid in the given context
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(40,37): error CS0103: The name 'CType' does not exist in the current context
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(40,53): error CS0119: 'System.Windows.Forms.Clipboard.GetDataObject()' is a 'method', which is not valid in the given context
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(40,94): error CS0118: 'string' is a 'type' but is used like a 'variable'
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(44,17): error CS1501: No overload for method 'Close' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(45,17): error CS1501: No overload for method 'Quit' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
Compile complete -- 8 errors, 0 warnings
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Why is VS crying over the number of arguments? All of the MSDN documentation I've read says that the arguments I leave out are optional. I'm rather exasperated, having been Googling this for a while, either to find a less frustrating method of implementing this (and preferably less hackish than copying and pasting it behind the scenes) or to see if somebody else that figured out what's up with the function parameters, but no luck.
Thanks in advance.
|
|
|
|
|
Alex, one thing I'd say is, are you sure you need to use the full blown Word spell checker? There are plenty of free, more lightweight alternatives out there. (I just searched for C# spell checker and got some articles).
Also, are you aware that WPF (the new UI toolkit part of .NET 3 and up) has text boxes and rich text boxes with built in spell checker?
Now, if none of that dissuades you from using Word's spellchecking, here are my thoughts:
-a couple of the errors are mistranslations from VB.NET, such as the CType one and possibly the "string is a type but is used like a variable". Are you aware there's a C# article showing how to use Word's spellcheck on CodeProject?
-the rest of the compiler errors may be differences between VB.NET and C#, where VB.NET allows for "optional" params, C# doesn't. For cases like this, try passing in the default value (such as null for objects, 0 for ints, false for bools, etc.).
Another thing to check out if you're set on Word's spellchecking is Microsoft's "Visual Studio Tools for Office" set of APIs. Microsoft built some interop dlls and tools for easier interop with Word from C#. Search MSDN for more info.
Life, family, faith: Give me a visit.
From my latest post: "When Constantine severed the Hebrew origins of this faith in Messiah, a new religion was officially created. It is this religion that Orthodox Jews fear their relatives and friends becoming members of."
Judah Himango
|
|
|
|
|
|
Alex MacDonald wrote: if (Clipboard.GetDataObject.GetDataPresent(DataFormats.Text)) { textBox1.Text = CType(Clipboard.GetDataObject.GetData(DataFormats.Text), String); }
i guess there are some bracets missing: Clipboard.GetDataObject().GetDataPresent(...
|
|
|
|