Click here to Skip to main content
15,907,183 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: !UPDATED! Debug works but release crashes (this one's tricky) Pin
Yawar Maajed30-Jun-04 13:40
Yawar Maajed30-Jun-04 13:40 
QuestionRe: !UPDATED! Debug works but release crashes (this one's tricky) Pin
dahill20-Mar-06 13:05
dahill20-Mar-06 13:05 
GeneralDisable start button Pin
Larsson30-Jun-04 10:52
Larsson30-Jun-04 10:52 
GeneralRe: Disable start button Pin
P-Rex30-Jun-04 20:32
P-Rex30-Jun-04 20:32 
GeneralRe: Disable start button Pin
Larsson1-Jul-04 0:36
Larsson1-Jul-04 0:36 
Generalicon question Pin
Spiritofamerica30-Jun-04 10:49
Spiritofamerica30-Jun-04 10:49 
GeneralRe: icon question Pin
David Crow30-Jun-04 10:52
David Crow30-Jun-04 10:52 
GeneralNewbee: OLE Drag&Drop CListCtrl Problem Pin
otrcomm30-Jun-04 10:35
otrcomm30-Jun-04 10:35 
Hello,

I am gleening some code that I found that uses OLE for Drag&Drop across multiple CListCtrls. The main problem is that I am very new to Visual C++ and need some help with LVITEM structures.


In my .h file I have

typedef struct {
LVITEM lvi;
char szLabel[256];
CString sFrom;
CString smsg_num;
} ListInfo;

And am trying to get multiple column data from a CListCtrl to drag&drop.

In my .cpp file I have:

...

void CDDListCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
...

// Create global memory for sharing dragdrop data, we allocate
// space for 2 int and nItem ListInfo structures
HGLOBAL hgData = GlobalAlloc(GPTR,m_nItem*sizeof(ListInfo)+2*sizeof(int));
ASSERT(hgData!=NULL);
char* p = (char*) GlobalLock(hgData);
ASSERT(p!=NULL);

// Place control type in first 2 bytes
*(int *) (p) = CT_LIST;

// Place number of list items in next 2 bytes
*(int *) (p+sizeof(int)) = m_nItem;

// Then the nItem ListInfo structures will start at:
ListInfo* lpData = (ListInfo*) (p + 2*sizeof(int));


CString DebugStr;

// Here is where we read all selected items into array. - Murrah
int jItem = -1;
int i = 0;
while ((jItem = GetNextItem(jItem,LVNI_ALL | LVNI_SELECTED)) > -1)
{
ASSERT(i>=0 && i <m_nItem);
ZeroMemory(&lpData[i], sizeof(ListInfo));

lpData[i].lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
lpData[i].lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
lpData[i].lvi.pszText = (char*) &(lpData[i].szLabel);
lpData[i].lvi.iItem = jItem;
lpData[i].lvi.cchTextMax = 255;

// GetItemText works here, now to figure out how to get it into lpData[i];
//DebugStr.Format(_T("%s"),GetItemText(jItem, 2));
//AfxMessageBox(DebugStr);

// pDragList->GetItem (lvi.plvi);
// lvi.sFrom = pDragList->GetItemText(lvi.plvi->iItem, 1);
// lvi.smsg_num = pDragList->GetItemText(lvi.plvi->iItem, 2);

BOOL bSuccess = GetItem(&(lpData[i].lvi));
ASSERT(bSuccess);
// lpData[i].sFrom = GetItemText(jItem, 1);

m_pSaveIndItem[i] = jItem;
i++;
}
...

I gleened this code from another application that I found (except I added the two CStrings in the ListInfo structure), and it works fine for a single column CListCtrl, but I can't figure out how to get my other column data into lpData[i].

GetItemText(jItem, 1) and GetItemText(jItem, 2) both return the correct data for the subitems, but I just can't figure out how to get it into lpData[i].

Also, once I do get the data into lpData[i], how do I get it back out when I finalize the drop?

Thanks,
Murrah Boswell
Generalphone number Pin
Nemok30-Jun-04 10:20
Nemok30-Jun-04 10:20 
GeneralRe: phone number Pin
David Crow30-Jun-04 10:50
David Crow30-Jun-04 10:50 
GeneralWhy does CreateProcess NOT work inside a service application Pin
Anonymous30-Jun-04 9:29
Anonymous30-Jun-04 9:29 
GeneralRe: Why does CreateProcess NOT work inside a service application Pin
palbano30-Jun-04 9:41
palbano30-Jun-04 9:41 
GeneralRe: Why does CreateProcess NOT work inside a service application Pin
Anonymous30-Jun-04 9:51
Anonymous30-Jun-04 9:51 
GeneralRe: Why does CreateProcess NOT work inside a service application Pin
Blake Miller30-Jun-04 10:39
Blake Miller30-Jun-04 10:39 
GeneralRe: Why does CreateProcess NOT work inside a service application Pin
Graham Bradshaw30-Jun-04 12:01
Graham Bradshaw30-Jun-04 12:01 
GeneralRe: Why does CreateProcess NOT work inside a service application Pin
Anders Molin30-Jun-04 14:44
professionalAnders Molin30-Jun-04 14:44 
Questionhow to write this program? Pin
theeastdevil30-Jun-04 6:54
theeastdevil30-Jun-04 6:54 
AnswerRe: how to write this program? Pin
Antony M Kancidrowski30-Jun-04 6:57
Antony M Kancidrowski30-Jun-04 6:57 
AnswerRe: how to write this program? Pin
Maximilien30-Jun-04 7:10
Maximilien30-Jun-04 7:10 
GeneralRe: how to write this program? Pin
palbano30-Jun-04 7:15
palbano30-Jun-04 7:15 
GeneralRe: how to write this program? Pin
Maximilien30-Jun-04 7:19
Maximilien30-Jun-04 7:19 
GeneralRe: how to write this program? Pin
palbano30-Jun-04 7:30
palbano30-Jun-04 7:30 
AnswerRe: how to write this program? Pin
Ravi Bhavnani30-Jun-04 7:47
professionalRavi Bhavnani30-Jun-04 7:47 
AnswerRe: how to write this program? Pin
Johan Rosengren30-Jun-04 8:59
Johan Rosengren30-Jun-04 8:59 
GeneralRe: how to write this program? Pin
Wes Aday30-Jun-04 9:07
professionalWes Aday30-Jun-04 9:07 

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.