|
Do you want to open a file and get a handle for it?
|
|
|
|
|
The problem is:
- I open a file
- do somth. with it.
- close it [fclose(f)]
- try to delete it
- it doesn't delete
I replaced fclose(f) with fcloseall() and thing went to normal.
|
|
|
|
|
Can you show your code,please
|
|
|
|
|
|
Hi there,
I'm trying to write a BHO that will intercept the load of any image
on a web page and prevent the images from being loaded.
I've searched through this site and others, and I've only found examples
which rely on waiting for the documentcomplete event to be fired.
The problem in my case is that I'm trying to accelerate the loading of
particular web pages and if I have to wait until the whole document is loaded to remove any images, it's already too late for me -- the user's
already preformed the long and costly download of the images.
How would I go about modifying the HTML content the browser is about to render on the fly as it downloads it? Is that even possible?
(If that's not possible, I might be okay with saving the HTML source to disk, modifying the code to remove any tags and then having my browser
render that temporary file. I'd like it to appear from coming from the same site though.. so for example, if they hit google.com, I'd like the address
bar to still say google.com but render the content from C:\temp\google.htm or whatever.)
Thanks very much in advance for any pointers!!!!
|
|
|
|
|
Laugh if you will, but I am looking for a speedy way of storing arrays of integers into the registry. Let me explain, my app has a listview control with 19 columns. There are 4 sets of data which can be displayed in this listview. Depending on which data set the user chooses, the column widths will change. Therefore for each column (4 * 19) I need to store the width.
I have created a basic function to loop through the column each time the data set changes and to store the values into the registry. Writing 19 values. The problem is, it takes too long maybe half a second each time which is noticable to the user. Can anybody suggest a faster way to do the same job?
|
|
|
|
|
Would it suffice to keep track of the column widths everytime they change, but write them to the registry only when the user exits the app?
/ravi
|
|
|
|
|
I feel like kicking myself, infact I think I will. It is kinda stupid writing to the registry when most of the time the values do not change. I changed the function slightly to write only when the value changes in the mean time keeping track of the values in memory.
Thanks for that.
|
|
|
|
|
Don't kick yourself! Instead, pat yourself on the back. You've just seen the value of "first get it to work, then improve its performance".
/ravi
|
|
|
|
|
I usually go one step further than the above suggestion and store the settings only if the user manually changed them.
Another thing I often do is store all the column settings as a single string with delimeters.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If I start up an MDI application, a new document appears in the
Window. How can I make that new document not appear and instead
an introductionary dialog box appear? I tried redoing the
CDoc::OnNewDocument(), but thats not making the new document not
appear (alot of nots!!).
Please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle Brina
|
|
|
|
|
This will prevent the new document (Put in your application ::InitInstance after ParseCommandLine).
// Added to prevent New Empty Document at startup
if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) {
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
}
|
|
|
|
|
I am inheriting from a template class in order to store strings within a list type of structure, CGenericList.
I would like to call an instance of this class so that I can use its methods within the implementation of the base class.
CSentenceList.h
class CSentenceList : CGenericList<char*>
{
public:
....
CGenericList<char*> Sentences(); //linked list of sentences
};
CSentenceList.cpp
CSentenceList::CSentenceList(char strFileToRead[MAX_SENTENCE_LENGTH + 1], bool bSorted)
: CGenericList<char*> ()
{//initialize}
...
void CSentenceList::readFile(char strFileToRead[MAX_FILENAME_LENGTH])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
fstream fileToRead(strFileToRead,ios::in);
while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
Sentences.Insert(&strLine);
// Error 2228: SentenceList.cpp(34): error C2228: left of '.Insert' must have class/struct/union type
Size++;
}
fileToRead.close();
}
How can I use methods of Sentences? Is it possible to implement it in another way?
Jon
|
|
|
|
|
typically derived class is whatever is base class. in this case derived class is defined as a base class and can access base class functions
template <typename t="">
base
{
public:
b(){}
};
template <typename t="">
derived : base<t>
{
public:
d{}
{
base<t>::b()
};
Kuphryn
|
|
|
|
|
I think that's what I'm doing, but I get compiler error C2228.
Jon
|
|
|
|
|
Just out of curiousity, is there some reason you are not using the string and list (or vector ) classes?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
This is an academic assignment and the tutor discouraged me from using strings, because I can understand arrays of chars more easily I guess. I don't know what vectors are to be honest.
Jon
|
|
|
|
|
jon_80 wrote: This is an academic assignment and the tutor discouraged me from using strings, because I can understand arrays of chars more easily I guess.
Most likely, he (or she) wanted you to understand what actually goes on under the hood of the string class (and those like it). This isn't a bad thing, but you should remember that once you understand what it does, there is no need to reinvent the wheel, and doing so is actually bad practice.
edit: Is this code for an assignment? If so, what are the restrictions on the assignment?
jon_80 wrote: I don't know what vectors are to be honest.
A vector is nothing more than an array. The vector template class wraps an array so that you can dynamically add/remove elements in it without worrying about the details of memory allocation/deallocation for the array yourself.
-- modified at 13:41 Thursday 10th August, 2006
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Btw, any idea on how I can resolve it, please? I'm sorry but as you know I'm quite new to c++... no wonder everyone says it's 'techy' tho
Jon
|
|
|
|
|
Without seeing what else you have defined in your CSentenceList class, I can't even tell you if you are using a decent design.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
CSentenceList.h
---------------------------------------------------
class CSentenceList : CGenericList<char*>
{
public:
//Methods
CSentenceList(char strFileToRead[MAX_SENTENCE_LENGTH], bool bSorted = false);
virtual ~CSentenceList(void);
void sort();
unsigned int search(const char *strSearch);
CGenericList<char*> Sentences(); //linked list of sentences
//Properties
unsigned int Size;
private:
unsigned int searchInSentence(const char* sentence, const char* strSearch);
void CSentenceList::readFile(char strFileToRead[MAX_FILENAME_LENGTH]);
};
CSentenceList.cpp (extract)
---------------------------
SentenceList::CSentenceList(char strFileToRead[MAX_SENTENCE_LENGTH + 1], bool bSorted)
: CGenericList<char*> ()
...
void CSentenceList::readFile(char strFileToRead[MAX_FILENAME_LENGTH])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
fstream fileToRead(strFileToRead,ios::in);
while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
Sentences.Insert(&strLine); //error C2228: left of '.Insert' must have class/struct/union type
Size++;
}
fileToRead.close();
}
Jon
|
|
|
|
|
Hi,
I'm using an active-x control to browse some web pages and part of what I need to do involves not letting it spawn IE windows if a link happens to want to navigate outside of my own browser window. I was finally able to use NewWindow2 to prevent it from spawning new windows, however it did not return the URL the link would have gone to, so I found that NewWindow3 could handle that. Per the docs (http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/newwindow3.asp) there is a BSTR flag that holds the URL of the link that is supposed to be opening. However when I capture the URL I am only getting a line of question marks (like ?????????????????????????????????) instead of the URL I need.
Can someone assist in figuring out how to use NewWindow3 so I can capture the proper URL of the link I click on?
Thanks in advance!
|
|
|
|
|
univega_r304 wrote: However when I capture the URL I am only getting a line of question marks (like ?????????????????????????????????) instead of the URL I need.
In a variable, or in the debug window?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In a variable. This is the code I am using to test....
void CLoadWebSite::OnNewWindow3(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL)
{
// Convert BSTR to CSTring
CString url = "";
VARIANT vnt;
vnt.bstrVal = URL;
url = vnt.bstrVal;
*Cancel = TRUE; // Prevent IE spawning
AfxMessageBox(url); // display popup of url value.
Browser.Navigate(url,NULL,NULL,NULL,NULL); // navigate to url
}
I get the same value if cancel is set to true or false. If it's false, the IE window spawns to the proper link. Both ways the URL is not returned to my variable, it just appears as all question marks.
|
|
|
|
|
univega_r304 wrote: VARIANT vnt;
You need to set the vt member to VT_BSTR .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|