|
Well I did try the "extern" keyword and that didn't make any difference. I'm really at a loss, and I guess I'll just have to try and put the impl in the header, which I really didn't want to have to do.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Is the __declspec( dllexport ) hard coded in the header?
If so you might try forward declaring the prototype with
dllimport and try that.
Thank You
Bo Hunter
|
|
|
|
|
nope, I am using the traditional DLL_API kind of macro to shift it to import or export as the case may be.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
How to include a .lib file in a activex control project?
I want to create a ocx project which uses some dll and lib file.
There is not link option in project menu.
How to do it?
Thanks!
|
|
|
|
|
char myOldFileName[99];
char myNewFileName[99];
myOldFileName = "myfilename.sch"
Here's what I need to do:
I take myOldFileName which = "myfilename.sch"
and set myNewFileName = "myfilename.cfm"
then I need to take myNewFileName and set it = to myfilerocks.cfm
the problem is I get little smiley face characters when I do it
so it becomes myfilenamerocks .cfm (not really that smiley face, the ascii one).
I'm using Visual c++ 4.2.
|
|
|
|
|
you can't assign stuff like that in C/C++;
try using either strcpy (bad, IMHO), or std::string (good). If you use std::string, it becomes:
#include <string>
std::string myOldFileName;
std::string myNewFileName;
myOldFileName = "myfilename.sch"
myNewFileName = "myfilename.cfm"
if Visual c++ 4.2 doesn't support STL (I have no idea if it does, though I'd love to know why you are stuck using it ), then you'll need to use strcpy (or even memcpy).
Cheers
Jim
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Jim,
the problem is 4.2 doesn't use strings. (as far as I can tell anyway)
I used strncpy to set mynewfilename = myoldfilename,
the problem I'm having is then manipulating mynewfilename.
I know in newer versions I can do an object.replace(...) but not on 4.2
I've broken it down by position number (ex: myoldfilename[x]) but that's where I start getting the smiley faces for some, but not all, of the characters.
----------------
why are we still on 4.2? because years ago someone decided it would be
too much work to upgrade to a newer version. Since then it's never been a priority. Luckily, that's about to change. In fact, I've got .net training next week and with any luck will soon leave 4.2 behind.
|
|
|
|
|
shaveyourhead wrote:
n fact, I've got .net training next week and with any luck will soon leave 4.2 behind.
Cool. Well if after that you still do C++, I can't emphasize enough how worthwhile it would be to replace this kind of code with std::string (or std::wstring if you need wchar_t support). It's just much less hassle and looks cleaner too.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I got it figured out.
null terminated string was the cause
needed to set mystring[x] = 0;
and voila! no more smiley faces on the screen.
Just a big smiley face on me.
|
|
|
|
|
I really need some help with this one. I am new to the computer world, I am a college student and I am currently taking a course that covers object oriented programming. I needed help in trying to figure out how to start it. If anyone reads this please help me. Thank you for taking the time to read this. Below I have provided the criteria for doing the assignment and see if anyone may know how to do it, because I DON'T!!!.
Objectives:
You are to write a program that simulates the operation of a calculator. The calculator will perform the simple arithmetic operation of add, subtract, multiply, and divide. The user will be allowed to invoke methods to get data from the user (i.e., the operands), perform a given type of calculation, and to display the result.
Specific Instructions:
1. Define the class -- Calculator
a) Data members: Operand1, Operand2, and Answer -- all of type float.
b) Methods: Constructor, GetData, Add, Subtract, Multiply, Divide, and ShowAnswer -- all void return types.
c) Data members should be private, but all methods should be public
2. Constructor -- Calculator
a) The constructor should provide for two arguments of type float: Op1, and Op2
b) Give default values of zero to Op1, and 1 to Op2 in case the user passes no arguments when objects are created.
c) The constructor should assign the values of Op1 and Op2 to Operand1 and Operand2, respectively.
3. Each method that does a calculation should store the answer in Answer but not do any output itself.
4. The ShowAnswer method is responsible for displaying the calculated result of the last calculation.
5. Create four objects, Problem1, Problem2, Problem3, and Problem4 as follows:
Calculator Problem1(3,7), Problem2(8,3), Problem3, Problem4(17,5);
6. Do the following method calls: (YOU MUST FOLLOW THESE INSTRUCTIONS!)
a) For Problem1, call the method that will add the default values, and call the method to display the result.
b) For Problem2, call the method that will subtract the default values, and call the method to display the result.
c) For Problem3, call the method to get data, provide values of 7 and 3, multiply them, and display results.
d) For Problem4, call the method that will divide the first operand by the second, and display the results.
Jonathan
|
|
|
|
|
You're getting a 1 vote because this isn't the place to post homework assignments. Grow up, grab yourself buy the balls, get some hair on your chest, and make a good faith effort to do the work *first*, then come back and ask *specific* questions, *after* you have made the effort to try and learn/solve the problem. Otherwise sod off.
Cheers and have a nice day!
Ooh and remember, chocolate milk is good for you, Reading is actually helpful, and Google is your friend.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Mr. Crafton, I was not trying to pass of my homework on anybody, I was simply asking for someone to help me with a starting point. The reason that I am taking this course because it was one of the few that was left, I had to register late for classes due to a outstanding balance, that until recently I could even pay for. If I knew what to do even after reading the chapter, which I did, I wouldn't have asked for help. I tried to start it and it was completely wrong, the assignment is one that I have yet to even do in my previous computer classes. Therefore, I would appreciate that you not post something like that under my message, when I am trying to find someone to help me, if you have no suggestions please don't bother posting.
And you too have a nice day.
Jonathan
|
|
|
|
|
Don't get so uptight, Jonathon. Folks post homework questions here at least once per week. Sometimes they are well received, other times they are not. Several factors are involved.
Like most, I do not mind helping, but I need a show of good faith that you are actually doing the work and only asking for help when you are stuck. It helps no one for a homework assignment to be posted verbatim and ask others to do it for you.
Are others in your class having like difficulties? Does the instructor favor going to him/her for "getting starting" questions such as yours?
A much better approach is to take your assigmnent, break it up into smaller pieces and ask for help with those individually, perhaps even rewording the text so that it longer resembles homework. This is much better than trying to get help for the assignment as a whole, which will either get you ignored or flamed.
DHAPPREP wrote:
I tried to start it and it was completely wrong...
Show us what you have and we can critique it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
You got flamed, that's normal because no one likes to answer yet another homework question.
I will though, give you some hints to start of...
1. Define the class -- Calculator -> see your book, if you can't do this, don't even start.
a) Data members: Operand1, Operand2, and Answer -- all of type float. -> create three variables of type float, that should be do-able
b) Methods: Constructor, GetData, Add, Subtract, Multiply, Divide, and ShowAnswer -- all void return types. -> actually, C++ consists of functions, but anyway, a function does something with your variables. The constructor normally initializes your variables, I suspect GetData will analyze the input. (take in input, put the first number in operand1, the second in operand two and decide if you have to add/substract/... [EDIT]Reading further I see this is not the case, I have no idea what it should do[/EDIT]
c) Data members should be private, but all methods should be public -> who-ever tells you all functions should be public is a moron. Only make public those things that you want other classes to see. Constructor, GetData, Add, Subtract, Multiply, Divide, and ShowAnswer are good to make public in this case.
2. Constructor -- Calculator
a) The constructor should provide for two arguments of type float: Op1, and Op2
public Calculater(float Op1 = 0, float Op2 = 0){ ... }
b) Give default values of zero to Op1, and 1 to Op2 in case the user passes no arguments when objects are created. -> see a)
c) The constructor should assign the values of Op1 and Op2 to Operand1 and Operand2, respectively.-> I hope you can do this
3. Each method that does a calculation should store the answer in Answer but not do any output itself. Answer = Operand1 +,-,* or / Operand2
4. The ShowAnswer method is responsible for displaying the calculated result of the last calculation. -> that would be something like cout >> Answer= >> endl; // make it nicer then this
5. Create four objects, Problem1, Problem2, Problem3, and Problem4 as follows:
Calculator Problem1(3,7), Problem2(8,3), Problem3, Problem4(17,5);
->this will create your Object
6. Do the following method calls: (YOU MUST FOLLOW THESE INSTRUCTIONS!)
a) For Problem1, call the method that will add the default values, and call the method to display the result. Problem1.Add(); Problem1.ShowAnswer();
b) For Problem2, call the method that will subtract the default values, and call the method to display the result. -> cf a)
c) For Problem3, call the method to get data, provide values of 7 and 3, multiply them, and display results.-> cf a)
d) For Problem4, call the method that will divide the first operand by the second, and display the results.-> cf a)
You're extremely lucky I'm bored for the moment .
So: define your class, with all the functions, then call the class from your main.
If you succed, you can always try to input the numbers yourself, making an interactive calculator.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
V. wrote:
actually, C++ consists of functions...
True, but when they belong to a class, they are called methods.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DHAPPREP wrote:
1. Define the class -- Calculator
a) Data members: Operand1, Operand2, and Answer -- all of type float.
b) Methods: Constructor, GetData, Add, Subtract, Multiply, Divide, and ShowAnswer -- all void return types.
c) Data members should be private, but all methods should be public
Here is a starting point:
class Calculator
{
public:
Calculator( float Op1 = 0.0, float Op2 = 1.0 );
void GetData();
void Add();
void Subtract();
void Multiply();
void Divide();
void ShowAnswer( void );
private:
float Operand1;
float Operand2;
float Answer;
}; DHAPPREP wrote:
5. Create four objects, Problem1, Problem2, Problem3, and Problem4 as follows:
Calculator Problem1(3,7), Problem2(8,3), Problem3, Problem4(17,5);
Since your class works with floating-point numbers, I think it would make sense to also test with floating-point numbers rather than just integers.
Calculator Problem1(17.2, 9.07),
Problem2(0.8, 3);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hint :
Calculator::Add()
{
Answer = Operand1 + Operand2;
}
It doesn't get much simpler!
|
|
|
|
|
Hi, I wonder if anyone could could help me with a Win32 coding problem. I was trying to program a notepad clone that supported encryption. The problem is that I have an EDIT control, initially set up using WS_HSCROLL and ES_AUTOHSCROLL as part of the windows style. This allows the text to scroll without word wrapping. In order to toggle word wrap on and off, I simply use SetWindowLong to set the window style with the WS_HSCROLL and ES_AUTOHSCROLL bits set to diable word wrapping, and with them unset in order to word wrap. This nearly works. Swapping between the two modes gets rid the horizontal scroll bar, as it does in notepad, but the text does not change. If I start with the word wrap set, then the text wraps as it should. After changing modes however, the Hscroll bar appears, but the text continues to wrap. Likewise, if I start with the text wrap off then the text scrolls when typed, but switching modes means that the scrollbar disappears but the text does not start wrapping.
Using MessageSpy to see what notepad does I saw that it destroyed the old Edit and created a new one with the appropriate windows styles set. Is there no way to change the wrap mode without destroying the edit? I wrote my own word wrap function and set it using the EM_SETWORDBREAKPROC message, but it is never called.
If anyone knows of any simpler way to switch in and out of word wrap I would be grateful to hear of it.
Many thanks, Jan
|
|
|
|
|
Have you tried calling
DWORD flags = SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
SetWindowPos( editHwnd, NULL, 0, 0, 0, 0, flags );
I know that the only way to get certain window style settings to take effect is to call SetWindowPos() like this. Hope this helps!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hi, and thanks for the reply. I didn't mention in my parent post, but I DID already have that code at the bottom of my function. I needed it to display the HSCROLL appearing or disappearing, but it does not help with the problem of word wrapping.
|
|
|
|
|
I copied my project from a Windows 2000 PC to a Windows XP PC, but now I get a load of compile erros and I a completely at a loss to why
Visual Studio 7.1 is installed on both PCs.
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1553): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1560): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1633): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1640): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1647): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1655): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1671): error C2059: syntax error : ')'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinNT.h(340): error C2143: syntax error : missing ';' before '*'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(204): error C2143: syntax error : missing ';' before '*'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(205): error C2143: syntax error : missing ';' before '*'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1620): error C2143: syntax error : missing ';' before '__stdcall'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1628): error C2143: syntax error : missing ';' before '__stdcall'
Does anyone know the cause of these errors, they have been no code changes.
grahamfff
|
|
|
|
|
The problem is plainly in the Windows SDK, perhaps you had a different SDK installed on one machine ? Either way, have you looked at the lines being complained about ? How about the project settings, are they unchanged ? The code that's blowing up shouldn't be, but it's not your code, either way. Having said that, the C++ compiler can report some weird errors, relative to what the real problem is...
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I had this happen at work. It "appeared" that the header was screwed up. In the end it got written up to a bad hard drive, which eventually got replaced, and later on I got a new system out of it! 3 cheers for MS!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Grahamfff wrote:
CodeProjectForum problems or suggestions?
I copied my project from a Windows 2000 PC to a Windows XP PC, but now I get a load of compile erros and I a completely at a loss to why
Visual Studio 7.1 is installed on both PCs.
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1553): error C2059: syntax error : ')'
...
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1560):
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(1628): error C2143: syntax error : missing ';' before '__stdcall'
Hello,
I got the same scenario also when I moved from Win2K to WinXP, and the problem was with old projects that did not define the corresponding preprocessor macros that are generated on a new stdafx.h file, for example: (I'm not sure which one of the #defines fixed my problem)
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define _AFX_ALL_WARNINGS
Look on Using the Windows Headers[^] in the MSDN docs.
Hope this solves your problem.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
The last thing I did on my Windows 2000 PC was to clean the project.
I have tried the above but still no luck.
This is mad, projects should be movable between PC's and Windows versions.
Completely
grahamfff
|
|
|
|
|