IonicWind Software

Aurora Compiler => GUI => Topic started by: walyrral on March 02, 2007, 01:32:04 AM

Title: OnControl() and OnCreate() - newbie questions
Post by: walyrral on March 02, 2007, 01:32:04 AM
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
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: Bruce Peaslee on March 02, 2007, 09:26:51 AM
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  ;)
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: walyrral on March 06, 2007, 01:11:17 AM
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.
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: Bruce Peaslee on March 06, 2007, 08:12:06 AM
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;
}
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: John S on March 06, 2007, 12:34:35 PM
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?
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: Bruce Peaslee on March 07, 2007, 10:42:14 AM
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 (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.
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: John S on March 07, 2007, 12:05:38 PM
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.
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: Bruce Peaslee on March 07, 2007, 12:49:42 PM
Here it is. There might be better ones out there, but this is fairly useful.
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: walyrral on March 16, 2007, 02:13:20 AM
Ah, I now understand. Cheers Bruce.
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: John S on March 16, 2007, 10:50:48 AM
looks like your constants list is popular.  thanks Bruce
Title: Re: OnControl() and OnCreate() - newbie questions
Post by: Bruce Peaslee on March 16, 2007, 10:55:14 AM
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.