.elseif	eax==WM_NCRBUTTONDOWN && (wParam==HTMINBUTTON || wParam==HTHELP)

	mov	note.cbSize,sizeof note						; NOTIFYICONDATA
	push	hWnd
	pop	note.hwnd
	mov	note.uID,IDI_TRAY
	mov	note.uFlags,NIF_ICON+NIF_MESSAGE+NIF_TIP
	mov	note.uCallbackMessage,WM_SHELLNOTIFY
	mov	eax,hMainIcon
	mov	note.hIcon,eax
	invoke	lstrcpy,addr note.szTip,addr ProgTitle0
	invoke	ShowWindow,hWnd,SW_HIDE
	invoke	Shell_NotifyIcon,NIM_ADD,addr note

.elseif	eax==WM_NCRBUTTONDOWN && wParam==HTMAXBUTTON

	invoke	GetWindowLong,hEditIn,GWL_STYLE
	mov	edi,eax
	invoke	GetWindowLong,hEditOut,GWL_STYLE
	mov	esi,eax
	invoke	GetWindowLong,hWnd,GWL_STYLE
	mov	ebx,eax
	mov	ecx,WS_MAXIMIZEBOX or WS_THICKFRAME
	mov	eax,WS_THICKFRAME
	mov	edx,eax
	and	edx,ebx
	.if	edx==eax							; if WS_THICKFRAME
		not	ecx
		and	ebx,ecx
		not	eax
		and	edi,eax
		and	esi,eax
	.else									; if not WS_THICKFRAME
		or	ebx,ecx
		or	edi,eax
		or	esi,eax
	.endif
	invoke	SetWindowLong,hWnd,GWL_STYLE,ebx
	invoke	SetWindowLong,hEditIn,GWL_STYLE,edi
	invoke	SetWindowLong,hEditOut,GWL_STYLE,esi
	jmp	@f

.elseif	eax==WM_NCRBUTTONDOWN && wParam==HTCLOSE

	invoke	GetWindowLong,hWnd,GWL_EXSTYLE
	mov	edi,eax
	invoke	GetWindowLong,hWnd,GWL_STYLE
	mov	esi,eax
	mov	edx,edi
	mov	ebx,(WS_MINIMIZEBOX or WS_MAXIMIZEBOX)
	mov	ecx,WS_EX_CONTEXTHELP
	or	edx,ecx
	.if	edx==edi
		not	ecx
		and	edi,ecx
		mov	ecx,WS_THICKFRAME
		or	eax,ecx
		.if	eax==esi
			or	esi,ebx
		.else
			or	esi,WS_MINIMIZEBOX
			mov	ecx,WS_MAXIMIZEBOX
			not	ecx
			and	esi,ecx
		.endif
	.else
		or	edi,ecx
		not	ebx
		and	esi,ebx
	.endif
	invoke	SetWindowLong,hWnd,GWL_STYLE,esi
	invoke	SetWindowLong,hWnd,GWL_EXSTYLE,edi
@@:
	invoke	SetWindowPos,hWnd,0,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_DRAWFRAME

.elseif	eax==WM_NCLBUTTONDBLCLK && wParam==HTCAPTION

	invoke	IsZoomed,hWnd
	.if	eax==0
		invoke ShowWindow,hWnd,SW_SHOWMAXIMIZED
	.else
		invoke ShowWindow,hWnd,SW_RESTORE
	.endif
