|
In the class view select the appropriate class that you want to add the handler for. In the properties window, click on the overrides button (little green boxy looking icon). Scroll down to onInitDialog, click in the right hand column, click on the drop down box, select on '<<add>> OnInitDialog', the code should have been added.
You add WM_* event handlers in the same way, except you click on the messages button first.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Wow, thankyou. Bizarrely, i'd not noticed the Overrides and Messages buttons!. I expected there to be either a mechanism for overrides on the Add Method dialog, or maybe something on the context menu you get when right clicking a method in the base class. But no.
Thanks
Jon
#include <beer.h>
|
|
|
|
|
Hi,
Is there a way of sending character keys to other apps (eg Notepad)?
Currently I can get the hwnd for the notepad window, and I can close it down by do ::PostMessage (hwnd, WM_QUIT, 0, 0) . Thus I know I have the correct hwnd. However when I send WM_CHAR no characters appear. Any ideas?
Also, is it possible to post keys that correspond with menu items (eg 'ALT-F' (for file) then 'S' (for save))?
cheers,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Hi,
To send file messages use this code:
#define NOTEPAD_FILE_NEW 9
#define NOTEPAD_FILE_OPEN 10
#define NOTEPAD_FILE_SAVE 1
#define NOTEPAD_FILE_SAVEAS 2
::PostMessage(hwnd,WM_COMMAND,NOTEPAD_FILE_OPEN);
To send key message use:
::PostMessage(hwnd,WM_KEYDOWN, 'm', 0);
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
I just encountered this "this" in a sample code. Can anyone explain what it means?.
_param->_this = this;
Is the "this" an operator?
Thanks.
Deepak Samuel
|
|
|
|
|
The this pointer refers to the object in which it is invoked.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
this is the current object instance.
you can do stuff like that...
class CClass
{
int i;
void Method();
}
void CClass::Method()
{
this->i = 1;
i = 1;
}
or if you you want to pass yourself to another class or method :
...
CPaintDC dc(this);
...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
"this" is introduced so the compiler could make the difference between members of the class and members of another object.
eg. if you would do this:
<br />
public void SetSomeInt(int input){<br />
input = input;<br />
}<br />
then the compiler probably would complain. which one is the parameter and which one is the variable of the class?
if you do this:
<br />
public void SetSomeInt(int input){<br />
this->input = input;<br />
}<br />
it will probably work.
It's just a pointer to the Object itself.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
"this" is introduced so the compiler could make the difference between members of the class and members of another object.
eg. if you would do this:
<br />
public void SetSomeInt(int input){<br />
input = input;<br />
}<br />
then the compiler probably would complain. which one is the parameter and which one is the variable of the class?
if you do this:
<br />
public void SetSomeInt(int input){<br />
this->input = input;<br />
}<br />
it will probably work.
It's just a pointer to the Object itself. (and that's the reason why you can't use it in static functions)
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I would advise that you *DO NOT* use the same naming convention for local function variables and member variables. It can, and will, always lead to confusion and mistakes.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Quite true.
Just to have no misunderstandings : "I do not do that" , but the example just explains nicely what 'this' means.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Antony M Kancidrowski wrote:
I would advise that you *DO NOT* use the same naming convention for local function variables and member variables. It can, and will, always lead to confusion and mistakes.
That's why they invented m_
Michael
CP Blog [^]
|
|
|
|
|
you've been having many good answers, so i won't add more about the this pointer you're asking for.
i'd just like to tell you that this is an important part of the C++ language, and you'd so better get a reference of the language to learn about it...
there are many books on the subject, and also the MSDN treats about it.
cheers,
TOXCCT >>> GEII power
|
|
|
|
|
If I use GetSysColour to get a system RGB value, then create a brush using that value and then draw a rectangle, the colour of the rectangle is different?
I'm puzzled by this, under 2000 you can see this all over the place, i.e menu bars. If you get the system colour then you get back the value C3C3C3, if you paint to the screen with this colour you get C6C3C3, you can verify this by reading back the pixel.
I've only noticed this because I'm implementing a VS.NET style gui and I couldn't figure out the luminance values, once I'd realised that the colours are actually different to what you request it all fell into place.
Adrian
|
|
|
|
|
Hi,
i'm using MS Visual C++ .Net and i have a problem with odbc and mfc. It occurs sometimes while running the release application *.exe - but never(!!) while running the programm under Visual in debug mode (no compiling error).
An "unhandled win32 exception" is thrown.
Debugging the *.exe shows line 624 in dbrfx.cpp, (function: void RFX_Text(...)). A message like: "cannot read in memory" comes up.
The exception is thrown while some database actions. I first do a select in table... (by CRecordset) and then i'm trying to do an update in the same table (also by CRecordset). RFX_Text is updated and sometimes: *pow*.
Does anyone have some helpful idea? I tried to do my update by CDatabase::ExecuteCommand(...) but everything is the
same...
Thanx
Jo
|
|
|
|
|
Are you using more than one thread to connect to the database in your application? If so DAO is not multithreaded and will lead to many problems.
John
|
|
|
|
|
Thanx for you reply.
I'm not using DAO, i take odbc.
Yes, my db operation runs in a separate thread. But thats not the problem. The error also occurs, while running sequential without thread.
|
|
|
|
|
Its ok to use a database in a thread as long as you don't try to use it (CRecordset) in more than one thread.
John
|
|
|
|
|
I've also found that CRecordset is prone to memory leaks so I started using ADO instead which I find to be a lot simpler. (which is what a simple mind like mine needs)
[insert witty comment here]
bdiamond
|
|
|
|
|
John: Its ok to use a database in a thread as long as you don't try to use it (CRecordset) in more than one thread.
Yes, I also think so. The problem is CRecordset. But - in my case - it does not depend on using it in more than one thread. I first created a CRecordset and did some SELECT statements, after that i used CDatabase (or another CRecordset) for the insertion of records. And thats it: the first CRecordset is bound to the database and the insertion by other instances causes the error. So, now i'm using only one CRecordset and everything works well .
bdiamond: I started using ADO instead which I find to be a lot simpler
OK, that's good to know . I'll remember that in next projects.
|
|
|
|
|
Hi
I have a vc++ application, which i would like to distribute as evaluation copy. The application should not run if the specified 30 days is over.
It should handle system time changes etc.
Could anyone help me out !
Thanks and regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
The best way to distribute an evaluation copy is to limit it's functionality. That is, comment out sections of code that offer functionality you do not want to provide in a trial version. Then build a trial version.
Another alternative is to limit the amount of executions. This can be handled by keeping a record of the execution times inside the executable itself, which makes it more difficult to hack. Using time periods is always difficult, because changing the BIOS date will mix up any period counters, and there's no way you can detect it, if done correctly.
So, when you hand out evaluation copies, cripple them. This allows your testers to evaluate the product, but they can't hack it (as there's nothing to gain), and if they feel like purchasing the full version, you can sell it to them.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi
Thankyou for your time.
I have a specific requirement for 30 day trial versions that is the main concern.
I just want to know the trick behind creating the 30 day trial versions.
Thanks & Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I just want to know the trick behind creating the 30 day trial versions.
Either write a hidden file or registry key that contains a data that you program checks at startup or roll out an encrypted code that the user is emailed that contains the date that the program quits working.
John
|
|
|
|
|
Hi
Thankyou very much.
I will be back after trying out some trials
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|