Hi,
Ive recently ported project from VS 6.0 to VS 2008. For now on, it seems that everything is working fine, except obtaining of non-client metrics. The following code compiles, but during program execution SystemParemetersInfo code is failing:
-------------------
<font size=2>
</font><font color="#010001" size=2>NONCLIENTMETRICS</font> <font color="#010001" size=2>ncm</font><font size=2>;
</font><font color="#010001" size=2>ncm</font><font size=2>.</font><font color="#010001" size=2>cbSize</font><font size=2> = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(</font><font color="#010001" size=2>NONCLIENTMETRICS</font><font size=2>);
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#010001" size=2>SystemParametersInfo</font><font size=2>(</font><font color="#010001" size=2>SPI_GETNONCLIENTMETRICS</font><font size=2>, </font><font color="#0000ff" size=2>sizeof</font><font size=2>(</font><font color="#010001" size=2>NONCLIENTMETRICS</font><font size=2>), &</font><font color="#010001" size=2>ncm</font><font size=2>, 0))
{
</font><font color="#010001" size=2> // Im removing this piece of code since app doesnt enter this execution path...</font> <font size=2>
}
</font><font color="#0000ff" size=2>else </font><font size=2>
{
<blockquote dir=ltr style="margin-right:0px
</font><font color="#010001" size=2>LPVOID</font> <font color="#010001" size=2>lpMsgBuf</font><font size=2>;
</font><font color="#010001" size=2>DWORD</font> <font color="#010001" size=2>dw</font><font size=2> = </font><font color="#010001" size=2>GetLastError</font><font size=2>();
</font><font color="#010001" size=2>FormatMessage</font><font size=2>(
</font><font color="#010001" size=2>FORMAT_MESSAGE_ALLOCATE_BUFFER</font><font size=2> |
</font><font color="#010001" size=2>FORMAT_MESSAGE_FROM_SYSTEM</font><font size=2> |
</font><font color="#010001" size=2>FORMAT_MESSAGE_IGNORE_INSERTS</font><font size=2>,
</font><font color="#010001" size=2>NULL</font><font size=2>,
</font><font color="#010001" size=2>dw</font><font size=2>,
</font><font color="#010001" size=2>MAKELANGID</font><font size=2>(</font><font color="#010001" size=2>LANG_NEUTRAL</font><font size=2>, </font><font color="#010001" size=2>SUBLANG_DEFAULT</font><font size=2>),
(</font><font color="#010001" size=2>LPTSTR</font><font size=2>) &</font><font color="#010001" size=2>lpMsgBuf</font><font size=2>,
0, </font><font color="#010001" size=2>NULL</font><font size=2> );
</font><font color="#008000" size=2>// Display the error message and exit the process </font><font size=2>
</font><font color="#010001" size=2>LocalFree</font><font size=2>(</font><font color="#010001" size=2>lpMsgBuf</font><font size=2>); </blockquote>
}
-------------------
As you can see, Ive placed <font color="#010001" size=2>GetLastError() call to see whats going wrong, but lpMsgBuf returns The operation completed sucessfully.
Whats wrong here?
(please note that version with <font size=2><font color="#0000ff sizeof</font>(ncm) call gives the same results</font>)</font> </font>
View the full article
Ive recently ported project from VS 6.0 to VS 2008. For now on, it seems that everything is working fine, except obtaining of non-client metrics. The following code compiles, but during program execution SystemParemetersInfo code is failing:
-------------------
<font size=2>
</font><font color="#010001" size=2>NONCLIENTMETRICS</font> <font color="#010001" size=2>ncm</font><font size=2>;
</font><font color="#010001" size=2>ncm</font><font size=2>.</font><font color="#010001" size=2>cbSize</font><font size=2> = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(</font><font color="#010001" size=2>NONCLIENTMETRICS</font><font size=2>);
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#010001" size=2>SystemParametersInfo</font><font size=2>(</font><font color="#010001" size=2>SPI_GETNONCLIENTMETRICS</font><font size=2>, </font><font color="#0000ff" size=2>sizeof</font><font size=2>(</font><font color="#010001" size=2>NONCLIENTMETRICS</font><font size=2>), &</font><font color="#010001" size=2>ncm</font><font size=2>, 0))
{
</font><font color="#010001" size=2> // Im removing this piece of code since app doesnt enter this execution path...</font> <font size=2>
}
</font><font color="#0000ff" size=2>else </font><font size=2>
{
<blockquote dir=ltr style="margin-right:0px
</font><font color="#010001" size=2>LPVOID</font> <font color="#010001" size=2>lpMsgBuf</font><font size=2>;
</font><font color="#010001" size=2>DWORD</font> <font color="#010001" size=2>dw</font><font size=2> = </font><font color="#010001" size=2>GetLastError</font><font size=2>();
</font><font color="#010001" size=2>FormatMessage</font><font size=2>(
</font><font color="#010001" size=2>FORMAT_MESSAGE_ALLOCATE_BUFFER</font><font size=2> |
</font><font color="#010001" size=2>FORMAT_MESSAGE_FROM_SYSTEM</font><font size=2> |
</font><font color="#010001" size=2>FORMAT_MESSAGE_IGNORE_INSERTS</font><font size=2>,
</font><font color="#010001" size=2>NULL</font><font size=2>,
</font><font color="#010001" size=2>dw</font><font size=2>,
</font><font color="#010001" size=2>MAKELANGID</font><font size=2>(</font><font color="#010001" size=2>LANG_NEUTRAL</font><font size=2>, </font><font color="#010001" size=2>SUBLANG_DEFAULT</font><font size=2>),
(</font><font color="#010001" size=2>LPTSTR</font><font size=2>) &</font><font color="#010001" size=2>lpMsgBuf</font><font size=2>,
0, </font><font color="#010001" size=2>NULL</font><font size=2> );
</font><font color="#008000" size=2>// Display the error message and exit the process </font><font size=2>
</font><font color="#010001" size=2>LocalFree</font><font size=2>(</font><font color="#010001" size=2>lpMsgBuf</font><font size=2>); </blockquote>
}
-------------------
As you can see, Ive placed <font color="#010001" size=2>GetLastError() call to see whats going wrong, but lpMsgBuf returns The operation completed sucessfully.
Whats wrong here?
(please note that version with <font size=2><font color="#0000ff sizeof</font>(ncm) call gives the same results</font>)</font> </font>
View the full article