|
Thanks for your reply, it helps.
|
|
|
|
|
hi,
I was wondering whether it is possible to set the mapping mode of MM_TEXT in CWnd scrolling functions? It is actually a custom control with a base class of CWnd which display drawing using CDC.
Thanks for any reply
|
|
|
|
|
MM_TEXT is the default mapping mode
|
|
|
|
|
i notice that when i set the scroll range using SetScrollRange function, the range i specify does not equal to mm_TEXT mapping mode. How can i make them same?
|
|
|
|
|
I guess I would need to see the code to understand what the problem context is. I'm probably just misunderstanding what you are asking.
A window will use MM_TEXT by default. This makes it arbitrary to use logical ranges or device ranges since there is a one to one ratio.
If your client area defines a different mapping mode such as MM_HIMETRIC, you have at least two choices...
1) Use logical ranges for the scrollbars
2) Use device ranges for the scrollbar. This requires conversions from one coordinate system to the other. This is much simpler to accomplish with a CScrollView than CWnd in my opinion.
If you are pursuing option 2, then my answer to your question would be that you need to convert your scroll info from LPtoDP before setting the scrollbar info. However, you will likely need to provide more information describing what you are trying to accomplish before anyone can provide you with clear and helpful information.
|
|
|
|
|
Hi, there are hundreds of posts on the internet about this but i still don't get it. I am writing a windows program using the g++ compiler and the RAD C++ library[^]. I get these errors:
WarpFile.o(.text+0x0): In function `ZN11_RADCPP_APP12getBuildTimeEv':
C:/Program Files/Dev-Cpp/include/radc++.h:2182: multiple definition of `_RADCPP_APP::getBuildTime()'
Main.o(.text+0x6a0):C:/Program Files/Dev-Cpp/include/radc++.h:2182: first defined here
WarpFile.o(.text+0x30): In function `ZN11_RADCPP_APP12getBuildDateEv':
C:/Program Files/Dev-Cpp/include/radc++.h:2181: multiple definition of `_RADCPP_APP::getBuildDate()'
Main.o(.text+0x6d0):C:/Program Files/Dev-Cpp/include/radc++.h:2181: first defined here
WarpFile.o(.bss+0x0): In function `ZN11_RADCPP_APP12getBuildTimeEv':
etc...
Can someone please look at my code (here[^]) and tell me what i'm doing wrong. Or alternatively explain how i can prevent this error. I know it's because something has been defined in two object files but i don't know how to stop it
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
I can not see the problem in your code, which implies it may be in the header. I could not figure out how to decompress the library download, so I could not look at “regc++.h” to check if it has code guards defined.
Try moving the ‘#include “regc++.h”’ from the header file ‘common.h’ and only include it in the files that need it.
Beyond that I can not tell why the errors are occurring.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Yes, i fiddled around with the code and merged Graphics.cpp with Main.cpp and made a Main.h where i did the same thing. It eventually worked, probably because, like you said, i only included things in the files that needed it.
btw, the library is "radc++.h" not "regc++.h" and i just remembered that i downloaded and installed it in Dev-C++. But all you need to know it that it is purely based on Microsoft Window API, no external libraries.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
Hello everybody today i was working on a project and was wondering if there is a more efficient way to do this. I have a .txt file with about 90,000 lines of data. The data is separated with tabs to form columns.
For Example:
Year Month Day Hour Income Expenses
90 1 1 1 19950.25 0
90 1 2 10 10.0 1000.22
In your opinion what will be the best way to print only the income column programmability.
I used a for loop and line.find('\t'...) to find the locations of each tab and store the results in an array. I do this for every line because the location of the tab differs from line to line. If there is a faster way I would love to know about it because I'm spending a lot of time waiting for the program to finish.
Thanks in advance.
|
|
|
|
|
When I learned to program we had to write stuff like this – why are you? You should be using the ‘list’ template.
Some of the modern MS languages allow you to ignore the fact that if you use ‘new’ you need to supply a ‘delete’, may be that is the problem. Any thing you allocate you need to deallocate – even in C++.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Are you pre-allocating space for the array or re-allocating each time something new is added to it?
Are you reading in the file a line at a time or reading in each character individually and performing a "find" after each character is read?
************************************
What does the process your using look like? It would greatly assist in finding any obvious inefficiencies.
|
|
|
|
|
Im reading in a line at a time...finding tab's, storing the locations of the tab's in an array then putting the array in a function where it pulls the necessary colums and does statistical analysis on it.
For example:
Line 1:
string line={1 1 1 1000 5}
loc=line.find('\t'...);//put this in array[0] and next tab in array[1]
array[]={location of tabs};
temp.assign(line,array[3],array[4]-array[3]);
at the moment temp=1000
now do something with that
and repeate using line 2 with getline(file,line)
|
|
|
|
|
Code would have been easier to digest but regardless, nothing jumps out that should cause an unreasonable delay. How much time are we talking here?
|
|
|
|
|
Hello, here is the function. The main function gets a line at a time from the file puts the line in the function and the function returns the array of tab positions via array reference. Hope this makes it easier. Thanks
<br />
int get_cols(int (&pos)[50], string line){<br />
<br />
<br />
unsigned int i,loc=0,x=0;<br />
for(i=0;;i++){<br />
<br />
loc=line.find('\t',x);<br />
<br />
if( loc != -1 ) {
pos[i+1]=loc+1;<br />
x=loc+1;<br />
}<br />
<br />
else{<br />
pos[i+1]=line.size();
break;<br />
}<br />
}<br />
<br />
<br />
x=loc=0;<br />
<br />
<br />
return 0;<br />
<br />
}<br />
|
|
|
|
|
I see nothing that would contribute to a noticeable increase in the time it takes to process a line of text. An optimizing compiler would catch and eliminate the few redundant instructions I see.
I'm more familiar with MFC's CString than basic_string or string. CString will not create a new copy of the string when passed into a function by value unless the function modifies the string. I'm not sure if basic_string or string have this ability. If not, you may save a few clock ticks by passing it in by reference but I'm guessing you won't notice or perceive any time savings but it's worth a try...
int get_cols(int (&pos)[50],const string& line){
The only unrelated things worth mentioning are...
the line x=loc=0; is not needed since they go out of scope right afterwards anyway and the function always returns the same value which raises the question whether a return value should even be defined for the function. I would return the column count so the caller could detect an error (i.e. too many columns or fewer than expected)
How long does it take to process a 90,000 line file for you? You may have issues elsewhere in the code if the time is excessive.
|
|
|
|
|
What does the code for reading the file look like?
Do you read the file from a slow media?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
hi!
can someone give me a sample code on how to pass 2 different structs to a function with lpvoid as parameter and how to convert back to the structs from lpvoid.
the structs should be received by the lpvoid... how to combine the 2 different structs together? and how to split the lpvoid back to the 2 structs?
the structs are something like
typedef struct
{ int dataStructCount;
DWORD totalSize;
} strHeader;
typedef struct
{ int num;
lptstr str;
} dataStruct;
the function to receive
func(LPVOID data)
{
// get the structs from data
}
this will be used for writing and reading data from named pipe.. the header will be used to determine the count of dataStruct send/read.
thanks for any help!
newbie
|
|
|
|
|
I have not idea why you would want to do this but:
void func(LPVOID data)
{
strHeader *pH = (strHeader*)data;
dataStruct *pS = (datasStruct*)(data + sizeof(strHeader));
}
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
A better way:
typedef struct
{
strHeader sh;
dataStruct dh;
} myData;
Void func( myData* md)
{
md->sh ….;
md->dh….;
}
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Although I don't know exactly what you are trying to accomplish, I would think you would just want to overload the function with different parameters.
For Example:
<br />
void MyFunction(strHeader tStruct)<br />
{<br />
}<br />
void MyFunction(dataStruct tStruct)<br />
{<br />
}<br />
Dustin
|
|
|
|
|
hi... thanks for the replies!
the idea in having the structs header and data is because the receiving end of the pipe have no idea how many data structs will be sent... thus the header contains the count of data structs. it will be written on the pipe together (header and data) and will be read by the other end of the pipe... the problem i have is how to code it efficiently...
i figured maybe i can just call readfile twice... read the header first and then the data.. since the header will also contain the size of the data struct sent..
for any better ideas pls do reply!
thanks again!
newbie
|
|
|
|
|
ginjikun wrote: i figured maybe i can just call readfile twice... read the header first and then the data.. since the header will also contain the size of the data struct sent..
Often, that's the only way to do it with pipes, sockets, etc. and a protocol that supports
variable length data.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all:
First ,I declare three variables:
IXMLDOMDocumentPtr pXMLDoc;
IXMLDOMNodePtr pNode=NULL;
HRESULT hr;
hr=pXMLDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
hr=pXMLDoc->loadXML(_bstr_t(sPath+"MAPDOMAIN.xml"));
The variable of hr shows that the pXMLDoc has been loaded successfully,and pXMLDoc is not NULL.But,I use pXMLDoc ::selectSingleNode:
pNode=pXMLDoc->selectSingleNode(_bstr_t("MAPDOMAIN"));//MAPDOMAIN is RootNode
The strange thing is that the pNode is NULL ,how can that happen?
My XML file is like this:
?xml version="1.0" encoding="gb2312"?>
<!--njnu-->
<MAPDOMAIN>
<DEVELOPMENTZONEDOMAIN>
<XMIN>135400</XMIN>
<YMIN>155900</YMIN>
<XMAX>141600</XMAX>
<YMAX>161600</YMAX>
</DEVELOPMENTZONEDOMAIN>
<AINDEXINFOFIELDNAME>
<OWNID></OWNID>
<MAPLEFT></MAPLEFT>
<MAPUPPER></MAPUPPER>
<MAPRIGHT></MAPRIGHT>
<MAPLOWER></MAPLOWER>
<UPPERLEFT></UPPERLEFT>
<UPPERRIGHT></UPPERRIGHT>
<LOWERLEFT></LOWERLEFT>
<LOWERRIGHT></LOWERRIGHT>
<INSERTFLAG></INSERTFLAG>
</AINDEXINFOFIELDNAME>
</MAPDOMAIN>
-- modified at 21:23 Saturday 14th April, 2007
|
|
|
|
|
You are assuming the XML document starts at the Document Element. Your XPath should be "/MAPDOMAIN".
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Sorry,I didn't understand very well,do you think the the code
pNode=pXMLDoc->selectSingleNode(_bstr_t("MAPDOMAIN"));
shoud be replaced by
pNode=pXMLDoc->selectSingleNode(_bstr_t("/MAPDOMAIN")); ?
Thanks!
|
|
|
|