|
Dude, there's not near enough pictures on that page.
|
|
|
|
|
Well, if we assume that "a picture is worth 1000 words," there's more than enough.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i want ro make a program to get input from parallel port and identify the input to perform function of key on keyboard.
i know how to get the input from the parallel port... now if i want that windows must act as if "windows key" of "capslock" key is presssed for particular input value how should i do that... how to instruct the os to perform function of a particular key or keys???
|
|
|
|
|
|
I have application that uses a serial port and I/O card. The application starts up add attempts to initializes the serial card and I/O card. If either of them fail and would like to throw an exception telling the user that corresponding object failed and terminate the applications. How do i accomplish this?
I have tried to use throw (" Unable to initialize Serial Port" ); However, it does not display my string. It does terminate the application but, the user is left clue unless..
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
If you want to implement something quick & throw just strings you can use std::exception
void main()
{
try
{
std::exception ex("My error");
throw ex;
}
catch(std::exception& ex)
{
cout<< ex.what();
}
}
The best way is to design your own exception class to deal with different cases -or even a struct, As C++ is quite flexible when it comes to throwing something
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Oops sorry. I was too quick to respond. If you want to catch any exception and then throw a meaningful one , you should do like
void IOReadFuntion()
{
try
{
}
catch(...)
{
std::exception ex("Error while reading port");
throw ex;
}
}
void main()
{
try
{
IOReadFuntion();
IOWriteFunction();
}
catch(std::exception& ex)
{
cout<<ex.what()
}
}
Signing off. good night!
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Vunic,
I am not using a console application. I have MFC application and when i throw and exception it creates window that say Microsft Visual C++ Runtime Error. It has big red x and Has the path of the exe that failed, along with a string telling the failure. I wanna use my string instead of the generic string provided.
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: when i throw and exception it creates window that say Microsft Visual C++ Runtime Error.
No way, when you throw your own exception. And if you are handling it, it should work. Try this one. No matter it is console or dialog.
try
{
std::exception ex("MyExeception");
throw ex;
}
catch(std::exception& ex)
{
AfxMessageBox(ex.what());
}
btw, if you want to catch any unhandled exception, you could try SetUnhandledExceptionFilter()
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Why use an exception? Why not just attempt to initialize the serial card and return an error code on failure? I actually have code that does exactly that (our system uses a lot of serial ports.) Most our code doesn't use MFC, but the few programs that do, I do this check in the InitInstance() function. On failure, it pops up a message box explaining the failure.
(For some applications, I return a resource ID of the error string; in others just a bool indicating success or failure--it all depends on the requirements.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I'd second Joe's reply - why on earth are you using exceptions for this.
A serial port being unavailable is by its nature a normal thing. Not exceptional at all!
Why not:
BOOL CMyDialog::InitialisePort (UINT nComPort, CString &Error)
{
...
if (!...)
{
Error = _T(" Unable to initialize Serial Port" );
return FALSE;
}
...
return TRUE;
}
?
I can't think of a single place I've written a throw command. I've written a few catchers for other people's libraries, so I'm not a exception virgin - just not a fan.
Good luck with your application,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hello all,
Is creating a DLL with Visual Studio the same as creating a Module Definiton File?
I don't see the option to create this file after right-clicking the source file folder, and hitting 'Add New Item' in the Solution Explorer.
Thanks
|
|
|
|
|
Found it!!!
http://www.functionx.com/visualc/libraries/moduledef.htm
I'll add add the ".def" extension
|
|
|
|
|
su_penguin wrote: I'll add add the ".def" extension
That's outdated.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
su_penguin wrote: Is creating a DLL with Visual Studio the same as creating a Module Definiton File?
No.
I'm no expert in the interfaces of visual studio later than 6 (I'm a dinosaur, I know...), but you'll have to add a new project to your workspace. When you do, you will be walked through a wizard, and some of those options will be DLLs.
If you're using VC express, it may be harder. Look over todays Q&As for a dicussion from this morning about that.
Good luck,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
in general that's a real old style way of doing it. A simpler way is to use the __declspec(dllexport) and __declspec(dllimport) in front of your function(s)/class(es). You can write a macro that switches between these - this is what the DLL wizard will do for you as well. Check those out on google, should answer the rest of the question.
|
|
|
|
|
For the most part what everyone has stated is accurate.
If you want more specific information click here[^]
|
|
|
|
|
Excuse my english
I have a library with many classes, but only one will be used by the final user of the library.
The problem is: the .h of the main class have private references to other classes, then the final user needs to include all of .h files.
I want a simple .h file for the final user with a declaration of the main class, is this posible?.
I think add a interface class to solve this.
tks in advance
|
|
|
|
|
This won;t be easy. But you may be able to use forward declaration. (Use that as a search term)
ie:
class CSomePrivateClass;
struct CSomePrivateStruct;
class CMyPublicClass
{
...
protected:
CSomePrivateClass *m_pClass;
CSomePrivateStruct *m_pStruct;
};
That's not great code, but I hope it gives you the idea.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Create a header file called simple.h
Inside that put the following
#include "firstclass.h"
#include "secondclass.h"
#include "thirdclass.h"
#include "fourthclass.h"
#include "fifthclass.h"
Now the final user only need to include simple.h.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
What kind of library are you developing (e.g. DLL)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Is a static library at this moment, in the future will be a DLL.
The question is, I dont want that the final user have .h of all my internal classes.
The first answer from Iain could be the solution.
|
|
|
|
|
Actually you haven't to expose headers for not exported objects.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm trying to load the small warning triangle system icon using the following code:
LoadImage(NULL,NULL,MAKEINTRESOURCE(OIC_BANG)IMAGE_ICON,16,16,LR_SHARED | LR_DEFAULTCOLOR)
This gives me an image but it's the 32x32 version, normally shown by MessageBox(), resized to 16x16. How do I get the proper 16x16 version shown by Event Viewer or by system tray balloon tips?
|
|
|
|
|
Hi,
I have a edit control,which needs to accept only values in between 1 and 999. I put DDV_MinMaxInt for the edit control variable . It works fine when user enters any value out of range 1 - 999 by popping up to enter a value in between 1 -999 .But the title of the dialog is the workspace name. I need the dialog with another name. How do I need to change the title of dialog.
In DotNet 2005 editor NUMBER = TRUE in properties of edit control. This is validating fine for any alphanumberic or special characters. When I type nothing in the edit control and click on the enter button a dialog pops up saying to enter a valid number. But the title of the dialog is the workspace name. How do I need to change the title of the dialog. Is there any way to do it.
Thanks,
Venkat
|
|
|
|