While working on the visual designer i ran into two problem:s
I'm creating controls using this format
ProgressControl #<window>pWin,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,0,0,#pControl.internal_id
InitDragSize(GetControlHandle(#<window>pWin,#pControl.internal_id),&DefaultControlProc)
$define LPFNPROP "ASD8VD76"
sub InitDragSize(HWND hwnd,UINT proc)
SetProp(hwnd, LPFNPROP, SetWindowLong(hwnd, GWL_WNDPROC, Proc))
return 0
endsub
which creates a control and then sub-classes it.
In the DefaultControlProc I have:
case WM_LBUTTONDBLCLK
ShowPropertyWindow(hwnd,pControl)
return 0
If the control is one of the regular EB controls double clicking fires the WM_LBUTTONDBLCLK and opens the property dialog.
If the control is one of the controls in the add-on ControlPak(progressbar,trackbar,calendar,etc) the WM_LBUTTONDBLCLK is never fired in the handler and the property dialog is never fired.
the other problem is:
In the DefaultControlProc I have:
case WM_CONTEXTMENU
' create custom menu
wParam = CreateMenu(1)
APPENDMENU(wParam,"Properties",MF_STRING,10000)
........
int res = TrackPopupMenu(wParam, TPM_RETURNCMD, lParam&0xFFFF, lParam>>16, 0, hwnd, 0)
DestroyMenu(wParam)
select res
case 10000
ShowPropertyWindow(hwnd,pControl)
endselect
This code results in the property dialog opening for all controls (including the ControlPak controls) except for richedit and treeview.
Anyone know how I can resolve these problems?
Larry
Larry, WM_CONTEXTMENU is a child message generated by unhandled WM_RBUTTONUP message. Richedit handles it, so DefWindowProc does not receive it, and this is why WM_CONTEXTMENU is missing.
QuoteDefWindowProc generates the WM_CONTEXTMENU message when it processes the WM_RBUTTONUP or WM_NCRBUTTONUP message or when the user types SHIFT+F10.
sub DefWindowProc(...) ' internal routine inside common controls
case WM_RBUTTONUP
sendmessage(parent, WM_CONTEXTMENU)
' richedit:
sub wndproc(...)
case WM_RBUTTONUP
handleit()
return 0 ' <- no WM_CONTEXTMENU
' other controls:
sub wndproc(...)
case WM_RBUTTONUP
handleit()
return DefWindowProc(...) ' <- sends WM_CONTEXTMENU
Availability of WM_LBUTTONDBLCLK depends on how the class is registered. If you need this message, set CS_DBLCLKS bit in WNDCLASSEX.style.
If CS_DBLCLKS is not set in ProgressBar class, you can try to add it, by calling
SetClassLong(hwndControl, GCL_STYLE, GetClassLong(hwndControl, GCL_STYLE) | CS_DBLCLKS)
Or use LBUTTONDOWN and compare the previously saved time:
DWORD g_oldclicktime
sub ProgressBarWndProc
... case WM_LBUTTONDOWN
DWORD currenttime = GetTickCount()
if ((currenttime - g_oldclicktime) <= GetDoubleClickTime()) then HANDLE_WM_LBUTTONDBLCLK()
g_oldclicktime = currenttime
thanks Sapero
LarryMc
Sapero
The CS_DBLCLKS fix did not work but the time compare did.
Now I just need a workaround for the richedit and treeview.
LarryMc
Quoterichedit and treeview
Replace WM_CONTEXTMENU with WM_RBUTTONUP, and call GetCursorPos to get the coordinates for context menu.
If you receive WM_RBUTTONDOWN, but WM_RBUTTONUP is missing, then do not forward WM_RBUTTONDOWN to the original handler, because it may be that the control or the default window proc enters another message loop, and waits for right button to be released, in order to detect double click, and optionally to send NM_RDBLCLK as WM_NOTIFY (listview,status,tree,toolbar).
case WM_RBUTTONDOWN
return 0 ' do not forward, this will disable NM_RDBLCLK and EN_MSGFILTER (richedit) for right button.
case WM_RBUTTONUP
showmenu()
return 0 ' do not forward
endselect + CallWindowProc()
thanks again
LarryMc