|
This is medium is to slow.
I assumed it was done every while loop, but what you have just posted still does not show it. What you are showing is how you are using it after it has been assigned. How are you assigning it; What line of code show us what ‘p_strToken’ is pointing too? This may not help me or anyone else solve the problem, but it may help you to do so; as that my be where the problem lays.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Sorry for my poor grammar, when I get online the English language starts looking like a second language to me.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I know but it irritates me when it type things like “This is medium is to slow.”. What the <blank> is that? It sounds like I am trying to translate from another language.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Norm,
The piece of code you are showing me shows how it is used after ‘p_strToken’ is assigned to point to a variable of type CString. If you are not assigning it, making it point to a variable of that type, before you use it then the only thing that is saving you from a systems crash is because modern systems have the option of only crashing your application. This line of code 'CString * p_strToken = NULL ' says that it points to nothing and this line of code '*p_strToken += ch; ' says we assume that it is pointing to something. The question remains that you have not shown any code where you assign ‘p_strToken ’ to point to anything but air, which means the line you highlighted will probably cause the compiler to give an error message. If it does not then something bad usually follows, other than the garbage output you mentioned.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi having a bit of trouble here using CMap...
So here is where it all begins, from application start routine:
PropertyFileReader o_Reader;
if(o_Reader.Load(sFileName))
{
CString sProperty1 = o_Reader.GetProperty("Property1");
...
...
}
PropertyFileReader's Load method is as such:
BOOL PropertyFileReader::Load(CString sFileName) {
BOOL bSuccess = TRUE;
CString * p_strToken = NULL;
CString csKey;
LPCTSTR pKey;
CString csVal;
LPCTSTR pVal;
... code ...
BOOL bEndOfLine = FALSE;
...
oFile.Open(sFileName, CFile::modeRead);
rowNo = 0;
columnNo = 0;
while(oFile.Read(&ch, sizeof(char)) > 0) {
... code ...
if(columnNo==0) {
if(p_strToken!=NULL) {
delete p_strToken;
p_strToken = NULL;
}
p_strToken = new CString();
}
if(ch!=13 && ch!=10)
{
*p_strToken += ch;
}
... code ...
bEndOfLine = ( ch == 10 || ch == 13);
if(bEndOfLine) {
p_strToken->TrimLeft();
p_strToken->TrimRight();
if( ((CString) *p_strToken).GetLength()>1) { // skip blanks at the end of each line in input file
index = p_strToken->Find('=', 0);
if(index> 0) {
// QUESTION: Option 2 works but don't understand why Option 1 does not.
// OPTION 1: This will NOT work - when GetAt some of the values will become jibberish
pKey = p_strToken->Left(index);
pVal = p_strToken->Mid(index+1);
// OPTION 2: This works. I don't know what's the difference ...
csKey = p_strToken->Left(index);
csVal = p_strToken->Mid(index+1);
lstProperties.SetAt(csKey, csVal);
}
columnNo = 0;
rowNo++;
bEndOfLine = FALSE;
}
} else {
columnNo++;
}
}
... mode code ...
oFile.Close();
return TRUE;
}
And to lookup property from a CMap:
CString PropertyFileReader::GetProperty(CString csKey)
{
CString csVal;
oProperties.Lookup(csKey, csVal);
return csVal;
}
In PropertyFileReader class:
class PropertyFileReader {
...
void Load(CString sFileName);
CString GetProperty(CString csKey);
...
CMap<cstring, lpctstr,="" cstring,="" lpctstr=""> oProperties;
...
}
Many thanks and sorry about the correction.
|
|
|
|
|
norm wrote: Option 2 works but don't understand why Option 1 does not.
How you are verifying this ? Have you used lookup to check back at some point of time ?
norm wrote: // OPTION 1: This will NOT work - when GetAt some of the values will become jibberish
Can you explain this ? GetAt is not member of CMap , isn't it ?
|
|
|
|
|
Can you show , how your code would look like with lookup ? Because, its should not be difference with option1 and option2 in you case.
Probably, its key , which is culprit while retrieving value back.
|
|
|
|
|
First come....;)
Hello, I have a question....
I try to convert a html to bmp.
(First of all, put the html file in a WebBrowser, and then paint to a bmp.)
The html file is big, when convert,
there is a warning - the memory is not enough.
Maybe I should try to part the html file.
I donnot know which function can do this....
e.g,
I tried those functions below, but show memory error......
SendMessage(
hw, // Handle of webBrowser
WM_PRINT,
(WPARAM)bmp->Canvas->Handle,
PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_OWNED
);
pViewObject->Draw(
DVASPECT_CONTENT,
1,
NULL,
NULL,
hw, // Handle of webBrowser
bmp->Canvas->Handle,
(LPRECTL)&Rect,
NULL,
NULL,
0
);
e.g,
English is hard to learn...
|
|
|
|
|
I can not help you, but I would like to point out that html is not an image format. That is it is a text format (or syntax) that tells the browser how to display some information to the viewer (user). It is possible to take snapshots of portions of the displayed results, but converting the whole thing to a bitmap is a major undertaking.
I admit that as simple as your code appears, I do not understand what it is attempting to do. You can use your browser to view the source code it that will help you. There are also some tools online that may be of use; try visiting ‘Google’ or ‘SourceForge.net” and see what you can find.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Do you want to get bmp file of a html page?
|
|
|
|
|
No, it's not to get the pictures from the web.
It is to convert the whole html page to image、bmp or Jpeg. (Yes, it's like the snapshot.)
I've already can "Draw" a html to bmp, with anyone of the functions given,
but it's only to html which is not very big.
I think it must have sth to do with the clipboard.
|
|
|
|
|
It looks like you posted this message as a reply to your self and I am assuming that you where trying to reply to me. I am sure that I do not have the answer, although it is possible that I do not understand the question.
You say that you can draw it to bmp but it is only to html, which is not the same thing. A bmp is basically a bunch of pixels (dots/pels/points) that can be displayed on a screen. Html is a language that describes what is to be displayed and more.
If you copy it (which is stored on the clipboard) then you will get a copy of the html file, which is just another text file. The reason for this is that it is just another text file and not a bitmap image. Every thing you see on your display is a bitmap image that has been created or loaded by the operating system (or application) and therefore when you make a copy you get a copy of the description or the image, depending on what form it was originally presented to the system.
I do not know exactly what you are looking for because a bunch of pixels does not tell you anything truly useful.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
In cliboard, it's not a text, it already became a image by GDI function.
Not only html, other formats can be convert to image too.
|
|
|
|
|
Well [blank] if you have a bitmap image on the clipboard then you can copy it to any program that accepts them. If your program does not then it is in your code and you already know that.
Any format that can be translated into a displayable (still) image can be converted to bmp, it is just that sometimes you have to steal them with other code because the code that does the translation does not provide that function.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
|
Oh ~Thx!
But I cannot use "DrawToDC" successfully, it always causes error in "QueryInterface()".......
It seems that it is not refer to the size of html?
|
|
|
|
|
I have written a basic program using MFC. the project name was mfc3.sln. I created it with the style: An empty project. I wrote all codes myslef. somewhere in my program, I have called AfxMessageBox(...). but my project's name appears in messagebox's title bar. how does messagebox know what is my project's name?
|
|
|
|
|
All the source code for MFC comes with your compiler. I quick look yields the fact that the main code behind AfxMessageBox is in the function CWinApp::ShowAppMessageBox . The following is copied from this function:
TCHAR szAppName[_MAX_PATH];
szAppName[0] = '\0';
LPCTSTR pszAppName;
if (pApp != NULL)
pszAppName = pApp->m_pszAppName;
else
{
pszAppName = szAppName;
DWORD dwLen = GetModuleFileName(NULL, szAppName, _MAX_PATH);
if (dwLen == _MAX_PATH)
szAppName[_MAX_PATH - 1] = '\0';
}
So it uses the m_pszAppName pointer in your project's CWinApp derived class or the name of the .EXE itself.
If CWinApp is used it's set like this:
CWinApp::CWinApp(LPCTSTR lpszAppName)
{
if (lpszAppName != NULL)
m_pszAppName = _tcsdup(lpszAppName);
else
m_pszAppName = NULL;
.
.
.
Steve
|
|
|
|
|
Stephen Hewitt wrote: All the source code for MFC comes with your compiler.
Actually it does not, the majority of it comes with the compiler. I learned this by digging very deeply into the code trying to find the source of a particular piece of information and ran up against a road block. That is the ultimate source of the information was outside of the code given us to look at.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi all,
i am having this lil doubt over pointers. In some books and links its said that its same i.e both means that it is pointer to character which holds the contents of the character type variable.
Please let me knw what is correct. I am so confused about this issue...
Thanks in advance...
|
|
|
|
|
You are right. Both are the same.
It is just a stylistic difference. Proponents of char* p say it emphasizes that the type of p is a pointer to a character. Proponents of char *p say it minimizes confusion with the syntax of C/C++. For example:
char* p, n, x;
char *p, n, x;
char* p, n, *x;
char *p, n, *x;
If you can't tell, I prefer the "char *p" syntax.
HTH,
Mike
|
|
|
|
|
ok gr8...
Now its making some sence ....
What do you understand by the below piece of code ..
class linklist
{
private:
struct node
{
int data;
node *link;
}*p;
So here link is a variable of type structure and node *link gives out the contents of the address of type struct node ..that means its giving the value stored in link. But what is this *p after the close bracket.
Pls correct me if i said something wrong....and pls tell me about this *p...
Thanks a lot
|
|
|
|
|
CS assignment?
Link is defined as a "node *" -- remember, node* p and node *p are equivalent. So that would not make link a variable of type structure but of type pointer to structure instead.
The *p is a shortcut syntax in C... it declares p to be a pointer to a node.
This is why you must place a semicolon after a struct or class declaration - otherwise it treats the struct {} as a type and the next token the variable name. So you could do:
struct {int x, y;} pt;
And then later you could access pt.x and pt.y . The type of pt would be called an "anonymous struct" since it has no name. I could have written:
struct POINT {int x, y;} pt;
and then pt would be a POINT structure.
Mike
|
|
|
|
|
That was I little confusing even for me. Let me clarify a little bit for ‘Software_Specialist’.
pt is a variable of type ‘struct POINT’.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
ah... right.. Thanks.
Sorry about that.
|
|
|
|