GetSystemMetrics

Can anyone help me out to build code on the following questions...
1)I know that using getsystem metrics i can get the noofscrollbars,icons,windows height,width supported by the system..Am i right,if else I want to know why we use the getsystemmetrics & what i'm trying to code is ,i have to display in my client area,how many scrollbars,icons are supported by system,i tried with putting get systemmetrics in for loop,i just incremented the index value.I got it.But my idea is i want to print even that commands like SM_CXICON,SM_CYICON also along with their values while get printed.I don't know how to do it..
2)How to print an integer in a client area without using textout,drawtext..
can anyone tell me the function for it..
1) Yes, you can get all kinds of info from GetSystemMetrics(). Check MSDN for exactly what all the uses are. Most people use it to get the sizes of certain window components or screen dimensions, for example.

You must create those strings yourself, since values like SM_CXICON are just #defined in winuser.h as integers. You could create an array of character strings to represent "SM_CXICON", "SM_CYICON", etc., and an array of values corresponding to each string. If you know STL containers, you could use maps to make this a bit easier and then iterate through the map.

However, be very careful if you loop from zero to a certain number, because the entire range of values accepted by GetSystemMetrics is not 100% continuous, and many are only defined depending on which version of Windows you're using. If you're only going from 0 to 43, you'll be fine no matter what. Take a look at winuser.h for the corresponding values.

2) You'll be displaying a lot of text, so you'll probably want to use a multi-line edit control. A static control likely cannot hold the amount of text you'll need, and you'd have to have a pretty large window and/or small font size to display all of that in one window anyway. With a multi-line edit control you can allow the text to be scrolled and take up a smaller amount of space.

If you're simply trying to view the return values for your own purposes, you could also just output the values to a text file.

Either way, if you're also asking how to convert the number to a string in the first place, then look at sprintf() or string streams.
Last edited on
Topic archived. No new replies allowed.