|
if(string.IsNullOrEmpty(Request.QueryString["myVariable"]))
{
}
|
|
|
|
|
J4amieC wrote: if(string.IsNullOrEmpty(Request.QueryString["myVariable"]))
{
// the variable does not exist in the URL
}
Actually, if the string is an empty string, the variable does exist in the url.
if (Request.QueryString["myVariable"] == null) {
}
if (string.IsNullOrEmpty(Request.QueryString["myVariable"])) {
}
---
single minded; short sighted; long gone;
|
|
|
|
|
try-catch is two orders of magnitude easier than reflection !
|
|
|
|
|
You can use reflection, but it seems odd to me that you wouldn't know, that's a compile time thing.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
M. Nauman Yousuf wrote: Is there any way that we can check if a specific variable is declared or not
Yes. Use Reflection for that.
SSK.
|
|
|
|
|
How can download file EvilMaker_By_Hesham.zip from this site?
Because when I am downloading, an error occur:
"
File not Found
The file '/useritems/TCP_IP_protocols/EvilMaker_By_Hesham.zip' doesn't exist. Please contact webmaster@codeproject.com.
This article appears to be an unedited contribution, meaning it has not been checked or edited by CodeProject. You should contact the author of this article in order to get any missing files.
Click here to go back to the article for this download."
Thanks.
|
|
|
|
|
Gee - which part of 'You should contact the author of this article in order to get any missing files.' is confusing you ?
The authors do not work for the site, nor are most of them even known to the site. Someone has made a mess of the upload, and so the files are not here. There's nothing anyone apart from the author can do for you.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How can capture image from Webcam use DirectX.Capture Library and transfer it to Client use TCP/IP Connection?
If anyone have source or demo about it, please share with me?
Thank you very much.
My project is Webcam Server. WebcamServer capture video and image from Webcam and send it to WebcamClient. So WebcamClient can preview the video and image as WebcamServer.
|
|
|
|
|
If you want to send real time images, you need to host some sort of control on the client side. Or you can just set a page to auto refresh and grab an image which is updated regularly. There are tons of articles about on capturing using DX.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I have a question I hope that someone can help me with. I wonder how to convert a binary text into ASCII characters. As an example, if I have a text file or text box, and type "1001000 1101001 100001" which is "Hi!" in ASCII, how would I go about to convert it into clear text?
Or if I'd type Alt + 0256 which would give me 100000001 as a result, which has 9 digits in it, compared to ! that only have 6 digits in it. Anyone understands what I mean, and can possibly help me with this? I've just started with Visual C# .NET, so I'm kind of trying to learn conversions and controls, so I appreciate all the help I can get on this matter.
Thank You,
ScIeNcE_ErRoR
|
|
|
|
|
Hi,
for the matter at hand, all characters are stored in either 1 or 2 bytes, and use
either 8 or 16 bits (i.e. there may be leading zero bits).
ASCII characters use 1 byte with 7 significant bits; there are extensions (such as ANSI) that
use all 8 bits in the byte.
Unicode characters use 2 bytes with 16 significant bits.
Some Windows functions may pack an ASCII character together with some flags (e.g. regarding
the state of the control, alt, and windows key), resulting in a 2-byte short or a 4-byte int.
That is useful for a keyboard state or so, but does not apply to text, or parts thereof.
A piece of text consists of a sequence of characters, and since these could be either 1 byte
or 2 byte, we need some encoding scheme. There are many.
The simplest one is all ASCII (hence 1 B/char), but this one has a lot of limitations.
Another one would be all Unicode (hence 2 B/char), that is expensive (especially in
storage or data communication).
Some mixed forms exist such as UTF8, they try to use 1B for popular characters, and more
when necessary.
If you are holding an array of bytes, and know what encoding scheme was used,
go have a look at the Encoding class: instantiate an Encoding object corresponding
to the way the text got encoded, then call its GetChars() method to decode the byte array,
the result is a string (now in Unicode, whatever it originally was).
That's what you asked for, isnt it.
There is more though. When encoding (i.e. from text to bytes) into Unicode, UTF8 and
then some, the convention is to prefix a 2-byte code indicating which encoding is used;
when using the correct way to decode such a byte stream, these optional markers get
consumed and cause the selection of the right decoder automatically.
This happens for instance in File.ReadAllText
Hope this clarifies a lot.
|
|
|
|
|
Well, being I'm all new to this I didn't understand all of it. The way I put it into binary though is as follows:
<br />
char[] arrChars = txtASCII.Text.ToCharArray();<br />
String sBinary = "";<br />
String D;<br />
D = " ";<br />
foreach (char ch in arrChars)<br />
{<br />
sBinary += Convert.ToString(Convert.ToInt32(ch),2) + D;<br />
}<br />
txtBIN.Text = sBinary;<br />
Now, I know that if I change the ,2 to ,16 I get a Hexadecimal output, or Octal if I put ,8 and Decimal if I put ,10. But is there an easy way, by using that code, to reverse the process then? I also tried (Convert.ToChar(ch)) and it gave me the text again. But that was by already typing in my Text Box, not typing in the Binary Box. Can this be simply reversed? And I apologize for the newbie questions, but I'm slowly learning as I go. Trial 'n' Error many times. I tried to type GetChar() but the option of GetChar was not in the drop down menu. I probably missunderstood something though.
Thank You,
ScIeNcE_ErRoR
|
|
|
|
|
OK, I misunderstood you; what you want is conversions between numbers and their
string representations (e.g. between 123 and "123").
Here it goes:
int intValue=123;
string strDecimal=intValue.ToString();
string strHex=intValue.ToString("X2");
string strHey=intValue.ToString("X4");
For more, read up on the ToString() method of the base types (int, byte, double, ...);
you may have to look for Int32 instead of int though.
The reverse is called "parsing", i.e. try to figure out if the string contains a
valid int, byte, double, whatever. Since .NET 2.0 they have two variants:
TryParse() will return a bool to indicate success
Parse() will return a value, and throw an Exception on failure
some examples:
string str="12345";
int myDecimal=int.Parse(str);
byte overfl=byte.Parse(str);
int myHex=int.Parse(str,NumberStyles.AllowHexSpecifier);
and there are many more.
Sorry about the confusion, but its not ASCII, everything in this message occurs
in memory, hence in Unicode; and the ints and bytes get their value (which happens
to be stored in binary but that is not relevant most of the time).
|
|
|
|
|
Thank you for your help, I really appreciate it, I've managed to do a reverse coding of it, so it displays the binary string back to text as follows:
<br />
string[] arrStrings = this.txtBIN.Text.Trim(' ').Split(' ');<br />
String sText = "";<br />
foreach (string st in arrStrings)<br />
sText += Convert.ToChar(Convert.ToInt32(st, 2));<br />
this.txtTEXT.Text = sText;<br />
I appreciate your help and explanation on this matter. I'm sure I will have more questions as I go along.
Thank You,
ScIeNcE_ErRoR
|
|
|
|
|
You're welcome.
We all have questions from time to time.
But first try to search the answers yourself, by reading documentation, or
searching CP/MSDN/Google before asking here; that way you will learn more and faster.
|
|
|
|
|
Hi
i would like to know to show a PPT in c#(anyway could help)
specific :
i have a webbrowser
and i wrote this :
Uri ppt = new Uri(@"C:\project poster.ppt");
webBrowser1.Navigate(ppt);
but it gives my a open save cancel dialog, I DONT WANT IT SHOW
just to show the PPT
if anyone can help TNKS
if there is another way to show the PPT using : PowerPoint.Presentation will be fine to
TNKS
kobkob
|
|
|
|
|
Have you looked around at the Office Interop for Powerpoint?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
AFAIK there are at least three ways to do such things, depending on what you want:
1.
use Process.Start() to launch a new process that opens the target program or the
target document; this opens outside your program, but you could see it become idle,
terminate, and possibly (depends on the app), redirect its input/output/error streams.
This method does not allow interaction at the document level: you can not let your program
change the PPT presentation
Two variations:
a) specify the PPT app as the cmd, and the file as the only argument (this means you must
know exaxctly where the app is on disk)
b) specify the document as the cmd; this simulates a double-click in Windows Explorer
(so there must be a File Association)
2.
use Office Interop; that's the most complex one, now you can do almost anything to the
document, by sending commands all the time to the external process.
I would not do this if you only want to view a document !
3.
use your approach: a web browser component inside your project.
You probably are very close to what you want.
Unfortunately I did it only with shdocvw.dll (a precursor of WebBrowser), and with Word.
Maybe your PPT app was already open, and had a dirty document, so it wanted to save
before opening your other document ?
Hope this helps
|
|
|
|
|
Luc,
I looked around at the Office Interop approach that I mentioned earlier, and it seems to let you open the Powerpoint file, and do some things with it. I'd like to try and open one and just start up as a slideshow. Any idea how this can be accomplished?
Paul
|
|
|
|
|
Sorry Paul, I have never used Office Interop.
If you have a PPT document that is a slide-show (maybe that's a PPS file ? anyway such
that double-clicking it is all it needs), then I would use Process.Start for an
external process, or try a WebBrowser for an internal window.
If it is just a PPT file, I guess you need Office Interop, which IIRC means you need a
special SDK, create one of its objects say "Presentation class"), then invoke Open(),
and either a one-off command ("SlideShow()" ?) or a command per slide, dont know.
I did use VBA once to control Word but that was long before .NET even existed (I managed
to convert a Word document into a web site before they supported that themselves);
I trust MS has now encapsulated their Office object model in a couple of CLR classes.
Greetings
|
|
|
|
|
Luc Pattyn wrote: I have never used Office Interop.
I've only used it for Excel and Word, when a client requested a productivity reporting tool. Could have used something else like Crystal Reports/Reportviewer, but we had standardization reasons to stick with Office. The shop likes to have everything in Office files/format. Ease of information sharing/passing I guess.
Luc Pattyn wrote: I did use VBA once to control Word but that was long before .NET even existed
Same here. I actually looked around in Powerpoint and saw a Run method, but when I went to the macro, it just disappeared
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
When I hittest for a location where a button is, i get ButtonChrome or TextArea. Now I know why, but how do I find 'Button' through code. There is e.Source and e.OriginalSource through the eventargs but for my specific implementation those won't ever return Button as any one of them. Is there another way of finding the Parent of ButtonChrome/TextArea from the HitTestResult?
The reason why the eventargs won't ever have that value is because i'm working with custom input (multitouch screen to be exact). So it doesn't come through the framework. Except if you can propose a better way to start the input. At the moment it starts at the Canvas level. No higher.
thanks in advance.
donovan
rather have something you don't need, than need something you don't have
|
|
|
|
|
Hi Donovan,
cant you turn the touchscreen event into a regular mouse event (or sequence of mouse events) ?
I havent any experience with touchscreens, but I would expect you want to use it like a
mouse, so why not have it do a SendMessage(WM_...) to the active form. In that way
all the Windowing logic would work for you.
What is it the touchscreen vendor provides ? how does he justify a different API ?
|
|
|
|
|
there is no vendor.everything is custom created. the screen works like the ms surface computer.but my code at the moment works ok,i can touch and manipulate images because hittest returns a system.windows.controls.image. but a button returns buttonchrome so there is no way to solidly check the control type to be able to raise the correct event.
i cant check for buttonchrome because it can change depending on the UI styling.
this is all WPF.
rather have something you don't need, than need something you don't have
|
|
|
|
|
OK, about no vendor.
I am not familiar with WPF, ButtonChrome and such.
But my basic question remains: I assume your touchscreen generates some events when
touched/dragged/etc., can't you just turn these into the regular Windows commands
and inject them with SendMessage or something similar (or are these all gone in WPF ?) ?
In Win32 and everything before WPF (and maybe, not sure, also in WPF) events get sent
to a Window, and if necessary that window will forward the events to its controls,
so you typically never have to "dispatch" them yourself. Turning your touchscreen events
in mouse events should give you the same thing.
I suggest you have a look at the old mouse_event function, and the recent SendInput function.
That is the way I would investigate. If that makes things easier, you could do first
experiments on a regular PC, just turn some keyboard actions into mouse actions
with one of the functions I mentioned; then substitute the touchscreen for those
keyboard events.
Hope this helps.
|
|
|
|
|