0

Hi friends, here's my code..

OnCreate(hwnd,cs,initRecArea(480,45,55,20),(HMENU)IDCE_SINGLELINE5);
	OnCreate(hwnd,cs,initRecArea(480,105,55,20),(HMENU)IDCE_SINGLELINE7);
	OnCreate(hwnd,cs,initRecArea(480,135,55,20),(HMENU)IDCE_SINGLELINE8);
	OnCreate(hwnd,cs,initRecArea(480,165,55,20),(HMENU)IDCE_SINGLELINE9);
	OnCreate(hwnd,cs,initRecArea(480,195,55,20),(HMENU)IDCE_SINGLELINE10);
	OnCreate(hwnd,cs,initRecArea(480,225,55,20),(HMENU)IDCE_SINGLELINE11);
	OnCreate(hwnd,cs,initRecArea(480,255,55,20),(HMENU)IDCE_SINGLELINE12);

Since all these lines are a repetition except the second argument of initRecArea() which increments by 30, and last argument of OnCreate() which only has the last character changing, i would prefer looping this code as follows...

char cnt;

	for (next=45, cnt=48;next<=255;next+=30, cnt++)	{
		sprintf(buffer,"%s%d","IDCE_SINGLELINE",cnt);
		OnCreate(hwnd,cs,initRecArea(205,45,55,20),(HMENU)buffer);
	}

but buffer is a string not a symbolic constant... How do i treat it as a constant? Or any other solutions to this?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
0

why not just put an int there, and you can juse use RECT instead of initRecArea

unsigned int cnt;

	for (next=45, cnt=48;next<=255;next+=30, cnt++)	{
		OnCreate(hwnd,cs,RECT(205,45,55,20),(HMENU)cnt);
	}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.