ホーム » VC » ::GetDeviceCaps(dc,HORZRES)

2022年10月
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

カテゴリー

アーカイブ

ブログ統計情報

  • 77,348 アクセス



::GetDeviceCaps(dc,HORZRES)

先日のコード を利用して,Windows API の動作のテスト.


#include	<clocale>
#include	<iostream>

#include	"_tdefine.hxx"
#include	"cmd_line.hxx"
#include	"ask_cli.hxx"
//#include	"ask_path.hxx"

#include	<Windows.h>

bool	test	(c_tstring& str)
{
//	std::terr << str << std::endl ;
	HDC	dc = ::GetDC(NULL) ;
	if (dc != NULL) {
		int	hres = ::GetDeviceCaps(dc,HORZRES) ;
		int	vres = ::GetDeviceCaps(dc,VERTRES) ;
		std::terr
			<< _T("HORZRES=") << hres << _T("\t")
			<< _T("VERTRES=") << vres << _T("\t")
			<< std::endl ;
		}
	return	true ;
	}

int	_tmain	(int argc,TCHAR* argv[])
{
	_tsetlocale(LC_ALL,_T("")) ;
	{
		::reg_argv (argc,argv) ;
		}
	{
	//	::call_func(argc,argv) ;
		}
	{
		::test(_T("Test")) ;
		}
	::ask_wait() ;
	return	0 ;
	}

GetDeviceCaps HORZRES VERTRES


::GetDpiForWindow を追加して FHD と 4K 環境で実行.

bool	test	(c_tstring& str)
{
	HWND	hwnd = ::GetConsoleHwnd() ;
	{
		HDC	dc = ::GetDC(hwnd) ;
		if (dc != NULL) {
			int	hres = ::GetDeviceCaps(dc,HORZRES) ;
			int	vres = ::GetDeviceCaps(dc,VERTRES) ;
			std::terr
				<< _T("HORZRES=") << hres << _T("\t")
				<< _T("VERTRES=") << vres << _T("\t")
				<< std::endl ;
			}
		}
//	#ifdef	DPI_AWARENESS_UNAWARE
	{
		HWND	hwnd = ::GetConsoleHwnd() ;
		UINT	dpi = ::GetDpiForWindow(hwnd) ;
		std::terr << dpi << std::endl ;
		}
//	#endif
	return	true ;
	}

GetDpiForWindow

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

1件のコメント

コメントは停止中です。

%d人のブロガーが「いいね」をつけました。