|
Did you find the solution for this problem? If so please let me know.
Thanks.
|
|
|
|
|
Hi
I am currently building an app that maintains a number of objects of a certain class, and the app performs computationally heavy calculations to determine the state of each object. The state for each object is determined by a number of variables: e.g. variables A, B, C, and D. However, since some of the variables, e.g. variable A is actually identical for all objects, I am now implementing A as a private static variable with a public accessor function. This way, I think I can save some computation and storage space.
My question is: is this the correct way to implement the class? Is building a base class and deriving from it better than my current solution?
Thanks!
|
|
|
|
|
hi indrawati,
in your case, the important thing is that what do your variables do. if there are required to be common for all the objects of the particular class, ie they share the same values, then u will have to use them as static. if this is the case then there should be no problem in the design
|
|
|
|
|
I am developing an application in VC++. I am using Read function of CStdioFile class to read Html files and storing the file contents in CString object. Special characters like TM, are being replaced by three characters â„¢ What can be the reason? & how to read such characters in VC++ appliction.
Arvind
|
|
|
|
|
Arvind Jagtap wrote:
I am using Read function of CStdioFile class...
Read() is actually a method of the CFile class. Since .html files are just text, shouldn't you be using CStdioFile 's ReadString() method instead? I guess it depends on what you are doing with the data after it has been read.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi David,
You are right. CFile has Read function and CStdioFile is derived from CFile. I used ReadString function of CStdioFile also. But still I am not able to read the special character ™ properly. This character is present in Html file name and its corresponding folder name. So this character is also present in Html file contents as the folder name appears in Html file many times.
I want to get the images present in Html file. I am parsing Html files and SRC attributes of tags. But the relative path contains ™ character. After reading this Html file by using any method (Read/ReadString), this character splits into three characters â„¢ and relative path of image becomes invalid and program fails. So I want to know why this happens and is there a workaround for this problems.
Thanks & regards,
Arvind
|
|
|
|
|
Hi David,
For example you can browse the following link and save this as an Html file on your Hard Disk. You will find ™ character in it. Try to open this file by using CStdioFile/CFile class, and read the contents of file. ™ character splits into three characters. If you find any solution please let me know.
http://products3.3m.com/catalog/us/en001/auto_marine_aero/aerospace/node_GSCT5B6VLBbe/root_GST1T4S9TCgv/vroot_GSNNJ6NQDKge/gvel_JTZPWXR1L1gl/theme_us_aerospace_3_0/command_AbcPageHandler/output_html
One more strange observation. If you try to save this file at another location in Hard disk (by using save as option), it can't save. I think becuase ™ character, this is happening.
Thanks and regards,
Arvind
|
|
|
|
|
Arvind Jagtap wrote:
Try to open this file by using CStdioFile/CFile class, and read the contents of file. ™ character splits into three characters. If you find any solution please let me know.
This worked fine for me:
CFile file("c:\\3M Aerospace 3M™ Heavy Duty Cable Ties.htm", CFile::modeRead);
TCHAR sBuffer[1024];
DWORD dwBytesRead;
do
{
dwBytesRead = file.Read(sBuffer, sizeof(sBuffer) * sizeof(TCHAR));
} while (dwBytesRead > 0);
file.Close(); While the VS editor did indeed show a "block" character right after the second 3M, its value was interpreted correctly.
Arvind Jagtap wrote:
If you try to save this file at another location in Hard disk (by using save as option), it can't save. I think becuase ™ character, this is happening.
Nope, saved fine.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello,
Trying to write a program in C++ that will do the following:
1)Input a string of characters from the keyboard, (up to 20 char max.) Allow the user to enter up to the length of the string (20).
2) Print the string out as entered.
3) Count the number of vowels (incl. upper and lower case)
40 Count number of spaces in the string
Count the number of digits in the string
60 If the string does not include vowels, spaces or digits, then print a zero for its count.
My background is not in C++ so if anyone could help this would be appreciated.
|
|
|
|
|
I supposed you are writing a console application right?
bctuthrcls wrote:
1)Input a string of characters from the keyboard, (up to 20 char max.) Allow the user to enter up to the length of the string (20).
Use _getch . It gets a character from the console without displaying it. You can then use it to limit the number of characters user can enter.
bctuthrcls wrote:
2) Print the string out as entered.
cout
bctuthrcls wrote:
3) Count the number of vowels (incl. upper and lower case)
Hmm, what u mean?
bctuthrcls wrote:
40 Count number of spaces in the string
Use a for loop to check for the space character
bctuthrcls wrote:
Count the number of digits in the string
Same as above. Use isdigit(...)
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
Brother this is code for your program
hope it work
<br />
void main();<br />
{<br />
int nLength=0;<br />
char *szData;<br />
cout<<"\nEnter he Length of string : ";<br />
cin>>nLength;<br />
szData=new char[nlength+1];<br />
getline(szData,nLength);<br />
cout<<endl<<"YOu have enter : "<<szData;<br />
int Vowels=0,Spaces=0,Digit=0; <br />
char ch=0;<br />
for(int i=0;i<nlength;i++)<br />
{<br />
if(isDigit(szData[i]))Digit++;<br />
if(szData[i]==char(32))Spaces++;<br />
ch=toupper(szdata[i]);<br />
if((ch=='A')||(ch=='E')||(ch=='I')||(ch=='O')||(ch=='U'))Vowels++;<br />
}<br />
cout<<endl<<"NO Of Vowels : "<<Vowels;<br />
cout<<endl<<"NO Of Spaces : "<<Spaces;<br />
cout<<endl<<"NO Of Digits : "<<Digit;<br />
<br />
getch();<br />
}
pls remove some compiler error if occur
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
tiziacaia wrote:
When I add the object library for MS Word the file "msword.h" isn't created.
The example uses "msword8.h", which is for Word 97 (versions 8). The version number will be different; I believe it will be version 11, although I haven't tested it. Try "msword11.h" instead - or look for a similar file in your project directory.
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"
|
|
|
|
|
I tried with "msword11.h" too but don't work. In the project directory there aren't files with similar name.
I don't understand where i miss.
Thaks.
|
|
|
|
|
When you want automation, you need to read a lot about it. I don't have experience with it myself, but I have written an application calling Word and it doesn't have an msWord.h file.
You have to import a sort of Object or component from your Word program. Every Microsoft Office version has another one. (you can find which one on msdn.)
Only advise I can give you is read and search.
PS: For Office 2003 it's not MSWord11 but MSWORD
I think you need the MSWORD.OLB file (somewhere in your office directory)
good luck and I hope this helps at least a little.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I'm trying to get work this example
Microsoft example[^]
When I add the object library for MS Word the file "msword.h" isn't created.
I'm using Visual c++ .net and Word 2003.
Somebody can help me?
Thanks a lot!
TiziaCaia
|
|
|
|
|
/* I have spent the last few days reading the articles on dlls and am still as lost as when I began.
If anyone can point (kick) me in the direction that I need to solve this problem I'd be grateful.
*/
All I want to do is to place a bitmap into a dll.
Then from my exe call the resource for usage. eg LoadBitmap(IDB_BITMAP)
/* So whats the best way of going about doing this?
Some working sample code would be great
*/
|
|
|
|
|
off the top of my head
1) call LoadLibrary to load the dll
2) call LoadBitmap passing the handle returned from step 1
HINSTANCE hMyDll = LoadLibrary("Somedllwithbitmap.dll")
ASSERT(hMyDll);
HBITMAP hBmp = ::LoadBitmap(hMyDll, MAKEINTRESOURCE(IDB_SOMEBMP));
ASSERT(hBmp);
CBitmap *pBmp = CBitmap::FromHandle(hBmp);
use pBmp
//clean up not so sure about this bit, check the doco
delete pBmp;
FreeLIbrary(hMyDll);
|
|
|
|
|
Ok, I had been doing something similar without success,
maybe I didn't make the dll correctly to start with.
Thanks for your help.
|
|
|
|
|
since this a VC++ forum, you can use your VC++ to create a windows dll and export the dll function.
I am sitting in my flame proof buncker, so don't even bother.
by the way, perl stinks.
|
|
|
|
|
that sounds way over my head in ability I'm afraid.
|
|
|
|
|
you'r going to have to learn....here are a series of beginner tutorials.
I am sitting in my flame proof buncker, so don't even bother.
by the way, perl stinks.
|
|
|
|
|
Hi there,
I have some variable-height controls which need to have some vertically-centered text written on them. My question is: knowing the height the text should occupy, what do I have to do in order to create a point-font?
Thanks a million,
David
|
|
|
|
|
Not really sure what you mean with a point-font, a a font in typographical points? Why not use the height of the control, deduct some margin and create the font with CreateFont using the resulting height?
|
|
|
|
|
Hey there!... and thanks for the reply.
I take it then that there is no way to use the simple BOOL CreatePointFont( int nPointSize, ...) function? I was wondering if there was a way of converting point-size to LP?
David
|
|
|
|
|
Well there is. You get the client CDC , call GetDeviceCaps(LOGPIXELSY) to get the vertical resolution per inch of the output CDC . After this, you divide the result with 72, and gets the height in pixels for a typographical point (you'd obviously have to use double values to do this). Finally, you divide the height of your control with the number of pixels-per-typographical-points calculated, and you're home.
Far easier to just use the height from the beginning
|
|
|
|