www.pudn.com > fd.zip > DIALOG.ASM


	.386 
	.model flat,STDCALL 
 
include win32.asi           ; some 32-bit constants and structures 
include win32.ase 
 
	.code 
 
CenterWindow	PROC	hwnd : dword 
	LOCAL	wrect : RECT, wWidth : dword, wHeight : dword 
 
	lea	eax,[wrect] 
	call	GetWindowRect,[hwnd],eax 
 
	call	GetSystemMetrics,SM_CXSCREEN 
	mov	[wWidth],eax 
	call	GetSystemMetrics,SM_CYSCREEN 
	mov	[wHeight],eax 
 
	mov     ecx,[wrect.rcRight] 
	sub	ecx,[wrect.rcLeft] 
	mov	eax,[wWidth] 
	sub	eax,ecx 
	shr	eax,1 
	 
	mov     edx,[wrect.rcBottom] 
	sub	edx,[wrect.rcTop] 
	mov	ebx,[wHeight] 
	sub	ebx,edx 
	shr	ebx,1 
	 
	call	MoveWindow,[hwnd],eax,ebx,ecx,edx,0 
 
	ret 
CenterWindow	ENDP 
;----------------------------------------------------------------------------- 
; 
; For dialog boxes that only have an 'ok' button 
; 
Public WaitingProc 
WaitingProc	proc uses ebx edi esi, hdlg:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD 
 
; now if we have a WM_COMMAND message one of the dialog controls 
; has been clicked so see which one 
; 
		cmp	[wmsg],WM_COMMAND 
		jnz	wpchkcenter 
		cmp	[wparam],IDOK 
		jnz	nomsg 
; 
; ok selected, close the dialog and return to the other window 
;		 
exitdlg: 
		call	EndDialog,[hdlg],0 
nomsg: 
		sub	eax,eax 
		ret 
 
wpchkcenter: 
	cmp	[wmsg],WM_INITDIALOG 
	jnz	wpx 
	call	CenterWindow,[hdlg] 
 
wpx: 
	sub	eax,eax 
	ret 
WaitingProc	endp 
;----------------------------------------------------------------------------- 
; 
; For dialog boxes that have Yes/No buttons 
; 
Public YesNoProc 
YesNoProc	proc uses ebx edi esi, hdlg:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD 
 
; now if we have a WM_COMMAND message one of the dialog controls 
; has been clicked so see which one 
; 
		cmp	[wmsg],WM_COMMAND 
		jnz	ynchkcenter 
		cmp	[wparam],IDYES 
		mov	eax,1 
		jz	ynend 
		cmp	[wparam],IDNO 
		mov	eax,0 
		jz	ynend 
		cmp	[wparam],IDCANCEL 
		mov	eax,-1 
		jz	ynend 
		sub	eax,eax 
		ret 
ynend: 
		call	EndDialog,[hdlg],eax 
		sub	eax,eax 
		ret 
ynchkcenter: 
	cmp	[wmsg],WM_INITDIALOG 
	jnz	ynx 
	call	CenterWindow,[hdlg] 
 
ynx: 
	sub	eax,eax 
	ret 
YesNoProc	endp 
	end