|
Strange i just tried that and it worked ?
Player.cdromCollection.Item(0).eject();
I dont know if you cut and paste you code on the fourm but the "item" has to be "Item",uppercase I. Strange even in the WMP 9 SDK it has a lowercase 'i'.
Are you using Visual Studio .Net it should have that autocomplete feature so you can get the true objects (except that get_item, it doesnt show it?)
if not try borlands C# builder its free and just like VS. NET
modified 16-May-21 21:01pm.
|
|
|
|
|
Hi All,
I've written a Windows Service (c#) which contains config params in a app.config.
I now need to extend it to offer a means to change the app.config via a winform.
The Question
Is it possible to add a winform to the service so that if the user executes the service executable by file selection, then it be launched as a normal winform app rather than the service?
I started writing a seperate app, but obviously the two apps don't share the target config file. Anybody know a clever way around that one?
Thanks in advance...
Andy
|
|
|
|
|
What you can do is combine the source code of the two applications. You can modify the Main function so that it will launch a windows form when the user specifies a special command line parameter, otherwise it will start the windows service.
I haven't tried this myself, but it sounds pretty straight forward.
My articles and software tools
|
|
|
|
|
HHOOK h;<br />
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)<br />
{<br />
<br />
switch(nCode)<br />
{<br />
case WM_SIZING:<br />
return 0;<br />
break;<br />
<br />
case WM_MOVING:<br />
return 0;<br />
break;<br />
<br />
default:<br />
return CallNextHookEx(h,nCode,wParam,lParam);<br />
}<br />
}<br />
void InstallHook()<br />
{<br />
h=SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,0,0);<br />
}
this code if made in mfc dll but i have 2 problems :
1- i dont know if the created DLL is created correctly or not
2- i used this DLL in another app and called InstallHook but a big msg appears said that there is no entry piont for the installhook in the dll
if anyone knows anything plz reply me
|
|
|
|
|
Perhaps if you post this on the Visual C++ forum[^] someone might be able to help.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hello,
I have created a control, extending UserControl, called ColorMixer. Then, I created a small app, call it Host, to host that contol. I right-clicked Host, chose Add Reference, went to the projects tab, and selected my ColorMixer project. Automatically, ColorMixer appeared in the toolbox in the My User Controls tab.
Now, I wrote another control, ColorMixerWithArgs, and another host app, and did the same thing. However, ColorMixerWithArgs does not appear in my toolbox.
Does anyone know why? I would rather the control automatically appear like ColorMixer did than go to the My User Contolrs tab and add the dll manually.
Thanx,
-Flack
|
|
|
|
|
Unfortunately, you're pretty much at the mercy of Visual Studio .NET when it comes to this behavior. Sometimes it works; other times, it doesn't.
One thing to keep in mind, however, is that I doubt you'll be needing the control in the toolbox so often within a solution. If this is a control you use often, then finalize the code and "install" it on your machine as a third-party control is. Put a copy in the Global Assembly Cache (drag and drop it into %WINDIR%\assembly or use gacutil.exe -i <filename>) for run-time use, so you don't have to worry about re-locating the file for each project that uses it.
If you need to include this in a project in order to design it and it doesn't show up in the toolbox, just do what the designer does (which isn't really magic - it's just code that you can type as well). Add a declaration along with the rest toward the top of your class definition. Go into the InitializeComponent method (hidden in a region) and instantiate it like all the others and add it to the container control's Controls collection property. When you switch back to design view, you can begin designing it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This is in regards to the AMS profile C# dll:
http://www.codeproject.com/csharp/ReadWriteXmlIni.asp
Is there any way to specify the path of the xml file to write the settings to? Below is the code I am trying to use, but I get the following error:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
It occurs when I try to set a value using:
sPath = System.AppDomain.CurrentDomain.BaseDirectory + "/test.xml";
sPath = sPath.Replace("/","");
if ( System.IO.File.Exists(sPath) == false ) {
// create the xml file
System.IO.File.Create(sPath);
}
AMS.Profile.Xml oXml = new AMS.Profile.Xml(sPath);
oXml.SetValue("test","testone","cool!");
Thanks in advance!!
_invid
|
|
|
|
|
|
Heath is right, you should have posted this in the article's message board, but since we're here...
The most likely reason you're having the problem is because you're calling System.IO.File.Create(sPath), which creates the file and then locks it. This causes the XmlDocument.Load to fail.
The solution is simple: You don't need to worry about the file's existence. If it's not found, AMS.Profile will create it for you automatically. So just get rid of the "if" code and you'll be fine.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
Cool! Thanks!! Sorry bout posting here :/
|
|
|
|
|
how can play macromedia flash file in asp.net pages randomly?
can use adrotator for this work?
Regards' Amir jalaly
|
|
|
|
|
The AdRotator has a specific, well-documented XML file schema that wouldn't work with Flash files. The concept is similar, though, just that instead of outputting IMG tags you'd need to output OBJECT tags with the right attributes (like the CLSID of the Macromedia Flash player, the codebase, and the src as a PARAM ).
This wouldn't be too difficult to implement, but if you're interested, download .NET Reflector[^] and see how the AdRotator works, duplicating the code for the most part, except of course for Flash-specific settings in the XML file (or whatever you want to use - I would recommend using the provider pattern) and the output HTML.
You should ask this on the ASP.NET forum, though. Besides being the proper forum for this question (since it is regarding ASP.NET, not a specific language), someone might've already done this. You could also try searching the CodeProject articles as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
i want to transfer files and data throw modem .we have 2 pc and 1 tel line and want to send and recieve by this line so how can do it?
Regards' amir jalaly
|
|
|
|
|
It really doesn't matter what the connection device is. So long as you're connected, you can use a myriad of classes to transfer files. You could create a simple TCP socket connection using the TcpClient class, for example. If an accessible share exists on one or the other machine (or both), then you can simply use File.Copy to copy files, although this typically won't work because of default security (and anonymous write permissions are too risky).
You could also go all-out and create a .NET Remoting client/server between the two, transfering files as byte[] arrays, or better yet use DIME (part of the WSE 2.0, which you can download from MSDN[^]. DIME gets around serialization, which is a big performance boost.
So, just forget that a modem is connecting to the two clients and use whatever class(es) you'd like. So long as TCP/IP is the protocol connecting the clients, your options are many; otherwise, you'll need to create a Socket connection with the correct AddressFamily .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have a datagrid, which represents a datatable fetched out of my DB. If I click on the column in the toprow in my grid the grid gets sorted. Perfect: So far so good.
Now it seems that (after sorting) the datatable and the datagrid do not correspond anymore .
Can anyone tell me how I can manage to sort my datatable together with my datagrid? (or equally good just to get the correct row (primary key or something??)) I don't want a roundtrip to my database.
TNX A LOT!!
I forgot: it's about winforms no webforms
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Tried a DataView?
Create a DataView from the DataTable, set the Sort property on the DataView, set the DataGrid's DataSourse to the DataView.
Hope this helps
Bill
|
|
|
|
|
Hi:
I am using WilsonDotNet (www.wilsondotnet.com) ORMapper to map my Business Objects to C# classes. My Business class, because of its object inheritance hiearchy contains more properties than I want to display in my DataGrids. The plain vanilla way of binding a IList object to a DataGrid is to set the DataGrid.DataSource property to the object. But since this displays all kinds of info that I want to hide I was exploring using the DataGridTableStyle object and DataGridColumnStyle object. Because of my neophyte status this exploration contains the distinct possibility of my banging my head against the .Net wall for a good period of time, so to avoid this mental anguish I was wondering if anyone had done this and whether it was possible.
Any hints would be deeply apreciated.
Mike
|
|
|
|
|
You can use table styles and column styles for objects besides the DataTable . The column style's MappingName is the name of the property, plain and simple. The information you need to read is the documentation for the DataGridTableStyle.MappingName property in the .NET Framework SDK. This is where it gets down to details about mapping to objects.
For a table, it's obviously the table name (whether you set a DataTable to the DataGrid.DataSource property, or set that property to a DataSet and specify the table name in the DataGrid.DataMember , which is actually a better way of doing it for many different reasons). For an array, use the type name plus the array indexer operator (ex: MyClass[] ). For another implementation of the IList interface besides those, just specify the type (ex: ArrayList ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath:
Thank you for your help. I found the help associated with the DataGridTableStyle.MappingName and created a small form based on the NorthWind Category to Product relationship. When I bind the DataGrid using:
this.productsGrid.DataSource = this.category.Products;
I can see all the data.
When I use this code duplicated from the Machine[] example in the help file the grid shows nothing
DataGridTableStyle productsTable = new DataGridTableStyle();
productsTable.MappingName= "Products";
DataGridTextBoxColumn nameColumn = new DataGridTextBoxColumn();
nameColumn.MappingName= "Name";
nameColumn.HeaderText = "Name";
productsTable.GridColumnStyles.Add(nameColumn);
productsGrid.TableStyles.Clear();
productsGrid.TableStyles.Add(productsTable);
My definition for product looks like:
public class Category : Wilson.ORMapper.IObjectHelper
{
private int id;
private string name;
private string description;
private IList products;
public int Id {
get { return this.id; }
}
public string Name {
get { return this.name; }
set { this.name = value; }
}
public string Description {
get { return this.description; }
set { this.description = value; }
}
public IList Products {
get { return this.products; }
}
}
|
|
|
|
|
As I mentioned to someone in an earlier post today, you don't need to clear the table styles. Note that plurality: DataGrid.TableStyles . So long as a unique MappingName exists for all the DataGridTableStyle s you have for the DataGrid , you can keep them all in the collection. This is especially nice when you want to bind different data sources to the same DataGrid .
Also, if you cleared the DataGrid.TableStyles and added a new DataGridTableStyle after setting the DataSource property, nothing will show up: table styles are used when binding the DataGrid , but from what I can tell in the IL for the related classes and methods is that changing the table styles does not re-bind the data source (which is actually a good idea in case you wanted to modify table styles while binding a large dataset).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I saw that posting. Even if I remove the clear nothing shows up. Could you clarify this statement:
When you're applying a style, you must re-bind the data source. The data source is "stylized" during binding.
1. How do you apply a style from the collection?
2. By rebind do you mean I need to issue a
productsGrid.DataSource = category.Products; or SetDataBindings after applying the style.
Which seems to just redisplay the entire products collection.
|
|
|
|
|
To re-bind, you must first set DataSource to null and then set it to your data source again.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
First, I am not a C# programmer (although I am trying to learn). I have an intern doing the coding for me on this current project, and he is still trying to put together what they teach in school with the real world.
OK, so here's the problem and question...
A form contains a datagrid (2 columns) and some buttons. We want to prevent a record with either of the fields being null from being written to the database (using MSSql). The table in question is set up with "Allow Nulls" as false. This means that if the user clicks "OK" the message "Column 'Div_Code' does not allow nulls......"
This is fine for me, I know what that means. My users don't. They know the field by the name "Division", and they have no idea what null means.
I would like to do either of the following (and I guess there could be a great deal of discussion about which of the solutions is the most elequent):
1) Either check when leaving the field that it is not null. We tried the columnChanging event, but this doesn't work because the field starts as null, ends as null, and only seems to fire when the value changes; or
2) Intercept the message from the database and substitute our own. I tried using a Try block, but although I traced the execution, I could not see where the message came back.
Anyone have a solution (and if there is a 3rd, 4th or 5th approach, that's good also).
Thanks much...
Alan B
|
|
|
|
|
Try handling the DataGrid.CurrentCellChanged event, which is actually independent of the data source. That way the "bug" (as it seems) where null values in a column doesn't fire the ColumnChanging event doesn't really apply. Another option is to bind to a DataView where AllowDBNull is false . The exception message should be fired immediately when the field looses focus so it would take a pretty stupid user (and, yes, I know they exist in mass quantities) to not realize that the value they just entered (or rather, the lack of a value) is not valid so they need to change it.
You can bind a DataGrid to a DataView just as you can any IList or IListSource implementation.
You're not catching an exception because an exception is not thrown by the DataGrid . If anything, it's handling the exception (or just using good error checking) and just displaying a message on its own. Simply throwing an exception would not result in such a message box (at least, not looking like that).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|