|
To the best of my knowledge, there is no LVM_MOVEITEMTOANOTHERPLACE message, so you'll have to write some code.
We'll assume that the item you want to move is as position N.
1/
Make a new item as position (up: N-2, down: N+2);
2/
Copy all the information from OldItem to NewItem.
3/
Delete the old item.
That's it really! Whether you read the OldItem information from the list view, or you can just regenerate it from the original data is up to you.
You also have to be careful about moving the top item up, or bottom item down. But this is a good time to add a selection handler for your list view, and disable the up and down buttons when appropriate.
Iain.
|
|
|
|
|
You idea is working fine . but a major problem is occuring now. every time I have to select the
row to move up and down . how it is possible like in visual studio directory structure that select the row and move up and down by clicking the up and down button with selecting the row every time .
Trioum
|
|
|
|
|
You'll want to make sure the list view has the "show selection always" bit set - though it probably already has.
And you'll need to select the new row after you've done your moving about.
Which is harder than it sounds... You'll need to use LVM_SETITEM (or the mfc equivalent), with LVITEM::mask set to LVIF_STATE, and LVITEM::state set to LVIS_SELECTED.
There may be niftier ways of doing it, but that's the brute force way.
Iain.
|
|
|
|
|
I checked it is not working. if I click the list view row it selected the row with blue color.
if you give me any idea that I select the list view row with blue color without clicking it, only on
the basis of item number i.e. row number then Problem will be solved.
Trioum
|
|
|
|
|
trioum wrote: if you give me any idea that I select the list view row with blue color without clicking it
That's the idea I was giving you. You need to read up on the LVM_SETITEM message - but you only want to set the state, not the whole item.
You may also need an Invalidate to get the listview to repaint itself.
Iain.
|
|
|
|
|
Hi,
I have MessageMap fucntion in Mainfrm.H
I want to use this function in another class.But the messagemap functions are protected i can't use this in another class.
Can i use public out of message map and declared the required fucntions in Public and then use it.
Is this correct way? Or is there any other option in it.
protected:
//{{AFX_MSG(CMainFrame)
afx_msg void OnCursessInfo();
I changed this to (after the line /}}AFX_MSG )
public:
afx_msg void OnCursessInfo();
Anu
|
|
|
|
|
A message map "just" maps incoming messages to methods, it shouldn't care if the given method is accessible from outside of the class or not, so basicly making it public is ok, just not too nice. As an alternative, you could call these methods thorough the message map by using SendMessage or PostMessage.
AtomAnt
- If God wanted man to code, man would have been born without the need to sleep.
|
|
|
|
|
Thank you.
I get tht.
Anu
|
|
|
|
|
How does one get the 'UNIT message' of the, say ONPAINT, function in the other class?
To get a dialog in a CTabCtrl to initialize when selected, unique identifiers (WM_APP + 1)were defined and sent. This works fine as the WindowProc function receives the message and then branches to the appropriate initialization. Would one have to do a user defined message to the WindowProc in the other class, and then issue the function call?
Thanks.
|
|
|
|
|
I want to add grid to list box. how can i add it.Please tell me.
|
|
|
|
|
|
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
|
|
|
|