|
that returns running processes
i just windows. i have some code that is close, i will post it when perfected.
kind regards,
g00fy
|
|
|
|
|
ok as promised and after trawling the windows api, always an excellent read.
i have this, which works nicely for my own screenshot app that is loaded with useful things.
i plan to add this to the explorer context menu so u can choose which window to capture or you can capture a region using a selection rectangle on the screen.
enough of that here is the code
of course, anyone using this will need to dllimport the requried functions
btw the reason it was failing was because i was using GeWindowText() instead of sending WM_GETTEXT.
public static Window[] EnumerateTopWindows()
{
ArrayList windowList = new ArrayList();
IntPtr hWnd = IntPtr.Zero;
Window window = null;
hWnd = GetActiveWindow();
hWnd = GetWindow(hWnd, GW_HWNDFIRST);
while (hWnd != IntPtr.Zero)
{
if (IsWindow(hWnd) && IsWindowVisible(hWnd))
{
IntPtr parentWin = GetParent(hWnd);
if ((parentWin == IntPtr.Zero))
{
string text = GetText(hWnd);
int length = text.Length;
if (length > 0)
{
if (text != "Tray" && text != "Start" && text != "Task Manager" && text != "Program Manager")
{
window = new Window();
window.Handle = hWnd;
window.Text = text;
windowList.Add(window);
}
}
}
}
hWnd = GetWindow(hWnd, GW_HWNDNEXT);
}
return (Window[])windowList.ToArray(typeof(Window));
}
private static string GetText(IntPtr hWnd)
{
int cap = 1048576;
StringBuilder buffer = new StringBuilder(cap);
SendMessage(hWnd.ToInt32(), WM_GETTEXT, cap, buffer);
return Convert.ToString(buffer);
}
kind regards,
g00fy
|
|
|
|
|
I am not sure my code,Is it right?
public class Macro_RemoveExcelDefaultGridLines
{
///
/// Excel Macro : Remove Microsoft Excel's Default Grid Lines
///
private static string _Name = "RemoveDefaultGrid";
private static string _Body =""
+ " Sub RemoveDefaultGrid()\n"
+ " Cells.Select\n"
+ " With ActiveWindow\n"
+ " .DisplayGridlines = False\n"
+ " .DisplayZeros = False\n"
+ " End With\n"
+ "End Sub\n";
public static string Name
{
get{return _Name;}
}
public static string Body
{
get{ return _Body;}
}
}
|
|
|
|
|
Just try it directly in Excel, and see what you get.
Best regards, Alexey.
|
|
|
|
|
My Excel macro is test in excel,my mean is i am not sure my c# class,I use static private variable and property,I think there is somthing wrong.
|
|
|
|
|
Old Gun wrote: I use static private variable and property,I think there is somthing wrong.
Looks like all Ok. Try this, and if you'll get trobles, change properties to functions, or make them non-static.
Best regards, Alexey.
|
|
|
|
|
I see nothing wrong with the code. Why do you think that there is something wrong with it?
If the class is only supposed to be a container for those static properties, you should make it sealed so that it can't be inherited, and make an empty private constructor to override the default empty public constructor, so that it's obvious that one should not create instances of the class.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks alexey N and Guffa,Both of you helped me.
|
|
|
|
|
Hi,Guffa,I can't understand "make an empty private constructor to override the default empty public constructor, so that it's obvious that one should not create instances of the class. ",Can you give me more tips?
|
|
|
|
|
how can i detect when a windows was added to the view. i mean for example how can we undrestand that a messagebox appear in a program. is there an api function that list all windows always?
|
|
|
|
|
Hello,
I have a Win Form name Settings where user can inout int value and save. And this form is a child form of the MainForm. now, I want that, whenever user enters new value in the child form and click Save Button, The MainForm should read the new saved XML (created by child) and turn a timer on with new interval.
I tried the following code,
MainForm myParent = this.Owner as MainForm ;
myParent.updateTimer(); // updateTimer is a public method in MainForm who read the XML file and update accordingly.
Now, i get an error message, "Object refrence is not set to an instance of an object."
I am wondering that, the same piece of code is working some other place and its not working some place. (Even in the same file. ) Can you give me any clue please.
thanks.
|
|
|
|
|
I'm pretty sure that "this.Owner" is null on this step. Either you forgot to set Owner property of your child form, either you show child form through ShowDialog function without argument. Check this out first.
____________________________________________
Robin Panther http://www.robinland.com
|
|
|
|
|
I have a website that allows users to upload files to the server. However, I would like to be able to display the progress of the upload in some sort of progress bar. So my question is, how do i get the percentage of the upload that is complete?
Any help is apreciated
|
|
|
|
|
Hi there,
you just do a quick search from this site, I believe you will have what you need. below is just one of them...Web Progress Bar
<< >>
|
|
|
|
|
Hi,
I have a datadridview control in Windows form (C#). In that DataGridView, I have a Date Column (DateTime Class). Now, when An user enters an invalid entry like (abcd/aa.etc) then An Exception is thrown with a messagebox. At the bottom of that message box, it is said that, if you want to replace this message, handle DataError Event. Now Where can I put the code ( try catch ) block to handle this dataError Event.
Thanks
Emran
|
|
|
|
|
I paint on Graphics object and i need to "pain" or change color of one, small pixel - and i have no idea how to do it. Drawing one-pixel-long lines don't work (lines don't show) - others Rectangles or Polygons don't work (they are too big or not visible) - any ideas? :/
Ideal compilator compiling comments without code...
|
|
|
|
|
If all else fails...
Create a 1x1 bitmap:
Bitmap bmp = new Bitmap();
bmp.SetPixel(0, 0, myColor);
and draw the bitmap on the Graphics:
myGraphics.DrawImageUnscaled(bmp, myPoint);
... but there's probably a more efficient way.
--
I've killed again, haven't I?
|
|
|
|
|
I think about creating bitmap from Graphics, use SetPixel and recreate Grahics object, but i can't while use Graphics object in OnPaint event...
Ideal compilator compiling comments without code...
|
|
|
|
|
Hi
I want to add a row with the value in the first and only column to be "oo", tried:
DataGridViewRow rw = new DataGridViewRow();<br />
....<br />
rw.SetValues("oo");<br />
dataGridView1.Rows.Add(rw);
This doesn't seem to work. What've I done wrong?
cheers
|
|
|
|
|
Your DataGridViewRow has no idea where to put "oo". You need to set the row schema from the DataGridView to which you intend to add the row. If you've defined your single column in your DataGridView definition, then it's cake:
DataGridViewRow rw = new DataGridViewRow();
....
rw.CreateCells(dataGridView1);
rw.SetValues("oo");
dataGridView1.Rows.Add(rw);
--
I've killed again, haven't I?
|
|
|
|
|
|
hi,
I am developing a Network Authentication Server, and I am using RAW Sockets to transmit packets to the internet.The receiving side works fine, but I get a "A blocking operation was interrupted by a call to WSACancelBlockingCall" ONLY when I try to send packets using TCP. Apparently this is due to the Windows update MS05-019 which disables the use of Raw Sockets.
I have tried the xpsp2tcpipfix.exe which modified the tcpip.sys...invain.
Then I tried to disable the SharedAccess service...still invain.
Apparently both of the above work fine for SP2 but not for MS05-019.
My alternate solutions would be either to
- reinstall windows without service packs (i need to confirm this will not be a waste of time)
- install an ethernet adsl modem (currently usb),-requires time & money :S
- find a way to uninstall MS05-019
I would apreciate any other solution, help, advice/clues on my options or any knowledge from anyone that has encountered this problem before or anybody that has ANY idea.
kind regards,
Dave
|
|
|
|
|
Sorry, I'm being a bit thick and lazy can you clarify what you mean by RAW?
Ed
|
|
|
|
|
RAW means that i am generating the whole IP packet from scratch, including both the IP header, and the TCP header.
This is done using
socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
socket.Connect(new IPEndPoint(IPAddress.None, 0));
socket.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.HeaderIncluded,1);
and sending the whole packet stored in a buffer 'byte[] tmp', which contains source ip, destip, checksum...etc...in other words all the headers.
socket.Send(tmp);
As I mentioned before, the whole thing works fine for any packet, coz I checked them out with Ethereal. However when I change the protocol field in the IP header to 6, standing for TCP, I get the afore mentioned error, probably due to the XP update disabling raw packets.
thanks for your reply, not lazy at all;)
regards
dave
|
|
|
|
|
Just trying to get more background here but:
Do you have to use raw sockets? Don't the wrapper's provided by the .NET Framework do what you want?
Ed
|
|
|
|