|
It probably is a VS2005 project, which VS2008 can convert.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
E_Gold wrote: How to print (and preview) any document
And while on the subject of magic: How to do anything and everything automatically?
Hint: Any document implies a system that can intelligently reverse-engineer any format presented to it, past, present or future, as well as one that can break encryption that is considered unbreakable. In short, you are asking for nothing less than magic.
|
|
|
|
|
it's 00:30 and I lost my mind in a few beers, came home and would do some coding before I hit the showers, but now I forgot an important part...
I remember how to add values and text to a combobox via a datasource, but can any remember how to add both text and value in a static way?
ie.
Combobox1.Items.Add(new ????("text","value"));
yes, yes I know, don't code drunk.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:59am.
|
|
|
|
|
nah can't really use that solution, then I wouldnt be able to use SelectedValue to get the current selected value and would have to rewrite too much code as I then couldnt load the combobox values elsewhere.
but thanks for the effort.
|
|
|
|
|
Why don't you create a static datatable with your static data??
static DataTable dt = new DataTable();
public Form1()
{
InitializeComponent();
dt.Columns.Add("MyTextToShow");
dt.Columns.Add("MyValueToShow");
dt.Rows.Add("OneText", 1);
dt.Rows.Add("TwoText", 2);
dt.Rows.Add("ThreeText", 3);
comboBox1.DataSource = dt;
comboBox1.ValueMember = "MyValueToShow";
comboBox1.DisplayMember = "MyTextToShow";
}
regards... and don't code drunk! is hateful haha
|
|
|
|
|
hi there
i am writing a program for video conference over internet i was looking for a sample for capturing a image from webcam i found that there is two way for doing this first is using WIA and second is using API i found a sample that use API (avicap32.dll) it work fine now i want to add another camera or webcam and the aouther is not accessible .i reviewed codes several times but i cant understand that. it is really complicated for me and as i cant understand the code i cant extend it for capturing image or video from any other devices synchronouslly here is the code and i would be really appriciated if you explan about the codes :
the class for capturing and sending image:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WebCam_Capture
{
[System.Drawing.ToolboxBitmap(typeof(WebCamCapture), "CAMERA.ICO")]
[Designer("Sytem.Windows.Forms.Design.ParentControlDesigner,System.Design", typeof(System.ComponentModel.Design.IDesigner))]
public class WebCamCapture : System.Windows.Forms.UserControl
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Timer timer1;
private int m_TimeToCapture_milliseconds = 100;
private int m_Width = 320;
private int m_Height = 240;
private int mCapHwnd;
private ulong m_FrameNumber = 0;
private WebCam_Capture.WebcamEventArgs x = new WebCam_Capture.WebcamEventArgs();
private IDataObject tempObj;
private System.Drawing.Image tempImg;
private bool bStopped = true;
public delegate void WebCamEventHandler (object source, WebCam_Capture.WebcamEventArgs e);
public event WebCamEventHandler ImageCaptured;
#region API Declarations
[DllImport("user32", EntryPoint="SendMessage")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
[DllImport("avicap32.dll", EntryPoint="capCreateCaptureWindowA")]
public static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);
[DllImport("user32", EntryPoint="OpenClipboard")]
public static extern int OpenClipboard(int hWnd);
[DllImport("user32", EntryPoint="EmptyClipboard")]
public static extern int EmptyClipboard();
[DllImport("user32", EntryPoint="CloseClipboard")]
public static extern int CloseClipboard();
[DllImport("avicap32.dll", EntryPoint = "capgetdeviiceproperties")]
public static extern int capgetdeviiceproperties(string lpszWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);
#endregion
#region API Constants
public const int WM_USER = 1024;
public const int WM_CAP_CONNECT = 1034;
public const int WM_CAP_DISCONNECT = 1035;
public const int WM_CAP_GET_FRAME = 1084;
public const int WM_CAP_COPY = 1054;
public const int WM_CAP_START = WM_USER;
public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41;
public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;
public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43;
public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44;
public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45;
public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46;
public const int WM_CAP_SET_PREVIEW = WM_CAP_START + 50;
#endregion
#region NOTES
#endregion
public WebCamCapture()
{
InitializeComponent();
}
~WebCamCapture()
{
this.Stop();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
this.Name = "WebCamCapture";
this.Size = new System.Drawing.Size(342, 252);
}
#endregion
#region Control Properties
public int TimeToCapture_milliseconds
{
get
{ return m_TimeToCapture_milliseconds; }
set
{ m_TimeToCapture_milliseconds = value; }
}
public int CaptureHeight
{
get
{ return m_Height; }
set
{ m_Height = value; }
}
public int CaptureWidth
{
get
{ return m_Width; }
set
{ m_Width = value; }
}
public ulong FrameNumber
{
get
{ return m_FrameNumber; }
set
{ m_FrameNumber = value; }
}
#endregion
#region Start and Stop Capture Functions
public void Start(ulong FrameNum)
{
try
{
this.Stop();
mCapHwnd = capCreateCaptureWindowA("WebCap", 0, 0, 0, m_Width, m_Height, this.Handle.ToInt32(), 0);
Application.DoEvents();
SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0);
SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0);
m_FrameNumber = FrameNum;
this.timer1.Interval = m_TimeToCapture_milliseconds;
bStopped = false;
this.timer1.Start();
}
catch (Exception excep)
{
MessageBox.Show("An error ocurred while starting the video capture. Check that your webcamera is connected properly and turned on.\r\n\n" + excep.Message);
this.Stop();
}
}
public void Stop()
{
try
{
bStopped = true;
this.timer1.Stop();
Application.DoEvents();
SendMessage(mCapHwnd, WM_CAP_DISCONNECT, 0, 0);
}
catch (Exception excep)
{
}
}
#endregion
#region Video Capture Code
private void timer1_Tick(object sender, System.EventArgs e)
{
try
{
this.timer1.Stop();
SendMessage(mCapHwnd, WM_CAP_GET_FRAME, 0, 0);
SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0);
if (ImageCaptured != null)
{
tempObj = Clipboard.GetDataObject();
tempImg = (System.Drawing.Bitmap) tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap);
x.WebCamImage = tempImg.GetThumbnailImage(m_Width, m_Height, null, System.IntPtr.Zero);
this.ImageCaptured(this, x);
}
Application.DoEvents();
if (! bStopped)
this.timer1.Start();
}
catch (Exception excep)
{
MessageBox.Show("An error ocurred while capturing the video image. The video capture will now be terminated.\r\n\n" + excep.Message);
this.Stop();
}
}
#endregion
}
}
thanks in advance
modified on Saturday, November 21, 2009 1:52 PM
|
|
|
|
|
Firstly you should put your code between <pre></pre> tags so it retains its formatting. The above code is very difficult to read, please edit the entry.
Secondly if you do not understand the code then you really should not be trying to use it. The most important aspect of any application is that you understand the code you are using. This forum does not have the space (and contributors do not have the time) to provide tutorials in this fashion. If this code came from an internet article then you should spend time studying the article until you understand it.
|
|
|
|
|
Whats the betting he just puts <pre>...</pre>tags around the existing unformated code?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Richard MacCutchan wrote: Secondly if you do not understand the code then you really should not be trying to use it.
I don't think this is the right way to look at it. Just because you don't understand the code doesn't mean you shouldn't try to use it in order to gain said understanding.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I think the rest of my comment tried to put this in context. I was trying to make the point that getting someone else to modify the code to do what he wants will not enhance his understanding of it.
|
|
|
|
|
at first excuse me because of confusing you i corrected the code and here is the site that i downloaded the file:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1339&lngWId=10[^]
|
|
|
|
|
Richard MacCutchan wrote: if you do not understand the code then you really should not be trying to use it
That depends on what the code is! Most of us use code all the time that we don't understand - in the .net framework. And it truly would be a waste of time to study every implementation detail (most of which are undocumented!) of the primitive types before permitting oneself to use them. I do not know the exact representation of System.Decimal nor what bit-level manipulation it performs to carry out a multiplication, but it would be ridiculous to claim I shouldn't use decimals for that reason.
Also, even code that was not written with the intent of becoming a library (though most code should be written that way imo!) can still be of good quality and of great utility. Trying to use it is sometimes the most effective way to learn about it, whether it's good or bad code, especially if one does not have access to documentation.
|
|
|
|
|
This reply was aimed at the OP, who has downloaded some code from the internet that they admit to not understanding, and then wants a major change made to implement a feature that they probably understand less. It was not aimed at people who provide the answers on these forums. And I know that we all use unfamiliar code to learn new things, but we also spend a lot of time answering questions like this from people who have not taken the time to learn some of the basics.
|
|
|
|
|
OK. I think we've both made some valid points. It's not necessary to interpret any additional perspectives as implying "you're wrong" and it's not really a competition.
|
|
|
|
|
dojohansen wrote: It's not necessary to interpret any additional perspectives as implying "you're wrong"
I was not for a moment implying this, so I hope you did not read it that way. I do accept the points you made, I was merely trying to clarify my earlier message which may not have been as clear as I thought it was.
|
|
|
|
|
And by the way,
Richard MacCutchan wrote: but we also spend a lot of time answering questions like this from people who have not taken the time to learn some of the basics.
If we do, we do so only by choice. (Reading them is at least partly another matter.)
|
|
|
|
|
First, you have to tell us where you got the code so we have a context in which to help yopu.
Second, you need to properly format the code you posted into a properly tagged PRE block.
Third, you need to use punctuation in your description so we can read it.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
|
Thank you for putting the proper tags around your code. The first thing that jumps out is that you're using int types for your interop methods. You should be using IntPtr so that the code will run reliably on both 32-bit and 64-bit operating systems.
Beyond that, I think you're going to have to find some additional code (or technique) that allows you to select a connected video capture device. I believe this will involve familiarity with the DirectX SDK, and more specifically buding what they call "graphs" to connect the various devices.
You may be able to use WMI to detect devices connected to the system (especially if they're USB or Firewire devices, but I've never done this before, so yo're gonna have to do the research.
Ain't programming fun?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
thank u for your post
where should i exactly change int to intptr and what is the difference
thanks
|
|
|
|
|
I believe it's the external methods that return int and that they should return IntPtr. These are windows api functions and though I didn't look at them individually they probably return windows handles. Such handles will be 32-bit on 32-bit systems but 64 bits on 64-bits systems. In other words they have nothing to do with your problem, but since int is just shorthand for Int32 you should use IntPtr instead, and your code would (or at least could) then work on 32-bit and 64-bit platforms. Also, if any of the parameters to these methods are handles they too should be IntPtr, but you'll likely find out simply by changing the return type of the extern methods and building, since any handles passed to one of these will come from one of these...
|
|
|
|
|
I have to develop an application that will capture the packets and display it information using winpcap..and for that i need help.how can i use winpcap in c#?? plz help me as I m already out of time
|
|
|
|
|
I have a data grid viewer populated from a SQL Server stored procedure which returns any number of columns from a minimum of 4 to a maximum of unknown columns.
I need to have the ability to print the entire grid.
This I can do.
However, to print the grid to specifications
-- I need to be able to print it on pages the size of 42x36 and 72x72.
-- I need to be able to visually scale the entire grid to one page?
Please help. what needs done for this ability?
|
|
|
|
|
Hello. I'm trying to get something like when a user inputs B, he gets back ß. I'm using
string b = "ß";
string what1 = Console.ReadLine();
if (what1 == "b")
{
Console.Write(b);
}
and it doesnt seem to work. Any Help?
modified on Friday, November 20, 2009 8:43 PM
|
|
|
|
|