Results 1 to 4 of 4
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    C# Reference Niggles (2005)

    I'm working on making an open-source C# Windows Application slightly more flexible. The issue is using the GetSystemMetrics functionality in user32.dll - which passes over into System.Windows.Forms.SystemInformation under C#. The aim is to extract the ScreenMetrics & MonitorCount, perform some maths on them & then include the calculations amongst the text output. The MSDN example happily shows how to pass ALL SystemMetrics into a ListBox. The granularity of extracting only 2 values, however, behind the scenes, seems to fall down - no matter how it's permed.

    This, of course, is possible with VB.NET, but the prospect of transcribing the existing rudiments from one language to the other is less than enthralling. Is this an example of stretching C# in directions it isn't ready for yet - or am I missing something?
    Gre

  2. #2
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: C# Reference Niggles (2005)

    Try this:

    int MonitorCount;
    MonitorCount=System.Windows.Forms.SystemInformatio n.MonitorCount;
    Size ScreenMetrics;
    ScreenMetrics = System.Windows.Forms.SystemInformation.PrimaryMoni torSize;
    listBox1.Items.Add("Monitor Count="+MonitorCount.ToString());
    listBox1.Items.Add("Screen Metrics=" + ScreenMetrics.ToString());

    Regards,
    Kevin Bell

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: C# Reference Niggles (2005)

    >int MonitorCount;
    >MonitorCount=System.Windows.Forms.SystemInformati on.MonitorCount;

    that is what is falling down - am going out but seem to remember that the error was something to do with "body" and "external" - CS1001 also comes to mind (although I may have caused that with a different attempt).

    on the second item, I was going for VirtualScreen (then adjust when MC>1) - although that point may be moot (in view of the MC issue).
    Gre

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: C# Reference Niggles (2005)

    Many thanks

    System.Drawing.Rectangle VirtualScreen;
    VirtualScreen = System.Windows.Forms.SystemInformation.VirtualScre en;

    Goodness knows where I'd disappeared to yesterday!! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Gre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •