Announcement

Collapse
No announcement yet.

Where to detect changing of system metrics

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Where to detect changing of system metrics

    Hi, all --
    My app doesn't like changing SM_CXSCREEN SM_CYSCREEN and similar.
    That's why I want to detect changing and to restart an app.

    I expected WM_SETTINGCHANGE message, but under Win2000 I can detect it for changing colors only.
    To take and to compare with previous in WM_ACTIVATEAPP is possible, but probably exist better solution ?

    ------------------
    E-MAIL: [email protected]

  • #2
    Does the WM_WININICHANGE message work?

    P.S. I just noticed this in the Win32 API help file:
    Windows NT: The WM_SETTINGCHANGE message is implemented on the Windows 95 platform. It is not implemented on the Windows NT platform. The Windows NT message WM_WININICHANGE provides equivalent functionality.
    Since Windows 2000 is really Windows NT, the WM_WININICHANGE message should work.

    [This message has been edited by Matthew Berg (edited October 10, 2000).]
    If you try to make something idiot-proof, someone will invent a better idiot.

    Comment


    • #3
      Matthew --
      thanks, but the same story. And this looks very strange.
      Probably, it's a feature of russian release, but I am very doubt.
      Anyway, if somebody is able to check, below is simple test code.

      Code:
         #Compile Exe
         #Dim All
         #Register None
         #Include "WIN32API.INC"
      
         Function WndProc (ByVal hWnd As Long, ByVal wMsg As Long, _
                           ByVal wParam As Long, ByVal lParam As Long) Export As Long
            Select Case wMsg
               Case %WM_SETTINGCHANGE: SetWindowText hWnd, "%WM_SETTINGCHANGE"
               Case %WM_WININICHANGE : SetWindowText hWnd, "%WM_WININICHANG"
               Case %WM_DESTROY      : PostQuitMessage 0: Function = 0: Exit Function
            End Select
            Function = DefWindowProc(hWnd, wMsg, wParam, lParam)
         End Function
      
         Function WinMain (ByVal hInstance As Long, ByVal hPrevInstance As Long, _
            lpCmdLine As Asciiz Ptr, ByVal iCmdShow As Long) As Long
      
            Local Msg         As tagMsg
            Local wndclass    As WndClassEx
            Local szAppName   As Asciiz * 80
            Local hWnd        As Long
      
            szAppName              = "Test"
            wndclass.cbSize        = SizeOf(WndClass)
            wndclass.style         = %CS_HREDRAW Or %CS_VREDRAW
            wndclass.lpfnWndProc   = CodePtr(WndProc)
            wndclass.hInstance     = hInstance
            wndclass.hCursor       = LoadCursor( %NULL, ByVal %IDC_ARROW )
            wndclass.hbrBackground = GetStockObject( %WHITE_BRUSH )
            wndclass.lpszClassName = VarPtr( szAppName )
            wndclass.hIconSm       = LoadIcon( hInstance, ByVal %IDI_APPLICATION )
      
            RegisterClassEx wndclass
      
            hWnd = CreateWindow(szAppName, "Place for a message", %WS_SYSMENU Or %WS_THICKFRAME, _
                %CW_USEDEFAULT, %CW_USEDEFAULT, %CW_USEDEFAULT, %CW_USEDEFAULT, _
                 %NULL, %NULL, hInstance, ByVal %NULL)
            ShowWindow hWnd, iCmdShow
            UpdateWindow hWnd
      
            While GetMessage(Msg, %NULL, 0, 0)
               TranslateMessage Msg
               DispatchMessage Msg
            Wend
            Function = msg.wParam
         End Function  ' WinMain


      ------------------
      E-MAIL: [email protected]

      Comment


      • #4
        Semen,
        I ran Your test-code, but nothing happened...
        Added Case %WM_DISPLAYCHANGE to WndProc and then it worked.
        (only tested on Win2k)

        Code:
           Function WndProc (ByVal hWnd As Long, ByVal wMsg As Long, _
                             ByVal wParam As Long, ByVal lParam As Long) Export As Long
              Select Case wMsg
                 Case %WM_SETTINGCHANGE: SetWindowText hWnd, "%WM_SETTINGCHANGE"
                 Case %WM_WININICHANGE : SetWindowText hWnd, "%WM_WININICHANG"
                 Case %WM_DISPLAYCHANGE: SetWindowText hWnd, "%WM_DISPLAYCHANGE"
                 Case %WM_DESTROY      : PostQuitMessage 0: Function = 0: Exit Function
              End Select
              Function = DefWindowProc(hWnd, wMsg, wParam, lParam)
           End Function

        Microsoft writes:
        The WM_DISPLAYCHANGE message is sent to all windows when the display resolution has changed

        WM_DISPLAYCHANGE
        cBitsPerPixel = wParam;
        cxScreen = LOWORD(lParam);
        cyScreen = HIWORD(lParam);

        Parameters
        cBitsPerPixel : Specifies the new image depth of the display in bits per pixel.
        cxScreen : Specifies the new horizontal resolution of the screen.
        cyScreen : Specifies the new vertical resolution of the screen.

        Remarks
        This message is only sent to top-level windows. For all other windows it is posted
        .
        -p


        ------------------




        [This message has been edited by Per Fimmeland (edited October 11, 2000).]

        Comment


        • #5
          Per --
          According MSDN WM_DISPLAYCHANGE should work in all OSes.
          It looks (at least under Win 2000) that, if to change something in "Design" tab (Control Panel, Display) appears %WM_SETTINGCHANGE.
          If "Settings" - %WM_DISPLAYCHANGE.

          Hope, that if I'll use CASE %WM_DISPLAYCHANGE, %WM_SETTINGCHANGE instead of %WM_ACTIVATEAPP this will be enough.
          Thanks.



          ------------------
          E-MAIL: [email protected]

          Comment

          Working...
          X