|
If its C and not C++ then use Structured Exception Handling. You can search on Google and MSDN for more information about it.
Try, Catch, Throw exception handling mechanism used in C++ and not in C.
I hope this helps
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks for the prompt response!
It is C code within a program that uses C++ (i think!).
Just to clarify then, you CANNOT use try() and catch() within C, only C++?
Thanks again
|
|
|
|
|
Yes. The file must be compiled as cpp and probably has to have a cpp extension.
John
|
|
|
|
|
Yes. Try() and catch() are part of C++, but not C itself! Therefore C code cannot use try and catch.
Note that C++ is almost a superset of C. Odds are very good that his program will work just fine if he compiles it as if it is C++ even though it is C. However this isn't 100%. Depends on how it is used.
Note that "extern C" might be required all over depending on how other things are defined. Look this up though, and experiment. (extern C might also turn off exception handeling though, I don't know. See what works, and test carefully, particularly if this is cross platform)
|
|
|
|
|
Anonymous wrote:
Just to clarify then, you CANNOT use try() and catch() within C, only C++?
Yes, as I said, try,catch and throw are part of C++ and not C. If you wish to use them in C then one option is to make your .C file to .CPP file and compile with the C++ compiler. All the code remains in C only, just change the extension and use it with C++ compiler. Many a times we use this approach just to use few features of C++ like - strict type checking, ability to declare variables at the exact place where they are needed rather than at start of function etc.
But if you want it to be pure C and compiled in C compiler then better use Structred Exception handling.
I hope this helps
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Also I hope he's not actually including the parentheses '()'. I don't know, but just in case, it's like this:
try
{
}
catch(CSomeException)
{
}
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hello everyone,
My question is how to change the font color of slide.
I have Automated PowerPoint Using Visual C++ MFC,such as:
_Application app;
Presentations presentations;
_Presentation presentation;
Slides slides;
_Slide slide;
ShapeRange shaperange;
Shapes shapes;
Shape shape;
TextFrame textframe;
TextRange textrange;
Font font;
FillFormat fillformat;
ColorFormat colorformat;
ShadowFormat shadow;
if(!app.CreateDispatch("Powerpoint.Application", &e))
{
CString str;
str.Format("CreateDispatch() failed w/err 0x%08lx", e.m_sc),
AfxMessageBox(str, MB_SETFOREGROUND);
return;
}
app.SetVisible(TRUE); Presentations presSet(app.GetPresentations());
_Presentation pres(presSet.Add(TRUE));
Slides slideSet(pres.GetSlides());
_Slide slide1(slideSet.Add(1, 2));
// Add text to slide, by navigating the slide as follows:
// slide1.shapes(#).TextFrame.TextRange.Text
{
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("My first slide");
}
{
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("Automating PowerPoint is easy\r\n"
"Using Visual C++ is powerful!");
font = textrange.GetFont();
font.SetName("Comic Sans MS"); //Set the font name.
font.SetSize((float)48);
}
Now the question is how to change the font color????
Help me,please!!
Thanks a lot!!;P
cengyikun
|
|
|
|
|
hi all,
I want to add multiple rows using Edit Control.
I did like this:
CEdit m_edit;
m_edit.SetWindowText("hellow \n code \n project\n");
But this is not working .
when I compile and run the application.it is displayed like this:
hellow|code|project|
But I want to show the output like this using Edit Control:-
hellow
code
project
So can any body help me to solve this..
Thanks in advance
|
|
|
|
|
Did you choose multiline for the options of the edit control ?
Right click on the edit ctrl -> properties -> 'Styles' Tab -> check 'Multiline'.
|
|
|
|
|
hi
yes..I already check the multiline
Is there a another way to set string instead of SetWindowText()
??
|
|
|
|
|
pubududilena wrote:
CEdit m_edit;
m_edit.SetWindowText("hellow \n code \n project\n");
Try this instead:
CEdit m_edit;<br />
m_edit.SetWindowText("hellow \r\n code \r\n project\r\n");<br />
|
|
|
|
|
yes ..Thank u for correct me..
That is working now..
|
|
|
|
|
I build an ATL control, but after fresh many time, it will crash.
I find that column "Gdi objects" in "Task Manager" will be 9999.
I doubt that there are some problem in below code:
Line1 HRGN rgn = CreateRectRgn(...);
Line2 SelectClipRgn(hdc, rgn);
Line3 Draw Something;
Line4 SelectClipRgn(hdc, NULL);
Line5 DeleteObject(rgn);
I find that column "Gdi objects" will increment randomly after execute Line1; but when execute Line5, the column value be always unchanged(I assume it will decrement).
Is there any relationship between "Gdi objects" and windows gdi objects?
and why?
|
|
|
|
|
I am not able to use various commands,macros, project settings and all other stuff of Visual Studio. Like yesterday i come to know TRACE is very usefule but yet not able to use it. Similiary many hidden. Do help me for proper use of Visual Studio tools.I work with VC++ using MFC and win32 API.
Thanks for kind help
Moyeen
Sr. Software Design Engineer
|
|
|
|
|
Moyeen_VC++ wrote:
...but yet not able to use it.
Why?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi friends,
Windows handles are always unique for the specific OS instance.Anybody is having idea from where this uniqueness coming from?
|
|
|
|
|
|
Well,
That Explains a lot
|
|
|
|
|
A window handle isn't really anything, but it could be an integer. If you increment the integer by some arbitrary value every time CreateWindow succeeds, you get reasonably unique values...
Steve S
Developer for hire
|
|
|
|
|
I have started programming one year ago; using vc, but now i have come to know that in VB one can also call APIs; which mean we can do all low level tasks.
Then why VC is considered more powerfull?
Is it a reality or just a result of good marketing?
|
|
|
|
|
Yeah VC is considered More Powerful as it give rawower to every thing.
windows Handle ,Dll etc.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
its sometimes not wot you do but how you do
There is no spoon.
mail
|
|
|
|
|
Didn't I just see this same post in 'The Lounge'?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
sorry for that; I should have deleted it from their.
|
|
|
|
|
I am using installshield; version which comes with visual studio 6;
How can I register/unregister AX controls and dlls using it;
I donot want to use any other installer/un installer; just above mentioned version of installshield.
plz help.
|
|
|
|