Results 1 to 5 of 5

Thread: Change screen resolution FAO J. Mcilhinney

  1. #1

    Thread Starter
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,492

    Change screen resolution FAO J. Mcilhinney

    Hi John,
    In October 2023 I posted a question with regard to changing the screen resolution, to which you replied:
    Re: Change screen resolution
    There's nothing built into .NET to set the screen resolution. You will have to use the appropriate Windows API function(s). This was written for VB6 but the same principle applies in VB.NET.
    But at that time I found a solution without having to implement anything. Now, because I couldn't buy a new Win.10 laptop I have the same problem that I had back then with a Win.11 one.

    So again I would like to find a way to change the resolution using vb.NET, your comment then was to use the appropriate Windows API function, that's fine, but I have no idea how to do that, I tried looking at https://learn.microsoft.com/en-us/wi...ndows-api-list, but I can't find where or what to look for specifically. I tried looking at things which seemed appropriate but couldn't understand much of what I was reading.

    Maybe you could point me to the API that you were referring to, even then I'm not confident that I'll understand it or (especially) how to use it.
    Also I've never used VB6 but I'm hopeful I'd be able to work out the principal.

    Poppa
    Along with the sunshine there has to be a little rain sometime.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,076

    Re: Change screen resolution FAO J. Mcilhinney

    Perhaps you could link to the original thread, so I can see what VB6 link/code I was referring to.

    As for the generalities of invoking the Windows API, you should do some research on Platform Invoke (pinvoke). Basically, you declare a method that maps to a function in an unmanaged library and then you call that method like you would any other. In VB6, you would use the Declare keyword to declare the external function. You can do the same in .NET but it is preferred to use the DllImport attribute or, more recently, the LibraryImport attribute. Sometimes you need to funble around a bit for the right method signature. pinvoke.net is a good place to start and you can usually find examples strewn about the web. If a method signmature was written for VB6, be sure to change all Long data types to Integer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: Change screen resolution FAO J. Mcilhinney

    Quote Originally Posted by Poppa Mintin View Post
    So again I would like to find a way to change the resolution using vb.NET, your comment then was to use the appropriate Windows API function, that's fine, but I have no idea how to do that, I tried looking at https://learn.microsoft.com/en-us/wi...ndows-api-list, but I can't find where or what to look for specifically. I tried looking at things which seemed appropriate but couldn't understand much of what I was reading.
    There are various monitor APIs you can use. First, you need to read all possible resolutions of the connected monitors. You can use the following APIs for this: EnumDisplayMonitors, GetMonitorInfo -> MONITORINFOEX structure, EnumDisplaySettingsEx -> DEVMODE structure. You need one of the DEVMODE structures and MONITORINFOEX.szDevice for the ChangeDisplaySettingsEx API to set the appropriate resolution for a specific monitor.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,017

    Re: Change screen resolution FAO J. Mcilhinney


  5. #5

    Thread Starter
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,492

    Re: Change screen resolution FAO J. Mcilhinney

    Quote Originally Posted by jmcilhinney View Post
    Perhaps you could link to the original thread, so I can see what VB6 link/code I was referring to.
    My apologies for the delay in replying, the original thread was : Change screen resolution, marked as resolved, Oct 21st, 2023, 04:10 PM

    Pop.
    Along with the sunshine there has to be a little rain sometime.

Posting Permissions

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



Click Here to Expand Forum to Full Width