0
高さと幅をピクセルで取得するサンプルコードがあります。 しかし、私の画面には間違った解像度が表示されます。私が何か間違ったことをやってGetSystemMetricsが画面に間違った値を返す
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, int in, int in2)
{
TCHAR szBuffer[1024];
va_list pArgList;
// The va_start macro (defined in STDARG.H) is usually equivalent to
// pArgList = (char *) &szFormat + sizeof (szFormat) ;
va_start(pArgList, szFormat);
// The last argument to wvsprintf points to the arguments
_vsntprintf_s(szBuffer, sizeof (szBuffer)/sizeof (TCHAR),
szFormat, pArgList);
// The va_end macro just zeroes out pArgList for no good reason
va_end(pArgList);
return MessageBox(NULL, szBuffer, szCaption, 0);
}
int WINAPI WinMain(HINSTANCE hTnstance, HINSTANCE hPreVInStane,PSTR szCmdLine, int iCmdShow)
{
int cxScreen=0, cyScreen=0;
cxScreen = GetSystemMetrics(SM_CXSCREEN);
cyScreen = GetSystemMetrics(SM_CYSCREEN);
MessageBoxPrintf(TEXT("ScrnSize"), TEXT("Wide %i High %i"), cxScreen, cyScreen);
return 0;
}
は、この目的球が古い(GetSystemMetrics関数)やIM:1920×1080
コード:私はX 2160
3840を持っている。しかし、アプリケーションが言う
? https://social.msdn.microsoft:
これらが有用である可能性にあります。 com/Forums/ja-ka/0a83bb55-31f3-4298-acbb-7ac1f48e3cad/why-getsystemmetricssmcxscreen-1920の代わりにsurface-pro--over-forum?= winappswithnativecodeおよびhttp://stackoverflow.com/質問/ 2630392/getsystemmetrics-returns-wrong-value-for-sm-cxscreen – enhzflep