CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Sep 2003
    Posts
    60

    Change Windows Display Settings

    Hi,
    I want to uncheck the following option programatically.
    Desktop->Properties->Appearance->Effects->Hide Underlined Letters for keyboard novigation until i press the Alt key.
    is there any api available to change the same.Please help me out in this.Thanks in advance.

    Vinoth

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Change Windows Display Settings

    Quote Originally Posted by nvinoth123
    Hi,
    I want to uncheck the following option programatically.
    Desktop->Properties->Appearance->Effects->Hide Underlined Letters for keyboard novigation until i press the Alt key.
    Have you checked allAPi net ? If not here is the link
    http://www.allapi.net/agnet/apiviewer.shtml
    Also maybe at VBAccelerator is maybe something of interest
    http://www.vbaccelerator.com/home/index.asp

    Good luck
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  3. #3
    Join Date
    Sep 2003
    Posts
    60

    Re: Change Windows Display Settings

    thanks jonny
    i've tried those sites, there is no such in them, can u further help me out in this.

    thanks in advance

    vinoth

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Change Windows Display Settings

    Hello Vinoth

    You can use the SystemParametersInfo API alongwith the SPI_GETMENUUNDERLINES and SPI_SETMENUUNDERLINES Constants.

    You can declare it like so :

    Code:
    Private Declare Function SystemParametersInfo Lib "user32" Alias _
    	"SystemParametersInfoA" (ByVal uAction As Long, _
    	ByVal uParam As Long, ByRef lpvParam As Any, _
    	ByVal fuWinIni As Long) As Long
    
    Private Const SPI_GETMENUUNDERLINES = &H100A
    Private Const SPI_SETMENUUNDERLINES = &H100B
    
    Private Const SPIF_SENDWININICHANGE = &H2
    Private Const SPIF_UPDATEINIFILE = &H1
    I am attaching a project with with which you can play with!

    Just note, that you might see the change immediately, but as soon as you open another window, you should see the effect, at least it is what it does with me.
    Last edited by HanneSThEGreaT; December 19th, 2008 at 03:09 AM.

  5. #5
    Join Date
    Sep 2003
    Posts
    60

    Re: Change Windows Display Settings

    thanks hannes,
    it worked for me, i'm trying to do it in c# and it really worked. thanks again.

    vinoth

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Change Windows Display Settings

    You're welcome Vinoth!
    The SystemParametersInfo API is extremely powerful, if not the most. You can change wallpaper, even disable system keys
    Enjoy!

  7. #7
    Join Date
    Sep 2003
    Posts
    60

    Re: Change Windows Display Settings

    hi hannes,
    I got it, thanks, with ur sample i'm able to uncheck the option, but i'm not able to find the code to check the option. can u please help me out in this. this is bit urgent.thanks in advance.

    Vinoth

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Change Windows Display Settings

    Hello again Vinoth!

    Here's a much more simpler example for you!

    Set - will set the Underlines
    Unset - Will remove the underlines

    Enjoy!!
    Last edited by HanneSThEGreaT; December 19th, 2008 at 03:09 AM.

  9. #9
    Join Date
    Sep 2003
    Posts
    60

    Re: Change Windows Display Settings

    thanks,
    but the example that u gave recently is the same one that u gave earlier.i'm able to unchech it, i just wanted to know how to check the same.i'll provide what i have done(its a c# coding). i know some constant/flag should be changed, but i dont know waht that is. pls help me out in this.



    public static extern int SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int fuWinIni);
    private const string SPI_GETMENUUNDERLINES = "100A" ;
    private const string SPI_SETMENUUNDERLINES = "100B";

    private const string SPIF_SENDWININICHANGE = "2";
    private const string SPIF_UPDATEINIFILE = "1";


    //API Call
    SystemParametersInfo((int)Convert.ToUInt32(SPI_SETMENUUNDERLINES, 16), 0, ref iOutputVal, (int)Convert.ToUInt32(SPIF_SENDWININICHANGE, 16));


    u pls tell me the change in Vb, i'll convert it to c#

    thanks in advance

  10. #10
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Change Windows Display Settings

    Hello again Vinoth! It seems as if my 2 versions I worked out for you gout mixed up, sorry about that.

    Here is the new one.

    It is much more simpler than the first one!

    Enjoy!
    Last edited by HanneSThEGreaT; December 19th, 2008 at 03:09 AM.

  11. #11
    Join Date
    Sep 2003
    Posts
    60

    Re: Change Windows Display Settings

    thanks hanees,
    but its not working in c#, i dont have vb installed in my mac, i'm trying to convert as such in c#, its working for unchecking but its not checking that option.i'm working on that.thanks a lot.

  12. #12
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Change Windows Display Settings

    Quote Originally Posted by nvinoth123
    thanks hanees,
    but its not working in c#, i dont have vb installed in my mac, i'm trying to convert as such in c#, its working for unchecking but its not checking that option.i'm working on that.thanks a lot.
    Hello again Vinoth!

    I'm not a C# expert. I'm also definitely not a VB expert. But at a guess, you have implemented something wrongly. It does work in VB. Maybe, hopefully a C# expert can answer it.
    Last edited by HanneSThEGreaT; August 4th, 2006 at 08:05 AM.

  13. #13
    Join Date
    Nov 2005
    Location
    Omaha, Nebraska, USA
    Posts
    696

    Re: Change Windows Display Settings

    This isn't really a Visual Basic issue if you're trying to make a Windows API call in C#, but that isn't to say we can't try to help. This is C# code from VS2005:
    Code:
            [System.Runtime.InteropServices.DllImport("user32.dll")]
            private static extern int SystemParametersInfo(int uAction, int uParam, int lpvParam, int fuWinIni);
    
            private const int SPI_GETMENUUNDERLINES = 4106; //100A
            private const int SPI_SETMENUUNDERLINES = 4107; //100B
    
            private const int SPIF_SENDWININICHANGE = 2;
            private const int SPIF_UPDATEINIFILE = 1;
    
            private void setCheckState(bool setCheck)
            {
                if (setCheck) {
                    // This sets it so the accelerator keys (underlines under the letter) always appear
                    SystemParametersInfo(SPI_SETMENUUNDERLINES, 0, 1, SPIF_SENDWININICHANGE);
                }
                else {
                    // This sets it so the accelerator keys (underlines under the letter) only appear when Alt is pressed
                    SystemParametersInfo(SPI_SETMENUUNDERLINES, 0, 0, SPIF_SENDWININICHANGE);
                }
            }
    The key thing is that in VB, the SPI consts are actually numbers, they're just written as Hex (the &H before denotes that in Visual Basic). So you only need to convert those consts to actual numeric values (and you can just use Calc to do that) and use those instead.

  14. #14
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Change Windows Display Settings

    Quote Originally Posted by HanneSThEGreaT
    Hello again Vinoth! It seems as if my 2 versions I worked out for you gout mixed up, sorry about that.
    I have just tested your version you had given it worked nice
    the code which changes the underline in Hannes Applcation is
    Code:
      Call SystemParametersInfo(SPI_SETMENUUNDERLINES, 0, _
    	  ByVal lngMenuUnderlines, SPIF_SENDWININICHANGE Or _
    	  lngUpdateINIFile)
    where lngMenuUnderlines is 0 or 1 depending if you are on or off.
    As much as I have read this code.
    BTW as you are doing C# why you didn't ask there we have a special forum for that I think. So you would not need to tranlate code
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  15. #15
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Change Windows Display Settings

    Quote Originally Posted by ChaosTheEternal
    This isn't really a Visual Basic issue if you're trying to make a Windows API call in C#, but that isn't to say we can't try to help. This is C# code from VS2005:
    Nicely done Chaos!

    Quote Originally Posted by JonnyPoet
    I have just tested your version you had given it worked nice
    the code which changes the underline in Hannes Applcation is
    Code:
     Call SystemParametersInfo(SPI_SETMENUUNDERLINES, 0, _
    ByVal lngMenuUnderlines, SPIF_SENDWININICHANGE Or _
    lngUpdateINIFile)
    Ah, that's good news. I was a bit worried.
    Last edited by HanneSThEGreaT; August 4th, 2006 at 08:48 AM.

Page 1 of 2 12 LastLast

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

Featured