data

;--location in registry for actual screensize
SCREENSIZE_KEY db 'Config\0001\Display\Settings\',0
SCREENSIZE_VALUE db 'Resolution',0


;-- strings for check if regvalue =
REG_VALUE_1 db '1024,768',0
REG_VALUE_2 db '800,600',0


; --flags so whe dont need to check all twice
SIZESCREEN_FLAG_1024 dd 0
SIZESCREEN_FLAG_800 dd 0



;--buffer for screensize
SCREENSIZE_ACTUAL DB 40 dup (0)

;--the rest
Vdatsize06 dd 40
handle dd 0


.code
.....
.....
;--- if WM_INITDIALOG = jmp dlginit
.....
.....
.....
.....
dlginit:
.....
call GET_SET_SIZE
.....
.....
.....
.....
ret


;********************************** G E T S I Z E F R O M R E G I S T R Y *****************************
GET_SET_SIZE PROC
mov SIZESCREEN_FLAG_1024,0 ;-- set flags to 0 to have allways fresh settings
mov SIZESCREEN_FLAG_800,0 ;-- set flags to 0.....

call RegOpenKeyEx,80000002h,offset SCREENSIZE_KEY,1, 1, offset handle ;--open regkey
call RegQueryValueExA, handle, offset sinfo, 0, 0, offset SCREENSIZE_ACTUAL, offset Vdatsize06 ;-- read value as string
call RegCloseKey,handle ;-- close the regkey

mov edi, offset SCREENSIZE_ACTUAL ;--- mov actual size from registry
mov esi, offset REG_VALUE_1 ;-- mov 1 string to check for
mov ecx, 5
repz cmpsb
jnz NOTOK_NEXT_2 ;-- not equal then jump to check next
mov SIZESCREEN_FLAG_1024,1 ;--- set flag from 0 to 1so whe dont need to check twice the reg later
call NEWSIZE_1024 ;-- is equal then call the function
ret
;--------
NOTOK_NEXT_2:
mov edi, offset SCREENSIZE_ACTUAL
mov esi, offset REG_VALUE_2
mov ecx, 5
repz cmpsb
jnz NOTOK_NEXT_3
mov SIZESCREEN_FLAG_800,1
call NEWSIZE_800
ret
;--------
NOTOK_NEXT_3:
;-- and again and again = next screensize......
;-- or make a error message shown up = error ,need bigger/smaller resolution to run.
ret
GET_SET_SIZE ENDP
;********************************** S E T N E W S I Z E *****************************
NEWSIZE_1024 PROC
call MoveWindow ,hwnd_,0,0,1024,40, TRUE ;-----set dialog window to new size & position 0,0,1024,40= left/right,top/down,widht,hight

call GetDlgItem, hwnd_, IDB_EXIT ;----- get the exit button
call MoveWindow,eax,990,9,20,20, TRUE ;----- move exit button to new postion
.....
.....
.....
ret
NEWSIZE_1024 ENDP
;***************************
NEWSIZE_800 PROC
call MoveWindow ,hwnd_,0,0,800,40, TRUE ;-----set dialog window to new size & position


call GetDlgItem, hwnd_, IDB_EXIT ;----- get the exit button
call MoveWindow,eax,773,9,20,20, TRUE ;----- move exit button to new postion
.....
.....
.....
ret
NEWSIZE_800 ENDP
;***************************



;-- other program code



;*************************************************
*********
;this function is if you have buttons on the dialog and when you press one the
;dialogbutton the function should set the dialog to your worksize and center on the screen
;use in wm_somebuttonpressed = call BIGWINDOW ;-)
;if you allways use the same size for your idebar or what ever ,forget this code.
;*************************************************
*********
BIGWINDOW PROC
cmp SIZESCREEN_FLAG_1024,1 ;---- check the flag so whe dont need to check the registry again
je CENTER_1024 ;---- if yes jump to function
cmp SIZESCREEN_FLAG_800,1
je CENTER_800
ret

CENTER_1024:
call MoveWindow ,hwnd_,200,260,662,257, TRUE ;-----set dialog window to new size & position

call GetDlgItem, hwnd_, IDB_EXIT ;----- get the exit button
call MoveWindow,eax,635,9,20,20, TRUE ;----- move exit button to new postion
......
......
......
......
ret


CENTER_800:
call MoveWindow ,hwnd_,80,160,662,257, TRUE ;-----set dialog window to new size & position

call GetDlgItem, hwnd_, IDB_EXIT ;----- get the exit button
call MoveWindow,eax,635,9,20,20, TRUE ;----- move exit button to new postion
......
......
......
......
ret
BIGWINDOW ENDP
Posted on 2001-12-18 07:41:27 by Max