Possible schema:

MIN-button + WM_NCRBUTTONDOWN => tray

MAX-button + WM_NCRBUTTONDOWN => disabled MAX-button + (not WS_THICKFRAME)

Disabled MAX-button + WM_NCRBUTTONDOWN => enabled MAX-button + WS_THICKFRAME

CLOSE-button + WM_NCRBUTTONDOWN => trigger: HELP-button instead of MIN/MAX-buttons and vice versa.

HELP-button + WM_NCRBUTTONDOWN => tray



Possible insertion to Msg-loop of WndProc:


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

mov note.cbSize,sizeof note ; NOTIFYICONDATA
mov eax,hWnd
mov note.hwnd,eax
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 NoteTipText
invoke ShowWindow,hWnd,SW_HIDE
invoke Shell_NotifyIcon,NIM_ADD,addr note

.elseif uMsg==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 ecx,WS_MAXIMIZEBOX or WS_THICKFRAME
mov ebx,WS_THICKFRAME
mov edx,ebx
and edx,eax
.if edx==ebx
not ecx
and eax,ecx
not ebx
and edi,ebx
and esi,ebx
.else
or eax,ecx
or edi,ebx
or esi,ebx
.endif
invoke SetWindowLong,hWnd,GWL_STYLE,eax
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 ecx,WS_EX_CONTEXTHELP
and edx,ecx
mov ebx,(WS_MINIMIZEBOX or WS_MAXIMIZEBOX)
.if edx==ecx
not ecx
and edi,ecx
mov ecx,WS_THICKFRAME
and eax,ecx
.if eax==ecx
or esi,ebx
.else
or esi,WS_MINIMIZEBOX
.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+SWP_NOSIZE+SWP_NOZORDER+SWP_NOACTIVATE+SWP_DRAWFRAME


; Plus (cose for HELP-button and disabled MAX-button):

.elseif uMsg==WM_NCLBUTTONDBLCLK && wParam==HTCAPTION

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



Attachment = working example, 9kb. Tested on Win98/2kSP4.
Posted on 2004-08-09 16:18:01 by kero