|
it is not, it is a CFrameWnd, container of CDocument and CView.
|
|
|
|
|
I think what you want to achieve is update two scroll views from the document?
i.e on update the two views simultanously?
Величие не Бога может быть недооценена.
|
|
|
|
|
exactly.
but I don't want to use two scrollbars, is it achievable?
|
|
|
|
|
I hope you want two Views, both derived from CScrollView? and using a single class.
If so then UpdateAllView is what you need.
Величие не Бога может быть недооценена.
|
|
|
|
|
i planed to use two views, and attached a scrollbar to CMDIChildWnd (i can't attach scrollbar to CDocument, as it is not a CWnd).
UpdateAllView only affect views, but not their container CMDIChildWnd.
If using scrollviews, I need to synchronize two scrollbars.....
|
|
|
|
|
I think you can get 2 CScrollViews and manage who is scrolling (the View is active) when you do the click in one of the scrolls, then from the document you get the new scroll position, give it to the other window using SetScrollPosition with pDoc->ActualPos_2 (assuming you made the click on View1) for the other one and call UpdateAllViews. Or just setting the scroll for both views where you need and call UpdateAllViews when opening a document.
Is that more or less what you wanted?
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: Or just setting the scroll for both views where you need
could you give a little bit more info?
are both views scrollviews or there is a scrollbar on top of them?
if both are scrollviews, how can I set scroll for both views? which class should handle scroll message?
thanks!
|
|
|
|
|
It would be using GetScrollPosition in the view that is getting scrolled with the OnScroll and sending it to the other view where you use it with SetScrollPosition before updating all views.
Yes, both views should be derived from CScrollView and each one would have its own scrollbar, but you synchronize one when moving the other
Here[^] is spoken about SetScrollPos and Here[^] about ScrollToPosition
If you manage the actual position of each View in the document, for instance m_pScrollPos_1 and m_pSCrollPos_2, you can call them in your OnDraw and move the actual position of the scroll for this view to the saved point. When you click on a scroll bar just save the new position in the document and call pDoc->UpdateAllViews.
It may have a bit delayment between the one and the other whilst synchronising. But it is a possibility
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
nelek
thanks for the detailed info.
|
|
|
|
|
You are welcome. I hope it works as you whish.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I'm not sure if this exactly fits your requirement, but it is possible to place two views derived from CScrollView into different panes of a splitter window and scroll them together.
You need to specify WS_VSCROLL when you create the splitter, otherwise you get a scrollbar for each pane instead of one that works them both.
I used WS_HSCROLL and WS_VSCROLL in a recent application to scroll around a matrix and get the row and column headings to scroll along with the body of the matrix. Like this (CMatrixSplitterFrame derived from CMDIChildWnd):
BOOL CMatrixSplitterFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_SplitterWnd.CreateStatic(this, 2, 2, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
if (!m_SplitterWnd.CreateView(0, 1, RUNTIME_CLASS(CKernelMatrixColHeadView), CSize(2000, CELL_YSIZE + CELL_INTER_GAP + CELL_INTER_GAP), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
Best Regards
Cliff Hatch
|
|
|
|
|
Cliff,
thanks for the clue, it is very useful.
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT, CCreateContext* pContext)
{
if (!m_SplitterController.CreateStatic(this, 1, 2, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL))
{
return FALSE;
}
CRect lRect;
GetClientRect(lRect);
if (!m_SplitterController.CreateView(0, 0, pContext->m_pNewViewClass,
CSize(lRect.Width() >> 1, lRect.Height()), pContext))
{
return FALSE;
}
if (!m_SplitterController.CreateView(0, 1, pContext->m_pNewViewClass,
CSize((lRect.Width() + 1) >> 1, lRect.Height()), pContext))
{
return FALSE;
}
SetActiveView((CView*)m_SplitterController.GetPane(0, 1));
m_IsInitialized = TRUE;
return TRUE;
however, it only partly works at here --- there is only one vertical scroll bar, but there are two horizontal scroll bars, did I miss anything?
and, how do you answer scroll message?
I added it to CChildFrame, which is a subclass of CMDIChildWnd, but it was never called.
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
...
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
ON_WM_HSCROLL()
ON_WM_VSCROLL()
ON_WM_MOUSEWHEEL()
ON_WM_SIZE()
END_MESSAGE_MAP()
...
void CChildFrame::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CMDIChildWnd::OnHScroll(nSBCode, nPos, pScrollBar);
}
any idea?
many thanks!
|
|
|
|
|
baumchen
It looks as though the scrollbars are associated with the panes in a manner that happened to be right for my application, but is perhaps not right for yours.
When you specify WS_HSCROLL and WS_VSCROLL you get a horizontal scrollbar on all the panes along the bottom of the window, and a vertical scrollbar on all those on the right hand side. So in my 2x2 display I have 4 scrollbars in total. (Without WS_HSCROLL and WS_VSCROLL there would be 8, 2 for each pane).
Sorry, the description in my earlier post was a little misleading. I had forgotten the existence of 2 of my scrollbars because the top row is sized such that it never needs vertical scrolling, and the left column never needs horizontal scrolling - so their bars are always grayed out.
It appears that the horizontal scrollbars are shared by all the panes stacked above them, and the vertical ones by all the panes on the row to their left. I haven't been able to test this completely because my top-left pane is a dummy - but this is certainly how the other 3 behave.
This would be consistent with your result. In a 1 row x 2 column display, you only get one shared scrollbar - the vertical one.
I haven't managed to find any documentation to confirm this, but Technical Note 29 (.Net 2002) has a very short section on shared scroll bars which hints at this arrangment.
I didn't write any special handlers. The base classes, CSplitterWnd and CScrollView, managed all the scrolling messages for me.
Best Wishes
Cliff
|
|
|
|
|
Cliff
thanks!
looks it is easier to live with two sets of scrollbars.
|
|
|
|
|
Howdy out there!
Without going into too much detail, I need to keep track of the drives -- to know if anything is attached, and if so what.
Currently (on a timer) I am use a combination of GetVolumeInformation and FindFirstFile -- to both get volume information and make sure that the device is readable. I am already processing device events to get changes, but still periodically I also scan all the drives.
For most users, my scheme isn't a problem. But, I have a user who is reporting activity on their A: drive periodically.
What's the best way to check the drive without being annoying to the user?
Do you think I am doing too much by trying to read the drive root?
Is there a good alternative to reading the drive root to verify the contents of a drive?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
ouch - thats a hard one
there a few ways of enumerating drives etc and determining if they are floppy, fixed drives etc .. the issue likely comes about if floppy's are detected because you then attempt to read from it, which is going to cause activity
do you really need to check floppy drives ? or can you say if its a floppy drive and through a parameter eg environment variable dont attempt to read it ?
Peter Weyzen wrote: Do you think I am doing too much by trying to read the drive root?
there's not enough context into the why for (tlbd) to say ...
I was thinking that maybe you can detect media inserted (or not) into a floppy drive, and dont scan it if there's no media there - but even that might cause activity
sorry, not much help, brain thinking out loud ...
'g'
|
|
|
|
|
Thanks for your thoughts.
I already listen to the device change events -- but one can never trust those to be completely accurate.
Is there a way to differentiate "removable" drives from "floppy" drives?
Some day, there will be no more floppy drives and my problem will go away!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: Is there a way to differentiate "removable" drives from "floppy" drives?
Im pretty sure there is - but cant search for the info right now - I did have a great article on doing such
'g'
|
|
|
|
|
What about Win32API GetLogicalDrives() and GetDriveType()? Are they of any use?
|
|
|
|
|
sure they can be used to determine what drives you've got - the Setup API can also do it ... but they cant tell you wether there's media in a floppy drive for example
(personally I'd disconnect the floppy drives - but thats skirting his/customers issue)
'g'
|
|
|
|
|
When you insert a CD or DVD, Windows will send a WM_DEVICECHANGE message. Does the same thing happen for a floppy disk?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Peter - have a look at CFileTreeCtrl from PJ Naughter - he has a comment under updates [v1.09 (18 July 2000)] "Code has been made smarter so that it does not have to spin up the floppy disk to determine if there are files on it. It now initially displays a "+" and only when you try to expand it will it do the actual scan. "
Maybe not having to 'Spin Up' means the user also doesnt see the floppy/select light come on !
http://www.naughter.com/filetreectrl.html[^]
'g'
|
|
|
|
|
Hi, folks
I met such a problem when implementing a CScrollView class.
what i want to do is to show two images in one CScrollView instance, so I have the following code (below only shows one image in the left part of the window).
void OnDraw(CDC* pDC)
{
CDC dcMem;
CRect lRect;
GetClientRect(lRect);
lRect.NormalizeRect();
dcMem.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = (CBitmap*) dcMem.SelectObject(m_SourceBitmap);
CPoint scrollPosition = GetScrollPosition();
pDC->BitBlt(scrollPosition.x, scrollPosition.y, lRect.Width() / 2, lRect.Height(), &dcMem, scrollPosition.x, scrollPosition.y, SRCCOPY);
DeleteDC(dcMem);
}
however, when I scroll the window, right half part of the window always has some problem, either too much background (scrolling left) or too few background (scrolling right).
when I hide and show the window, everything is fine.
alternatively, I tried calling Invalidate() from OnScroll, flicker happens because OnDraw is called multiple times.
anyone got a solution?
thanks!
baum
|
|
|
|
|
I don't know for sure if this will help you, but I used this (simplified version) and for me was working good.
CClientDC dc(this);
CDC dcNormMem;
dcNormMem.CreateCompatibleDC (&dc);
CString szTempText = "";
CPoint cpTempPos, cpTempTextPos, cpScrollPoint = GetScrollPosition ();
CBitmap bmNormIn;
BITMAP bmNormTemp;
if (bmNormIn.m_hObject != NULL)
bmNormIn.DeleteObject ();
bmNormIn.LoadBitmap (IDB_NORMIN);
bmNormIn.GetObject(sizeof(bmNormTemp), &bmNormTemp);
dcNormMem.SelectObject(&bmNormIn);
cpTempPos.x = pDoc->m_cmlInputSet[nIn].m_cpInCoord.x - cpScrollPoint.x;
cpTempPos.y = pDoc->m_cmlInputSet[nIn].m_cpInCoord.y - cpScrollPoint.y;
dc.BitBlt(cpTempPos.x, cpTempPos.y, bmNormTemp.bmWidth, bmNormTemp.bmHeight, &dcNormMem, 0, 0, SRCCOPY);
szTempText = pDoc->m_cmlInputSet[nIn].m_szInName;
dc.SetTextColor(RGB(0,0,0));
dc.TextOut (cpTempPos.x, cpTempPos.y + SIGHEIGHT + 1, szTempText);
.
.
dcNormMem.DeleteDC();
ReleaseDC(&dc);
and
BOOL CMyView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
Invalidate ();
UpdateWindow ();
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
And for me was working good, I had up to 48 tiny Bitmaps on the screen and the Scroll of the window worked fine.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek
thanks for the reply.
Do you have a counter to count how many times OnDraw is called per scroll? in my code, I found it was called 2 or 3 times per scroll, and it caused flicker when scrolling (when dragging the scrollbar).
any clue?
thanks!
|
|
|
|
|