|
Somehow, I just knew there was no good reason behind this...
If you launch the .EXE using the Process class, you can easily get the window handle of the .EXE. Keep in mind, I have no idea if this is going to work for your ShockWave EXE! This code assumes there is a Panel control on your form called myPanel .
[DllImport("user32.dll"), EntryPoint = "SetParent", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent);
...
Process p = Process.Start("MyShockwave.EXE");
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, myPanel.Handle);
...
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
1) Create a new project, File.ReadAllBytes and then write them to a separate file ( .txt, .dat )
2) Add this file to your resources.
3) Load it from the resource at runtime and save to a new file
4) Change extension to .exe
OR
1) Change extension from .exe to .dat
2) Add as a resource
3) Load it from the resource at runtime and save to a new file
4) Change extension to .exe
?) What am I explaining at the moment? Are you trying to write a new kind of virus or just trying to make innocent programmers like me crazy?
-- modified at 12:24 Monday 7th May, 2007
|
|
|
|
|
Actually, his version of "embedding" was hosting the window of another .EXE in a form of his application.
|
|
|
|
|
I need to add a checkbox right side to list box.How can i do that.
pls let me know.
|
|
|
|
|
Why not use the CheckedListBox control instead?
Last modified: 13mins after originally posted --
|
|
|
|
|
there are 4 colums in the list view i want to show checkbox in last column
|
|
|
|
|
Then, why not use DataGridView with the column you want DataGridViewCheckBoxColumn type?
|
|
|
|
|
How do I make an installation program for multiple applications?
I have two windows applications, one web application and a database that I want to install.
I want them all in the same installationprogram. And the user should be able to choose which of the applications to install.
Additionally I want a license verification thru a webservice in the installation program. The webservice will validate the license key and download a license file when the correct license key is submitted. This license file must exist for the applications to run.
I have been looking at WIX to accomplish this but have some problems with accessing some variables when I want to change an already made installation. While using WIX I also only get one entry in “Add or remove programs”.
Since I’m not really satisfied with WIX I been thinking of writing my own userinterface and call separate MSI files made for each application. But I’m not sure if this is the right approach.
Is this the right way to do it and if not how do I accomplish this?
|
|
|
|
|
|
OK - new to generics (very...)
I have a DataTable which contains the data and I want to create classes that visually represent this data in different ways. Eg, a CheckBoxList and a ListBox.
So, hitting the keyboard I come up with :-
public class MyCheckBox : CheckBoxList
{
private BLL.myData _theData;
public MyCheckBox(BLL.myData theData)
{
_theData = theData;
DataSource = _theData.GetDataTable();
DataValueField = "code";
DataTextField = "desc";
DataBind();
}
}
public class MyListBox : ListBox
{
private BLL.myData _theData;
public MyListBox(BLL.myData theData)
{
_theData = theData;
DataSource = _theData.GetDataTable();
DataValueField = "code";
DataTextField = "desc";
DataBind();
}
}
In the front end (web) I can simply add an instance of these to the page and the databinding is taken care of. Cool. But...the code is identical in both classes apart from the derived class type, and the name I've given it.
How would I define a generic class which I can instantiate with the derived type?
I understand how to write generic classes which contain the <t> type, eg
(from memory...)
public class MyStack<T>
{
T[] arrayofMyThings;
}
but not how to create an instance of the <t> type - if that makes sense.?
Regards
Angel
*********************************************
|
|
|
|
|
If by CheckBoxList you mean CheckedListBox , then a common ancester of it and ListBox is ListControl , so make a base class that derives from ListControl and derive from that.
|
|
|
|
|
I may be being very thick here, so stay with me...
...I derive a class (MyListControl) from ListControl, add my databinding etc. No problem.
How do I go from here to get a CheckedListBox and a ListBox which derives from MyListControl and not ListControl.
When you paste the blindingly simple and obvious answer I will most probably take Christian Grauss' suggestion of buying a large book on VB and smashing myself in the face with it.
Regards
Angel
*********************************************
|
|
|
|
|
You can't change the ancestors of existing classes (Without rewriting them), but with a little extra work, you could encapsulate them into a host control.
public class GenericListBox<T> : Control
where T : ListControl
{
public GenericListBox(data...)
{
T innerControl;
if (typeof(T) == typeof(MyListBox))
innerControl = new MyListBox(data);
else if (typeof(T) == typeof(MyCheckedListBox))
innerControl = new MyCheckedListBox(data);
else
throw new ArgumentException("Some descriptive error message");
innerControl.Dock = DockStyles.Fill;
this.Controls.Add(innerControl);
}
}
...
GenericListBox<MyListBox> ctl = new GenericListBox<MyListBox>(someData);
Of course, you'd have to provide wrapper methods for many functions, or just expose the innerControl object as a ListControl and wrap any methods from below that on the inheritance chain.
Honestly though, I don't think this is the best way to do it. I'd suggest making a factory for it, and just passing an enum with the type of control to create:
public static ListControl CreateListControl(MyControlTypes ctlType, DataObject data)
{
if (ctlType == MyControlTypes.NormalListBox)
return new MyListBox(data);
else
return new MyCheckedListBox(data);
}
(MyControlTypes would be an enum, of course)
Of course, I might be misunderstanding you completely, but maybe this will spark an idea.
|
|
|
|
|
Your first suggestion is nearer to what I want. I was hoping not to use encapsulation, but this is a good start for the generic knowledge I'm lacking. Thanks for taking the time.
Regards
Angel
*********************************************
|
|
|
|
|
Hi,
Hello friends, i need your help..my problem is that i want to export my sql server database to MS access file in a specified location say in a folder..i am using .net 2.0 c# as the language...can anybody help me...
Regards
Alex.
|
|
|
|
|
It's hard to say how to help, when you give no indication of what you have done so far, and where you are stuck.
So... What have you done so far? Where are you stuck?
|
|
|
|
|
Hi,
I have a problem with the conversion of a string of type "07:30" into a time. I want to take only the time, without the date. I tried
DateTime openTime = DateTime.Now.ToShortTimeString(open);
,where open = "07:30".
Please help me with this problem.
|
|
|
|
|
Hi,
a DateTime always contains date and time.
TimeOfDay gives time since midnight.
Hence:
DateTime dt=DateTime.Parse(myInputString);
TimeSpan time=dt.TimeOfDay;
|
|
|
|
|
But if my string is like this "07:30", what can I do? Because I tried that method and my result is 00:00:00.

