Board index » Visual Studio » How to Add OnClick Message for a dynamic control
|
Win32,
|
|
Win32,
|
How to Add OnClick Message for a dynamic control
Visual Studio78
Hi Group If i had included a static control via resource , i would need to add the OnClick message handler via Class Wizard. So when the user clicks that control the OnClick function would be called. But if i had created the control dynamically during runtime, how can i add such message handler. Regards - |
| David
Registered User |
Fri Sep 29 06:35:40 CDT 2006
Re:How to Add OnClick Message for a dynamic controlQuoteIf i had included a static control via resource , i would need to add the give it. In such circumstances you can usually add the message handler directly as if the Wizard did it (see what the Wizard does and duplicate it), or you may have a range of command ID values to handle, in which case you can use ON_COMMAND_RANGE. Dave - |
| beauwlf
Registered User |
Fri Sep 29 07:36:13 CDT 2006
Re:How to Add OnClick Message for a dynamic control
Actually i am creating an array of CStatic controls.
And after i arrange them on the dialog i want call a click function each time the user clicks on that control. QuoteWhen you create the control, you'll usually know the command ID you in the header file CStatic ctl_gridBox[9][9]; In the cpp file //creating the control for(int col=0;col<9;col++) for(int row=0;row<9;row++) ctl_gridBox[col][row].Create(_T(" "),WS_VISIBLE,GridBox,this);//|SS_CENTER|WS_CHILD //Positioning the control for(int col=0;col<9;col++) for(int row=0;row<9;row++) { ..... ctl_gridBox[col][row].SetWindowPos(this,GridBox.left,GridBox.right,GridBox.Width(),GridBox.Height(),SWP_FRAMECHANGED ); ctl_gridBox[col][row].SetBitmap(mGridBmp); ctl_gridBox[col][row].GetDC()->DrawEdge(GridBox,EDGE_BUMP,BF_RECT); ctl_gridBox[col][row].ShowWindow(SW_SHOW); .. } Now the control appears on the dialog Now i want to call a function for each control when the uses clicks on them . - |
| Ajay
Registered User |
Fri Sep 29 08:34:37 CDT 2006
Re:How to Add OnClick Message for a dynamic control
As mentioned by Dave, you need to specify ID for each of the CStatics
that you are creating. Your code is not doing it. Its the last parameter in Create method(after parent). You are currently using the default value. --- Ajay beauwlf wrote: QuoteActually i am creating an array of CStatic controls. |
| Tom
Registered User |
Fri Sep 29 08:50:52 CDT 2006
Re:How to Add OnClick Message for a dynamic control
Could you use this sort of thing?
www.codeproject.com/staticctrl/cmyhyperlink.asp">www.codeproject.com/staticctrl/cmyhyperlink.asp Tom "beauwlf" <beauwlf@fruggle.com>wrote in message QuoteActually i am creating an array of CStatic controls. - |
