|
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!
|
|
|
|
|
No, I didn't use a counter.
For me the problem of flickering was when I was moving the signals or placing a conection between two signals because I was calling Invalidate and UpdateWindow inside OnMouseMove so I was expecting that fliccker, but with the clicks of mouse or when scrolling it was working fine.
In the worst case, if you know that it is getting updated more times you can use a bool to draw only the first call (you can do it false when the mouse moves or at button release). I know it is not an elegant solution but at least can help while you search for the real issue.
On the other hand, I am sorry I can not help you more. My previous laptop died and I have no MS in this one, I am speaking with my boss to Install MS 2008 but not have it yet.
By the way... which version of VC are you using?
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 am using a rather old vc, 2003.
It is amazing to see that mspaint doesn't have any flicker when you drag the mouse and scroll it around.
dunno how they achieved that.
I tried creating a DDB bitmap, but it doesn't help.
|
|
|
|
|
I've got a DLL I'm able to call into without a .lib or header file. I'm using LoadLibrary and GetProcAddress to find the entry points for the exported function names. However, I am unable to determine what the functions take as arguments.
I used DumpBin to determine the exported function names.
Functions that have a "(void)" parameter list work OK. How do can I determine what the function signatures (e.g. arguments) are so I can effect a proper function call?
|
|
|
|
|
If the exported names are C++, you've got some chance of determining the signatures (because C++ embeds the signature information into the exported name to allow function overloading). Otherwise, you're pretty much out of luck, I think.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
I was afraid that was going to be the case.
Thanks for the info.
|
|
|
|
|
I'd agree with Stuart - if the dll is c++, you can decode the 'mangled' function names, because there is info there on the parameters - if its straight 'c', you need a .h file or documentation to determine the parameters
'g'
|
|
|
|
|
Hi all,
I'm working on a backup project in C++ for Windows XP and Server 2003. I want to be able to backup locked files like the registry and database files. I've looked into Volume Shadow Copy and it seems like the right direction to head, but I can't understand how to implement it in C++.
Here is our current method for backing up a file.
1. FindFirstFile/FindNextFile
2. Send path to file to compression function
3. Compression function simply calls zip.exe with the proper arguments (path to file, path to zip, etc)
3a. zip.exe is Info-ZIP.org's zip program.
My major issue with shadow volumes is that I want to directly access the files and not copy them. Since I'm trying to backup database files, it doesn't make sense to copy them (they are several GB in size sometimes). I'm curious to know if there are other methods outside of VSS to read/process locked files. The majority of enterprise backup solutions can do it without any issue or delay, so I know it's possible, I just don't know how.
I've looked at Hobocopy and it seems to be a valid option, but I don't think it'll work with my current compression method. I tried creating a shadow copy and using the \\?\GLOBALROOT\... path with zip.exe, but it failed, of course.
Thanks.
|
|
|
|
|
What if you granted your code the SE_BACKUP_NAME privilege and then used CreateFile() with FILE_FLAG_BACKUP_SEMANTICS ?
"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
|
|
|
|
|
Here's my sample code and output:
#include <windows.h>
#include <iostream>
#include <time.h>
#include <tchar.h>
using namespace std;
BOOL SetPrivilege(LPCTSTR lpszPrivilege, BOOL bEnablePrivilege);
HANDLE hFile;
void main() {
BOOL ret = SetPrivilege(SE_BACKUP_NAME,TRUE);
cout << "Ret: " << ret << endl;
DWORD dwErr=0;
hFile = CreateFile(L"c:\\windows\\system32\\config\\system", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
cout << "Handle: " << hFile << endl;
if (INVALID_HANDLE_VALUE == hFile) {
dwErr = GetLastError();
CloseHandle(hFile);
cout << "Could not open file: " << dwErr << endl;
}
CloseHandle(hFile);
SetPrivilege(SE_BACKUP_NAME,FALSE);
}
BOOL SetPrivilege(LPCTSTR lpszPrivilege, BOOL bEnablePrivilege)
{
TOKEN_PRIVILEGES tp;
LUID luid;
HANDLE hToken;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
if ( !LookupPrivilegeValue(NULL, lpszPrivilege, &luid) )
return FALSE;
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
if (bEnablePrivilege)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;
AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
return ( (GetLastError()!=ERROR_SUCCESS)?FALSE:TRUE);
}
<br />
Ret: 1<br />
Handle: FFFFFFFF<br />
Could not open file: 32<br />
As you can see, it gave an Error 32, which is:
ERROR_SHARING_VIOLATION
32 (0x20)
The process cannot access the file because it is being used by another process.
I think I'm doing it properly...
|
|
|
|
|