VB gurus - I need your help please

Discussion in 'OT Technology' started by Mugatu, Sep 19, 2003.

  1. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    I am trying to make a small program that allows individual users in NT/2K/XP to set their own resolution (so that a change is not applied to all users as is the norm).

    I am completely done, except for one thing. When I change the resolution, the task bar and icons do not refresh (they stay in the same place, on or off the screen). The open windows do change size to reflect the resolution change but the taskbar and icons do not.

    Does anyone know how to fix this? I would be really appreciative (I need this because my mom has bad eyes and it would really help her if she could lower the resolution but, as it is, that would change everyone else's resolution as well.

    TIA.

    PS. I will post the code I am using as well as some screenshots in the next couple of messages.
     
  2. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    This is the code to change the resolution (it works but the taskbar/desktop icons do not update)
    Code:
            Dim a As Boolean
            Dim i As Integer
            i = 0
            Do
                a = EnumDisplaySettings(0&, i, DevM)
                i = i + 1
            Loop Until (a = False)
    
            Dim b&
            DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
    
            DevM.dmPelsWidth = NativeScreenX / NativeTwipsX
            DevM.dmPelsHeight = NativeScreenY / NativeTwipsY
    
            ChangeDisplaySettings DevM, CDS_UPDATEREGISTRY
    here are the decelrations
    Code:
    Private Const CCDEVICENAME = 32
    Private Const CCFORMNAME = 32
    Private Const DM_PELSWIDTH = &H80000
    Private Const DM_PELSHEIGHT = &H100000
    
    Private Declare Function EnumDisplaySettings Lib "user32" _
        Alias "EnumDisplaySettingsA" _
        (ByVal lpszDeviceName As Long, _
        ByVal iModeNum As Long, _
        lpDevMode As Any) As Boolean
        
    Private Declare Function ChangeDisplaySettings Lib "user32" _
        Alias "ChangeDisplaySettingsA" _
        (lpDevMode As Any, _
        ByVal dwFlags As Long) As Long
    
    Private Type DEVMODE
        dmDeviceName As String * CCDEVICENAME
        dmSpecVersion As Integer
        dmDriverVersion As Integer
        dmSize As Integer
        dmDriverExtra As Integer
        dmFields As Long
        dmOrientation As Integer
        dmPaperSize As Integer
        dmPaperLength As Integer
        dmPaperWidth As Integer
        dmScale As Integer
        dmCopies As Integer
        dmDefaultSource As Integer
        dmPrintQuality As Integer
        dmColor As Integer
        dmDuplex As Integer
        dmYResolution As Integer
        dmTTOption As Integer
        dmCollate As Integer
        dmFormName As String * CCFORMNAME
        dmUnusedPadding As Integer
        dmBitsPerPel As Integer
        dmPelsWidth As Long
        dmPelsHeight As Long
        dmDisplayFlags As Long
        dmDisplayFrequency As Long
    End Type
     
  3. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    here are the pic (sorry for the size)

    normal screenshot
    [​IMG]

    taskbar still at higher resolution location (off the screen)
    [​IMG]

    taskbar still at lower resolution location
    [​IMG]
     
  4. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    One simple solution would be to end explorer.exe and restart it.
     
  5. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    hmm, I'd rather not do that ;)

    but it's weird, I read about this problem on some other sites and they all said to add the "CDS_UPDATEREGISTRY" to the call and that would fix it - but that did nothing for me :dunno:
     
  6. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Why not? I do it all the time.
     
  7. DatacomGuy

    DatacomGuy is moving to Canada

    Joined:
    Oct 14, 2002
    Messages:
    16,546
    Likes Received:
    0
    Location:
    Tampa, FL
    Why not? Nothing wrong with it, just cleans up the system.
     
  8. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    I've never done it from VB before but if I restart explorer manually, I lose the system tray icons of some other programs - I think I'll try this from VB but I think the outcome will be the same. And I'd rather not do that.

    Besides that, the above SHOULD work (it seems to for other people) so I must be doing something wrong :(
     
  9. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    hmm, I've got everything else working now but this. I did just find an API call to refresh explorer, I'm hoping that will do something :x:
     
  10. Mugatu

    Mugatu Ask me about market research. OT Supporter

    Joined:
    Oct 21, 2001
    Messages:
    245,192
    Likes Received:
    0
    well that didn't do anything - I'm going to try restarting explorer (I hope it works) but if it gives me any problems I'll have to put this project on hold until I can figure this out :(
     

Share This Page