News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Forum members' graphics/monitor setup

Started by sinsi, January 24, 2025, 04:45:25 PM

Previous topic - Next topic

TimoVJL

#15
@NoCforMe thanks for hinting this
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>

#pragma comment(lib, "user32.lib")

int __cdecl main(void)
{
    DEVMODE dm;
    dm.dmSize = sizeof(dm);
    //EnumDisplaySettings("\\\\.\\DISPLAY1", ENUM_CURRENT_SETTINGS, &dm);
    EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
    printf("%d x %d\n", dm.dmPelsWidth, dm.dmPelsHeight);
    return 0;
}
EDIT: for poasm
; ml.exe -coff hello.asm -link -subsystem:console
.386
.model flat
option casemap:none
exit PROTO C :DWORD
printf PROTO C :PTR,:VARARG
INCLUDELIB msvcrt

EnumDisplaySettingsA PROTO STDCALL :PTR, :DWORD, :PTR
INCLUDELIB user32.lib

POINTL struct
x DWORD ?
y DWORD ?
POINTL ends

DEVMODEX        struct
dmDeviceName    BYTE 32 dup (?)
dmSpecVersion   WORD    ?
dmDriverVersion WORD    ?
dmSize  WORD    ?
dmDriverExtra   WORD    ?
dmFields        DWORD   ?
union
struct
dmOrientation   SWORD   ?
dmPaperSize     SWORD   ?
dmPaperLength   SWORD   ?
dmPaperWidth    SWORD   ?
ends
dmPosition      POINTL  <?>
ends
dmScale SWORD   ?
dmCopies        SWORD   ?
dmDefaultSource SWORD   ?
dmPrintQuality  SWORD   ?
dmColor SWORD   ?
dmDuplex        SWORD   ?
dmYResolution   SWORD   ?
dmTTOption      SWORD   ?
dmCollate       SWORD   ?
dmFormName      BYTE 32 dup (?)
dmLogPixels     WORD    ?
dmBitsPerPel    DWORD   ?
dmPelsWidth     DWORD   ?
dmPelsHeight    DWORD   ?
union
dmDisplayFlags  DWORD   ?
dmNup   DWORD   ?
ends
dmDisplayFrequency      DWORD   ?
dmICMMethod     DWORD   ?
dmICMIntent     DWORD   ?
dmMediaType     DWORD   ?
dmDitherType    DWORD   ?
dmReserved1     DWORD   ?
dmReserved2     DWORD   ?
dmPanningWidth  DWORD   ?
dmPanningHeight DWORD   ?
DEVMODEX        ends

.data
msg db "%d x %d",10,0
dev db "\\.\DISPLAY1",0
dm DEVMODEX <<?>>

.code
mainCRTStartup PROC C
invoke EnumDisplaySettingsA, 0, -1, ADDR dm  ; default monitor
;invoke EnumDisplaySettingsA, ADDR dev, -1, ADDR dm
invoke printf, ADDR msg, dm.dmPelsWidth, dm.dmPelsHeight
invoke exit,0
mainCRTStartup ENDP
END mainCRTStartup
May the source be with you

Greenhorn

The screen resolution does not matter. What matters is the DPI.
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

daydreamer

Quote from: TimoVJL on January 25, 2025, 08:08:48 PM@NoCforMe thanks for hinting this
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>

#pragma comment(lib, "user32.lib")

int __cdecl main(void)
{
    DEVMODE dm;
    dm.dmSize = sizeof(dm);
    EnumDisplaySettings("\\\\.\\DISPLAY1", ENUM_CURRENT_SETTINGS, &dm);
    printf("%d x %d\n", dm.dmPelsWidth, dm.dmPelsHeight);
    return 0;
}

I agree  :thumbsup:
Good starting point together with variables for intended width and height to downscaling from 4k resolution or upscale to bigger resolution, for example use in bigger or smaller windows controls, stretchblt
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

zedd151

