If you ask me this is going to be a never ending battle between the controls
and the scrollbar.
But here are some pointers.
area of the FormView.
order. And you can get its rectangle
order is visible or not.
anyway, and do your processing there instead of OnKeyDown.
Hope this helps.
AliR.
AliR (VC++ MVP) a ?crit :
What is it that you are trying to do? That's not very clear in your
post.
AliR.
"mosfet" <john.doe@anonymous.org> wrote in message
news:46a07c5f$0$9922$426a74cc@news.free.fr...
Hi,
I am developping on pocket pc an application with some views deriving
from CFormView.
On this platform you cannot resize your MainFrame because it's always
maximized.
So let's say I have a CAboutView and inside it I am putting some
controls outside the client rect, for now here is what I am doing to
have the scrollbar appeared :
void CAboutView::OnWindowPosChanged( WINDOWPOS* lpwndpos )
if ( rcItem.bottom > rc.bottom ) {
// Scroll bar info
SetScrolling( TRUE );
SetScrollPos( SB_VERT, 0 );
SetScrollSizes( MM_TEXT, CSize( rc.Width(), rcItem.bottom + 2) );
}
else {
// Scroll bar info
SetScrollSizes( MM_TEXT, rc.Size() );
}
}
So basically I am taking the last controls and I resize my scrollbars.
But I am not very satisfied by this solution, do you have a better idea
?
Ok What I want to do is to be able to scroll a view deriving from a
CFormView on a smartphone knowing that on this platform you cannot move
scollbars "by hand". For that you have to use keypad.
The problem is usually a WM_KEYDOWN is eaten in the PreTranslateMessage.
So when I have a CFormView with some controls(listboxes for instance) on
it, a WM_KEYDOWN is receive in the PreTranslate and after the
shell/OS/framework(I don't know who exactly) move the focus from one
control to another.
Now consider the case :
We have a view with one vertical scrollbar and one static control to
display some text and a CStaticlink(CButton) to open a URL when clicking
on it.
If I want to be able to move my scrollbar I do the following
UINT CBaseView::OnGetDlgCode()
{
if (m_nScrollPolicy == 0)
return (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS |
DLGC_WANTALLKEYS);
else
return ( CFormView::OnGetDlgCode() );
}
I receive the WM_GETDLGCODE and I say that my view wants to receive
WM_KEYDOWN.
When I receive the WM_KEYDOWN I call OnVScroll to move my view BUT the
problem is if I do that my CStaticlink cannot get focus and I cannot
click on it.
void CBaseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
...
switch (nChar)
{
case VK_UP:
nVPos = ((nVPos - 15) < 0) ? 0 : nVPos - 15;
OnVScroll(SB_THUMBTRACK, nVPos,NULL);
break;
case VK_DOWN:
OnVScroll(SB_THUMBTRACK,nVPos + 15,NULL);
break;
case VK_LEFT:
nHPos = ((nHPos - 15) < 0) ? 0 : nHPos - 15;
OnHScroll(SB_THUMBTRACK,nHPos,NULL);
break;
case VK_RIGHT:
nHPos += 15;
OnHScroll(SB_THUMBTRACK,nHPos,NULL);
break;
}
}
So to fix it I would need inside the OnKeyDown to check if the next tab
control is on screen and in this case instead of calling OnVScroll maybe I
should set focus to my CStaticlink.
And what if a ClistView get the focus, normally each call to WM_KEYDOWN
should move the item and not the focus.
ANOTHER problem is that this first case relies on the fact that I receive
the WM_GETDLGCODE and it's not always the case. it works ONLY if my view
doesn't have a focus on a control.