April 26, 2024, 09:54:26 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


OnControl() and OnCreate() - newbie questions

Started by walyrral, March 02, 2007, 01:32:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

walyrral

QuoteOnControl(int nID, int nNotifyCode, unsigned int hControl)

Hi everyone.

I can see what nID does but what about the other parameters?

Also, what is the difference between OnCreate() and a constructor?

Cheers

Bruce Peaslee

nNotifyCode is the message that the control generated such as BN_Clicked [0x0000] when the control is clicked with the mouse. hControl is the handle to the control.

The constructor is called when the class is instantiated (an "instance" of the class is made), while OnCreate is called when the window(dialog, control, etc.) is created. When the constructor is called the window does not yet exist. Probably someone can give a better answer than this  ;)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

walyrral

Your second answer makes perfect sense Bruce.

So nNotifyCode is the event id? I am still unsure about hControl because the switch is testing nId, so I thought it would be the control handle. The switch seems to ask which control fired an event and nNotifyCode tests the type of event. I'm still not 100% sure of this.

Bruce Peaslee

nID is not a handle, it is the id you assign to the control when you create it.

myDlg.AddControl(int  type, string  title, int  l, int  t, int  w, int  h, int  style, int  exstyle, int  ID)
// ID is the control's id number


hControl is the handle.


const CMD_OK = 1;
const CMD_CANCEL = 2;
...
ItemDialog::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
   select nID
   {
      case CMD_OK:
         // process OK button here
      case CMD_CANCEL:
         CloseDialog(IDCANCEL);
   }
   return 0;
}
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

John S

Bruce,
do you have or can you tell me where I can get a listing of all of these messages and how to apply them?
John Siino, Advanced Engineering Services and Software

Bruce Peaslee

John,

I'm not sure I understand the question. I use

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/wincontrols.asp

to get information about controls and their messages. I also rely heavily on the examples that come with the compiler and help from the Forum. I have a list of Windows constants that is in a text file (the source is long forgotten) that I could post, if that would be helpful.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

John S

Quote from: peaslee on March 07, 2007, 10:42:14 AM
...I have a list of Windows constants that is in a text file (the source is long forgotten) that I could post, if that would be helpful.

That list would be great!  I have gone to MSDN & I just found an old book that I lost.  I'm not as experienced at API stuff (control messages, etc.) as some of you other guys.  I like to have off-line resources to look and study.
John Siino, Advanced Engineering Services and Software

Bruce Peaslee

Here it is. There might be better ones out there, but this is fairly useful.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

walyrral


John S

looks like your constants list is popular.  thanks Bruce
John Siino, Advanced Engineering Services and Software

Bruce Peaslee

Quote from: John S on March 16, 2007, 10:50:48 AM
looks like your constants list is popular.  thanks Bruce
You're welcome. I wish I could remember who sent it to me to provide proper credit.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles