|
_Magnus_ wrote:
i dont see the point
sorry, my english is poor sometimes
what do you mean with this ?
TOXCCT >>> GEII power
|
|
|
|
|
The protected keyword is for people who trust others to properly augment the implementation of a class in a derived class.
In the last three or four weeks I have wasted endless amounts of time because VCL (Borland's MFC) made far too many things private. I couldn't fix the bugs in their code without completely replacing their classes.
If they had made their stuff protected and trusted me, I would have saved a lot of time.
I hardly ever use the private keyword because I trust the programmers not to screw up the implantation. If they do screw things up, I beat them up and then make them fix it. I would rather them do that than have to reimplement my classes in their own stuff creating two implementations of the same theme.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
The protected keyword lets you differentiate between accesses of the value by users of the class from accesses by derived classes. Ordinary users of the class may not access a member marked protected . A derived class, which supplements or modifies the behavior of the base class, is granted privileged access.
Software Zen: delete this;
|
|
|
|
|
What you are doing will work then, but it is really bad code. Sometimes people do what you do when they have no choice and need to access protected and private members in a given class. This is usually do to poor design of the base class. (*cough* BORLAND VCL)
However, what you are doing is very questionable indeed. It looks like a maintenance nightmare.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
It works but it is very very bad (and wrong).
What if B had another variable J and a routine IncJ? If you invoked IncJ, you would be trashing memory and could cause your program to crash.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Yes i know its really ugly but i managed to do it by
misstake and got a bit surprised that it worked. =)
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
IT may work for your particular sutiation... but the proper way of casting in this sense is with dynamic_cast:
A *pa = new A;
B *pb = dynamic_cast<B *>(pa);
pb will either contain a valid pointer to a B object, or will be NULL if it can't be casted safely.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
It works by accident. It's why you should never use the old style C cast. This compiles,
B * pb = (B*)0;
pb->Inc () ;
but goes bang.
Paul
|
|
|
|
|
Hmm
B * pc = reinterpret_cast < B *> (0);
This compiles too, so does that mean you should never use it either?
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
reinterpret_cast stands out like a sore thumb whereas the C style one doesn't. In either case you can blow your foot off by demanding the compilation of something absurd, like the original poster.
Paul
|
|
|
|
|
Hello Robert,
After going through the Code Project tutorial "Three Ways to inject Your Code into Another Process" I have started writing an application.
In that applcation in NewProc I want to use some local variables which are of types char* (char array of size 100) , int, HMODULE etc. I want to load a library in the address space of the remote process , and acess the library's function by using GetProcAddress API. But the problem that I am encountering
is that the remote process just crashes if I use assignment in the code in
NewProc, such as HMODULE h; h=LoadLibrary("libname");
such assignment operations even in case of integers are causing the remote process crash. Will you please help me in this regard? Thanks for any
suggestion in this regard.
Biswas
|
|
|
|
|
You should use GlobalAlloc and GlobalLock
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for the help. But The problem is not solved using GlobalAlloc , GlobalLock & GlobalFree. It invites the same access violation "Memory could not be Read". Still I can't find any way to assign an integer or HMODULE from within the NewProc. What should I do? Please show me a way. I have to solve this problem as soon as possible.Thanks.
|
|
|
|
|
The problem is solved finally using GlobalAlloc. Now I
have another problem. I have created an anonymous pipe
in the process from which I want to inject code to the remote process & passed the write end handle of pipe
to the remote thread as a member of its data. Now
from within the remote thread I want to write to the pipe using writefile & from within the other side I want to read the pipe. But the writefile is returning null. Please help me to solve the problem.
|
|
|
|
|
How can I open a new window with for e.g. www.ceco.se as a url.
Following code:
ShellExecute(NULL, "open", “ValidUrl/abc.html”, NULL, NULL, SW_SHOWNORMAL);
Opens a new explorer window if none already is open. Otherwise it uses an already open one, which I want to prevent.
...and justice for all
APe
|
|
|
|
|
Internet Explorer supports the -new command-line switch. Try that.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
This depends on the user's setting, which you should probably follow.
If you want to turn it off yourself, look in IE's Internet Options, Advanced tab, and uncheck Reuse Browser Windows For Launching Shortcuts.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Is there any way for a program to be notified when other processes are created and destroyed?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
if they are parent, yes, the child notify its parent when it is created and destryed
TOXCCT >>> GEII power
|
|
|
|
|
|
Hello CodeProjecters,
I am working on a multi-protocol chat client, and very stuck on what to use for HTML rendering. AIM uses HTML in its profiles, but it doesn't support very much of it: text foreground/background colors, font size and face changes, bold, italics, etc. Everything that a RichEdit supports -- except for a horizontal rule! I would like to avoid additional DLLs -- so QHTM/HTMLayout is out of the question. It is ridiculous how heavyweight the WebBrowser control is, too. Does MSHTML load in like 10 DLLs when you use it?
Now, I can write a HTML parser using Boost's Spirit parser framework library, and then apply those styles to the RichEdit control. I have already done this. However, I do not know what to do for the horizontal rule. I tried using a bunch of _'s, but it looked really ugly -- is there something else I could do? Perhaps owner-draw the control? I know demand for something like this control is very high, so I'd be willing to write an article about it. I just need to support HR's somehow.
Thanks.
|
|
|
|
|
I saw a lightweight HTML renderer in Windows Developers Journal, a long way back - maybe you could rummage through their archives or find someone who subscribes to the CD-Rom
This might also be of interest :-
http://www.codeproject.com/cpp/utf8ostream.asp[^]
Else, and I know you are going to hate me, go the the website for the author of the previous article (Andrew Fedoniouk, http://terrainformatica.com) and check out his offering - but its not source, it might only serve as 'inspiration')
sorry I cant help more .. ps.. just modified this - seems I should have re-read that link, he's just generating html not rendering it - sorry... follow the link to his homepage and look at his tools, anyway ..
'G'
|
|
|
|
|
Thank a lot
but it's wrong
I have a Class: CPolyBtn
I have a control: Button : IDC_BUTTON1
in MFC ClassWinzard I need :
ControlIDs Type Member
IDC_BUTTON1 CPolyBtn m_polybtn
In Dialog : Add Member Variable. I need:
Variable Type:
Cpolybtn
Help me. Thank alot
Hello
|
|
|
|
|
CTRL + W
Add member variable
Find and replace
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hello, this is probably my first post ever in this forum.
I need your help with writting two simple and small programs that simulate a server and a client running on the same computer(same host). In addition, one pair of client/server would concern TCP(stream sockets) and another that works with UDP(datagram sockets).
The two main classes that would interest me are CAsyncSocket and CSocket. If there is anyone who could show me a very simple code (like an echo application) or provide me a tutorial/link with such programs ,I would be most happy.
Note that if you're too bored or unwilling to provide code ,I wouldn't mind if you provided me a tutorial on how to build such a program.
Thank you in advance.
|
|
|
|