|
Hi,
some people insist on having just one return statement in a function; that makes having it in a
catch block rather hard. If you feel more lenient, go ahead.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I guess there's nothing so wrong with returning -1 from catch block. But I personally, just HATE it.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hi Clawton
I have the same issue. It seems the same happens in VC2010 too.
First I tried to find out what's wrong in my code, but a few days trial failed and I came here after searching internet. Now I see it's not my code problem but the compiler.
Have you found out how to make the debugger not step into the 'return 1'?
All the replies below do not clearly commented why it happens and how to overcome it.
If you summarize your answers that'd be great.
thx
HaeRim
|
|
|
|
|
After seeing the replies and studying the assemble code, I ended up convencing myself that all was operating as it should and I need to just be aware of it.
Although I do try to code a bit differently - i.e. not put a return in a catch block.
Chris
|
|
|
|
|
Hello,
I am working on a project where I need to figure out the MAC address associated with a particular IP, in code. I could do this from the command line, and am tempted to have the program just do that...but would rather deal with the raw sockets to keep everything in one program.
Ideally I need a way to send an arp request out and capture the return response. I would also like to use as FEW non-standard libraries as possible, as the SW will be ported to a PPC once it is "working".
Any ideas or pointers of how I should go about doing this would be GREATLY appreciated. Thanks for your help in advance!
|
|
|
|
|
thelonesquirrely wrote: Any ideas or pointers of how I should go about doing this would be GREATLY appreciated.
Maybe this will help[^]
|
|
|
|
|
funny. clever even. not doing msdn development. fedora core 10.
|
|
|
|
|
thelonesquirrely wrote: funny. clever even
That's nothing, watch this, nothing up my sleeve PRESTO![^]
|
|
|
|
|
Almost had me there. I thought there was gonna be a bunny . The raw sockets use MAC to MAC. And I have the IP/port. I need to get the MAC.
ps. I was gonna make some snide comment about reading the headline, but then i realized i mis-typed it. oops .
|
|
|
|
|
If there's a command line way of doing it, can't you have a peek at the source of the comamnd that does it?
If the IP is of a local network adaptor, you can probably use an ioctl on the socket to get the MAC address (see this bit of code[^]).
If it's remote, then you either need to decode a packet coming back from the remote address (it ill contain the MAC address in the ethernet part of the packet) or search through the ARP cache...
From what I can see, this book[^] is the definitive source for this stuff. It's on Safari and looks to have everything you'd want.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i need to drawline on picture box in MFC/C++
how can do it?
please give some tip or hint to me
thanks so much....
|
|
|
|
|
- Override CStatic to give you an MFC class that subclasses the picture box.
- Add an OnPaint handler to that new class.
- In the OnPaint handler, get a DC with BeginPaint
- Use MoveTo[^] and LineTo[^] to draw a line
- Add a class variable (of the type you created in step 1) for the picture box in your parent window
drawline on picture box - DONE!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Can you pls help me with the sample code of converting Byte array to variant and vice versa
Thanks
|
|
|
|
|
Create a SAFEARRAY[^] of VT_UI1 (a VT_UI1 is equivalent to a BYTE) and encapsulate it in a VARIANT[^] with a type of VT_UI1|VT_ARRAY.
There's a sample of that in this page[^]. Search for VT_UI1 in that page to find the code!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks a lot, it was very helpful
|
|
|
|
|
We are looking to add customized toolbars (and commands) to our application.
We do not necessarily need something as extensive as what is done in Visual Studio (or MS Word).
Are there easy solutions to have those kind of features in a MFC application ?
I know there's a basic support in MFC (CToolBarCtrl::Customize) but from what I see when trying to use it is that
it does not really work well.
Thanks
Max
This signature was proudly tested on animals.
|
|
|
|
|
Hi,
I did a lot of Work With Device Contexts and thought I would have to abondon that knoweledge when I used Rich edit
Then I came across ITextServices Which has a Object ITextHost with TxGetDC member
The problem ???
The Code I wrote to implement Rich Edit was in C
Is there some paragma that I can use to have piece of code compiled as C++
Or do I have re-compile the whole program as a .cpp extension to use the ITextHost Interface ??
thankx
|
|
|
|
|
Tell the compiler to compile as C++, either using project properties (for a Visual Studio project) or with the /TP option (on the command line) - that is what altering the VS project option adds in.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have project properties to compile as C++
I got the following compile errors including textserv.h
dont know if its becuase I have a .c extension
thankx again
Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(152) : error C2061: syntax error : identifier 'ITextServices'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(152) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(152) : error C2059: syntax error : ':'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(271) : error C2061: syntax error : identifier 'ITextHost'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(271) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(271) : error C2059: syntax error : ':'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(411) : error C2143: syntax error : missing ')' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(411) : error C2143: syntax error : missing '{' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(412) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(413) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(413) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(416) : error C2143: syntax error : missing ')' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(416) : error C2143: syntax error : missing '{' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(417) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(418) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(418) : error C2059: syntax error : ')'
1>.\HERCCMD.C(562) : error C2065: 'ITextServices' : undeclared identifier
|
|
|
|
|
Sorry about that .....
I got other compile errors but I think I am invoking the C++ compiler
|
|
|
|
|
Hello,
First off, If this question has been answered could you direct me to the correct place. I've carried out a search but had little luck.
I've got a basic drawing program written in C++(Win32 API) which allows me to draw rectangles (using GDI functions) on the screen. I click two points on the window and a rectangle appears. When I minimize the window and restore it again, as expected the rectangle is gone.
Is there a neat solution which keeps the rectangle on screen? The only why I can see is to save the data points and call them when a WM_PAINT message is requested. To me, this method seems like it can get pretty messy, but then again I am a newbie to programming.
Thanks in advance
|
|
|
|
|
en9ap wrote: The only why I can see is to save the data points and call them when a WM_PAINT message is requested. To me, this method seems like it can get pretty messy
The other way you could do it is to draw onto a bitmap and use the bitmap as backing store for the window. You would then BitBlt the bitmap onto the window in the window's OnPaint handler.
CMemDC[^] would be useful, if you have VS2008. Otherwise, this CP article[^] could be useful.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
en9ap wrote: The only why I can see is to save the data points and call them when a WM_PAINT
It's not the only way but teh Scribble[^] Sample project that has been around for like a decade used to do that. I don't know what the current versions do.
|
|
|
|
|
en9ap wrote: To me, this method seems like it can get pretty messy
Why should it be pretty messy ? The other way around would be pretty messy because it means there's no real way 'remove' some parts of your drawing. Suppose that your user wants to remove one of the rectangle he drawn. If everything stayed visible on the screen, then it would mean that you have no way to remove only one rectangle, unless you kept all the rectangle coordinates in memory and draw everything again except this specific rectangle. But then, you end up with something similar as what you have with the WM_PAINT message.
Storing your rectangle coordinates in memory also help making your view indepedant from your data (your 'model'). Suppose that you want to incorporate a zoom functionality in your view, if your data is separated from your view, it is extremly easy to do. It wouldn't be easy at all if your rectangle was still on the screen.
en9ap wrote: Is there a neat solution which keeps the rectangle on screen?
To answer your question, if there was a solution to do this, it wouldn't be neat for the reasons explained earlier.
In fact, what you have to do is capture the mouse movement and once you have to draw your rectangle, do not draw it immediately. Instead store the coordinates and ask a refresh from your view (invalidate your view). This way, a WM_PAINT message will be sent and you can redraw your view.
|
|
|
|
|
Thank you all for your replies. I shall look into saving the data points. Indecently, is this how vector drawing packages such as Corel Draw operate?
|
|
|
|