|
Does anyone have the MFC equivalent of
directory.exists()?
|
|
|
|
|
How about GetFileAttributes(file)
and check for FILE_ATTRIBUTE_DIRECTORY ?
|
|
|
|
|
One solution is FindFirstFile() and FindNextFile().
Kuphryn
|
|
|
|
|
Or how about CFile::GetStatus
Joel Lucsy
|
|
|
|
|
Or you could use SetCurrentDirectory(). If the function returns FALSE then the directory doesn't exist. You should also call GetLastError() and make sure that it returns ERROR_PATH_NOT_FOUND (I am not sure if that's the actual error but you can figure that out), because there could be several reasons why SetCurrentDirectory() might return FALSE. (make sure you save the current directory before calling the function, in case the directory you are seaching for exists).
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Of course there is the venerable
if (_access(strDir, 0) == 0)
{
TRACE("exists\n");
}
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Hi,
Appreciate your help on this one...
Under what circumstances does IE run in the explorer.exe process?
Thx,
/Tommy
|
|
|
|
|
In new versions of Windows, whenever you type a web URL into the Address combo, or select a web resource from the Favorites menu.
What is commonly thought of as 'IE' is really an ActiveX control that you can load into any frame. Explorer.exe and IExplore.exe really just control what gets loaded into the frame when it's first created - either an Explorer-style ListView or a WebBrowser control. It's been like this since IE 4.0 and the Desktop Update (Active Desktop).
If you type a local address (e.g. C:\Work) into an IE window, it'll turn into an Explorer.
The only thing that Explorer.exe does which IExplore.exe doesn't is to run your desktop and taskbar.
Downloading a new version of 'Internet Explorer' basically updates most of how the shell works.
|
|
|
|
|
Thx Mike!
My problem is this:
I have a BHO which is only supposed to load and run in
Internet Explorer; the BHO is a web tool. It has a heavy init phase which is
very annoying having to wait for if it's loaded in explorer.exe (that is in folders and such frequently used objects), the way it is now.
Is there a way to know under what circumstances IE is run under the explorer.exe process so that I can skip the heavy loading in these cases...? Because when I had this piece of code
if (dwReason == DLL_PROCESS_ATTACH)
{
TCHAR pszLoader[MAX_PATH];
GetModuleFileName(NULL, pszLoader, MAX_PATH);
_tcslwr(pszLoader);
if (_tcsstr(pszLoader, _T("explorer.exe")))
return FALSE;
}
my BHO did not load at all in IE on some machines... which ones with what spec I don't know. Removing the code (the _tcsstr part) makes the whole BHO dependent on open folders and explorer views...
For example, before uninstalling my app (the BHO) I need to shut down every folder (eplorer.exe) unless I want to reboot after the uninstall.
Any idead on what do to?
/Tommy
|
|
|
|
|
Hi All
i have a modeless dialog, which i call from pressing a button
on my toolbar, within my SDI application, this then calls
a function defined by myself
for some reason, the dialog is always displayed in the top left of the screen,
im using the following code,
whenever i call modeless dialogs for anywhere else in my program,
they are always in the center, im controling this from my view class
if that makes a difference
CCPServerWait* m_pWaitDlg;
m_pWaitDlg = new CCPServerWait;
m_pWaitDlg->Create(IDD_DCPSERVER_WAIT);
m_pWaitDlg->UpdateData(FALSE);
m_pWaitDlg->ShowWindow(SW_SHOW);
m_pWaitDlg->UpdateWindow();
/// do something here
// close
m_pWaitDlg->DestroyWindow();
any1 any ideas
thanks
si
|
|
|
|
|
sorry,i should have put....
how do i get it to display in the middle, of the screen
thanks
si
|
|
|
|
|
try m_pWaitDlg->CenterWindow(CWnd::GetDesktopWindow()); before ShowWindow();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks greg
|
|
|
|
|
Hi, I am using Wes Rogers class CDragDropMgr to drag and drop CBitmaps. I am dragging the bitmap fine, but when I try to drop it (by calling CDragDropMgr::DoDrop() in View::OnDrop()) I can't get hold of the actual bitmap. I understand that the user defined class derived from CBitmap must implement the Serialize() method in order for this to work. I am implementing this method (archiving the bitmap size and the bits), but it still isn't working. Anyone have any ideas/tips??
Thanks,
Selena
|
|
|
|
|
Hi !
In our team, we used to develop COM/DCOM components for our applications. That made it easy to work in separate entities and not having to merge code.
But now, we have to develop a crossplatform application, which means COM/DCOM is not a usable solution.
I heared a little about CORBA, but I'm wondering if anyone of you already used it, or if I should use something different. And what about the price for a commercial application ? Is CORBA free ?
Thank you for your help !
Jerome
|
|
|
|
|
COM is actually available on a number of UNIXes, and there's been an on going .NET type compiler for Linux/BSD.
|
|
|
|
|
CORBA is simply a spec. What costs are the various implementation of the CORBA spec, typically referred to as a CORBA ORB (Object Request Broker). There are a number of good impls out there that are free. The two that come to mind are :
Mico[^]
TAO[^]
Both are written in C++ and supposed to be quite good, and both are cross platform.
CORBA is supposed to be a bit complex to get working/using, though if you have a lot of COM experience, I doubt it's much worse of a learning curve.
You might consider using Mozilla's XPCOM[^] which is nearly identical to how MS's COM works AFAIK. It support C++ as well and also runs cross platform.
Cheers
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Dear MFC Gurus,
I have been struggling with a simple MFC demo. The project is basically for a tree view control, there are two views, the left view and the right view. The left view is derived from CTreeView and the right one from CEditView,the two views are separated by a Splitter window.
The project is designed to work as follows
On the left hand side are numbers (1,2,3,4...10)
When I click on 1,2,3.. (which is the parent), the children(1.1,1.2,1.3....1.9) are supposed to appear on the right side (The Edit View Window).
I found a similar example on this site but did'nt quite understand the programming logic behind it!
Could any body kindly make this project up for me, I am in the learning stages and would appreciate such valuable contributions..
hoping for the best
rahul
|
|
|
|
|
The best way to learn is to try to do it yourself and ask specific questions along the way. Don't ask for people to do your work(homework?) for you. Use some initiative. You will go a long way if you problem solve tasks like this yourself. I'm not trying to be mean, just giving advice.
Best of luck!
|
|
|
|
|
hi Tim,
Alright, here is the specific question, so far I have managed to have the tree view control and it does display the parent and children on clicking, with the static splitter window I see the same view on both sides, however this is not what I need! I need the children to be displayed on the right side.(CEditView)
I have an idea of mouse event functions such as OnSelChange that handles Tree View control notifications and takes care, but am not able to implement it.
For your information, I have created a class called Numbers that has an Index (Parent) and a CStringArray (Call it Child)that would hold the children.
All these objects referred as Numbers are stored in a CArray called Number_Array.The Numbers_Array and the Child are being populated in the OnInitialUpdate function of the CTreeView class.
I have been trying my best to get this through, I am also of the opinion that self help is the best way to learn, but at this point I feel completely lost and hence the question!
It would be great if you could reply
thanks
rahul
|
|
|
|
|
Hello Rahul,
It appears you already have the CSplitterWnd member variable added to your SDI frame or MDI child frame(not sure which you're using). To add the edit view you need to override the OnCreateClient() function of the frame window containing the CSplitterWnd member variable .
Example:
BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect rect;
CSize size;
GetClientRect( &rect );
size = rect.Size();
size.cx /= 2;
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CYourTreeView), size, pContext)
{
TRACE("Failed to create tree view.");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CYourEditView), size, pContext)
{
TRACE("Failed to create edit view.");
return FALSE;
}
return TRUE;
}
If you are using the standard doc-view architecture, there is a CDocument derive class that is shared by the two views. When you click on an item in your tree view, you can update a variable in the document which contains the number that was selected. After that document varialbe has been updated, you can UpdateAllViews and have the OnUpdate function of the CEditView display the data stored in the document. Remember, the purpose of the document object is to store the data the views need to display that data.
Happy programming!
Tim
|
|
|
|
|
hi Tim,
Thanks for the snippet, I am doing as you have suggested,I have created the function
OnSelChange(NMHDR *pNMHDR,LRESULT *pResult)
{
NM_TREEVIEW *pNMTREEVIEW = (NM_TREEVIEW*) pNMHDR;
CTreeCtrl &tree = GetTreeCtrl(); // Get the Tree Control reference
HTREEITEM hItem = tree.GetSelectedItem();// Get the currently selected item
*temp = tree.GetItemData(hItem); // Get the item value in this case 1,2,3.. I suppose
CString item_data = temp;
CTree1_ExampleDoc * pDoc = GetDocument(); // Get hold of the document
// Get the children of the selected item and update the document object!
for(int i=0;i<num_array.getsize();++i)
{
="" numbers="" num;="" refer="" below="" for="" the="" number="" defn.
="" cstring="" sfulllist;
="" num="Num_array.GetAt(i);
" if(item_data="Num.index)
" pdoc-="">Doc_Number.index= item_data;
for(int k=0;k<num.child.getsize();++k)
{
="" pdoc-="">Doc_Number.Child.Add(Num.Child.GetAt(k));
sFullList =sFullList+Num.Child.GetAt(k)+"\r\n";
}
break;
}
}
GetDocument()->SetModifiedFlag();
GetDocument()->UpdateAllViews(this,1L,(CObject*) &sFullList);
}
In the EditView Class there is a function OnUpdate listed below,for which I am retrieving the updated document object.
void CTree1_ExampleView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
if(lHint==1L)
{
CEdit & theEdit = GetEditCtrl();
// sFullList = ((CString*)pHint)->GetBuffer(0);
CTree1_ExampleDoc *pDoc = GetDocument();
Numbers View_Number;
View_Number.index = pDoc->Doc_Number.index;
CString sFullList;
for(int i=0;i<pdoc->Doc_Number.Child.GetSize();++i)
{
View_Number.Child.Add(pDoc->Doc_Number.Child.GetAt(i));
sFullList = sFullList+pDoc->Doc_Number.Child.GetAt(i)+ "\r\n";
}
// AfxMessageBox(sFullList);
theEdit.SetWindowText(sFullList);
this->Invalidate();
}
}
This however is not displaying the text in the edit window.
// Definition for Numbers
class Numbers
{
public:
CString index;
CString sub_index;
CStringArray Child;
Numbers& operator=(Numbers &num)
{
index = num.index;
sub_index = num.sub_index;
Child.Copy(num.Child);
return *this;
}
};
class Numbers_Array:public CArray<numbers,numbers&>,Numbers
{
};
Last question, How do I get the item currently selected by the mouse, Will I have to write a message handler such as OnMouseClick(); ???
Please suggest.
thanks
rahul
|
|
|
|
|
I'll answer the easy question first.
Question:
rahulmsaxena wrote:
How do I get the item currently selected by the mouse
Answer:
// find the currently selected item
HTREEITEM hCurSel = pCtrl->GetNextItem(TVI_ROOT, TVGN_CARET);
Now for the rest of the project. First of all, I would say you use of the Numbers_Array and CStringArray is overkill for what I understand the project requirements are. Lets simplify quite a bit. Just use one CString variable in your document to store the generated text.
Have your edit control display the text in the CString when OnUpdate occurs. For testing purposes, set the CString to the ASCII equivalent of the value stored in the Tree Controls ItemData that you are using currently. The CEditView should now be displaying the text of the data in the tree item you have slelected with a mouse click.
To get the whole tree heirarchy(1.1.3 for example), write a quick loop that will recursively traverse up the tree control by getting the data of the item's parent until the root of the tree has been reached. Build your string as you go up the tree. Now you won't need any arrays and the code should be able to handle multiple levels of items and their children in the tree.
Trees like this should be easy:
1
2.1
2.2
2.3.1
3.1
3.1.1.1
... and so on.
Tim
|
|
|
|
|
I have a serial device that has a checksum in the communication data packet.
The only description the documentation has is "2's complement of the sum of
all bytes from byte1 to byte n-4". This sound as though I should add all bytes
in the structure from the first byte to the byte before the checksum byte and place the
twos complement of this value into the checksum byte.
When I create a packet and add the bytes together then I get a value that is larger
than a 8 bit value. I have asked the found from asking in other forums and scanning
the internet that a 2's complement is taking a number and inverting all bits and then
adding 1 to it. my problem is that the size of the value should be 8 bits and when I
add them up I get 16 and some times 32 bit values.
I am trying to communicate with this device using VB.Net, I ask this question in the VB.Net
forum but no one has answered. So I thought I would ask here and try to port any answers to
VB. Now that I think I have explained everything my question is:
how do I do a 2's complement of the sum of all bytes in an array and put that value into a single 8 bit byte?
Thank you for any help you can offer.
=================================
When I was in school, all I wanted was to get out into the real world.
Now that I'm in the real world, all I want is to go back to school.
|
|
|
|
|
The checksum is generally the twos-complement of the low byte of the sum, so I would code it like this:
BYTE CalculateChecksum(BYTE *pData, UINT dataSize)
{
UINT sum = 0;
for(int i=0; i<dataSize; i++)
sum += pData[i];
sum = -sum;
return (BYTE)(sum & 0xff);
} Where pData is a pointer to you data buffer, and dataSize is the length of the data. I'll leave it to you to translate this to VB
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|