|
how to config a serial number in InstallShield.
Thank in advance.
QuocBao
|
|
|
|
|
The InstallShield documentation explains this and gives examples if you look. This has nothing to do with C#.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm writing an MP3 player, with queueing capabilities - it writes the queue to a temporary text file, and I also have another form in the app that allows me to view the queue. This works fine, but I can't refresh the queue automatically. I would like to be able to just call the writeQ function in the main form to write the queue, then call the queue viewer forms' load function which would read the necessary data. But, my problem is, I don't understand how I can get the handle of the main form to call the writeQ. simply doing a MainPlayer mainP = new MainPlayer() then calling mainP.writeQ() (MainPlayer is the main form class) won't work, because it'll try to read the listBox in the queue viewer form...Anyone know how I could force it to read the listBox in its own form? I would think I can do it using IntPtr and window handles, but I have no idea quite how to do this.
|
|
|
|
|
The thing you want to do, i think is done more easily in that way.
Once the user want to change your playlist immediately you go and update the file you are writing. The other form will use a filesystemwatcher component so that once it sees that the file you want changed he will go and update the view of the playlist. If you want to do the thing you are saying you will have to mark the writeQ method as public and when you create the viewer form pass a variable of type MainPlayer with the mainform in it in the constructor and store this variable as a member and call the function writeQ in it.
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
I have a TabControl with 7 different tabs. One of the Tabs has numerous text boxes and labels and a few buttons. When I run the app on this particular laptop that is running windows 2000 professional the text boxes, labels and buttons are shifted down and to the right. Part of the text boxes and labels are obscured and cannot be moved. This problem does not occur on XP nor does it happen on a Windows 2000 professional Desktop. I had to laugh when I saw it because I don't have a clue as to why it is happening. If my explaination is not clear let me know and I'll try harder to make it clear.
Any insight would be awesome!
Parrish
|
|
|
|
|
Format and reinstall windows 2000 on the laptop !!! Most users play with the settings of the windows and they end up with a windows operating system missfunctioning
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
What kind of advice is that? If you can't give a reasonable answer, please don't answer at all.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ignore that last reply. That's not a solution but in the most extreme circumstances.
On laptops - and even some desktops - it's common that the DPI (dots per inch) is set higher. Desktops are typically at 96 DPI while newer laptops (with much better displays capable of higher resolutions) are at 120 DPI. Unfortunately, the .NET Framework uses pixels, a logical unit. VB6, for example, uses twips which are a physical unit (like an inch or a point). See http://visualbasic.about.com/cs/visualbasicfaq/a/dykpixeltwip.htm[^] for more information.
How do you convert this? By P/Invoking GetDeviceCaps and initializing a couple of static properties with the scale factor. You should also handle the Microsoft.Win32.SystemEvents.DisplaySettingChanged event so that you can update these when the display settings change. See How to Write High-DPI Applications[^] in the MSDN Library.
Using those concepts, you could create a class like so:
public sealed class Display
{
static Display()
{
SystemEvents.DisplaySettingsChanged += new EventHandler(Update);
}
private Display() {}
[DllImport("gdi32.dll")]
private static extern IntPtr GetDeviceCaps(IntPtr hdc, IntPtr index);
[DllImport("user32.dll")]
private static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
private static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);
private static void Update()
{
Setup(true);
}
private static void Setup(bool force)
{
if (initialized && !force) return;
logsPerPixelX = logsPerPixelY = 0;
IntPtr hdc = GetHDC(IntPtr.Zero);
try
{
if (!hdc.Equals(IntPtr.Zero))
{
IntPtr value;
value = GetDeviceCaps(hdc, 88);
logsPerPixelX = 1440 / value.ToInt32();
value = GetDeviceCaps(hdc, 90);
logsPerPixelY = 1440 / value.ToInt32();
ReleaseDC(IntPtr.Zero, hdc);
}
}
catch {}
if (logsPerPixelX == 0) logsPerPixelX = 15;
if (logsPerPixelY == 0) logsPerPixelY = 15;
initialized = true;
}
private static bool initialized;
private static int twipsPerPixelX;
private static int twipsPerPixelY;
public static int TwipsPerPixelX
{
get
{
Setup(false);
return TwipsPerPixelX;
}
}
public static int TwipsPerPixelY
{
get
{
Setup(false);
return TwipsPerPixelY;
}
}
public static int FromPixelsX(int x, ScaleMode mode)
{
switch (mode)
{
case ScaleMode.Points:
return PixelsToTwipsX(x) / 20;
case ScaleMode.Inches:
return PixelsToTwipsX(x) / 1440;
default:
throw new ArgumentException("Invalid scale mode.", "mode");
}
}
public static int FromPixelsY(int y, ScaleMode mode)
{
switch (mode)
{
case ScaleMode.Points:
return PixelsToTwipsY(y) / 20;
case ScaleMode.Inches:
return PixelsToTwipsY(y) / 1440;
default:
throw new ArgumentException("Invalid scale mode.", "mode");
}
}
public static int ToPixelsX(int x, ScaleMode mode)
{
switch (mode)
{
case ScaleMode.Points:
return TwipsToPixelsX(x * 20);
case ScaleMode.Inches:
return TwipsToPixelsX(x * 1440);
default:
throw new ArgumentException("Invalid scale mode.", "mode");
}
}
public static int ToPixelsY(int y, ScaleMode mode)
{
switch (mode)
{
case ScaleMode.Points:
return TwipsToPixelsY(y * 20);
case ScaleMode.Inches:
return TwipsToPixelsY(y * 1440);
default:
throw new ArgumentException("Invalid scale mode.", "mode");
}
}
public static int PixelsToTwipsX(int x)
{
Setup(false);
return x * twipsPerPixelX;
}
public static int PixelsToTwipsY(int y)
{
Setup(false);
return y * twipsPerPixelY;
}
public static int TwipsToPixelsX(int x)
{
Setup(false);
return x / twipsPerPixelX;
}
public static int TwipsToPixelsY(int y)
{
Setup(false);
return y / twipsPerPixelY;
}
}
public enum ScaleMode
{
Points,
Inches
} This is similar to code I developed for our application, based on the Type Microsoft.VisualBasic.Compatibility.VB6.Support, Microsoft.VisualBasic.Compatibility . You can use this to convert pixels to physical units more suitable for different display resolutions.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am really sorry if my answer was not reasonable. I have seen your code and it is really excellent! But lot of times and i mean (lot of times) i have installed a product of mine which worked perfectly in all of the previous installations on a computer and simply on that computer didn't play, after lot of time on debuging my code for the problem i have seen, i found that the user has deleted some keys from the registry himself and this was the problem!!!!!! My answer was not a programming one and i am sorry, but it is true that sometimes you need to go that way!!!
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
Then why don't you reinstall your product? Your installation should be responsible for setting default registry keys as well as removing them during uninstall. Formatting and reinstalling the OS is a last-ditch effort. It's your application that was screwed up more than likely - thorugh no fault of your own, just the users - so it's your application that should be repaired first. There are many other things one could do before resorting to reinstalling the OS.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath,
I appreciate your insight and expertise but your talking to someone who only has a very basic understanding of this type of development environment. Please forgive my ignorance. To be honest I'm not completely sure I understand how to use it. Whenever the screen size is changed do I run all my Text boxes and labels through the scaling functions to reposition them? I did incorporated this class into my code. I instantiate a Display object when I bring up my application and the Update service is called when I change the screen dimensions. I did have to make a few changes to get it to work (as I'm sure you expected). I had to add the following at the appropriate places...are they ok?
static int logsPerPixelX,logsPerPixelY;
IntPtr eightyEight = new IntPtr(88);
IntPtr ninety = new IntPtr(90);
value = GetDeviceCaps(hdc, eightyEight); // LOGPIXELSX
logsPerPixelX = 1440 / value.ToInt32();
value = GetDeviceCaps(hdc, ninety); // LOGPIXELSY
logsPerPixelY = 1440 / value.ToInt32();
ReleaseDC(IntPtr.Zero, hdc);
Because I'm not real sure how to use it, I don't understand why the logsPerPixelX and logsPerPixelY are setup but never used and why twipsPerPixelX and twipsPerPixelY are never setup?
I also don't understand why it is only one tab page out of 7 that has this problem? I have numerous other Forms that display properly. If you could just grit your teeth and drop kick me into the right areas I would be most appreciative.
If it jams, force it!!
Parrish Pope
|
|
|
|
|
You don't instantiate the Display class as I presented it - it defines static methods and properties: there is no need to instantiate it (which is why I made it sealed and the default constructor private ).
Yes, when your display changes you would need to run the sizes and locations of the controls through these methods. If you don't understand them, read the other links I gave you.
There is more information about programming for different resolutions at http://msdn.microsoft.com[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I designed one process, multi appdomain system.
One process is Main.exe.
Multi AppDomain execute assembly(A.exe, B.exe, C.exe ...)
ex >
Thread newThread = new Thread(new ThreadStart(OpenSystem));
newThread.ApartmentState = ApartmentState.STA;
newThread.Name = currentSystemID;
newThread.Start();
private void OpenSystem()
{
try
{
AppDomain domain = AppDomain.CreateDomain(currentSystemID);
//According To Current SystemsID A.exe, B.exe, C.exe Run
domain.ExecuteAssembly(asmName, null, args);
AppDomain.Unload(domain);
}
catch(Exception e)
{
Debug.WriteLine("OpenSystemError=" + e.Message);
}
}
However,
When error occurred in A.exe, .Net Framework showed MessageBox.
when i pressed close button in MessageBox, Main.exe process killed.
I think .Net Framework kills Process.
I want to stop only A.exe AppDomain, when error occurs in A.exe.
Is there good way to do that?
|
|
|
|
|
Assembly A is the process. When your entry point method terminates, so does the program. This is why facilities like Application.Run and message pumps exist - to keep the application running. If creating your second AppDomain and executing an assembly fails, then your method continues and terminates, thus your application terminates. That's the way it works. And since you executed assembly B in a new thread, when the exception is thrown the thread is aborted if it's not handled. Since you are handling, then threaded method continues and terminates.
If you want to execute assembly A and B independently of each other, then you should create a new AppDomain for each assembly and launch them from a separate process with a little better exception handling.
You also need to consider a loop that keeps methods running until you want them stopped. If you're working with Windows Forms, Application.Run creates a message pump that translates and dispatches Windows message which are still at the heart of Windows Forms. If you're not using Windows Forms, you'll have to have your own loop and be sure to perform good exception handling since you don't want your app stuck in an infinite loop, forcing the client to kill it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
The .NET BCL doesn't know anything about a PDF file, so no, you can't use it to print one. You'd have to use a 3rd party control, ranging from one of the projects on SourceForge.net (free), to very expensive versions costing a couple thousand $.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The question is simple:
How is it possible to control the sound volume.
I suppose its something with winmm.dll or whatever...
thanks
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
I can successfully load an assembly dynamically at runtime. But what if I want to unload it and load another one without having to shutdown my application. Does anyone know how to do that? I use Activator.CreateInstance to load assemblies. But I have not found anything that I can use to unload one.
|
|
|
|
|
Assemblies are loaded into an AppDomain when you Type they define is required. You cannot unload assemblies from an AppDomain without shutting down the AppDomain (closing/killing the process is one way of doing this).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Similar to what Heath said, but you can create your own AppDomain's and load the assemblies into there. Then, when you want to unload the assembly, destroy the AppDomain. I think there's some article on MSDN about doing that.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
|
|
|
|
|
Well I did try following that example and it worked up to a point. I get Serialization exceptions because .NET is trying to serialize System.Threading.Thread and other System classes. I can only modify my own classes to meed serialization requirements. What do I do about the System classes I need objects of sever System types in the assembly that I am trying to load into a separate AppDomain.
For more than 2 years I did not have any such issue because I was loading assemblies into the default AppDomain. But I now have a need to dynamically load and unload them. Do you know of a solutions that will not try to serialize System classes. I can only modify my classes with MarshalByRefObject or [Serializable].
Thanks
Robert
|
|
|
|
|
Why can't I have two functions with the same name and the same input paramters, but different return types. The two functions are obviously different. I did this in C++ with no problems. Is there any way to do it in c#?
Gary Kirkham
A working Program is one that has only unobserved bugs
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Who you are in Christ
|
|
|
|
|
It's not allowed by the CLI. See ECMA 335, section 10.2 (Overloading), with one exception: overloaded operator methods can differ only by return type.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks...I wonder why the C# development team thought that capability wasn't useful? O' Well, maybe I am the only one who used it in C++.
Gary Kirkham
A working Program is one that has only unobserved bugs
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Who you are in Christ
|
|
|
|
|
It's not C#: it's the CLI - the Common Language Infrastructure (sometimes Interface), which describes assembly and type metadata (Common Type System, or CTS), as well as the Common Intermediate Language (CIL) and a few other things. It's what makes the language independence possible.
Microsoft MVP, Visual C#
My Articles
|
|
|
|