|
Hi All,
I used customized ListCtrl in my application. I derived class from CListCtrl clas. I add JPEG images in ListCtrl now i want to check that which JPEG image is selected by the user. I use following code but it does not return me image path or image name.
void
CSelectBusCategory::OnSelectItemFromList(NMHDR* pNMHDR, LRESULT* pResult)
{
int nItem,nSubItem,nLen;
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
// CString strJPEGFileName = mWebPagePrvListCtrl.GetItemText(pNMListView->iItem,pNMListView->iSubItem);
// MessageBox(strJPEGFileName);
}
Is there any other code to retrive path of JPEG image
Thanks in Advance
Atul
|
|
|
|
|
Atulmahajan wrote: I use following code but it does not return me image path or image name.
Store that information by calling SetItemData() for each image added to the control. Then when you are responding to an image selection, call GetItemData() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for reply,
If I use SetItemData() function it takes 2 parameter 1)index 2) 32 bit DWORD value. I can pass index but what value should i pass to DWORD parameter.
Plz reply to this question.
Thanks in Advance
atul
|
|
|
|
|
Atulmahajan wrote: what value should i pass to DWORD parameter.
Remember that pointers to memory address are just 32-bit numbers.
char *pszPath = new char[29];
strcpy(pszPath, "c:\\windows\\system32\\calc.exe");
int nIndex = mWebPagePrvListCtrl.InsertItem(...);
mWebPagePrvListCtrl.SetItemData(nIndex, (DWORD) pszPath);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In addition to DavidCrow's reply - if the parameter for SetItemData() is a DWORD_PTR,
use that instead of a DWORD in the cast.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I have a childframe derived from CMDIChildWnd on which there are 2 windows controls. One window control is a list box and another is an edit box . The list box is above the edit box.
When I keep the mouse cursor on the list box it appears as if the the mouse cursor is on the edit box and when I click the edit box gets clicked.
How can I bring the list box on the foreground and send the edit box in the background?
Pritha
|
|
|
|
|
You can use m_list.SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
And I expect some painting issues...
m_edit.ModifyStyle( 0, WS_CLIPSIBLINGS ); may solve that issue.
Dont forget to let me know the results...
- NS -
|
|
|
|
|
I presume the two controls have the same coordinates, and you are swapping between them?
In addition to changing the Z order as NS17 showed you, you should also make the one you're not using disabled,
GetDlgItem (IDC_MYNEGLECTEDCONTROL)->EnableWindow (TRUE / FALSE) , or the user will end up selecting them using TAB - and they will be very puzzled why the things they are typing don't show up...
Iain.
|
|
|
|
|
prithaa wrote: How can I bring the list box on the foreground and send the edit box in the background?
call BringWindowToTop() for list box
|
|
|
|
|
are you still on about this. your best bet is to get the window sizes and adjust the edit box such that it doesnt overlap the listbox. am I gunna give you the code to do that ? no. GetWindowRect(), GetClientRect(), MapWindowPoints(), SetWindowPos(). Maybe in response to a WM_SIZE message.
|
|
|
|
|
the title says it all. i just want to show the text and disable the option that user can input some text in the rich edit box control
thanx
|
|
|
|
|
You can call SetReadOnly() API
- NS -
|
|
|
|
|
thanx. that did the trick
|
|
|
|
|
You are welcome...
- NS -
|
|
|
|
|
You can disable or read only your control(Richedit) with set these opition (disable or readonly) on the property window of control.
|
|
|
|
|
Does it need to be read-only all of the time? If so, do that in the resource file rather than at runtime via SetReadOnly() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How can I resize Rich Edit Box in the code? I already know the width and the height.
thanx
|
|
|
|
|
barbarini wrote: How can I resize Rich Edit Box in the code
Use MoveWindow or SetWindowPos
- NS -
|
|
|
|
|
I tried this:
void CTextView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
m_RichEdit.SetWindowPos(this, 0, 0, cx, cy, SWP_NOMOVE);
}
program will not start beacuse i get some message. I think the problem is in "this" in SetWindowPos. My base class is CFormView. Any ideas?
|
|
|
|
|
That may be due to the following reason.
m_RichEdit will not be subclassed when OnSize is called for the first time. This usually happens in the dialog based applications.
In your case, you can do as...
GetDlgItem( IDC_RICHEDIT )->SetWindowPos(this, 0, 0, cx, cy, SWP_NOMOVE);
Hope it will work...
- NS -
|
|
|
|
|
barbarini wrote: SetWindowPos(this, 0, 0, cx, cy, SWP_NOMOVE);
One thing i ignored...
Why are you passing the "this"? It is not needed. You can set it as NULL and modify it as ( 0, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE )
- NS -
|
|
|
|
|
This is safe:
void CTextView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if (m_RichEdit.GetSafeHwnd())
m_RichEdit.MoveWindowPos(0, 0, cx, cy);
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
cannot convert parameter 1 from 'struct HWND__ *' to 'const class CWnd *'
this is the message I get when I try your solution.
Grhhhhh.... This is driving my crazy......
|
|
|
|
|
I'm sorry - it was my mistake - I didn't delete the "Pos" when I changed the
SetWindowPos to MoveWindow
void CTextView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if (m_RichEdit.GetSafeHwnd())
m_RichEdit.MoveWindow(0, 0, cx, cy);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
YES YES YES......
Many Thanx...... You saved the day......
|
|
|
|