|
You can simulate PrintScreen in your Program using
keybd_event API Function
This small program will take screen shot and display it in picture box
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);
<code>private void btnPrintScreen_Click(object sender, System.EventArgs e)
{
keybd_event(44,0,0,UIntPtr.Zero);
IDataObject screen=Clipboard.GetDataObject();
if(screen.GetDataPresent(DataFormats.Bitmap))
{
pictureBox1.Image=(Image)screen.GetData(DataFormats.Bitmap,true);
}
}</code>
Note:
It use the Clipboard to get the image you can save the clipboard before printscreen and restore it after you get the image to get it back to its original state
MCAD
-- modified at 21:23 Monday 29th August, 2005
|
|
|
|
|
have received the following error a few times now :-
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 test.tmrTimersTimer_Elapsed(Object sender, ElapsedEventArgs e) in C:\test\test.cs:line 1717
I have read how to enable JIT Debugging (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskEnablingJust-in-TimeDebuggingForWindowsForms.asp[^]).
I have created MyApp.exe.config, machine.config with the following
?xml version="1.0" encoding="utf-8" ?
configuration
system.windows.forms jitDebugging="true"
configuration
NOTE < and > have been removed to allow posting
I have placed them in the same folder as my .sln file and also in the same folder as .exe. But it does not seem to work. By the way I am using a setup project to install this applicaiton is there anything special I have to do in the setup project to allow JIT debugging on the installed machine?
Anyone have any idea what I am doing wrong? I would like to enable JIT debugging permanently.
Thanks,
Liam
|
|
|
|
|
Hi,
I'm planning to build an application. It will dispaly a office layout map. What I want to do is:
1. Is it possible to auto detect each room?
2. If not, I'm planning to mark each room by using rectangle or polygon manually. After marked, the information should be stored.
3. Next time when the map is loaded, the marked area should be highlighted and blinked.
4. When the map resized, the stored mark information should still work.
Can anyone who is an expert in graphice give me some clue?
Thanks
|
|
|
|
|
1) You're joking, right?
2, 3, 4) There's no question here. There really not much in the way of graphics to this. This is mostly just data objects representing rooms, floors, whatever, ..., that will probably draw themselves. If you want to save the layout, you'll have to serialize the object your using to a file. When the map is resized, the objects should redraw themselves. Whether or not they still work after being resized is not an issue here.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dear Dave,
Thanks for your message.
I'm new to C#. The above are just my thought based on my IT knowlwdge. I appreciate if you can provide more information on how to do 2, 3, 4. Some sample code will be nice and helpful to me.
Thanks in advance.
|
|
|
|
|
I don't have any sample code. I can just picture how it would work in my head and generate a rough design from that.
The most important part of this is the data model, not the drawing. You don't even need drawing at this point. Just model the data that you want to handle. Do some research on Serialization to XML files. You need to save your objects then reload them from the files.
When you have this working, then you can add to it, like drawing code. You'll need to add position and size data to your objects. They will also need to be able to take a Graphics object as a parameter to a Draw method that you'll have to write. What you draw in this is entirely up to you. If you have no idea how to draw anything in Windows, Google for articles on "Drawing Windows Graphics C#" and learn the basics before you attempt to do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm using the System.Net.Sockets class to set and retrieve information from a socket. I am running into a problem because a half second delay is needed before the response can be read. Any ideas why this delay is needed and how it can be avoided? Thank you,
Jason W.
|
|
|
|
|
I'd like to know if there is a way to send clicks to the other applications.
At least to send a click to the window behind my app's window.
thanks in advance to all helpers!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
|
You can also use SendMessage API Function
This Example will Click Backspace Button in Calculator
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private void btnClickBack_Click(object sender, System.EventArgs e)
{
IntPtr calcPtr=IntPtr.Zero;
calcPtr=FindWindow("SciCalc","Calculator");
if(!calcPtr.Equals(IntPtr.Zero))
{
IntPtr backSpaceButton=IntPtr.Zero;
backSpaceButton=FindWindowEx(calcPtr,IntPtr.Zero,"Button","Backspace");
if(!backSpaceButton.Equals(IntPtr.Zero))
{
SendMessage(backSpaceButton,0x00F5,IntPtr.Zero,IntPtr.Zero);
}
}
}
MCAD
|
|
|
|
|
Thanks to all!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
I have a custom control. When focus is given to this control, the Enter event is triggered. Is there any way to determine what caused focus to come to this control (Tabbed in, Shift-tabbed in, mouse click)?
My control has various items on it. Depending on what caused my control to gain focus, I'd like to highlight one of them. For example, if the user clicks on an item, that item will be highlighted. If the user tabbed in from another control, then the "first" item will be highlighted, but if it was a shift-tab, then the "last" item will be highlighted.
I can watch mouse events to figure out what was clicked on, of course, but what about when the user uses tab or shift-tab to give my control focus? Is there any way of obtaining this information?
Thanks for any help.
--
Scott
|
|
|
|
|
AFAIK, there's no facility to determine what caused the control to get the focus.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can any body tell me how can i measure the size of a string with definite precision in Millimeters,inches etc. I have used MeasureString, GenericTypographic, AntiAliasing etc. I need any accurate method. Any hint or link ,suggestion
|
|
|
|
|
use Graphics.MeasureCharacterRanges! it returns the exact size of your string.....
|
|
|
|
|
i work with c# windows application, and i want to know how to do documentation? if i use UML or Flowchart or DFD ? if exists some site or book or same example to help.
Thanks
|
|
|
|
|
If you need to write the CODE documentation, you should use XML Doc, that is integrated in the C# compiler. Search in CP, some articles are available about that topic.
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
i need code for crearing namespace for test case
that finds whether the specified path having the directory or not.(i.e., directory exists or not?)
|
|
|
|
|
|
Hi,
if you want to check if a specified path exists you can use the following function:
System.IO.Directory.Exists(sMyPath))
This return a bool, true if the path exists, otherwise false.
Regards
Sebastian
|
|
|
|
|
Hi
I'm trying to get information form an html file, then replacing some placeholders with values, then printing them to screen and generating a DataTable (or a DataGrid) with all the information.
I already managed to read from the file, replacing and printing. The only thing missing is the DataTable Generic generator.
Anyone can help? Have anyone ever done something like this?
Thanks
Nelson
|
|
|
|
|
Did anyone override the TabControl in a good way to be able to give it
a custom background color? I have a specific background color used in my entire application so of course I want the tab control to be this color as well, but it doesn't seem to be easy to accomplish. Did anyone do it in .NET?
Also what is the reason it is restricted so much by windows? I mean it cannot be so hard to allow for a tab control to have a different background color after all...
regards,
Bjorn
|
|
|
|
|
Please gothrough my article. That will surve your purpose.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Thanks, it's a good start, however I don't want only the tab labels to be custom drawn but also the entire edges around the control. The DrawItem event is only received for each tab as far as I can see...
/Bjorn
|
|
|
|
|
Hi
Im writing an app keep notes on poker players but having a little difficulty with dataview.
Im loading an xml file containing the data into a dataset, the xml file looks like this:
<table>
<Player>
<Alias></Alias>
<Category></Category>
<Notes>
<Hand></Hand>
<Bet></Bet>
<Position></Position>
<Blinds></Blinds>
<Stack></Stack>
</Notes>
</Player>
</Table>
Im then creating a dataview object using the "Player" table.
I then set the row filter to return all rows matching an "Alias".
Then display the results in a datadrid.
This all works fine but what i actually want is to only show and edit the nested "Notes" tables for each player as the Alias will not need to change and there only needs to be one instance of the players category.
You can get to the notes table by expanding the nodes on the datagrid but thats not how i want it to look plus by only showing the notes table the user wont have to enter the alias and category when greating a new entry.
Any help would be great as to how i can achieve this, could it be solved by writing the xml file a little different?
-- modified at 6:19 Monday 29th August, 2005
|
|
|
|