|
I have two classes in a MFC DLL that use AFX_EXT_CLASS to export the classes (like below), but when I link it up to my application and include the header files for the classes I get a lot of errors (error C2228: left of '.Disconnect' must have class/struct/union type) - meaning the functions in the class don't have any code for them... but they should be in the DLL. Here are the classes I am trying to export. Any help would be good on what I am doing wrong, this is my first DLL experience. Thank you.
class AFX_EXT_CLASS CFirstClass
{
}
class AFX_EXT_CLASS CSecondClass
{
}
|
|
|
|
|
Supposing I want to allow the user to supply the file name when creating a file, I am not sure how to do it? I know you can do something similar to this:
#include <fstream.h>
int main()
{
ifstream infile;
infile.open("this_file.txt");
infile.close();
}
What would I use for a declaration to allow the user to name the file whatever they wanted? I hope this is clear enough, I know it is a rather generic question. Thanks in advance.
Nick Parker
|
|
|
|
|
I'm sure if you think about it, the answer is obvious.
#include <fstream>
int main(int argc, char *argv[])
{
ifstream infile;
infile.open(argv[1]);
}
Or, you can ask the user for the name.
int main()
{
string name;
cout << "Enter a filename";
cin >> name;
ifstream infile;
infile.open(name);
}
BTW, there is no need to close the file because it will close automatically when the ifstream object goes out of scope.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
This is really strange, but I get a compile error when I try to do:
<small>Erik Funkenbusch wrote:
</small>int main()
{
string name;
cout << "Enter a filename";
cin >> name;
ifstream infile;
infile.open(name);
}
I can't get that to work, only when I specify the name, I know this sounds really strange. Obviously I am using a char instead of string for declaration, does this sound wierd or do you think I am doing something goofy here? Thanks.
Nick Parker
|
|
|
|
|
Try this it should work fine...
#include <iostream.h>
#include <fstream.h>
void main(){
char name[20];
cout << "Enter a filename" << endl;
cin >> name;
ifstream infile;
infile.open(name);
}
Joshua
Sonork ID: 100.9944
ICQ: 519642
Hotmail: JoshuaJGuy@hotmail.com
|
|
|
|
|
I've created a CDialog dlg and I want it to have a system tray icon.
Also I want to handle the messages that are sent from it (the icon).
the code I've wrote for adding the icon:
BOOL CMyDlg::OnInitDialog()
{
//.....................
//.....................
NOTIFYICONDATA nd =
{
sizeof(NOTIFYICONDATA), //.......Structure size
m_hWnd, //.......................Dialog's HWND
m_nIconID, //....................Icon's ID
NIF_ICON|NIF_MESSAGE|NIF_TIP,//..Flags
SYSTRAY_ICO_NOTIFY, //...........#define SYSTRAY_ICO_NOTIFY 12345
m_hIcon, //......................Dialog's HICON
"The tip!" //....................Tooltip text
};
Shell_NotifyIcon(NIM_ADD, &nd);
return 1;
}
BOOL CMyDlg::PreTranslateMessage(MSG *pMsg)
{
if( pMsg->message == SYSTRAY_ICO_NOTIFY ){
//Call some user defined message handler
return TRUE;
}
CDialog::PreTranslateMessage(pMsg);
}
***************************************************
the SYSTRAY_ICO_NOTIFY is never sent, WHY???
***************************************************
Thanks in advance!
--BlackSmith--
|
|
|
|
|
bar-cochva wrote:
the SYSTRAY_ICO_NOTIFY is never sent, WHY???
hm... 12345 is not the right value for that message!
define it as this:
#define WM_TRAYICON WM_APP + 10
But what you realy should do is to use the CSystemTray class by Chris M here on Code Project! go see that
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Does anyone know of a way to find out what was thrown in a "catch all" catch clause?
The app I'm working on throws all sorts of things in addition to exceptions. I hate having to catch each one.
e.g.
throw TRUE;
throw 3;
throw ErrObject;
Thanks for the help,
Bill
|
|
|
|
|
You can't figure what is cought. That's the catch of catch(...)
|
|
|
|
|
u can combine C++ error handling with C's SEH and u can use SEH to get information abt the exception. Please refer to John Robbins article on SEH and C++ in MSDN Magazine( i forgot the issue ) or his book
Ganesh Ramaswamy
|
|
|
|
|
There's no general way to catch anything throwable inside a try block. However, you can consider the possibility of having your app send an object of generic type, this meaning a class capable of holding values of an undetermined type. This beast indeed exists, and has been implemented in Boost any library (hey, it even works with MSVC++ 6.0). If you follow this approach, all you have to do is replace your throw s with:
throw bost::any(TRUE);
throw boost::any(3);
throw boost::any(ErrObject); Hope this helps.
Joaquín M López Muñoz
Telefónica, Ivnestigación y Desarrollo
|
|
|
|
|
You're probably right about this being the way to go. I was hoping to avoid replacing several hundred assorted throw stmts that are already in the app.
Oh well, Guess I'll get to work!
I appreaciate all the responses.
Thanks for the help,
Bill
|
|
|
|
|
The easiest thing to do is to always throw exceptions using classes that derive from a single "exception" class, similar to how it works in Java. This allows you to always catch any of your exceptions using one
catch(MyBaseException e) statement. I recommend using the std::exception class as your base class.
Regards,
Alvaro
|
|
|
|
|
Thanks for the suggestion. I agree that this is the "best" solution. I was hoping to avoid replacing about 1300 throw's in the existing code base.
Thanks for the help,
Bill
|
|
|
|
|
I don't think I've ever had to cast calls to str{len|cpy| etc..} before.
What's more is that it's an error:
error C2664: 'strlen' : cannot convert parameter 1 from 'unsigned char [256]' to 'const char *'
as used in:
dwLen = strlen(modemInit[i]);
They should be warnings - if anything is to be said at all.
Is there someway for me to set it so I don't have to cast it?
|
|
|
|
|
|
The char type is signed, so an unsigned char* doesn't match a signed char* .
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (133K)
|
|
|
|
|
Hello everybody,
Where can i find good information in order to know how to
automate excel throught VC++6.0.
Thanks for help.
S.
|
|
|
|
|
M S D N - thats it
Ganesh Ramaswamy
|
|
|
|
|
How I can use IMAPI classes? After the installation, I haven't seen the file imapi.idl into directory include. So the Visual C++ compiler give me a link error (LNK2001).
Is there someone that can help me?
Thanks.
|
|
|
|
|
Hi,
I write a program to run some CGI Script in some domain in Internet. I use MSHTML.DLL in my program, so if I distribute my program, I'll distribute this DLL too?
|
|
|
|
|
Hi
I tried to get my app to show Euro, but I failed. I'm
using English Windows with Japanese multilanguage
package. By using GetCurrencyFormat(
LOCAL_USER_DEFAULT ...), I managed to get a yen mark,
according to my windows currency setting. Dollar also
normally works. But when I set my currency to Euro, a
question mark is returned. Could anybody please tell me
how to get the Euro character?
Thank you,
Danny
|
|
|
|
|
Microsoft Says:
---------------
(There is a bug in the original release of Visual Studio 6.0. The dialog editor writes the symbol to the .RC file as WS_EX_LAYOUT_RTL rather than WS_EX_LAYOUTRTL. This should be fixed in a future version of Visual Studio.)
-------------------------------------
The Operating system is Window2000 and Tool is VC++ 6.0. When i set the "Right to left allignment property of a dialog box" and error occured "error RC2104 : undefined keyword or key name: WS_EX_LAYOUT_RTL" which means this symbol is not defined. then i checked the microsoft site and i come to know that it is a bug in VC6.0. To fix the bug i used "WS_EX_LAYOUTRTL" instead of "WS_EX_LAYOUT_RTL"as told me by the microsoft site but now compiler says "WS_EX_LAYOUTRTL" is not defined. so what is the solution of this bug.
Have a nice wishes for helper.
|
|
|
|
|
I think you should install SP5
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
A look in afxpriv.h shows the define. I guess one of the service packs must have added it for MFC use.
Michael
|
|
|
|