|
What I do in my screen grabber applet is...
Define a bitmap of the appropriate size:
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap
(
this.pPanel.Width
,
this.pPanel.Height
) ;
Get a Graphics object for the bitmap:
using ( System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage ( bitmap ) )
Copy the area of the screen that the Panel covers to the bitmap:
gr.CopyFromScreen
(
this.pPanel.PointToScreen ( new System.Drawing.Point ( 0 , 0 ) )
,
new System.Drawing.Point ( 0 , 0 )
,
this.pPanel.Size
) ;
Save the bitmap to a file (I prefer PNG):
bitmap.Save ( sw.BaseStream , System.Drawing.Imaging.ImageFormat.Png ) ;
(Details left as an exercise.)
|
|
|
|
|
Hello,
I've a timer that run every 1 second (and do some check),
how can i insert it to a thread? because it interrupt to my application.
can someone please help me here?
|
|
|
|
|
tamir101 wrote: I've a timer that run every 1 second (and do some check),
Is that a System.Windows.Forms.Timer or System.Threading.Timer ? First one runs on the main thread and second one runs on a pooled thread.
If you are using Forms.Timer , consider changing to Threading.Timer . This[^] MSDN article will help.
|
|
|
|
|
Hi,
Can you please explain me how to use it?
I can't understand how i need to do it...
|
|
|
|
|
i want to stored the image which i have in a picturebox to be stored in sqldatabase. and which datatype i should use in sql
|
|
|
|
|
|
You can place your own contol in the dropdownlist of a combobox, see here:
http://www.codeproject.com/KB/combobox/CustomComboBox.aspx
modified 27-May-14 5:28am.
|
|
|
|
|
If I want to grab a DataRowView I use:
DataRowView arrangement = (DataRowView)BindingContext[debtorDataSet, "Debtor.FK_PaymentArrangements_Debtor"].Current;
How can I get a DataRowView for the previous position without changing the position to do so please?
|
|
|
|
|
BindingContext[debtorDataSet, "Debtor.FK_PaymentArrangements_Debtor"].Position will give the current position. Get the table from debtorDataSet and take the row at position - 1.
|
|
|
|
|
Hi all,
Is is possible to add the result of two anonymous LINQ queries together (when the data is gathered from two different data sources), to form a variable that one foreach loop can iterate on. For example:
var query1 = from x in dataCollection
select new
{
name = x.Name,
surname = x.Surname
};
var query2 = from x in xmlCollection
select new
{
name = x.Name,
surname = x.Surname
};
foreach (var result in .....
Many thanks in advance,
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Ravi Mori wrote: You have to post this question in Linq Forum..
Your right ... sorry about that
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
If I open a web page (http://www.google.co.in/) on Mozilla firefox, How can I save to a specific Path (e.g., "C:\New Folder\WebPage.html")?
How to do this using c#
|
|
|
|
|
Check this link^
Might help you out..
|
|
|
|
|
hi,
i have many text boxes on my web page,
how can i get which text box is focused.
Thank You
|
|
|
|
|
foreach (Control c in Controls)
{
if (c.Focused)
{
MessageBox.Show(c.Text);
}
}
Remember to check if it is a TextBox, as buttons etc can also have the focus.
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
|
|
|
|
|
i am receiving error-
Cannot convert method group "Focus" to non delegate type 'bool'
|
|
|
|
|
Have you had a look at the TexBox Class[^]?
Maybe you can find something there...
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Something like this should work:
foreach (Control ctrl in Page.Controls)
{
if (ctrl is TextBox && ctrl.Focused)
{
((TextBox)(ctrl)).Text = "FOUND YOU!!";
}
}
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Controls have an event that's triggered when they get focus, so you could just hook into this on every control, and store the last focused item yourself
|
|
|
|
|
You would probably get better responses on the Web Development Forum, but for what it's worth in Windows Forms there is the ActiveControl property. Is that also available For ASP?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I want to know how can I retrieve the GUID stored in the Assembly Information in the project properties using C#?
|
|
|
|
|
using System.Reflection;
Assembly asm = Assembly.GetExecutingAssembly();
Console.WriteLine(asm.GetType().GUID.ToString());
Cheers...
|
|
|
|
|
Unfortunately, the previous solution is highly unlikely to work. However, you can find a small snippet which shows the method (and some code) here[^]
|
|
|
|
|
I want to extract frames from video files without playing them. I used the GetCurrentImage of IBasicVideo2 to extract frames of videos as thumbnails of them. I Successfully extracted frames from video files of the format of WMV, AVI, DAT, ASF except MPG and VOB. When I extract frames of MPG and VOB files, It returns black frames.(The frames extracted are Successfully saved as bmp image files on my pc. however, they are all black frames.) Why??
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Imaging;
using DShowNet;
using QuartzTypeLib;
namespace test2
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
string videoFileName = "d:\\aaaa\\《OVER IT》MV.MPG";
string bitmapFileName = "d:\\《OVER IT》MV.MPG.bmp";
GetThumbnail(videoFileName, bitmapFileName);
}
private bool GetThumbnail(string videoFileName, string bitmapFileName)
{
FilgraphManagerClass filgraph = new FilgraphManagerClass();
try
{
filgraph.RenderFile(videoFileName);
filgraph.CurrentPosition = filgraph.Duration / 2;
int width = filgraph.SourceWidth;
int height = filgraph.SourceHeight;
int pBufferSize = 0;
DShowNet.IBasicVideo2 video = (DShowNet.IBasicVideo2)filgraph;
video.GetCurrentImage(ref pBufferSize, IntPtr.Zero);
IntPtr pDIBImage = Marshal.AllocHGlobal(pBufferSize);
video.GetCurrentImage(ref pBufferSize, pDIBImage);
int stride = -4 * width;
System.Drawing.Imaging.PixelFormat format = System.Drawing.Imaging.PixelFormat.Format32bppRgb;
IntPtr scan0 = (IntPtr)(((int)pDIBImage) + (pBufferSize - (4 * width)));
Bitmap bmp = new Bitmap(width, height, stride, format, scan0);
bmp.Save(bitmapFileName);
Marshal.FreeHGlobal(pDIBImage);
}
catch
{
return false;
}
while (Marshal.ReleaseComObject(filgraph) > 0) ;
return true;
}
}
}
BR,
Smilefishcc
|
|
|
|