|
Hi all,
I'm still working on a CTreeCtrl View that is a variation of the Drive view in windows explorer. My problem is this:
I put in a CD rom, and then proceed to "expand" the folders of the cd rom. With the folders still expanded (in view), I remove the CD and insert a NEW cd with a different directory structure. I then Hit my refresh key and Viola! I'm still looking at the old folders from the first CD. This is unacceptable. here's the code in my OnRefresh:
//
// Get all the views
//
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CDriveView* pDriveView = pFrame->GetDriveViewPane();
CFileView* pFileView = pFrame->GetFileViewPane();
//
// Get the current path
//
CString path = pDriveView->GetPathFromItem(pDriveView->GetTreeCtrl().GetSelectedItem ());
//
// Update all the views
//
pDriveView->GetDocument()->UpdateAllViews((CView*)this, 0x5A,NULL);
pFileView->GetDocument()->UpdateAllViews((CView*)this, 0x5A, (CObject*) (LPCSTR) path);
So what the heck am I doing wrong? If I collapse the folder and then re-expand them, the new folders show up. I've been fighting for 3 hours with this one.
Any help/suggestions or comments are greatly appreciated
Dan Willis
Code Project Rocks!
|
|
|
|
|
It sounds like your CViews' OnUpdate handlers are not verifying the existence of new/non-existing folders, since the last cache of nodes was created. It does sound like this is happening when expand events are happening, though, for child subtrees. Perhaps you need to add further verification code outside of expand events. I do not know the details of your updating code, so this is just a guess.
Cheers
|
|
|
|
|
Yup, That makes sense. Looking a little further into it I found that I can force the redraw. I got an idea of what to do now. My next question is Does anyone know of a windows message that gets sent out when a cd is changed? That would make my life alot easier. Do you know of anything?
Dan Willis
|
|
|
|
|
|
Can it be done?
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Not really since the mapping isn't one to one. However, for any given process ID, should be able to get a list of all root windows attached to the process by using GetWindowThreadProcessId on all the children of the processes windows desktop.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
You might try using EnumWindows API. Compare the PID of each top-level window to the one you are searching for.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
I've tried this but it doesn't work:
HDC dc = GetDC(wndMainWin);
HRGN r = CreateRoundRectRgn(1,1,WND_WIDTH-1,WND_HEIGHT-1,10,10);
SetWindowRgn(wndMainWin, r, TRUE);
HBRUSH br = CreateSolidBrush(RGB(0,255,0));
FrameRgn(dc, r, br, 10, 10);
DeleteObject(r);
ReleaseDC(wndMainWin,dc);
It's my main window I'm trying to put a black frame on.
What am I doing wrong here?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Are you doing this in your Erasebackground or WM_PAINT handler. Possibly what you are writing is getting erased?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Neither of them!
I want the user to choose if he want a round window with black frame or the standard region.
If I mark a flag and then call WM_PAINT/WM_ERASEBK.. then it should work if my WM_PAINT/WM_ERASEGk.. check if the user want round window or not?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
What am I doing wrong here?
Not reading the documentation?
After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not close this region handle.
Your code violates both of the the only two documented restrictions.
|
|
|
|
|
Mike Nordell wrote:
Not reading the documentation?
Not that careful...
Mike Nordell wrote:
Your code violates both of the the only two documented restrictions
Which means?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
Mike Nordell wrote:
Your code violates both of the the only two documented restrictions
Which means?
That your code did both of the only two documented things discouraged and/or forbidden.
Your displayed code, after a (hopefully) successful call to SetWindowRgn :
1) did use the region handle.
2) deleted the region.
I wouldn't expect 1 to make (that much of) a difference in this case, but 2 sure does.
Let's visit the documented restrictions again, but this time I'll underline what I think are the important passages:
After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not close this region handle.
|
|
|
|
|
I'm trying to figure out how to use a file passed or used to start my application when started by a file association through either double-clicking a data file or launched from an attachment from an email. The command line passes the pathname of the file that opened the app, however since the data file is locked I can not access the data through normal file opserations. Somehow the dataptr or filehandle is being passed or managed somewhere. Can someone explain how I can get access to that handle so I can read the data file?
|
|
|
|
|
The app that is launching your app must have the file locked. If you start your app via. Explorer you shouldn't have a problem. There are different ways to lock a file (deny write, deny read, deny read/write) so you may still be able to read the file if you open it with the appropriate mode settings and you only need read access.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
The system is launching my app passing the datafile using a shell command or something. This does indeed lock the file, out of my control. If I only needed to worry about launches from explorer I coul dsimply assos the ext with a helper app that simply records he filename of interest and then launches my app after the file has been unlocked. I need to be able to get access to the data in the example of a launch from an email attach whereby the file itself is persistant only while the system launcher is running my app call.
|
|
|
|
|
Is there a way for me to change to color of the font in a static text box?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
on WM_PAINT call SetBkColor. see MSDN for a sample
|
|
|
|
|
A really simple way of doing this and givng you control over quit a bit of the control is to subclass the CComboBox and override the OnCtlColor virtual funtion. Example of changing thetext color follows:
HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
pDC->SetTextColor(RGB(255,255,0));
pDC->SetBkMode(TRANSPARENT);
return m_Brush;
}
In addition to chaging the text color, the disply mode will be transoarent so you don't have to worry about a background color, however, you could change that as well. The m_Brush being returned is a var that is defined in the constuctor so that the entire controls background uses that brush to paint the controls background.
This method can be used on any of the control, listbox, edit, ect.
|
|
|
|
|
Do I always have to set an exception class in my catch function to tell me whats going on? Also how do I know which CException to use? For instance for socket connections?
Thanks
Tom Wright
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You do not have to set exception unless you want to.
CException provides interface to extract basic information for any MFC exception.
As far as I know CSocket does not throw specific exceptions.
|
|
|
|
|
Hi folks, after many months passed in writing a suitable Visual C++ 6.0 wizard I realized that is completely incompatible with the Visual C++ .NET wizard model.Even the reference language is changed: from C++ to Jscript!!! Does anybody know a trick for quickly converting my code or even reuse it making it available in a COM DLL, or whatever?
Regards,
Andrea
|
|
|
|
|
Hi...
I'm trying to use a cListBox object, but the string that I'm displaying gets truncated when it is longer than the width of the listbox. I don't wan't to use a horizontal scroll, so i'm wondering how to make the displayed string continue on the next line. Can anyone tell me?
I've seen that there's a LBS_OWNERDRAWVARIABLE style - which includes that there are variable height involved with this, but creating a CListbox with this style only gives me an error message. Currently i'm using the LBS_STANDARD style. How do i use the LBS_OWNERDRAWVARIABLE one if this is the solution to my problem!?
Regards
Jeffrey
|
|
|
|
|
|
I want to write Bold data (28 points) on a Dialog...against a buutton click
here is code snippet
{
CPen pen;
pen.CreatePen(PS_SOLID,28,RGB(255,0,0));
CDC* pDC=GetDC();
pDC->SelectObject(&pen);
pDC->TextOut("Computer is the killer of nature");
}
it writes data but not bold and Selected color.. Can any one tell where I am doing wrong
|
|
|
|