|
Do an && to strip the bits you don't want, and shift them down with >>
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
There is an alternative, that may be interesting when many variables need to
available in both packed and unpacked form.
Using structs you can obtain a "union" effect in C# in the following way:
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
public struct Overlay {
[FieldOffset(0)]public uint u32;
[FieldOffset(0)]public byte u8_0;
[FieldOffset(1)]public byte u8_1;
[FieldOffset(2)]public byte u8_2;
[FieldOffset(3)]public byte u8_3;
}
public override void Run() {
Overlay overlay=new Overlay();
overlay.u32=0x12345678;
log("lo to hi: "+overlay.u8_0.ToString("X2")+" "+overlay.u8_1.ToString("X2")+
" "+overlay.u8_2.ToString("X2")+" "+overlay.u8_3.ToString("X2"));
}
On a little-endian machine (such as Intel x86) the Run method will log
"lo to hi: 78 56 34 12"
Be careful though, you are responsible for the offset values !
-- modified at 11:54 Sunday 4th February, 2007
Luc Pattyn
|
|
|
|
|
I want my program to be able to dock on any side of the screen and have all of the other windows to resize so that my program gets its own space. (Bad example, but kind of like the taskbar)
thanks!
|
|
|
|
|
hi
i want to set focus on specified row in My datagridview, how to do ?
thanks
|
|
|
|
|
Try this:
DatGridView1.CurrentCell = DatGridView1.Rows[RowIndex].Cells[0];
|
|
|
|
|
I'm not asking for a complete program or anything, but if I was going to make an application that would allow people to communicate from different computers via the web (similar to AOL Instant Messenger), how would I go about doing it? Something to get me started would be helpful. Thanks!
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
max29297 wrote: I'm not asking for a complete program or anything, but if I was going to make an application that would allow people to communicate from different computers via the web (similar to AOL Instant Messenger), how would I go about doing it? Something to get me started would be helpful. Thanks!
This article[^] should give you some pointers.
|
|
|
|
|
Thanks a lot!
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
can anyone tell me how wrappers are created. im relatively new to c#. i want to create wrappers to a c++ process code in C#?
|
|
|
|
|
To get from C++ to C#, you probably want to use p/invoke, if the C++ code is in a dll. Another option is to write it in C++/CLI, which .NET can call. Depending on the process and the code involved, a C# rewrite may be an option ( this is usually best, with p/invoke for any calls you need to make to Win32 functions )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi , i stored my connection in application settings i.e. project > properties> settings tab.
Now i need to access the connection string from code. How do i do it ??
any help is appreciated,
yojimbo
|
|
|
|
|
Hello,
I'm currently working on a project.
I use icons for my tool bars, ListViews etc.
The problem is that I sometimes need to use the same icon more than once, but in a different ListView, or tool bar.
When using a tool bar there's no problem because I can add an icon as a resource, and later on use this resource without adding it again and again.
However if I take a ListView, which of course needs an ImageList to display its icons, I have to add the same icons to the ImageList over and over again.
Does VS know not to add the same icon file to the exe twice?
Should I add the icons as resources, and then add those resources to the ImageLists using code?
Thanks in advance,
Shy.
|
|
|
|
|
hello
i wanto create an application (C#) like "free download manager" for download files.
i use "System.Net.WebClient" class for this .
such as following
...
string filename
System.Net.WebClient client = new System.Net.WebClient();
....
try
{
Uri uri = new Uri(urlTextBox.Text);
string fileName = System.IO.Path.GetFileName(urlTextBox.Text);
string downloadString = client.DownloadString(uri);
this.toolStripProgressBar1.Value = 0;
client.DownloadFileAsync(uri, fileName);
this.downloadButton.Text = "Cancel";
isBusy = true;
}
catch (UriFormatException ex)
{
MessageBox.Show(ex.Message);
}
...
my problem in use of this class is, i don't know how recognize file extension (in my code "fileName" vaiable) to download like .txt, .pdf
|
|
|
|
|
hi
you can verify the url when the Download url is entered in the textBox like
[CODE]
string s="http://www.google.com/file.txt";
if(s.EndsWith(".pdf")||s.EndsWith(".exe")))
{
//call the function for file download
}
else
//error message
[/CODE]
Q@!$3r
|
|
|
|
|
string fileExtention = System.IO.Path.GetExtension(urlTextBox.Text);
|
|
|
|
|
hmm just wondering how to check if the download url is like this..
http://www.some-site.com/sessionid/file?get=74
Like many site don't provide direct download link to prevent leeching ...
Q@!$3r
|
|
|
|
|
yes
my problem is this
|
|
|
|
|
hmm, try send WebRequest to url like this, and watch what the WebResponse is doing (or maybe the WebResponse's stream).. or create function to handle redirections, which MUST come from the WebResponse...
VirtualVoid.NET
|
|
|
|
|
i have a multi threaded program, and i'm confused about how thread works.
well, my question is that if i create a new thread, it will run along with the thread
of the main program, and if i call any function form within the new thread that i create, it will be excuted in the new thread, but if i want to call an asynchronous
operation from the new thread, what will happen then(since any asynchronous operation
will create new thread), it will be a thread inside thread or what?
i just need a little illustration a bout this situation.
|
|
|
|
|
Threads are not inside each other, threads are inside the application. If you start a new thread, it will be inside the same application, not inside any other thread.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
I am using the following method to download a file from the internet ;
WebClient.DownloadFile(url,file_name_to_save)
Is it possible to show the progress of Download in a ProgressBar? I know it can be done via WebRequest and WebResponse object..But can it be done with WebClient Object?
Regards
Q@!$3r
|
|
|
|
|
hi , you can use this code ...
but befor i put code , i have a question :
for download , how can recognize the file extention ?
--------------------------------------------------------------
you can use "Download Progress Indicator Technology Sample "
topic in msdn
--------------------------------------------------------------
code
--------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace downloadManager
{
public partial class Form1 : Form
{
private bool isBusy;
private WebClient client;
public Form1()
{
InitializeComponent();
client = new WebClient();
// Wire up the download complete event handler.
// The operation will either complete successfully or with an
// error code.
client.DownloadFileCompleted += client_DownloadFileCompleted;
// Wire up the download progress event handler.
client.DownloadProgressChanged += client_DownloadProgressChanged;
}
private void button1_Click(object sender, EventArgs e)
{
// If an operation is pending, then the user has clicked cancel.
if (isBusy)
{
client.CancelAsync();
isBusy = false;
this.downloadButton.Text = "Download";
}
// Otherwise go ahead and start the download
else
{
try
{
Uri uri = new Uri(urlTextBox.Text);
string fileName = System.IO.Path.GetFileName(urlTextBox.Text);
string fileExtention = System.IO.Path.GetExtension(urlTextBox.Text);
string downloadString = client.DownloadString(uri);
this.toolStripProgressBar1.Value = 0;
client.DownloadFileAsync(uri, "test");
this.downloadButton.Text = "Cancel";
isBusy = true;
}
catch (UriFormatException ex)
{
MessageBox.Show(ex.Message);
}
}
}
// Displays a message indicating that the download completed
// successfully, or if there was an error it will be displayed instead.
private void client_DownloadFileCompleted(
object sender, AsyncCompletedEventArgs e)
{
isBusy = false;
this.downloadButton.Text = "Download";
if (e.Error == null)
{
MessageBox.Show("Download Complete");
}
else
MessageBox.Show("Download Not Complete: " + e.Error.Message);
this.toolStripProgressBar1.Value = 0;
}
// Updates the progress indicator with the latest progress
private void client_DownloadProgressChanged(
object sender, DownloadProgressChangedEventArgs e)
{
this.toolStripProgressBar1.Value = e.ProgressPercentage;
}
}
}
|
|
|
|
|
hi,
I am using .Net 1.1 and I guess it doesn't have the namespace "DownloadProgressChangedEventArgs"
Thats why I got the following error
D:\VS\my C#\RssReader\Form1.cs(250): The type or namespace name 'DownloadProgressChangedEventArgs' could not be found (are you missing a using directive or an assembly reference?)
Well as far as File extention is concered it can be determind when the user enter the url the entered url then be validated to get the last chars to (using string EndsWith method)find the extention and it will be then comapred against the allowed ext type.....
Q@!$3r
|
|
|
|
|
I need Urgently The Source code for video watermarking..
If Anyone out there has it Please Forward it to me.. Or Please paste it In the Discussion Board.,,
I've created the pseudocode But not sure about how to Implement it or which language should i use.(tyhinkin of VJ#.NET and C#.NEt)_..
i just need a small Utility and the basic idea as of yet is a 1min video.. split it into frames and watermark the frames and recompile images to video..
please help me out.. thank U.
Christin
|
|
|
|
|
Well, DirectShow is what you need to do this, do you have that downloaded ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|