Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-06

Windows unit problems

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Matthews

I'm attempting to retrieve information about the current resolution settings, but I'm not having much luck. I've downloaded the Borland Win32 API, but I'm still stuck with creating the device context, and so on. I need some massive help with this... =(

Thanks in advance.

-Lukas

PS The code below is just a snippet from a larger program, but only the important stuff has been included.

Program ResGrabber;
Uses
	crt,windows;
type
	tResSettings=record
			w,h,bits,refresh:integer;
		end;
var
	res:hdc;
	display:pchar;
	curr:tResSettings;
	dev:devmode;
BEGIN
	clrscr;
	Display := 'DISPLAY';
	res := CreateDC(Display,Display,nil,{Am not sure what to put here... =( });
	if res = {Also, what type does res return, so I can know what should go
here for a failure} then
		begin
			writeln('GetCurrentSettings failed - the return value to res was
null/nil.');
			writeln;
			write('<Press any key to continue...>');
			readkey;
			halt;
		end;
	with curr do
		begin
			w := GetDeviceCaps(res,HORZRES);
			h := GetDeviceCaps(res,VERTRES);
			bits := GetDeviceCaps(res,BITSPIXEL);
			refresh := GetDeviceCaps(res,VREFRESH);
		end;
	writeln('The current resolution is ',curr.w,'x',curr.h,'x',curr.bits,'
with a refresh rate of ',curr.refresh,' hz.');
	DeleteDC(res); // Clear it out
END.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.699 / Virus Database: 456 - Release Date: 04-Jun-04

Reply by email

Thomas Schatzl
to Matthews

Hello,

I'm attempting to retrieve information about the current resolution settings, but I'm not having much luck. I've downloaded the Borland Win32 API, but I'm still stuck with creating the device context, and so on. I need some massive help with this... =(

Because the Borland help file is really outdated... use either the online MS-Platform SDK help (or alternatively the search engine of your choice =) or download it from MS.

Here's a small program which prints the screen characteristics you need to the console (no need to fiddle around with device contexts, no error handling):

program PrintScreenCharacteristics;
uses
  Windows;
var
  mode : TDevMode;
const
  // this constant does not seem to be defined in my FPC distro
  ENUM_CURRENT_SETTINGS = $FFFFFFFF;
begin
  EnumDisplaySettings(nil, ENUM_CURRENT_SETTINGS, mode);
  writeln(mode.dmPelsWidth, 'x', mode.dmPelsHeight, 'x',
    mode.dmBitsPerPel, '@',mode.dmDisplayFrequency);
  readln;
end.

See the MS-docs for this function for further explanation.

Compiles and runs with FPC 1.9.3 - 2004/04/09.

Regards,
Thomas

Reply by email

Matthews
to Thomas Schatzl

Thank you.

That was exactly what I needed.

-Lukas

you wrote 52 lines
Hello, > I'm attempting to retrieve information about the current resolution > settings, but I'm not having much luck. I've downloaded the Borland Win32 > API, but I'm still stuck with creating the device context, and so on. I > need some massive help with this... =( Because the Borland help file is really outdated... use either the online MS-Platform SDK help (or alternatively the search engine of your choice =) or download it from MS. Here's a small program which prints the screen characteristics you need to the console (no need to fiddle around with device contexts, no error handling): program PrintScreenCharacteristics; uses Windows; var mode : TDevMode; const // this constant does not seem to be defined in my FPC distro ENUM_CURRENT_SETTINGS = $FFFFFFFF; begin EnumDisplaySettings(nil, ENUM_CURRENT_SETTINGS, mode); writeln(mode.dmPelsWidth, 'x', mode.dmPelsHeight, 'x', mode.dmBitsPerPel, '@',mode.dmDisplayFrequency); readln; end. See the MS-docs for this function for further explanation. Compiles and runs with FPC 1.9.3 - 2004/04/09. Regards, Thomas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.699 / Virus Database: 456 - Release Date: 04-Jun-04

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.699 / Virus Database: 456 - Release Date: 04-Jun-04

Reply by email