Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Systemparametersinfo Api Code Won't Work?

Posted on 1998-06-03
5
1,344 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
0
Comment
Question by:brockway
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 100 total points
ID: 1462410
The 2nd param should be 0, according to the API reference
0
 

Author Comment

by:brockway
ID: 1462411
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).
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1462412
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.

0
 

Author Comment

by:brockway
ID: 1462413
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.
0
 
LVL 1

Expert Comment

by:dtivmk
ID: 30792520
// 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;
}
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question