;Win32API includes

include windows.inc
include kernel32.inc
include user32.inc

includelib kernel32.lib
includelib user32.lib

;DX includes
include Dx8Include\d3d8.inc

includelib Dx8Include\d3d8.lib

;include macros.inc

;PROTOS

DlgProc			PROTO	:HWND,:UINT,:WPARAM,:LPARAM
GetMonitorsDX			PROTO
ReleaseDX				PROTO
GUID2Str				PROTO	:DWORD,:DWORD
DriverVersionString		PROTO	:DWORD,:DWORD
GetRealMonitor			PROTO	:DWORD,:DWORD
FillDlg					PROTO	:DWORD
ShowMonInfo				PROTO	:DWORD,:DWORD
DXVideoMode2Str			PROTO	:DWORD,:DWORD
ShowVModes				PROTO	:DWORD,:DWORD,:DWORD

;MACROS
zeroReg macro reg
    xor     reg,reg
endm

minusOne macro var
    or      var,-1
endm

regTrue macro reg
    zeroReg reg
    inc     reg
endm

retVar macro var
    mov     eax,var
    ret
endm 

return macro val
    ife val ;if val==0==FALSE==NULL
        zeroReg eax
        ret
    elseif val EQ -1   ;if val==-1==INVALID_HANDLE_VALUE
        minusOne eax
        ret
    elseif val EQ 1   ;if val==1==TRUE
        regTrue eax
        ret
    else            ;in other cases
        retVar val
    endif
endm



.const
;indicates that this monitor is the primary monitor in system
MONITORINFOF_PRIMARY equ 00000001h

;size of szDevice string in bytes
CCHDEVICENAME equ 32

;structures

;this structure was not in my windows.inc thus it had to be added here
MONITORINFOEXA struct
    cbSize      DWORD ? 
    rcMonitor   RECT<?>
    rcWork      RECT<?>
    dwFlags     DWORD ?
    szDevice    BYTE CCHDEVICENAME dup (?)
MONITORINFOEXA ends

DXMON_INFO struct
    nAdapterOrdinal dd ?
    hMonitor        dd ?
    CurrDispMode    D3DDISPLAYMODE<>
    MonInfo         MONITORINFOEXA<>
    DispDev         DISPLAY_DEVICE<>
    AdapterInfo     D3DADAPTER_IDENTIFIER8<>
DXMON_INFO ends

.const

;constants of dialog controls
IDD_DIALOG1			equ 101

IDC_STC1            equ 1001
IDCB_ADAPTERS       equ 1002
IDC_STC2            equ 1003
IDC_STC3            equ 1005
IDS_NAME_ADAPT      equ 1006
IDS_INT_NAME_AD     equ 1007
IDC_STC6            equ 1008
IDS_DRIVER_NAME     equ 1009
IDC_STC8            equ 1010
IDS_DRIVER_VER      equ 1011
IDC_STC10           equ 1012
IDS_DRIVER_ID       equ 1013
IDC_STC12           equ 1014
IDS_MON_NAME        equ 1015
IDC_STC14           equ 1016
IDS_MON_INT_NAME    equ 1017
IDC_STC16           equ 1018
IDS_MONRECT         equ 1019
IDC_STC18           equ 1020
IDS_WORKRECT        equ 1021
IDC_STC20           equ 1022
IDS_CURR_VMODE      equ 1023
IDC_STC22           equ 1024
IDC_STC23           equ 1025
IDCB_VMODES         equ 1026
IDB_REFRESH         equ 1027
IDB_SAVE            equ 1028
IDB_CLOSE           equ 1029
IDS_ADAPTS          equ 1004


;const strings
align 4
szAppName   db "Monitor Detector",0
szAuthor    db 13,10,13,10,"Created by SolidCode in 2005",13,10,13,10,0
szNoDX      db "Error occured when obtaining information about monitors",13,10
            db "or when accessing DirectX interface.",0

;#########################################################################

.data?
align 16
pd3d                dd ?    ;ptr to DirectX 8.1 interface
nAdapters           dd ?    ;amount of adapters in system
hInstance			dd ?    ;handle to application in memory
hDlg                dd ?    ;handle to main dialog
align 16    ;structures that will contain info about monitors
;I obtain info only about first 2 monitors. You can go for more.
DXMon_Info0         DXMON_INFO<>
DXMon_Info1         DXMON_INFO<>
align 16
;all purpose string of good length
szString            db 1024 dup (?)
;it is also the last var in data page, so going little beyond the end of the string
;will not harm anyone as long as we do not cross page limit

;#########################################################################
