We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Systemparametersinfo Api Code Won't Work?

brockway
brockway asked
on
Medium Priority
1,587 Views
Last Modified: 2010-04-15
Systemparametersinfo Api Code Won't Work?

From Tim Brockway.   Email : BROCKWAYJT@AOL.COM
VB Version = Visual Basic 5, Windows 95

PROBLEM DESCRIPTION.

The following code to call the  SystemParametersInfo api won't work.  Calls to other functions of this api have worked fine ok for me but not the SPI_GETNONCLIENTMETRICS function.

Can anybody get this call to work.?? Any ideas ? Any thoughts would be most welcome.

Many thanks,
Tim

Option Explicit
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 LF_FACESIZE = 32
Private Const SPI_GETNONCLIENTMETRICS = 41
Private Const SPI_SETDRAGFULLWINDOWS = 37
Private Const SPI_SETNONCLIENTMETRICS = 42
Private Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1

Private Type LOGFONT
        lfHeight As Long
        lfWidth As Long
        lfEscapement As Long
        lfOrientation As Long
        lfWeight As Long
        lfItalic As Byte
        lfUnderline As Byte
        lfStrikeOut As Byte
        lfCharSet As Byte
        lfOutPrecision As Byte
        lfClipPrecision As Byte
        lfQuality As Byte
        lfPitchAndFamily As Byte
        lfFaceName(LF_FACESIZE) As Byte
End Type
Private Type NONCLIENTMETRICS
        cbSize As Long
        iBorderWidth As Long
        iScrollWidth As Long
        iScrollHeight As Long
        iCaptionWidth As Long
        iCaptionHeight As Long
        lfCaptionFont As LOGFONT
        iSMCaptionWidth As Long
        iSMCaptionHeight As Long
        lfSMCaptionFont As LOGFONT
        iMenuWidth As Long
        iMenuHeight As Long
        lfMenuFont As LOGFONT
        lfStatusFont As LOGFONT
        lfMessageFont As LOGFONT
End Type
Private Sub Form_Load()
Dim x As Long
Dim Struct As NONCLIENTMETRICS
Struct.cbSize = Len(Struct)
x = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, Struct.cbSize, Struct, 0&)
MsgBox (x)
End
End Sub
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Sorry Mike the api reference (in the small print) requires that the second parameter be set to the length of the main structure as quoted below:

Any other ideas?

SPI_GETNONCLIENTMETRICS
Retrieves the metrics associated with the nonclient area of nonminimized windows. The pvParam parameter must point to a NONCLIENTMETRICS structure that receives the information. Set the cbSize member of this structure and the uiParam parameter to sizeof(NONCLIENTMETRICS).
This is taken from VC4.1 help:
PI_GETNONCLIENTMETRICS      Windows 95 only: Retrieves the metrics associated with the nonclient area of nonminimized windows. The pvParam parameter points to the NONCLIENTMETRICS structure to fill in.

uiParam
Depends on the system parameter being queried or set. For more information about systemwide parameters, see the uiAction parameter. If not otherwise indicated, specify zero.

Author

Commented:
Exactly we are agreeing,

Your quote says "set to zero if not otherwise indicated by the the Uactions parameter.

When the uaction parameter is set to SPI_GETNONCLIENTMETRICS  the length must be put in the second parameter.

To settle the matter I tried a zero in the parameter you suggest and it did not work.

Thanks for the ideas, keep 'em comming.

Cordially

Tim.

Commented:
// http://chabster.blogspot.com/2010/01/systemparametersinfo-with.html

NONCLIENTMETRICS ncm = { sizeof(NONCLIENTMETRICS), 0 };
#if (WINVER >= 0x0600)
OSVERSIONINFO osvi = { sizeof(OSVERSIONINFO), 0 };
VERIFY(GetVersionEx(&osvi));
if (osvi.dwMajorVersion < 6) {
    ncm.cbSize -= sizeof(int);
}
#endif
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)) {
    _defaultLogFont = ncm.lfMessageFont;
}
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.