|
|
|
|
|
When I run the code snippet
DateTime dt=DateTime.Parse("07:30");
TimeSpan time=dt.TimeOfDay;
log(time.ToString());
I get "07:30:00" as expected.
BTW if you're not satisfied by Parse, there also is DateTime.ParseExact().
|
|
|
|
|
Cool. I've always padded it out with current day/month/year. Learn something new everyday here....
Regards
Angel
*********************************************
|
|
|
|
|
try
<br />
System.DateTime nowTime = System.DateTime.Now;<br />
<br />
System.DateTime openTime = System.DateTime.Parse(nowTime .ToShortDateString() + " 07:30:00");<br />
<br />
TimeSpan open = nowTime - openTime;<br />
<br />
<br />
if (nowTime > openTime)
Console.WriteLine("We've been open for {0:0} minutes", open.TotalMinutes);<br />
else<br />
Console.WriteLine("We will open in {0:0} minutes", -open.TotalMinutes);<br />
<br />
There must be better methods though...?
Regards
Angel
*********************************************
|
|
|
|
|
The problem is that I will take the string from a Xml file and I cant use it like that. I really need help.
|
|
|
|
|
what exactly are you trying to do? can you post more code?
Regards
Angel
*********************************************
|
|
|
|
|
I read a Xml file and from it I will have a string, for example the string name is open="07:30".
I tried to read it like this
DateTime oTime = DateTime.Parse(open);
TimeSpan openTime = oTime.TimeOfDay;
where openTime is of type TimeSpan.
But the result is 00:00:00 and it doesnt work.
|
|
|
|