I found this technique very useful for sending notifications to the main window. Function keys and control /escape/return keys are intercepted in the message loop before they reach child windows.
'MESSAGE LOOP
'============
'
sys bRet
'
do while bRet := GetMessage (&wm, 0, 0, 0)
if bRet == -1 then
'show an error message?
else
if wm.message=WM_KEYDOWN
m=wm.wparam
select case m
case VK_RETURN
for i=1 to nchw
if wm.hwnd=hchw(i)
SendMessage hwnd,WM_COMMAND,2000+VK_RETURN,0
if i>1 then continue while 'first window is editor
end if
next
case VK_ESCAPE
'SendMessage hwnd,WM_CLOSE,0,0
case VK_F1 to VK_F10
SendMessage hwnd,WM_COMMAND,1001+m-VK_F1, 0
case "A" to "Z"
if CtrlKey then
SendMessage hwnd,WM_COMMAND,2000+m, 0
if m=65 or m=70 or m=71 then continue while
end if
end select
end if
TranslateMessage @wm
DispatchMessage @wm
end if
wend
'
function=wm.wparam
end function ; end of WinMain
On the receiving end, WM_COMMAND messages are captured. The originating child window can be identified by GetFocus. (it may be the built-in Find Box or Goto Box here)
case WM_COMMAND
sys id,co,hw,a,b
id=wparam and 0xffff
co=wparam >>16
hw=hchw[0]
select case id
case 1001 'F1
SetWindowText hWnd, "Help"
s=GetText hw
HelpMessageBox
case 1003 'F3
FindKeyword hchw, 0
SetWindowText hWnd, "Find Next"
case 1004 'F4
FindKeyword hchw, 1
SetWindowText hWnd, "Find Next Word"
case 1005 'F5
SetWindowText hWnd, "Compile"
s=GetText hw
Exec s
case 1008 'F8
string f
SetWindowText hWnd, "Load File"
f=GetFileName fi,0
if f then
fi=f
s=GetFile fi
le=len s
SendMessage hchw[0],WM_SETTEXT,le,strptr s
end if
SetWindowText hwnd,strptr fi
case 1009 'F9
string f
if fo="" then fo="_.o2bas"
f=fo
if GetAsyncKeyState VK_SHIFT
f=GetFileName fo,1
end if
if f then
fo=f
s=GetText hchw[0]
putfile fo,s
SetWindowText hWnd, "Saved "+fo
end if
case 2065 'Ctrl A
SelectAll hw
case 2070 'Ctrl F
SelectAll hchw(1)
case 2071 'Ctrl G
SendMessage hw,EM_GETSEL,@a,@b
a=SendMessage hw,EM_LINEFROMCHAR,a,0
string sl=str(a+1)
SendMessage hchw(2),WM_SETTEXT,len(sl),strptr sl
SelectAll hchw(2)
case 2013 'VK_ENTER
sys v,w,h=GetFocus()
if h=hchw(1)
FindKeyWord hchw,0
elseif h=hchw(2)
string g=nuls 24
SendMessage h,WM_GETTEXT,24,strptr g
v=val g
if v then
v=SendMessage hw,EM_LINEINDEX,v-1,0
SetFocus hw
SendMessage hw,EM_SETSEL,v,v
SendMessage hw,EM_SCROLLCARET,0,0
end if
end if
end select
Charles