Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOw to setup a dynamic array of buttons with Visual C++

Status
Not open for further replies.

Insider1984

Technical User
Joined
Feb 15, 2002
Messages
132
Location
US
My experience: Mostly dialog based MFC applications.

Based on a input of say Row = X Column = Y (X and Y being user configuarable) what is a good method of creating an array of buttons in a fixed size window (800x600) to represent this array.



It's a tiny project that is low priority so they gave it to me (typically a machine designer creating simple apps and converstion type programs).

I will be taking data from files putting them into a 2D array and based on the "severity" of each failure (each button represents an object) give a color representation to track repeating issues etc.

Thanks for any help.

=====================
Insider
4 year 'on the fly' programmer
C++ Basic Java
 
I guess you could create a matrix or array or vector, whatever, of CButton objects and call CButton::Create(...) for each one. I'm not sure if that answers your question.

-pete
 
I'll take a look at the function. It looks like it has a position that I can calculate based on the user inputs.

I havn't been inside Visual C++ for abou 2 years so sometimes the simple methods are the ones that get me =-)... I assume that I can create dialog type windows and can stay within the rehlm I am familiar with?

=====================
Insider
4 year 'on the fly' programmer
C++ Basic Java
 
Okay here is what I got. No button being displayed:
Code:
	CButton first;
	first.Create("Test", WS_VISIBLE, ButtonSize, this, 0x8000+200);

=====================
Insider
4 year 'on the fly' programmer
C++ Basic Java
 
Yeah, you created a local scope object so when it goes out of scope it’s destructor is called which in turn results in a WM_DESTROY message being sent to the window and “poof” it’s gone as quick as it came.

You might try using a tutorial or getting a beginners book or something that will cover the many fundamental subjects of Windows development. Using a message based conversation mechanism to learn C++ Windows programming could take, ummm…. a really long time. I could be to old to type before we get finished! [lol]

Make sure you get/use one that is MFC based if you intend to use MFC for development. Years ago there was a series of books title something like Understanding Visual C++, I think.


-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top