|
One reason is access permission such as share.
Kuphryn
|
|
|
|
|
You don't do any of that with CreateFile() itself, that API only opens/creates the file. ReadFile() and WriteFile() to read and write. To append, call SetFilePointer() to move the pointer to the end, then write.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
I have an SDI Application with a splitter as follows
------------------------------------------------------------------
Property Sheet containing a few tabs
------------------------------------------------------------------
Log View
------------------------------------------------------------------
Most of the application activities happen in the upper pane where i have a property sheet containing few tabs that have bunch of controls
All the data is contained in the document class. Every activity is logged in the lower pane which contains a CListView
In the document template i have attached the document with the view used in the upper pane.
I created the panes in CMainFrame as follows.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
BOOL flag;
if (!Splitter.CreateStatic(this,2,1))
return FALSE;
flag=Splitter.CreateView(0, 0,pContext->m_pNewViewClass,CSize u(90,90), pContext);
if(!flag)
return FALSE;
pContext->m_pNewViewClass= RUNTIME_CLASS(CLoggingView);
flag=Splitter.CreateView(1,0,pContext->m_pNewViewClass,CSize s(10,10),pContext);
return flag;
}
Now i basically need a pointer to the lower pane Log View in my document as document as all the data which is required while logging. The way i am doing it is basically since i know that this is the second view, i am iterating through the two views and getting the keeping the second view as pointer to log view, as shown below. Have feeling this is not the best way of doing this.
bool anotherfFlag = true;
POSITION posi = GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = GetNextView(posi);
if (!anotherfFlag )
m_PointerToLogView = (CLoggingView*)pView;
anotherfFlag = false;
}
Could you please suggest some better way of doing this?
|
|
|
|
|
My question is the program I am working on was developed awhile ago and it will only execute on a machine the has Visual Studio on it. But I have taken the proper steps so that this should not happen. Yet it still does.
Please help.
Matt
|
|
|
|
|
My guess is that you are attempting to distribute a debug version of your application. The debug version is usually dependent on some VS specific libraries, which only are on a machine which VS is installed. That's my first guess.
|
|
|
|
|
Anonymous wrote:
But I have taken the proper steps so that this should not happen. Yet it still does.
I'm not sure how we can help you. If you've 'taken the proper steps' then it will work. Presumably this is not the case, so you should list the steps you've taken, so we can fill the gaps. How does it fail ? What have you done to make it work ? Does it use the C runtime ? MFC ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
If your program uses MFC check to see if you linked MFC statically or if you linked to use the shared DLL. If you linked to use the shared DLL then you need to have those DLL's in the path.
Another thing to look at...Did you use any ActiveX controls, if so, then you need to have those accessible
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
|
When I use TextOut() to display a string, the string is displayed horizontally. So I create a font with lfEscapement & lfOrientation = 900. And select it to the CDC object. I think the string should be displayed vertically. Unfortunately, it isn't displayed vertically.
How can I do that?
Thanks in advance.
Vincent
|
|
|
|
|
Did you check the return value from CreateFont? There may be some other problem...show us some code
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
1. Make sure it's a TrueType font.
2. If it still doesn't work, please post some code.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Dear Alvaro,
Thank you very much. After I added "lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;", it worked.
Thanks again
Vincent
|
|
|
|
|
For some reason when i try to delete a node and print out the remaining list its prints a bunch of numbers i dont need
The list after deleting 92:
6685124 82 62 72 99
The list after deleting 72:
6685124 82 62 7801996 99
i need it to display like this
The list after deleting 92:
82 62 72 99
The list after deleting 72:
82 62 99
u can see what i need to get rid of.
heres is some code that i think could be the problem, and by the way this list is circular! if this isent enough code please say so
void ClosedList::Delete(int item)
{
NodeType* delPtr;
NodeType* currPtr;
if (item == head->component)
{
delPtr = head;
head = head->link;
}
else
{
currPtr = head;
while (currPtr->link->component != item)
{
currPtr = currPtr->link;
}
delPtr = currPtr->link;
currPtr->link = currPtr->link->link;
}
delete delPtr;
}
here is my print function
void ClosedList::Print() const
{
NodeType* currPtr = head->backlink;
if(!IsEmpty())
{
do
{
cout << currPtr->component << " ";
currPtr = currPtr->backlink;
}while (currPtr!= head);
cout << currPtr->component << " ";
}
cout <<endl;
bool ClosedList::IsEmpty() const
{
return (head == NULL);
}
|
|
|
|
|
I just ripped this out of an old assignment, you might try something like this as I know it works. Keep in mind this is only for a singly linked-list.
int records::DeleteNode(double num)
{
ListNode *NodePtr, *PreviousNode, *BufPtr;
bool bIsFound;
BufPtr = head;
while(BufPtr != NULL)
{
if(BufPtr->ssan == num)
{
bIsFound = true;
}
else
{
bIsFound = false;
}
BufPtr = BufPtr->Next;
if(bIsFound == true)
BufPtr = NULL;
}
if(bIsFound == false)
return -1;
if(!head)
return -1;
if(head->ssan == num)
{
NodePtr = head->next;
delete head;
head = NodePtr;
}
else
{
NodePtr = head;
while(NodePtr != NULL && NodePtr->ssan != num)
{
PreviousNode = NodePtr;
NodePtr = NodePtr->next;
}
PreviousNode->next = NodePtr->next;
delete NodePtr;
}
return 0;
}
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Actually this is a two part question.
My first question is to anyone who has used the MSFlexGrid control in their software. In my MDI the resource file is huge. And I believe it is because of the flexgrid. Because this file is so huge it takes a long time to recompile the program. I am asking is there a way to reduce this time.
My second question is the program I am working on was developed awhile ago and it will only execute on a machine the has Visual Studio on it. But I have taken the proper steps so that this should not happen. Yet it still does.
Please help.
Matt
|
|
|
|
|
Hi All,
I'm looking for an all-inclusive article or series of articles or a reference book of somesort on iostream and its uses, along with throughough documentation on cout and cin. I need to at least start using these but I really don't know how and am having a hard time finding information about it. Thought this is a good place to ask.
any comments or suggestions is greatly appreciated.
Thank you.
|
|
|
|
|
groover4life wrote:
I'm looking for an all-inclusive article or series of articles or a reference book of somesort on iostream and its uses
This[^] is an excellent reference.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Oh yeah. Much better. Thanks alot!!! now I have another whole website.
Thank you!!
|
|
|
|
|
hi All,
I'm looking for an article and/or source code for a super fast search algorithm. I'm traversing a directory searching for certain files, but there is a huge amount of files involved and I need to group the files together. I need to be able to do this preferably using a super fast search method.
Any help is greatly appreciated.
thank you.
|
|
|
|
|
So you're only searching for specific file names?
There are two ways that come to mind:
1. Use the FindFirstFile and FindNextFile APIs. You can also go with the CFileFind class, which is probably only a little less efficient than calling the APIs directly. As you read the file names, organize them into groups.
2. Do a "DIR" into a file:
WinExec("dir /b > zzFiles.txt", SW_HIDE);
Read each line of zzFiles.txt up to the last one (which should be zzFiles.txt) and get the file names from there. I haven't timed it, but I bet the first approach is more efficient.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Right, That's actually what I am doing right now is using the FindFirstFile and FindNextFile. So I'm not really searching for 1 specfic filename. I'm writing a custom "windows explorer" which requires me to take a series of files in a directory and group them togther, display the master file.
So at this time, I'm searching through the directory several times:
- once to find the master files
- then one time for every master file I have found
So, there could be 5,000 files in the directory with say, 50 master files. This would result in traversing the directory 50+1 times, totalling 51 independent searches in 1 directory.
Becuase of this, I am looking to figure out a method that requires searching the directory only once, and group the files as I go using an container class or something. But I don't know enough about STL yet and it would take too long to write 1 up on my own.
Sorry I wasn't this clear the first time. but that is my real delimea. What I want to do is use STL in such a way that I could just traverse the directory once, creating a map such as:
master_file1: file1, file2, file3
master_file2: file1, file2, file3
Any ideas? Anyone? Thanks alot!
|
|
|
|
|
OK, so you need a map of vectors:
1. Define your types
using namespace std;
typedef string FileName;
typedef vector< FileName > FileNames;
typedef auto_ptr< FileNames > FileNamesPtr;
typedef map< FileName, FileNamesPtr > MasterToFileNamesPtrMap;
2. Then you can use:
MasterToFileNamesPtrMap map;
FileNamesPtr pFN(new FileNames);
pFN->push_back(fileName);
map[masterFileName] = pFN;
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Isn't that Simple.... Thanks. I've been reading up on STL. I think I'm gonna start using it. I have lots of uses for it. Just have to learn more.
Thank you very much for your help. The example you gave helps alot in explaining a solution to my problem, but more importantly helps me understand STL much more as it is applied to one of my specific applications.
Thank you. I appreciate it greatly Alvaro.
|
|
|
|
|
typedef std::list<std::string> FileList;
typedef FileList::iterator FileListIterator;
struct SortByDate : public std::binary_function<std::string, std::string, bool>
{
public:
SortByDate(const char* dir) : m_dir(dir) {}
bool operator()(const std::string& lhs, const std::string& rhs)
{
struct stat st = {0};
std::string filename = m_dir;
filename += "\\";
filename += lhs;
if (stat(filename.c_str(), &st) == -1)
{
return true;
}
int lhs_ctime = st.st_ctime;
filename = m_dir;
filename += "\\";
filename += rhs;
if (stat(filename.c_str(), &st) == -1)
{
return false;
}
int rhs_ctime = st.st_ctime;
return lhs_ctime < rhs_ctime;
}
private:
const char* m_dir;
};
bool GetDirectoryList(const char* dir, FileList& fileList)
{
DEBUGF("GetDirectoryList %s", dir);
HANDLE hSearch;
WIN32_FIND_DATA FindData;
char tmpDir[MAX_PATH*2];
lstrcpy(tmpDir, dir);
lstrcat(tmpDir, "\\*.*");
hSearch = FindFirstFile(tmpDir, &FindData);
if (INVALID_HANDLE_VALUE == hSearch)
{
return false;
}
do
{
if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
fileList.insert(std::upper_bound(fileList.begin(),
fileList.end(),
FindData.cFileName,
SortByDate(dir)),
FindData.cFileName);
}
}
while (FindNextFile(hSearch, &FindData));
FindClose(hSearch);
return true;
}
Here's a simple example. You can exclude the SortByDate function if you like. I should have made it more STL like but didn't have time.
Todd Smith
|
|
|
|