SystemParametersInfo call hanging.

  • Thread starter Thread starter Flyte
  • Start date Start date
F

Flyte

Due to the nature of our application, it is necessary to set a system
setting that increases the size of the scrollbars when the application
is the "active" one. When it is not, the system setting is reverted so
that the scrollbars appear in their normal size.

To achieve this, I am overriding the WndProc method and checking if the
message received is WM_ACTIVATEAPP, (this is the message received when
the application gets focus). Upon receipt, I make a call a call to the
user32.dll call SystemParametersInfo to make a change to the scrollbar
size.

This seems to work just fine, but when my application receives a
SystemEvent.PowerModeChanged or SystemEvent.DisplaySettings event, my
call to SystemParametersInfo (called via the WndProc override) seems to
hang... and I can't figure out why.

Does anyone have any ideas on why the call to SystemParametersInfo
would hang? It requires the user to kill the application.

Thanks,
 
Sorry for the double post - not sure what happened there.

Anyways, here is my WndProc method:

protected override void WndProc(ref Message m)
{
if (m.Msg == WM_ACTIVATEAPP)
{
if (m.WParam == IntPtr.Zero)
{
ToggleNonClientAreaControls(false);
}
else
{
ToggleNonClientAreaControls(true);
}
}
}
base.WndProc(ref m);
}

And here is how I call SetSystemParamsInfo

if (isTouchScreen)
{
result =
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,

m_touchScreenNonClientMetrics.cbSize,
ref m_touchScreenNonClientMetrics,
0);
}

else
{
result =
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,
m_standardNonClientMetrics.cbSize,
ref m_standardNonClientMetrics,
0);
}
 
Back
Top