|
|
Dear gurus,
I'm having a problem in using ParseDisplayName.
1) I have a path of USB drive, such as: G:\
2) I pass this driver path into my function, which will call
ParseDisplayName to get PIDL item, as below:
LPITEMIDLIST CTemp::getItemIDList( CString p_strPath )
{
USES_CONVERSION;
if( p_strPath.IsEmpty() )
{
return NULL;
}
LPITEMIDLIST l_pIDL;
LPSHELLFOLDER pDesktopFolder;
if( ::SHGetDesktopFolder( &pDesktopFolder ) != NOERROR )
{
return NULL;
}
OLECHAR ochPath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hRes;
::MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, W2A(p_strPath), -1, ochPath,
MAX_PATH );
hRes = pDesktopFolder->ParseDisplayName( NULL, NULL, ochPath, &chEaten,
&l_pIDL, &dwAttributes);
pDesktopFolder->Release();
return l_pIDL;
}
3) The hRes result is 0x80070003 指定されたパスが見つかりません.
I don't know why it was failed.
I also try another way to solve this bug and I realize that, if i access to
this USB drive before calling ParseDisplayName, this method ParseDisplayName
always return good result, S_OK, such as:
a) Call the function ParseDisplayName at the first time, right after calling
ParseDisplayName again, the hRes result will be S_OK.
b) Declare a file path variable to one file in USB drive.
Call ParseDisplayName with this file path, then call ParseDisplayName with
the USB drive path, the hRes result will be S_OK.
c) Use while loop to browse each drive after using CSIDL_DRIVES, then
calling ParseDisplayName, the hRes result will be S_OK.
So can you help me to explain two issues:
1) Why does the ParseDisplayName method fail in this case ?
2) Why does the ParseDisplayName method success after accessing the USB
drive at first time?
If anybody here had the same situation like mine, please help me to clarify
the mystery surrounding this phenomenon.
I'm looking forward to seeing your replies.
Best regards,
Jetflower
|
|
|
|
|
I not sure but, but I think had faced the same problem some moths ago and at that time when I changed the CoInitializeEx to CoInitialize( or reverse ) the problem go fixed. Could you please try changing it?
|
|
|
|
|
Yes, that could be it. If your threading model is wrong, the shell won't be able to execute except when you call in to it, which explains that it does not see your drive before you allow it execute. See my other answer on this thread.
|
|
|
|
|
Your HRESULT indicates WIN32/PATH_NOT_FOUND. The only thing I can imagine is that the shell has not 'seen' your USB drive yet (i.e. it hasn't handled the mount on the G: reparse point and updated it's data structures). Calling into the shell once (through ::SHGetDesktopFolder) causes it to execute some code, and probably notice the mount event. Subsequent calls will the succeed.
|
|
|
|
|
|
Hi Friends,
I have an interesting question for all.
How can i restrict a dialog box(Modal or modeless) to stay within the
application boundaries?
Just like CView derived objects will not move out of application.
I know we can do it with OnMove(..) event handling.
But, i wanted to know whether there are any other direct means
like by setting some properties to CDialog class.
Please help me with this.
Regards,
K ARUN KUMAR
modified on Tuesday, May 4, 2010 5:30 AM
|
|
|
|
|
Add some code in your OnInitDialog() method (where you handle the WM_INITDIALOG message) to set your diaolg's window within the confines of its parent Window, assuming it is large enough.
It's time for a new signature.
|
|
|
|
|
Hi Richard,
As advised I have limited the size to be with in the application.
But, the problem comes when user is trying to move the dialog.
It goes out of application boundaries. I want a functionality
similar to CView child objects which stay with in the MainFrame.
|
|
|
|
|
Hi Arun,
To the best of my knowledge, it doesn't get any better than handling the move messages.
If you also handle the move/size messages of the parent, you'll know what your boundary dimensions without requesting them specifically every time your child dialog is moved. (unless of course mfc does this for you behind the scenes)
|
|
|
|
|
Hi enhzflep,
Yep.I have implemented the OnMove(..) solution for this.
But seriously searching for some direct method like
inheriting some poperties of CView which will make the dialog
to be constrained to be with in application.
Hope any one knows the better solution.
Thanks Mate.
|
|
|
|
|
K ARUN KUMAR wrote: Hope any one knows the better solution.
There isn't one, other than the suggestions you have already been given by other posters. You need to remember that a dialog should be a short lived window that allows interaction between your app and the user. If you want it to be longer lived and/or to restrict its positioning then you should make it a child window of your frame as described below.
It's time for a new signature.
|
|
|
|
|
A CFrameWind is the top window in an application. Embed a CDialog into a CFrameWnd so that
when the CFrameWnd is moved or minimized, the CDialog will also be moved and minimized.
CFrameWnd manages all of its child windows so that they fill its client
area. If you have a toolbar, a status bar and a CFormView they will all
be positioned and sized automatically by the CFrameWnd.
CFrameWnd
http://msdn.microsoft.com/en-us/library/4y17z36a(VS.80).aspx
|
|
|
|
|
Hi Micheal,
Thanks for your reply.
How to embed the CDialog into the CFrameWnd in SDI application
so that my requirement is accomplished.
I mean a bit of code.
Please help me.
|
|
|
|
|
|
Nop. This does not work for me.
Any ways thanks for the help.
|
|
|
|
|
See if this helps.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks David..
That worked.
One more thing.
If the dialog is a modeless dialog and if the
user goes back to the main frame window and moves the
window, the modeless dialog will go out of application.
So for this i have added the WM_MOVING event in MainFrame class.
void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect)
{
//CFrameWnd::OnMoving(fwSide, pRect);
HWND hWnd = pDlg->GetSafeHwnd();
RECT rc;
RECT* pRc=&rc;
rc.left=rc.top=rc.right=rc.bottom=0;
LRESULT result = ::SendMessage(hWnd, WM_MOVING, (WPARAM)fwSide, (LPARAM)&rc);
}
and modified the WM_MOVING handler of Modeless Dialog as below.
void CModelessDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
CDialog::OnMoving(fwSide, pRect);
CRect rcParent;
if(pRect->right==0) //Calin from MainFrame
GetWindowRect(pRect);
GetOwner()->GetWindowRect(rcParent);
// keep the child's left edge inside the parent's right edge
pRect->left = min(pRect->left, rcParent.right - m_nWidth);
// keep the child's left edge inside the parent's left edge
pRect->left = max(pRect->left, rcParent.left);
// keep the child's top edge inside the parent's bottom edge
pRect->top = min(pRect->top, rcParent.bottom - m_nHeight);
// keep the child's top edge inside the parent's top edge
pRect->top = max(pRect->top, rcParent.top);
// keep the child's right edge inside the parent's right edge
pRect->right = min(pRect->right, rcParent.right);
// keep the child's right edge inside the parent's left edge
pRect->right = max(pRect->right, rcParent.left + m_nWidth);
// keep the child's bottom edge inside the parent's bottom edge
pRect->bottom = min(pRect->bottom, rcParent.bottom);
// keep the child's bottom edge inside the parent's top edge
pRect->bottom = max(pRect->bottom, rcParent.top + m_nHeight);
if((rcParent.Width() < pRect->right - pRect->left) || (rcParent.Height() < pRect->bottom - pRect->top))
{
this->ShowWindow(SW_HIDE);
}
else
this->ShowWindow(SW_SHOW);
this->MoveWindow(pRect); //Added by Arun
}
Once again Thanks a lot David.....
modified on Wednesday, May 5, 2010 5:31 AM
|
|
|
|
|
hi friends,
1.i created project in vc6.
2. project default setting is debug.
3. i am trying to change debug to release mode
vc6 editor->project ->setting
<project setting=""> dialog
<setting for=""> i changed win32 debug to win32 release..
clicked ok...
but i project setting is win32 debug only...i want to change win32 release...
please help any body...
|
|
|
|
|
You left out one important step.
Changing from the Debug Mode to the Release Mode:
The steps:
Step 1: Click the Project menu -> setting -> change "win32 debug" to "win32 release".
Step 2: Click the Build menu -> Set Active Configuration.
From the popup box, select the win32prog – Win32 Release (win32prog should be your project name).
Then click OK button.
...
|
|
|
|
|
thank u friend.. but i am facing another problem...
Release folder automatically create right....
after change release mode...
i am trying to compile and run...
C:\bujji\server\Release\Server.exe
this file does not exist. do u want to build it?
yes no
i am clicking yes
cannot Execute program
|
|
|
|
|
Member 3653751 wrote: C:\bujji\server\Release\Server.exe
After compiling/linking, does C:\bujji\server\Release\Server.exe exist?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi
I have what I think to be a small problem.
I'm working with templated graph class that uses linkedlist for adjacent vertexes.
I'm just trying to test out the functions, but I keep getting a link unresolved error.
I'm thinking I might be typing it wrong, but who knows.
I'm using microsoft visual studio 2008.
thanks in advance.
here's my int main()
i purposely left out my openfile function
(it works,i've used it many times before) :
int main()
{
graphType<int,11> cGraph1();
ifstream fsFileIn,
fsFileIn2,
fsFileIn3;
openFile(fsFileIn,fsFileIn2,fsFileIn3);
cGraph1().createGraph(fsFileIn);
return 0;
}
here's most of the graphType.h file
(minus all the other header files graphType.h uses):
#ifndef H_graph
#define H_graph
#include <iostream>
#include <fstream>
#include <iomanip>
#include "linkedList.h"
#include "linkedListForGraph.h"
#include "queueLinked.h"
using namespace std;
const int infinity = 10000000;
template<class vType, int size>
class graphType
{
public:
void createGraph();
void createGraph(ifstream& infile);
void clearGraph();
graphType();
~graphType();
protected:
int maxSize;
int gSize;
linkedListGraph<vType> graph[size];
private:
void dft(vType v, bool visited[]);
};
template<class vType, int size>
void graphType<vType, size>::createGraph()
{
ifstream infile;
char fileName[50];
vType vertex;
vType adjacentVertex;
if(gSize != 0)
clearGraph();
cout<<"Enter the input file name: ";
cin>>fileName;
cout<<endl;
infile.open(fileName);
if(!infile)
{
cerr<<"Cannot open the input file."<<endl;
return;
}
infile>>gSize;
for(int index = 0; index < gSize; index++)
{
infile>>vertex;
infile>>adjacentVertex;
while(adjacentVertex != -999)
{
graph[vertex].insertLast(adjacentVertex);
infile>>adjacentVertex;
}
}
infile.close();
}
template<class vType, int size>
void graphType<vType, size>::createGraph(ifstream& infile)
{
char fileName[50];
vType vertex;
vType adjacentVertex;
if(gSize != 0)
clearGraph();
cout<<"Enter the input file name: ";
cin>>fileName;
cout<<endl;
infile.open(fileName);
if(!infile)
{
cerr<<"Cannot open the input file."<<endl;
return;
}
infile>>gSize;
for(int index = 0; index < gSize; index++)
{
infile>>vertex;
infile>>adjacentVertex;
while(adjacentVertex != -999)
{
graph[vertex].insertLast(adjacentVertex);
infile>>adjacentVertex;
}
}
infile.close();
}
template<class vType, int size>
void graphType<vType, size>::clearGraph()
{
int index;
for(index = 0; index < gSize; index++)
graph[index].destroyList();
gSize = 0;
}
template<class vType, int size>
graphType<vType, size>::graphType()
{
maxSize = size;
gSize = 0;
}
template<class vType, int size>
graphType<vType, size>::~graphType()
{
clearGraph();
}
#endif
|
|
|
|
|
You do understand that the Link Unresolved error has nothing to do with the project exerpts you present us? (There's no error text "link error unresolved" or similar text in the source)
I'd be willing to bet my little finger that it's not a Link(ed list) Unresolved Error, but rather a Link(er) Unresolved Error.
Have you double-checked to see that all required dependencies are included in the project - i.e .lib & .cpp files?
|
|
|
|
|
sorry,
linker unresolved error is exactly what i meant:
and yes, i do have all the necessary files in my project folder
and all the filenames match with my code declarations for the ifstream variable type.
I can declare a graph no problem, but when i try to use any functions, i get that linker error.
|
|
|
|