|
I just tried it on my XP machine and it didn't show. The problem was Notepad remembers it's last size and location and it assumes that relative to the hwnd's top left.
Using SetWindowPos sorts it. This will make it the same size as the panel and at point 0,0.
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start("Notepad.exe");
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel1.Handle);
SetWindowPos(
p.MainWindowHandle,
IntPtr.Zero,
0, 0,
panel1.Width, panel1.Height,
0u);
}
[DllImport("user32.dll", EntryPoint = "SetParent", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent);
[DllImport("user32.dll")]
private static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int X, int Y,
int cx, int cy,
uint uFlags);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: The problem was Notepad remembers it's last size and location and it assumes that relative to the hwnd's top left.
Mine too. Test app was loading on the left monitor, notepad on the right before being captured.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Try SetWindowPos a coule of replies down here[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Here is a sample application that shows how to host other windows: Window Tabifier[^]
|
|
|
|
|
thanks guys, but since the videowindow cant be hosted/tabbed, and has to be fullscreen, ive sort of given up
But thanks anyway
|
|
|
|
|
I have edited project options Build-> "Conditional compilation symbols" /define:CLASSTEST
In my main function i have>>
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
#if (CLASSTEST)
Console.WriteLine("works");
#else
Console.WriteLine("not defined");
#endif
I have tried project build, rebuild solution etc and the #if section is not recognized in IDE code completion does not evaluate statement
build configuration also has debug
Any ideas on what is going on?
|
|
|
|
|
remove the /Define:
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
How can I add a button when run time? and if there is a button in the form, how can it added next to it? Could you help me,please?
Thanks in advance.
|
|
|
|
|
drago123 wrote: How can I add a button when run time?
You just create the button and add it to the forms Controls collection.
Button b = new Button();
this.Controls.Add(b);
drago123 wrote: and if there is a button in the form, how can it added next to it? Could you help me,please?
You need to work out the position of the existing button, and position your new button alongside it.
int left = existingButton.Left;
left += existingButton.Width;
left += 20;
int top = existingButton.Top;
Button newButton = new Button();
newButton.Left = left;
newButton.Top = top;
this.Controls.Add(newButton); That help?
Simon
|
|
|
|
|
|
Hi,
I have a grid, that has a column of checkboxes. I also have a button outside the grid, that if clicked should toggle the grid view to show only the rows that have checkboxes checked.
What whould be the best way to achieve that?
Set the grid's datasource to a dataview with the filter set?
Any code samples will be really appreciated.
Thank you very much.
|
|
|
|
|
The easiest way is to assign a name attribute to all of the check boxes in the grid that is the same. You can then get a collection returned in javascript and do the assignment without a postback.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Sorry,
I am talking about a Windows forms grid.
|
|
|
|
|
On the checkbox click event assign the underlying datasource to have the value alternated and then Rebind or Refresh the datagrid.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
I want to know how can I send a text file through a phone line to another computer just like pcAnyWhere?
|
|
|
|
|
modem
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
You need a FoneFileFunnel (tm).
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
what is that?
and how to do it in c#?
any examples?
|
|
|
|
|
jrahma wrote: what is that?
Search the web for it, then you'll see what it is.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Good Afternoon All
I have a Windows Service and its Task is to kill a process. the Service is accepting the name of the Process through a Application.Config file. The Service does not Kill the Process. Here is a code that kills the Process as long as the Process is running
namespace Process_Killer
{
public partial class Process_Killer : ServiceBase
{
public Process_Killer()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
String Process_Kill = ConfigurationSettings.AppSettings.Get("Process");
FindAndKillProcess("Process_Kill");
}
protected override void OnStop()
{
}
public void FindAndKillProcess(String name)
{
Process[] procList = Process.GetProcessesByName(name);
while (procList.Length > 0)
{
procList[0].Kill();
}
}
}
}
What is Wrong ?
What is Wrong ?
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Killing a process using a service sounds a little bit odd/risky.
However, if there's no error, the first thing I would do is to check that procList.Length is at least 1 when you expect to find a process. Writing to a log file would be an easy way since service may not communicate with desktop.
Also surround your code in OnStart method using try block and in catch write any problems to the same log file.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Good Morning Sirs
The Problem was the Variable, it was in Quotes, after that it, worked , but it will kill only one Process. at that moment. i want it to Kills all the Processes with that same name and Sleep for 10 min and wakeup again and kill again. Here is the Changed code
namespace Process_Killer
{
public partial class Process_Killer : ServiceBase
{
String Process_Kill = ConfigurationSettings.AppSettings.Get("Process");
public Process_Killer()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
FindAndKillProcess(Process_Kill);
}
protected override void OnStop()
{
}
public void FindAndKillProcess(String name)
{
Process[] procList = Process.GetProcessesByName(name);
if (procList.Length > 0)
{
procList[0].Kill();
}
}
}
}
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Your code makes no sense as a service.
You only attempt to find and kill the process once when the service starts,
then you do nothing except loop endlessly trying to kill the same process
over and over again (and consuming pretty much all the CPU cycles for a processor).
What if there's more than one process of the same name running?
Not returning from OnStart() prevents the service from starting.
If you intend your service to stay running and watch for that process and kill it,
you need to start a thread to do that. You can start the thread in OnStart().
You also need to kill ALL the processes in the procList then reload the procList
to check for new instances. You should also sleep a bit in that loop if you're going to
use a loop like that.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you for your Answer, How can i Archive that, because that is exactly what i want. can you please refer me to an article or give me an example.
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Thank you for your Reply i have Found a Solution .i did it like this
protected override void OnStart(string[] args)
{
String Process_Kill = ConfigurationSettings.AppSettings.Get("Process");
Thread thread = new Thread(new ParameterizedThreadStart(DoWork));
thread.Start(Process_Kill);
}
public void DoWork(object data)
{
string Process_Kill = data.ToString();
while (true)
{
FindAndKillProcess(Process_Kill);
Thread.Sleep(5000);
}
}
public void FindAndKillProcess(String name)
{
Process[] procList = Process.GetProcessesByName(name);
for (int i = procList.Length - 1; i >= 0; i--)
{
procList[i].Kill();
}
}
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|