|
For seialization of an ArrayList you would have something defined like this:
[Serializable]
public class myList:ArrayList
{
incorporate strong-typed exposures
}
[Serializable]
public class myDataType
{
private data and public accessors
}
Now you can easily Marshal this ArrayList across an application boundary.
If your applications closely follow the MS Design Guidelines, you would have to change the ArrayList to a Collection, since the MSDG states that Arrays should not be Serialized.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost the most.
|
|
|
|
|
I came accross the DirectShow Media Player article (http://www.codeproject.com/cs/media/DirectShowMediaPlayer.asp) and added a fullscreen mode to that sample application. My problem is that I would like to be able to display a panel on top of that Video window when I move the mouse cursor (I cant even display the mouse cursor when moving mouse). But it seems that the Video window covers everything. Does anybody knows how to solve this (must be possible, since I can make a Context menu display on top).
Thx in advance...
|
|
|
|
|
The video window is designed to cover anything. This is true of most video players, mostly to facilitate DRM and DRM-like technologies so that you can't take screenshots of unlicensed material and other stuff like that. If there is a way, it'll definitely be a hack that would void your license and would be a difficult one at that. Especially in the case of Windows Media Player, it was designed by Microsoft so they would know all the (possibly) undocumented APIs to use to keep windows from overlapping in the same process or when in full screen.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everyone,
Is it possible to add an "Uninstall" shortcut to the user's programs menu in addition to the shortcut to the project output when creating a setup deployment project in VS.NET 2003? And if so how? I can't seem to find a way to do this, any clues are highly appreciated!
Thanks,
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Windows Installer automaticlly contain uninstallshield too. There is no need to do that. If the program installed and you run installer again it shoes the Uninstll option..
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
Thank you for your response. I know that the installer adds an uninstall item automatically to the Add/Remove Programs in the Control Panel, and the Setup deployment project even allows you to change the icon that is used there.
What I am trying to do is include a shortcut to uninstall the application into the application's folder in the user's programs menu. I can add a shortcut to the main project output there (so the user can launch the application from the Start -> Programs -> ProductName menu). I would also like to have the "Uninstall ProductName" shortcut in the Start -> Programs -> ProductName menu, as I find this more convenient for users that want to try the application.
Thanks again,
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Windows Installer is a completely separate product from Microsoft. It includes a runtime (msiexec.exe) and the install packages are actually relational databases. Trust me, I've been beta-testing this since before 1.0 and consult for several companies regarding their installers.
InstallShield is a company that makes an development environment for Windows Installer, just like Wise Solutions does.
for the answer to this question, see my direct response to the initial post.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Since you're using the Windows Installer project in VS.NET, you can add an icon by first adding the icon to your project. The best way, however, is to use the icon embedded in your application (if you have an application as part of the installer, or even a library will do - anything with icons embedded (and that means into the executable, not as an embedded resource in the assembly)).
First (as I mentioned) add the icon or application to your installer project. Find the folder in which this will be located using the File System view, right-click and select either File or Project Output (project output is especially handy for projects in your solution, that way the latest build of that project is a dependency of the setup and the latest version is always used). Then, select the project itself in the solution explorer. At the top of the Property Grid, you'll see an AddRemoveProgramsIcon. Select the drop-down and click (Browse...). It will give you a window showing you all the possible files that can be icon sources. Select the appropriate one from the directory in which you added the icon or executable before. Click OK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Microsoft MVP
Congratulation Heath.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
|
Thanks for your response, but this only changes the icon that is displayed in the "Add/Remove Programs" (unless I am doing something wrong), I was looking for a way to add a "Uninstall" shortcut to the user's "Start / Programs" menu.
But thanks anyway for a detailed response!
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Sorry for the misunderstanding.
Windows Installer recommends that you DO NOT add an Uninstall shortcut to the start menu. In fact, IIRC, this violates Windows Installer guidelines and you cannot certify your application for Windows.
If this is not a big deal, you could do so by making a shortcut to msiexec.exe and use "/x [ProductCode]" as the command-line parameter.
Unfortunately, the crappy Windows Installer project in VS.NET won't let you do this (as well as MANY other things, which is why I never use it and either use Wise for Windows Installer or from scratch with Orca). You need to download the Windows Installer SDK, part of the Platform SDK, which includes an install for a handy utility called Orca. This opens the MSI package as it is - a relational database. You can find more information about the Platfrom SDK from http://msdn.microsoft.com/platformsdk[^].
Once you do this, you need to enter the following information into the Shortcut table:
(Column: Description)
Shortcut: Unique key - type anything
Directory_: Key to a directory in the Directory table for your program group
Name: Name of the shortcut (i.e., title)
Component_: Key to a component in the Component table for which this shortcut is associated
Target: [SystemFolder]msiexec.exe
Arguments: /x [ProductCode]
Description: Description of the shortcut
Hotkey: Leave empty
Icon_: Key to an icon to use in the Icon table
IconIndex: 0-based index for icon if Icon_ points to an executable
ShowCmd: 1 for normal, 3 for maximized, 7 minimized/not active If you like, I could also probably send you Orca since the EULA seems to allow it so long as I send you the entire installation (which isn't bit). If you would rather me do that, send me a direct email (you can get my email from the message sent to you if you configured your settings for notification of replies).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I was learning array and came to a problem I ...
I have a struct containing some info:
public struct SomeInfo
{
public string Value1;
public int Value2;
public SomeClass Type1;
}
And an array of SomeInfo: public SomeInfo[] SomeArray;
So by now I should have an array that every item has 3 properties (Value1, Value2, Type1) and I can access them by doing like this: SomeArray[1].Value1 = ... Right ?
The only problem here is that the size of SomeArray array if fixed (I cannot add any more items if the array is full). I also cannot use ArrayList, because that way I cannot access the array item's properties (Value1, Value2, Type1), right ? So what to do ?
Think of as of the classical addressbook example - You have a struct named Person with 3 fields - Name, Age, and a class for some reason. Also a array that contains the list of Persons.
Regards, Desmond
|
|
|
|
|
desmond5 wrote:
I also cannot use ArrayList, because that way I cannot access the array item's properties (Value1, Value2, Type1), right ? So what to do ?
I guess that you can access the item properties in a similar way when using ArrayList , but you must cast the type of the item to SomeInfo like this. I'm not 100% sure but I think it works like this:
((SomeInfo)SomeArrayList[i]).Value1 ...
Let me know if this helps
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
I can't try right now, but isn't there any other way ?
|
|
|
|
|
I can't try right now, but isn't there any other way ? What else could I do ?
|
|
|
|
|
The previous post isn't correct.
When you instantiate an array, the elements Types of that array are not instantiated. All you have is an array of your Type, in which the array is derived by the CLR from System.Array . In order to instantiate each element in the array, you must do so by iterating through each element:
public SomeInfo[] SomeArray = new SomeInfo[3];
for (int i=0; i<SomeArray.Length; i++)
SomeArray[i] = new SomeArray(); If you want to make your struct easier to use, you can add a constructor that takes params of the Types you need for your members. The only restriction when declaring constructors is that - for structs - you cannot declare the default constructor (parameterless constructor):
public struct SomeInfo
{
public SomeInfo(string value1, int value2, SomeClass value3)
{
this.Value1 = value1;
this.Value2 = value2;
this.Value3 = value3;
}
public string Value1;
public int Value2;
public SomeClass Value3;
} Then you can either instantiate a default instance (all member types use their default values and reference members (like Value3 ) are null) or an initialized struct when you're looping through (assuming you had a source you could iterate through and pull values from):
string[] names = {"One", "Two", "Three"};
SomeClass theOneInstance = new SomeClass();
SomeInfo[] SomeArray = new SomeInfo[3];
for (int i=0; i<SomeArray.Length; i++)
SomeArray[i] = new SomeInfo(names[i], i, theOneInstance);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This works only this way:
string someValue = ( (SomeInfo)SomeArrayList[0] ).Value1;
.. but not this way wich is what I really need (the value in object in array gets a new value):
( (SomeInfo)SomeArrayList[0] ).Value1 = someValue;
P.S. Someinfo is a struct.
How to solve that ?
|
|
|
|
|
You're running into problems because of the value copying. You should be able to solve your problems by changing your struct to a class.
Regards,
Jeff Varszegi
|
|
|
|
|
I was trying to translate a unit from Delphi to C#. What to do with a record type ?
MyRecord = record
Name: string; // String value
Age: integer; // Int value
Proc: TMyProc; // A type
... ....
end;
Should I use use a enum or something ?
Regards, Desmond
|
|
|
|
|
Sounds like a new reference type... which at its most elemental is simply a class that contains public properties:
public class myRecordType {
public string name;
public int age;
public myRecordType {
}
}
somewhere else, you get to say:
myRecordType newRecord = new myRecordType();
newRecord.name = "My Name";
newRecord.age = 24;
is that what you are thinking of?
|
|
|
|
|
Technically, those aren't properties they're fields. The difference is that you can include validation code in property getters and setters (as well as other useful code, like recreating a native window handle or refreshing a drawing surface). With fields, you only get type safety.
To the original poster, you could always use a property to validate a param like so:
private int age;
public int Age
{
get { return this.age; }
set
{
if (age < 18) throw new ArgumentException("You're too young!", "value");
this.age = value;
}
} Both structs and classes can use properties. If you do use properties (and you typically should), make sure you declare the fields as protected or private. If you're going to validate values using properties, make sure you force callers.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know nomenclature is important, so thanks for the clarification on the distinction between properties and fields... I often make the mistake of over-simplifying these issues... and you provide an amazing level of detail in your posts.
|
|
|
|
|
The one thing I was concerned of was that in Delphi there are both, records and classes (Borland Delphi in basicly Object Pascal). As far as I know, record in Delphi is just a "field-container", it cannot contain any methods or functions, cannot assign any values and etc.
|
|
|
|
|
Yeah, that sounds pretty close to a struct, even though it can contains methods and do several things similar to classes.
To know for sure, you could probably answer yourself better than I (since like I mentioned before I don't know Delphi). If records are allocated on the stack, then they are definitely closer to structs.
Microsoft MVP, Visual C#
My Articles
|
|
|
|