Quote from: Greenhorn on January 25, 2025, 11:02:47 PMThe screen resolution does not matter. What matters is the DPI.
Thats what she said.  :biggrin:

Just kidding of course.
¯\_(ツ)_/¯

sinsi

Quote from: Greenhorn on January 25, 2025, 11:02:47 PMThe screen resolution does not matter. What matters is the DPI.
Pretty sure they are independent. Increase the DPI and the resolution stays the same.

TimoVJL

Quote from: sinsi on January 26, 2025, 02:55:04 AM
Quote from: Greenhorn on January 25, 2025, 11:02:47 PMThe screen resolution does not matter. What matters is the DPI.
Pretty sure they are independent. Increase the DPI and the resolution stays the same.
is there correlation with screen size?
May the source be with you

sinsi

Quote from: TimoVJL on January 26, 2025, 04:14:43 AMis there correlation with screen size?
In Windows, DPI is a logical measurement so physical resolution should be the same.

Some "light" reading :biggrin:
DPI and device-independent pixels

I am working on resolution and ignoring DPI for now, but another wrinkle is aspect ratio :rolleyes:

NoCforMe

Using that I get:

What is my Screen Resolution?
My Screen Resolution is: 1210 pixels wide x 908 pixels high
My Viewport Size is: 1170 pixels wide x 769 pixels high
My Device Pixel Ratio is: 1.3229166269302368
My Display Dimensions are: 9.53" (24.20 cm) x 7.15" (18.16 cm)
My Screen Diagonal Size is: 11.91" (30.26 cm)
My Color Depth (bits per pixel) is: 24
My Pixel Depth is: 24
My Display Aspect Ratio is: 605:454

Their screen resolution is very, very close to what I got using GetSystemMetrics() (but not exact):
1210 x 908 vs 1209 x 907.
So what do you think accounts for the discrepancy? Is it my adjusting the size of things in Control Panel?
I don't even know how that works. Something to do with DPI Awareness???
Assembly language programming should be fun. That's why I do it.

Greenhorn

Quote from: zedd151 on January 26, 2025, 12:25:54 AM
Quote from: Greenhorn on January 25, 2025, 11:02:47 PMThe screen resolution does not matter. What matters is the DPI.
Thats what she said.  :biggrin:

Just kidding of course.

Yes, told her my DPI is 10 inches long..., and she believed me.  :skrewy:  :eusa_boohoo:
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

NoCforMe

Quote from: Greenhorn on January 26, 2025, 07:51:25 AM
Quote from: zedd151 on January 26, 2025, 12:25:54 AM
Quote from: Greenhorn on January 25, 2025, 11:02:47 PMThe screen resolution does not matter. What matters is the DPI.
Thats what she said.  :biggrin:

Just kidding of course.

Yes, told her my DPI is 10 inches long..., and she believed me.  :skrewy:  :eusa_boohoo:

OK, since there appear to be no women withing hearing distance:

Q: Why do women make such bad carpenters?
A: Because they've been told that *this* is 6 inches.

(ba-da-BOOMP)
Assembly language programming should be fun. That's why I do it.

TimoVJL

May the source be with you

Mikl__

My Screen Resolution is: 1920 pixels wide x 1080 pixels high

Biterider


jj2007

Quote from: NoCforMe on January 26, 2025, 08:41:04 AMQ: Why do women make such bad carpenters?
A: Because they've been told that *this* is 6 inches.

In front of the mirror:
He: two inches more, and I'd be a king
She: two inches less, and you'd be a queen

TimoVJL

Quote from: jj2007 on January 27, 2025, 12:19:12 AM
Quote from: NoCforMe on January 26, 2025, 08:41:04 AMQ: Why do women make such bad carpenters?
A: Because they've been told that *this* is 6 inches.

In front of the mirror:
He: two inches more, and I'd be a king
She: two inches less, and you'd be a queen
Good to be king - Mel Brooks: History, of the World, Part I
May the source be with you