Click here to Skip to main content
15,902,938 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: array of Strings Pin
convert_sg29-Oct-03 15:48
convert_sg29-Oct-03 15:48 
GeneralRe: array of Strings Pin
vcplusplus29-Oct-03 15:39
vcplusplus29-Oct-03 15:39 
GeneralRe: array of Strings Pin
Christian Graus29-Oct-03 15:48
protectorChristian Graus29-Oct-03 15:48 
GeneralChange font size for CComboBox and CEdit Pin
srev29-Oct-03 14:14
srev29-Oct-03 14:14 
GeneralRe: Change font size for CComboBox and CEdit Pin
Yonatan26-Nov-03 2:04
Yonatan26-Nov-03 2:04 
Generalsimple console input question Pin
rajdawg29-Oct-03 14:09
rajdawg29-Oct-03 14:09 
GeneralRe: simple console input question Pin
Christian Graus29-Oct-03 15:23
protectorChristian Graus29-Oct-03 15:23 
GeneralRe: simple console input question Pin
Christian Graus29-Oct-03 15:47
protectorChristian Graus29-Oct-03 15:47 
GeneralRe: simple console input question Pin
rajdawg30-Oct-03 1:08
rajdawg30-Oct-03 1:08 
GeneralLayered Service Provider (LSP) Pin
catmust29-Oct-03 13:55
catmust29-Oct-03 13:55 
GeneralRe: Layered Service Provider (LSP) Pin
Alexander M.,30-Oct-03 2:49
Alexander M.,30-Oct-03 2:49 
GeneralRe: Layered Service Provider (LSP) Pin
catmust30-Oct-03 8:55
catmust30-Oct-03 8:55 
GeneralLoading dll issue during debuging Pin
catmust29-Oct-03 13:48
catmust29-Oct-03 13:48 
Generalmemory allocation issues Pin
Steven M Hunt29-Oct-03 13:21
Steven M Hunt29-Oct-03 13:21 
GeneralRe: memory allocation issues Pin
Christian Graus29-Oct-03 15:52
protectorChristian Graus29-Oct-03 15:52 
Generalsockets and threads Pin
michael_cowan29-Oct-03 13:14
michael_cowan29-Oct-03 13:14 
GeneralWINS Pin
Jair29-Oct-03 13:06
Jair29-Oct-03 13:06 
GeneralRe: WINS Pin
Jair1-Nov-03 3:29
Jair1-Nov-03 3:29 
QuestionXP GetSysColor()??? Pin
alex.barylski29-Oct-03 12:17
alex.barylski29-Oct-03 12:17 
AnswerRe: XP GetSysColor()??? Pin
michael_cowan29-Oct-03 13:00
michael_cowan29-Oct-03 13:00 
GeneralRe: XP GetSysColor()??? Pin
alex.barylski29-Oct-03 15:17
alex.barylski29-Oct-03 15:17 
GeneralCalling a dialog from a dll question Pin
Steve Messer29-Oct-03 11:53
Steve Messer29-Oct-03 11:53 
GeneralRe: Calling a dialog from a dll question Pin
igor196029-Oct-03 12:49
igor196029-Oct-03 12:49 
GeneralRe: Calling a dialog from a dll question Pin
Steve Messer29-Oct-03 14:35
Steve Messer29-Oct-03 14:35 
GeneralProblem with control arrays Pin
Stephan Poirier29-Oct-03 11:49
Stephan Poirier29-Oct-03 11:49 
Hi everyone!

I need to create a button array that can be resized.
I tought it was easy like in VB but I got a problem. I'm unable to create buttons!

For example, I placed this is my header file :

//Pointer to button array<br />
CButton* myButton;<br />
<br />
//Hold number of buttons in the list<br />
int nbButtons;<br />
<br />
//Add a button in the list<br />
void InsertButton(LPCTSTR lpszText);


Then in the implementation file, I've set

void CLinkList::InsertButton(LPCTSTR lpszText)<br />
{<br />
        // Memory allocation ( preserve existing!! )<br />
	if(nbButtons<1)   // First memory allocation<br />
	    myButton=(CButton*)malloc(sizeof(CButton)*(nbButtons+1));	<br />
        else              // Dynamic realoccation<br />
	    myButton=(CButton*)realloc(myButton, sizeof(CButton)* (nbButtons+1));	<br />
<br />
        // Set location<br />
	CRect rect(0,nbButtons*25,60,20);<br />
	<br />
        // Create the button control<br />
	myButton[nIndex].Create( lpszText, WS_VISIBLE | WS_CHILD, rect, this, GetDlgCtrlID() );<br />
<br />
        // Increment number of buttons in the list<br />
	nbButtons++;<br />
<br />
}


But I'm not able to create any button. I didn't get any assertion error but it stop within the CButton::Create function. I don't have any idea of what is the problem.

I know that if I create a static array like :

CButton myButton[30];

it works very well...

What's wrong with the way I do, and how can I solve it? Notice that I want my array to be resized because I don't want to hold a "big" static array. And probably because I'm curious to know how it works too! Big Grin | :-D

It will be very appreciated if somebody here could help me!!

Stef

Progamming looks like taking drugs...
I think I did an overdose. Poke tongue | ;-P

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.