|
Hi !
Thanks for your answer, but it seems __try and __except are MS specific keyword. I'm compiling in a linux environnement...
Any onther hint ?
Thanks !
Jerome
|
|
|
|
|
You could give more information, here is my guess.
If you are calling a C-function from a C++-class, you have to do this in the third party .h-file:
Surround all function declarations with this code:
#ifdef __cplusplus
extern "C" {
#endif
// the original function prototypes
#ifdef __cplusplus
}
#endif
Else, the first parameter of all function calls will be the this pointer. And that will make the funcion call to crash...
|
|
|
|
|
Hi thanks for your answer.
I'm actually calling a C++ function from a C++ class. The call to the function works in most cases, but crashes in some specific cases.
Jerome
|
|
|
|
|
Chenxing's solution will work - As much as catching an unexpected exception will ever work. Here's how to do it:
__try
{
api_call(mydata);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
Note that catching an unexpected exception is never a good idea - For example the exception might have occurred while a node was being linked into a linked list but has only been half linked in. Or perhaps after a CRITICAL_SECTION was entered but before it is released. Once an unexpected exception occurs the state of the application is suspect.
I realize you may have no choice but nethertheless beware - You may end up creating more problems for yourself.
Steve
I just noticed the comment where you said you're programming on Linux - Sorry.
-- modified at 4:22 Friday 10th March, 2006
|
|
|
|
|
Hi, me again!?
Sorry to be such a pain in the a$$, but was wondering if anyone knows if it is possible to control a powerpoint presentation with a c++ program?
I have been building a remote control application for the computer (eventually, I want to add a USB-serial adapter, so that I can connect a remote receiver to USB...). So far, I can control Winamp, iTunes, WMP and BSPlayer (the only programs I really use for multimedia) and when theyre not running, it will control windows volume. It also has an overriding mute, that will always mute everything.
I was thinking the next/prev track buttons could be used to control a powerpoint presentation, as this could be useful for the future... but its proving difficult to find any information on it...
Does anyone have any ideas?
Thanks,
Mark
|
|
|
|
|
Try this[^]. PowerPoint's fairly easy to control - I've done it a lot.
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"
|
|
|
|
|
wow! thats great! ive looked everywhere... dont know y i couldnt find anything...
but thanks a lot! looks like its gonna take me a while to get my head round, but at least it must be doable! is always nice to know...!!
do you know if this would also control the presentation if being viewed through powerpoint viewer/standalone presentation? im guessing not...
Also, it doesnt mention controlling slides when the slideshow is running... is that similar?
Thanks a lot,
Mark
|
|
|
|
|
markhaslehurst wrote: do you know if this would also control the presentation if being viewed through powerpoint viewer/standalone presentation?
PowerPoint has to be installed for it to work. Your application will start PowerPoint and work from there.
markhaslehurst wrote: Also, it doesnt mention controlling slides when the slideshow is running... is that similar?
You can use the Next() and Previous() methods on the SlideShowView class for that.
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"
|
|
|
|
|
great! that gives me a lot to work with!
Thanks for the help!
Mark
oh, btw... one question... I dont have Visual C++, i use a free command line Borland compiler... so do you know how I can use the MSPPT.OLB file?
Thanks!
|
|
|
|
|
markhaslehurst wrote: I dont have Visual C++, i use a free command line Borland compiler... so do you know how I can use the MSPPT.OLB file?
Oh, just a minor detail
I've never used Borland, so I don't know how it does things. You can download the free Visual C++ Express Edition from here[^]
BTW, the file is just a renamed type library. You can rename it to .tlb if Borland handles them...
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"
|
|
|
|
|
lol.
no.. renaming doesnt work... but i have downloaded the visual c++ installer... it wants to download a lot more though... so i think ill run it tonite, or else the rest of the company wont be able to get on the net!
thanks a lot for all the help mate.
Mark
|
|
|
|
|
markhaslehurst wrote: no.. renaming doesnt work...
Bummer. I could send you the source files that are generated when the Visual C++ compiler imports it, but they are MFC specific, so won't work with Borland or the Visual C++ Express Edition.
I hope the express edition supports .olb files, or you might have a small problem
Anyhow, glad I could help Have fun!
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"
|
|
|
|
|
na. s'ok. thanks a lot for all help mate.
ill just have to give it a go and see...!
Thanks a lot, its really appreciated.
Mark
|
|
|
|
|
markhaslehurst wrote: I dont have Visual C++, i use a free command line Borland compiler
have you noticed on what forum/site you asked ??
Codeproject is quite dedicated to Microsoft technologies...
|
|
|
|
|
sorry... didnt realise... and to be honest, most sites are geared at MS products... just also seems like the best c++ forum around... and for most things, the compiler is not important.
|
|
|
|
|
markhaslehurst wrote: for most things, the compiler is not important.
hum, if you mean "most" for "standard C++", yeah, if is stands in the standard implementation of the compiler (knowing that nowadays, no compiler implements 100% of the C++ Standard, not even VC++2005).
but if you ask for an OWL question, i think that most people here won't know about it at all...
|
|
|
|
|
well i dunno what OWL is. im only a beginner, but all the advice i have received and all the articles that i have read on this site have worked using my compiler until this library problem, so dont think it really matters for the majority of coding.
|
|
|
|
|
OWL is the graphical library of borland (equivalent of MFC in Visual C++).
actually, if you work in console, yes, using cout/cin (or worse, C function like printf(), etc...) will work because there are part of the standard. standard mean that all C++ compiler provides them, and they work the same way.
if you need to use a specific library (gotoxy() for instance), it won't work on microsoft compiler.
|
|
|
|
|
oh right. well wasnt asking questions about it... jus said do you know if theres another way to convert the file...
but up until now, ive been doing fairly simple things like program control and serial port interface, so havent needed anything special like that... just standard header files.
im not using console cout/cin type applications... im generating proper win32 windows and that... in the same ways that all the articles on the net do... but i guess most of the common stuff is the same no matter what you use...
|
|
|
|
|
Sir
I want to know the when to Add a Virtual Funtion and Message Handler for a class in classview pane of editor.
generally we do it by right clicking on a particular class
we get a pop menu.please help me in knowing it better.
in what generic case we go for a virtual Function.
and what other case we opt for Message Handler.
thank u.
|
|
|
|
|
a virtual function is a functionnality of the C++ language.
events handlers are really dependant of the system they're targetted for...
|
|
|
|
|
Hi,
What is the difference between a process handle and a window handle? Is there any convertions between the two?
Thanks
|
|
|
|
|
A window handle (a HWND ) identifies a window and a process handle (HANDLE ) enables you to monitor/control a process. There is no direct meaningful conversion between them. That said writing code what enumerates all the windows handles in a given process is possible. It is also possible to go from a HWND to a HANDLE for the owning process as follows:
DWORD dwProcessID;
GetWindowThreadProcessId(hWnd, &dwProcessID);
HANDLE hProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessID);
Steve
|
|
|
|
|
HWND is a Handle to a Window
Where as process handle is a handle to a process (Note: a process may or maynot have a window)
So Both are different things, the correct question will be
how can i get the process id if i have the HWND of one of its windows
GetWindowThreadProcessId gives the process id
to get the opposite (processid to window handle) you have to enumerate all the windows and compare the process id.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Yeah. I do accept that a window handle is a handle to a window and a process handle is a handle to a process and not all the time a process can have a window. But, Internet Explorer has a window by default. If I am gonna launch IE from my application as a process I get the process handle for IE. At this point of time, will I be able to get the window handle of the new IE process launched or is there any methods that converts my process ID got(from createprocess functions) to a window handle.
|
|
|
|