|
Shilpi Boosar wrote: Click Here -->[^]
its listctrl not listbox!
|
|
|
|
|
But why you dont use of CListCtrl?
|
|
|
|
|
In the existing code,they r using list box. They r passing the listbox variable to some other functions.If i changed listbox to listctrl,i need to change the existing code also. So i want to add gird to list box without doing any changes in the existing code.
|
|
|
|
|
Does this[^] help?
Regards,
Sandip.
|
|
|
|
|
i have this code guys:
j = -3;
for (i=0;i<3;i++)
{
switch (j+2)
{
case 3:
case 2: j--;
break;
case 0: j += 2;
break;
default: j=0;
}
if (j>0) break;
j = 3-i;
}
i want to write this without the breaks and goto
how can i do it gurus?
phokojoe
|
|
|
|
|
int j = 1; Remove everything else.
It's better to do your homework yourself.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
j = -3;
int k = 0;
for (i=0; (i < 3) && (j > 0); i++) {
k = j + 2;
if((3 == k) || (2 == k)) {
j--;
} else if (0 == k) {
j += 2;
} else {
j = 0;
}
if(j <= 0) {
j = 3 - i;
}
}
|
|
|
|
|
I am trying to create 512 CEdit boxes with a "3D" look to them. I know I need to use CreateEx with the style WS_EX_CLIENTEDGE. My Code is below (I have this code in OnInitDialog):
CEdit *EditArray[512];
for(i=0;i<512;i++)
{
EditArray[i] = new CEdit;
EditArray[i]->CreateEx(WS_EX_CLIENTEDGE, _T(controlname), _T(""), WS_CHILD | WS_VISIBLE, CRect(topleft,bottomright), this, i+1500);
}
This code compiles and runs without a hitch...except that the textboxes are never visible. If I switch to a simple CEdit::Create it works and all the textboxes display. Please note that I have code in addition to the above which displays the textboxes in different locations (topleft & bottomright are changed for each textbox). Does anyone have any suggestions as to why I am unable to view these textboxes?
modified on Wednesday, November 12, 2008 2:16 PM
|
|
|
|
|
If you want CreateEx() called more than once, you should consider wrapping it with curly braces.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Right...as I said, this isn't my exact code...curly brackets have been added...back to main question...
|
|
|
|
|
The controlname is CString.
controlname.Format("EDIT%u", i);
So...
EDIT0
EDIT1
EDIT2
...
EDIT511
|
|
|
|
|
Mark Gilson wrote: Right...as I said, this isn't my exact code
If your car doesn't work, do you send another car of the same type to the garage?
I mean, it's hard to help you if you don't provide accurate information and post something else than the code that doesn't work.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Here is my entire OnInitDialog().
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
int i = 0;
int k = 0;
int editcnt = 0;
int staticcnt = 0;
int blockcnt = 0;
CPoint topleft;
CString controlname, staticval;
CPoint bottomright;
CFont *pFont;
pFont = new CFont();
LOGFONT lf;
memset((void*)&lf, 0, sizeof(lf));
lf.lfHeight = 14;
lf.lfWeight = FW_NORMAL;
strcpy(lf.lfFaceName, "Times New Roman");
pFont->CreateFontIndirect(&lf);
for(i=0;i<512;i++)
{
EditArray[i] = new CEdit;
TextArray[i] = new CStatic;
}
for(blockcnt=0;blockcnt<4;blockcnt++)
{
for(int k = 0; k < 320; k += 40)
{
for(int i = 0; i < 464; i += 29)
{
topleft.x = i+30;
topleft.y = k+44;
bottomright.x = i+24+30;
bottomright.y = k+16+44;
controlname.Format("STATIC%u", staticcnt);
staticval.Format("%u", staticcnt);
TextArray[staticcnt]->Create(staticval, WS_CHILD | WS_VISIBLE, CRect(topleft,bottomright), this, staticcnt+3500);
TextArray[staticcnt]->SetFont(pFont);
TextArray[staticcnt]->ModifyStyle(0, ES_CENTER, SWP_DRAWFRAME|SWP_FRAMECHANGED);
staticcnt++;
}
}
for(int k = 0; k < 320; k += 40)
{
for(int i = 0; i < 464; i += 29)
{
topleft.x = i+30;
topleft.y = k+60;
bottomright.x = i+24+30;
bottomright.y = k+20+60;
controlname.Format("EDIT%u", editcnt);
EditArray[editcnt]->CreateEx(WS_EX_CLIENTEDGE, _T(controlname), _T(""), WS_CHILD | WS_VISIBLE, CRect(topleft,bottomright), this, editcnt+1500);
editcnt++;
}
}
}
for(i=128;i<512;i++)
{
TextArray[i]->ShowWindow(FALSE);
}
tabs.InsertItem(0, "Block 0");
tabs.InsertItem(1, "Block 1");
tabs.InsertItem(2, "Block 2");
tabs.InsertItem(3, "Block 3");
tabs.SetCurSel(0);
return TRUE;
}
|
|
|
|
|
Hint: Have a look at what CreateEx() returns and if it happens to be FALSE you might want to check out what GetLastError() returns....
You have to use a registered window class and the names you create on the fly are not registered window classes.
Your call should look like this:
CreateEx( WS_EX_CLIENTEDGE, _T("EDIT"), _T("").....
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
How would I be able to use a registered window class for each of these CEdit boxes? Where/How do I register "EDIT0", "EDIT1", etc...
|
|
|
|
|
You really need a different CLASS for each control?
I'm curious - what are you trying to do?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm simply trying to make 512 Edit Controls programatically. In addition to this I would like them to be "3D" which requires the CreateEx. Other than that I'm open to any solution.
|
|
|
|
|
Ah...found my problem. If I simply use "EDIT" as the class name it works. I guess for some reason I thought I needed a new class for each Edit Control. Thank you Mark for giving me the right clues!
|
|
|
|
|
Give them different names... different IDs.... but different classes?
Glad you got it!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Gilson wrote: I guess for some reason I thought I needed a new class for each Edit Control.
Don't confuse a window class (EDIT) with an MFC class (CEdit ).
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Mark Gilson wrote: If I simply use "EDIT" as the class name it works.
I thought I told you that, or at least I tried with the code snippet...
Glad it works now, but a dialog with 512 edit boxes?
I guess I would close that window and never open it again....
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Mark Gilson wrote: Right...as I said, this isn't my exact code
You may have intended to say it, but that does not mean it got read. Go back and re-read your post. Notice anything missing, like:
"...display. Please note that I have code in addition to the above which displays the textboxes in different locations (topleft & bottomright are changed for each textbox). Does anyone have any suggestions as to why I am unable to view these textboxes?"
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
If David's most accurate reply doesn't help because you've posted code that's not the same as you're trying to build, then I'm curious about what's hidden behind the "controlname " identifier.
Is it really "Edit" for edit boxes, as CEdit::Create() would use, or is it a window class you've registered yourself?
On the other hand, since you're already walking through the array of CEdit pointers and presumably calling SetWindowPos() , you could also call ModifyStyleEx() in order to add the WS_EX_CLIENTEDGE style to your controls.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I am having problem opening a file after I change the version number. I would like to add an extra variable to class... changed int Version = 6; and said if(Version >5) ar>>newVariable;
void CLineClass::Serialize(CArchive& ar)
{
if(ar.IsStoring()){
int Version= 5;
ar<<Version;
ar<<m_ChannelName<<m_IsAltered<<m_MaxNumberOfBoards<<m_LineAddress<<m_LineColor<<m_ShortChannelName<<
m_LookUpTableFilename<<m_Units<<m_DecimalPlaces<<m_Description<<m_PrivateNotes;
}
else{
int Version;
ar>>Version;
ar>>m_ChannelName>>m_IsAltered>>m_MaxNumberOfBoards>>m_LineAddress>>m_LineColor>>m_ShortChannelName>>
m_LookUpTableFilename;
if(Version>2)
ar>>m_Units;
else
m_Units=0;
if(Version>3)
ar>>m_DecimalPlaces;
if(Version>4)
ar>>m_Description>>m_PrivateNotes;
}
m_COperationArray.Serialize(ar);
m_LookUpTableArray.Serialize(ar);
}
modified on Wednesday, November 12, 2008 12:52 PM
|
|
|
|
|
What you've posted can be considered as "dummy code".
Dummy code only works for explaining a concept, but you've already proven the concept with "version 5".
I suggest you post the real code instead.
What you've posted doesn't even compile due to spelling errors and mismatching braces.
This is to prevent an endless loop where the rest of us find errors in the code you've posted and you go "my real code doesn't look like that". And if no error is found in the dummy code you won't know what's wrong with the real code.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|