|
See the SystemInformation class. The VirtualScreen property gives you the entire Rectangle that spans all monitors in a multi-monitor system. You can then calculate where your windows are supposed to be. This still requires a multi-monitor system (either with a dual-head graphics card, or multiple graphics cards), but doesn't require that you have to support a specific driver (like NVIDIA).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello Heath and thanks for your response. I didn't know about the VirtualScreen property of the SystemInformation class, but I'm already using the Screen.AllScreens[i].Bounds to get the bounds of all monitors connected to the system and to properly position the windows.
What I'm trying to do is to switch the card into a mode when both screens display the same thing (clone) - I can do this manually using the display settings but I was looking for a way how to do this from a Windows Forms application (if possible at all). The reason for this is that I need to display the same content on both screens (one of them would be a projector) at certain times and instead of cloning the content programatically I thought that it would be more efficient to use the graphic driver capabilities to clone screen content.
Thanks again,
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Oh...I see, sorry.
This really warrants that you visit NVIDIA's web site and see if they have an SDK to download, or at least API documentation. This is nothing that is covered by C# or the .NET Framework (since C# is really just a language that targets the CLR, but anyway...).
You'll most likely end-up P/Invoking native calls to their drivers or some library that is installed as part of nView.
For more information on P/Invoke, see the System.Runtime.InteropServices.DllImportAttribute . This will allow you to call native methods from managed code.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Radoslav Bielik wrote:
For example to switch the card between "clone mode" (where the image on both screns is identical) and "dual mode"
I don't know of a way to do it programatically, unless nVidia as an API available to do this. While DirectX can let you do some things with the card, it's not quite what you're looking for.
I had a similar situation when I upgraded my video card a few months ago. Unfortunately, I'm at work and the control panel is different, but I'll try to walk you through what may help.
Go to the Display control panel, click on the Settings tab and click the Advanced... button.
Click on the tab for nVidia (this is the part where I'm going from memory - I'm not sure exactly how it's labeled, but since you're asking this question, I assume you've poked around these settings already!)
On the navigation menu that sticks off the side (at least on the recent driver versions) one of the last options is Desktop Utilities. Click to Enable Desktop Utilities and then click the Desktop Manager Configuration button.
In the dialog box that pops up, one of the tabs is for Hotkeys. You can set one of these for various settings. I set up a hotkey to toggle Clone mode on and off.
I hope this helps. If I rambled on all this time and completely missed the point, please forgive me!;P
--Noah Duke
____________________________________________
// TODO: Insert incredibly witty sig here.
|
|
|
|
|
Noah Duke wrote:
I hope this helps. If I rambled on all this time and completely missed the point, please forgive me!
I am looking for a programmatic way but I highly appreciate your effort - the HotKey approach seems like a good idea. The problem is that now I have a localized Slovak version of the graphic card driver and can't find the settings I'm looking for at all! I hate localized software
thanks,
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Hi All,
Does anybody know a way to access the tag that is generated when the ImageUrl property of a System.Web.UI.WebControls.HyperLink is set?
I'm trying to write some onmouseover code to the image. If I could get the ID (which isn't written to the source of the page) I could call a javascript function passing it the Image ID.
I think it may have something to do with RenderChildren method.
If anyone has any suggestions, your help is greatly appreciated.
Thanks,
Mike Kushner
mike@kushners.com
|
|
|
|
|
Extend HyperLink and add your own properties and / or events to do this, and then override Render to output your properties as HTML attribute for the IMG tag that is generated. There are several methods you can use to apply the styles and what-not for the control. It's all documented in the SDK documentation for WebControl .
Either that (easier), or output a script block (see Page.RegisterClientScriptBlock or Page.RegisterStartupScript - and you can get the Page in which the control is contained by using the control's Page property) that uses the ID to dynamically attach an event handler, although you have to then take the ClientID (as dictated by how the control is nested in one or more INamingContainer implementations, like the Page or a Panel ). The first method would definitely be easier.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Are you stuck maintaining VB.Net code when you prefer to work in C#? Our C-Sharpener For VB tool is a Visual Studio Add-in that converts VB.Net projects to C# projects. It translates the code and other project related files.
We are looking for a limited number of Beta Testers to help test our new tool. If you are interested, please go to
http://www.elegancetech.com/CSVB_Download.aspx?src=1
Thanks!
Roger Jack
Elegance Technologies, Inc.
www.elegancetech.com
|
|
|
|
|
I'm not sure how possible this is. It probably is doable (creating some kind of rich-client-side control), just not very wise. Certainly there will be a lot of security implications with this (i.e. Client Browsers not permitting anything dodgy to happen). Best bet might be with an ActiveX control.
Out of curiosity - Why do you want to access the serial port on a client machine via an ASPX page?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
I have a windows Form written in C#. I would like to "import" an Access MDB file into the project as a resource, then write this MDB file to dish at runtime. This was fairly simple in VC++ 6.0, but I'm finding little to no information about it in C#, any suggestions ?
Michael Malling
|
|
|
|
|
Whats the part you having difficulty with?
|
|
|
|
|
I've saved the MDB as an Resource template (RCT) file now i need to write it to disk...
|
|
|
|
|
|
Besides what Mark was saying, you can also add that MDB to your project and change the Build Action to "embedded resource". Then the file is added as an embedded resource when you compile and you can extract it easily:
Type t = this.GetType();
Stream s = t.Assembly.GetManifestResourceStream("Namespace.ResourceName.mdb");
Based on other things you posted, generally you still clear of resources the way you do them in VC++. Instead of string resources (or anything that can be represented as a string, hence those things with TypeConverters that can convert to/from strings) you use ResX files and a ResourceManager . Other files can be added as embedded resources. The VersionInfo block is automatically created by the linker using the assembly attributes.
You can still add/edit/remove an RC script using VS/VS.NET (opening the executable itself), but you have to delay-sign your assembly if you sign it (and you should). See my Windows XP Styles article for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
GetManifestResourceStream
That's what I was trying to remember.
|
|
|
|
|
Thanks for the replys, where do I change the Build Action ?
|
|
|
|
|
The RCT file I have created by importing the MDB does not have a build action option. I see it on the RESX files, but they seem to only hold strings...
|
|
|
|
|
What is an RCT file? You mean a RC script? If so, don't (see my previous comment). Instead, just right-click on your project (or a subfolder) and click Add Existing. Browse to the MDB file and double-click to add it to your project. Select the file in your solution explorer and you'll see a Build Action in the property grid. If you import an RC file into the executable (i.e., post-build) you'll have no way to access it through managed code. Like I said before, modifying the executable after compiling it is not a good idea since you're modifying the executable itself - not the assembly (which is a collection of modules and resources files, along with assembly attributes and the all-important MANIFEST (like JAR files also have). You can then use the Assembly.GetManifestResourceStream method to extract the MDB to wherever you want to put it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Very kewl, I was importing the MDB as a Resource Template (RCT) file, but your way was exactly what i was looking for....thanks
|
|
|
|
|
ok, I imported the MDB as HL7Builder.dat into my project and added the following code:
Stream s = t.Assembly.GetManifestResourceStream("Namespace.HL7Builder.dat");
It errors when I try and read from the stream using s.ReadByte()
any thoughts ? Am I missing something ?
|
|
|
|
|
Guinness4Strength wrote:
Am I missing something ?
Yeah, replacing "Namespace" with the namespace of your resource!
When you add resources to your assembly via VS.NET, the namespace is created from the root namespace of the project (by default, your project name) plus any folders in which the resource is contained. So, if your project is "MyProject" and you create a folder in your project called "Databases" into which the MDB was added, then the fully-qualified resource name is "MyProject.Databases.HL7Builder.dat". If you're unsure, open your assembly with ildasm.exe (installed with the .NET SDK) and look at the manifest file. Toward the bottom (after the assembly references and assembly attributes, plus any public key info), you'll see .mresource Name. That full name is what you'd use in GetManifestResourceStream .
Also, why ReadByte ? You know how long that'd take you to write out the file? Use Read and Write with appropriate buffer sizes to make it much faster. 4096 is a good buffer size:
Type t = this.GetType();
Stream s = t.Assembly.GetManifestResourceStream
("MyProject.Databases.HL7Builder.dat");
Stream mdb = null;
try
{
byte[] buffer = new byte[4096];
mdb = File.Create("C:\TEMP\MyDB.mdb", buffer.Length);
int read = 0;
do
{
read = s.Read(buffer, 0, buffer.Length);
mdb.Write(buffer, 0, buffer.Length);
} while (read == buffer.Length);
}
finally
{
if (mdb != null)
{
mdb.Flush();
mdb.Close();
}
} This is just a basic example and you should add some decent exception handling, but hopefully you get the picture.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks forall the info. The reason I used ReadByte, was that Read didn't work at first because I couldn't read off the stream, I am trying new things Once I cn read off the Stream I'll go back to Read using a byte buffer.
|
|
|
|
|
Right a file (your mdb) in the Solution Explorer, select propetries. You should see the build action property with choices of compile, content, embedded resource
|
|
|
|
|
Perhaps I'm not being clear, or I'm not understanding you.
I imported the MDB into an RCT file in my project which does NOT have a build option in its properties.
The RESX files DO have a build property, but these types of resourse files only appear to be able to hold string values. I need to acces the RCT file or perhaps theres another way to import the MDB file into an RESX file?
|
|
|
|