|
I developed an application which is based on capturing the screen shots and save as the desired name given by the user.I used sendkeys method to avoid the usage of typing
printscreen key in my keyboard to copy the current screen to my clipboard.In my case I used a picturebox to hold the image and for saving.But if we are pressing the PrintScreen key the it works and without that it also works.The problem occurs during the second time,error occurs that the clipboard is empty or a null value exception is occured.
here is the code which I used.
Public Class main_frm
Dim sav As New SaveFileDialog
Dim i As Integer = 0
Dim abc, nam, path As String
Dim opd As New FolderBrowserDialog
Private Sub main_frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
disp_pb.SizeMode = PictureBoxSizeMode.StretchImage
abc = "D:\vishnu\Screen\Shots\"
'path = InputBox("Enter the location of file", "Please Respond", i)
End Sub
Private Sub capall_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles capall_btn.Click
'Try
Me.WindowState = FormWindowState.Maximized
Me.Hide()
SendKeys.Send("({PRTSC})")
disp_pb.Image = Clipboard.GetDataObject.GetData("Bitmap", True)
'Dim path As String
'abc = "D:\vishnu\a.jpg"
'disp_pb.Image.Save("D:\vishnu\a.jpg")
'path = "D:\vishnu\Screen\Shots\"
' abc = InputBox("Enter the name of file", "Please Respond", i)
' path = path + nam + ".jpg"
opd.ShowDialog()
path = opd.SelectedPath
path += "\"
nam = InputBox("Enter the name of file", "Please Respond", i)
path = path + nam + ".jpg"
disp_pb.Image.Save(path)
Me.Show()
Me.WindowState = FormWindowState.Normal
Clipboard.Clear()
'Catch ex As Exception
' MsgBox(ex.ToString)
' End Try
End Sub
Private Sub actcap_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles actcap_btn.Click
End Sub
End Class
|
|
|
|
|
|
Hi,
you don't need the PRNT SCRN key to capture the screen or the active window; there are better ways to get it done, search the nice CP articles on the subject.
And you definitely don't need a PictureBox to save the content to a file; PictureBoxes exist for
looking at an image, no more, no less.
BTW I did not look at your code since it has no formatting and no monospaced font. Please use
the "code block" button (which inserts PRE tags) when publishing some code.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
http://vbnet.mvps.org/index.html?code/bitmap/printscreenapi.htm
Sorry, I could not know how to post the address above as url.
hth
Samir R. Ibrahim
|
|
|
|
|
Hi
I am trying t print I-cards of employees, 4 at a time, on A-4 size paper. The program to generate these cards which is written by me,generates this Image of type '.JPEG'.Size is [640,1040].
Now, When I try to print cards on HP OfficeJet, if I select "Fax print" then it prints correctly, alignments are correct;but the print quality of image becomes poor.
I get the required quality by selecting "Photo Print" but then last 3 lines do not get printed. 3 lines get cropprd.
I don't understand the reason behind it. May I get some ideas??
|
|
|
|
|
Your description isn't very good and it's pretty difficult to diagnose a problem like this without actually seeing what you're getting as output. But, from what i can gather, you didn't check the size of the page you're printing on, didn't do the math to see if your images would fit, and did not scale the images accordingly when you rendered them using the Graphics object you got from the system.
|
|
|
|
|
I will try to explain it again.
The JPEG image of size 640 by 1050 pixels. "Fax print" and "photo print" are the print layouts which is asked to select at the time of printing.
|
|
|
|
|
And that doesn't help.
When you says stuff is getting "cut off", what do you mean?? Is it just the images on one side of the page?? More than one?? Which sides?? Maybe if you posted a link to a picture of the results...
|
|
|
|
|
Oops - that was meant to be the reply button, not the vote button
|
|
|
|
|
Right back at ya!
|
|
|
|
|
Selecting between fax print and photo print alters the device settings (dots per inch and page margins). Your print code needs to see what these settings are before it prints.
|
|
|
|
|
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at WindowsApplication1.Login.OK_Button_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:----------------------------------------
Contact List
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:----------------------------------------
ADODB
Assembly Version: 7.0.3300.0
Win32 Version: 7.10.2346
CodeBase: file:----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Thanx's in advance.
|
|
|
|
|
OK, from the top of JIT dump, you got an "Object reference not set to an instance of an object." error somewhere in your OK button in a Login form. This means that you didn't check to see if you actually had an object instance before you tried to access a property or object somewhere in there. Basically, you used an object that was Nothing instead of an actual object instance.
|
|
|
|
|
I remove all code in OK Button and I assigned as nothing. But Still that error is occurring.
|
|
|
|
|
Go back to your development code and run it from there. Somewhere in your code, just follow the stack trace you got, you've got a problem where your calling methods or using properties of an object that doesn't exist, otherwise known as "Nothing" in VB.NET.
|
|
|
|
|
Ya thanx's I got my mistake. Problem in Register key creation.
|
|
|
|
|
Colleagues,
Does anyone know how to scroll the CWGraph control? Here's the behavior I want to achieve:
1. The graph's X axis spans from 0 to 3000. In the beginning, it's charting a baseline (using ChartY method).
2. Let's say, it charted to 2500, when the user initiates a certain activity of interest.
3. Graph scrolls left leaving only the last 500 points of the baseline (this is the part I don't know how to do). The rest can be discarded.
4. Plotting continues from 500 onward.
Here's the same behavior on a storyboard: http://www.prolifictec.com/filehost/CWGraph_shifting_rev01.PNG[^]
Could anybody give me some suggestions?
Thanks,
- Nick
P.S. I'm using VB6 and Measurement Studio 8.1.11.
|
|
|
|
|
Nick Alexeev wrote: S. I'm using VB6 and Measurement Studio 8.1.11.
VB6 is long dead and completely unsupported. You should put VB6 in your subject line if you want help in obsolete technologies.
Also, don't the people who wrote this grid have a forum ? I mean, EVERYONE there uses this grid, the odds are good, given it's a VB6 control, that close to no-one here uses it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Oh, I remember those guys at National Instruments. Not the best libraries in the world. I wasn't writing code against them, but I had to support systems using some of their work. Ugh.
You single best source of information is going to be here[^]. It's extremely unlikely that you will find any help with those controls her, or on any other forum that doesn't belong to National Instruments.
|
|
|
|
|
Dave Kreskowiak wrote: [NI Measurement Studio is] Not the best libraries in the world.
IMHO, they are pretty good. May be they have improved since the last time you worked with them. I've just started using it. I've been looking for a chart control for plotting large amounts of data in real time (8 traces, 3000 points on the screen per trace, 10 new points a second on each trace). Among the chart controls that I've tried, CWGraph from MStudio had the best performance.
- Nick
|
|
|
|
|
Nick Alexeev wrote: May be they have improved since the last time you worked with them
Not likely. I was supporting the stuff for 4 years, as recent as last summer. Very little improvement and poor design decisions abounded from the start.
|
|
|
|
|
Dave what are some of the poor design decisions in your opinion? May be you could give me a heads-up. I'd really appreciate that.
- Nick
|
|
|
|
|
I'm a little concerned about thread safety and I'm not sure how to interpret the MSDN docs in this case. I'm making use of a VB.NET Module that has a public function for the code base I am working on to log events. This logging function can be called from anywhere at any time.
The code skeleton looks like;
Module Utility
...
Public Sub LogSomething(ByVal logData as string)
...
Dim srLog as StreamWriter = new StreamWriter()
...
End Sub
...
End Module
Is this thread safe? Could this turn into an issue? The code I'm looking at hangs occasionally for no apparent reason and I'm wondering if there's any possible way this could be influencing what's happening since every thread whatever it's doing is making use of this logging function.
Thanks!
Neil
|
|
|
|
|
I would definitely put a lock around this code. I mean, it's obvious that two threads can't have the same file open at the same time. I'd also consider opening the file once and having a lock on it for the length of the program, or doing all logging to a stringbuilder and having that dump it's contents in a try/catch as a last action before the app crashes or closes naturally.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I was thinking the log route myself, I'm not a big fan of doing it this way but it's mandated for me right now unfortunately. Sadly, the amount of logging that's actually thrown out there over the life of the code (services) would end up sucking up all the memory way before it dies naturally.
Unfortunately when it does go wrong it doesn't crash *OR* close naturally, it's still running to all intents and purposes just hanging which is what was leading me to wonder if thread contention could be coming into play.
Thanks for your response!
|
|
|
|