Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualParadigm Shifter

Posted 22 July 2013 - 09:35 PM

More thoughts if you want to go down the Win32 route:

 

C++ is probably the worst possible language choice for doing this kind of stuff. If you're doing it just to learn about dynamically created controls, fine, but just create child windows on your application window which are common controls, have a look at this simple example:

 

http://www.winprog.org/tutorial/app_one.html

 

You have to handle all the control messages yourself in your Windows Procedure. The DLGTEMPLATEEX stuff allows you to handle dialog messages but it's harder to create the initial dialog.

 

BUT...

 

There is probably a better way to do what you want anyway. Instead of using a variable number of controls, use a single ListControl, with multi-columns, one row for each item you need. If you need to create extra entries at runtime, have a button to add a row to the listbox. Double clicking a row in the listbox brings up a dialog which allows editing of that row (and only that row), this dialog box will be the same for each row, so easy to handle. Handle the delete key to delete a row from the list control.

 

Dynamic controls are rarely needed unless you need to create a large variety of different controls at runtime. If you just want to create a bunch of a single type (or group of types) of controls, go the ListControl way every time, with one column for each control in the group you would have created with the dynamic route.

 

Dunno if I'm explaining myself very well there ;) EDIT: Summary though - ListControl FTW


#1Paradigm Shifter

Posted 22 July 2013 - 09:32 PM

More thoughts if you want to go down the Win32 route:

 

C++ is probably the worst possible language choice for doing this kind of stuff. If you're doing it just to learn about dynamically created controls, fine, but just create child windows on your application window which are common controls, have a look at this simple example:

 

http://www.winprog.org/tutorial/app_one.html

 

You have to handle all the control messages yourself in your Windows Procedure. The DLGTEMPLATEEX stuff allows you to handle dialog messages but it's harder to create the initial dialog.

 

BUT...

 

There is probably a better way to do what you want anyway. Instead of using a variable number of controls, use a single ListControl, with multi-columns, one row for each item you need. If you need to create extra entries at runtime, have a button to add a row to the listbox. Double clicking a row in the listbox brings up a dialog which allows editing of that row (and only that row), this dialog box will be the same for each row, so easy to handle. Handle the delete key to delete a row from the list control.

 

Dynamic controls are rarely needed unless you need to create a large variety of different controls at runtime. If you just want to create a bunch of a single type (or group of types) of controls, go the ListControl way every time, with one column for each control in the group you would have created with the dynamic route.

 

Dunno if I'm explaining myself very well there ;)


PARTNERS