|
|
You can handle the LVN_ENDLABELEDIT message in the CListCtrl, and in the message handler, post a custom Windows message to the parent:
void CMyListCtrl::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
...
GetParent()->SendMessage(WM_LISTWASMODIFIED);
...
}
There's a great article on custom windows messages somewhere on CodeProject. I don'w remember who wrote it, but if you google, "custom windows messages codeproject", you should find it.
Hope this helps.
-Ian
|
|
|
|
|
This message will not be sent, when i use SetItemText to change the item
text.
I want the parent to be notified when SetItemText is called, because I don't call SetItemText in CListCtrl's parent.
|
|
|
|
|
When an item is changed, the control will send a LVN_ITEMCHANGED notification to its parent.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Is there any code for seaching a pattern in a given string
example
String given for search -
HELLO THIS IS A TEST
Pattern given for search -
1 - ?ELLO
2 - *IS A
3 - THIS*
4 - *THIS*
5 - T?IS
6 - ?ELLO
7 - ??LLO
These all must return as found the pattern in string
? - For any charecter
* - Any word
|
|
|
|
|
|
Hi,
I have a VB6 application with a listview control in it. I have written an app in VC++ to
get the handle of the ListView control of the VB6 app.Then I used Jeff Ritcher's suggestion
from http://www.microsoft.com/msj/0997/win320997.aspx and according read the items from the
listview.Then I have to select the item. The problem comes here.When I select an item in the
listview, it gets selected ,but the previously selected item is still hilighted.The multiple
selection property of the listview is set to false.I have also tried to deselct the items.But
it didnot work.I am pasting the code below:
void CListtestDlg::OnButton1()
{
CString str1,str2,str3,str4="Item1";
HWND hWnd=::FindWindow ("ThunderRT6FormDC",NULL);
str1.Format ("%x",hWnd);
//::MessageBox(0,str1,"Handle1",MB_OK);
HWND hWnd1=::FindWindowEx (hWnd,NULL,"ListView20WndClass",NULL);
// HWND hWnd1=::GetWindow (hWnd,GW_CHILD);
HWND hWnd2=::FindWindowEx (hWnd,NULL,"ThunderRT6CommandButton",NULL);
str2.Format ("%x",hWnd2);
//::MessageBox(0,str2,"Handle2",MB_OK);
// BOOL hWnd2=::EnableWindow (hWnd,TRUE);
//int m=::GetDlgCtrlID (hWnd1);
/* if(hWnd2)
{
str3.Format ("%d",hWnd2);
::MessageBox (0,str3,"m",MB_OK);
}
//long c=::SendDlgItemMessage(hWnd,
*/
//::SendMessage(hWnd1,LVN_INSERTITEM,1,5);
TCHAR sz[100];
LV_ITEM lvItem;
//LPTSTR lpText=(LPVOID*)::HeapAlloc (::GetProcessHeap (),0,200);
//int x;
//x=ListView_GetCountPerPage(hWnd1);
// lvItem.mask=LVIF_TEXT;
//lvItem.pszText="Item 100";
// lvItem.iItem=0;
// lvItem.iSubItem=0;
// lvItem.pszText=sz;
//lvItem.cchTextMax= sizeof(sz);
//LRESULT lResult = ::SendMessage(hWnd1, LVM_GETITEM, 0, (LPARAM) &lvItem );
//BOOL b = ListView_GetItem(hWnd1,&lvItem);
TCHAR* szText1=NULL;
TCHAR* szText2=NULL;
TCHAR* szText3=NULL;
TCHAR *szText4=" Item 1";
// int n=ListView_GetItemCount(hWnd1);
// str3.Format ("%d",n);
//::MessageBox (hWnd1,str3,"Item count",MB_OK);
getItemTextFromListBox(hWnd1, 0,0, &szText1);
getItemTextFromListBox(hWnd1, 0,1, &szText2);
getItemTextFromListBox(hWnd1, 1,0, &szText3);
// ListView_SetItemState(hWnd1, -1, 0, LVIS_SELECTED)
//int x=ListView_GetItemState(hWnd1,1,1);
// str3.Format ("%d",x);
//::MessageBox (0,str3,"Value",MB_OK);
// ListView_SetItemState(hWnd1,-1,0,LVIS_SELECTED );
//ListView_SetHotItem(hWnd1,2);
//ListView_RedrawItems(hWnd1,0,2);
if( 0==_tcscmp(szText1,szText4))
{
TRACE("Matched");
//
// ListView_RedrawItems(hWnd1,0,2);
// int dd=ListView_GetSelectedCount(hWnd1);
//if(dd>0)
//{
//::SetFocus (hWnd1);
// ::SetActiveWindow (hWnd1);
//ListView_SetItemState(hWnd1, -1, 0, 0);
//::SendMessage(hWnd1,WM_SETFOCUS,0,0);
::SendMessage(hWnd1,WM_SETFOCUS,0,0);
::SendMessage(hWnd1,LVM_SETITEMSTATE,0,0);
//::SendMessage (hWnd1,LVM_REDRAWITEMS,0,0);
//ListView_SetItemState(hWnd1, -1, 0, (LVIS_FOCUSED) ); // deselect // deselect
// ::SetFocus (hWnd1);
// ListView_RedrawItems(hWnd1,0,2);
//if(!x)
//{
// ListView_SetItemState(hWnd1, -1, 0, LVIS_SELECTED);
//ListView_SetItemState(hWnd1, 1, 0, LVIS_SELECTED );
//}
//if(dd>0)
//{
RECT re;
//ListView_GetViewRect(hWnd1,&re);
//long d=re.left ;
//long e
//BOOL k= ::UpdateWindow (hWnd1);
int x=ListView_GetSelectedCount(hWnd1);
// ListView_SetItemCount
//ListView_SetItemState(hWnd1, 2, LVIS_SELECTED , LVIS_SELECTED );
//}
//:: UpdateWindow(hWnd1);// select iListPos
//ListView_SetItemState(hWnd1, 0, LVIS_FOCUSED , LVIS_FOCUSED );
//::UpdateWindow(hWnd2);
// ListView_Update(hWnd1,1);
//Button_Click(hWnd2);
//::SendMessage(hWnd2,WM_LBUTTONDOWN,0,0);
//::SendMessage(hWnd2,WM_LBUTTONUP,0,0);
}
if(szText1)
delete szText1;
if(szText2)
free(szText2);
if(szText3)
free(szText3);
}
bool
getItemTextFromListBox(HWND hWndListView, int item, int subItem, TCHAR** ppwszText)
{
bool retcode=false;
TCHAR szReadBuffer[1024];
memset(szReadBuffer, 0, sizeof(szReadBuffer) );
LV_ITEM* plvi=NULL;
DWORD dwProcessId;
GetWindowThreadProcessId(hWndListView, &dwProcessId);
// Open a handle to the remote process's kernel object
HANDLE hProcess = OpenProcess(
PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE,
FALSE, dwProcessId);
if (hProcess == NULL) {
MessageBox(NULL, __TEXT("Could not communicate with process"),
"ERROR", MB_OK | MB_ICONWARNING);
goto cleanup;
}
// Allocate memory in the remote process's address space
plvi = (LV_ITEM*) VirtualAllocEx(hProcess,
NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if(plvi==NULL) {
goto cleanup;
}
// Get the ListView item's text data
// Initialize a local LV_ITEM structure
LV_ITEM lvi;
memset(&lvi, 0, sizeof(LV_ITEM) );
lvi.mask = LVIF_TEXT;
lvi.iItem = item;
lvi.iSubItem = subItem;
// NOTE: The text data immediately follows the LV_ITEM structure
// in the memory block allocated in the remote process.
lvi.pszText = (LPTSTR) (plvi + 1);
lvi.cchTextMax = 100;
// Write the local LV_ITEM structure to the remote memory block
if( !WriteProcessMemory(hProcess, plvi, &lvi, sizeof(lvi), NULL) ) {
goto cleanup;
}
// Tell the ListView control to fill the remote LV_ITEM structure
ListView_GetItem(hWndListView, plvi);
// Read the remote text string into the end of our clipboard buffer
if( !ReadProcessMemory(hProcess, plvi + 1, (LPVOID) &szReadBuffer, sizeof(szReadBuffer), NULL) ) {
goto cleanup;
}
*ppwszText = (TCHAR*) malloc( _tcslen( szReadBuffer ) + sizeof(TCHAR) );
if(!*ppwszText) {
goto cleanup;
}
retcode=true;
_tcscpy(*ppwszText, szReadBuffer);
// ListView_SetItemState(hWndListView, -1, 0, LVIS_SELECTED);
cleanup:
// Free the memory in the remote process's address space
if(hProcess) {
VirtualFreeEx(hProcess, plvi, 0, MEM_RELEASE);
// Cleanup and put our results on the clipboard
CloseHandle(hProcess);
}
return retcode;
}
|
|
|
|
|
A general way is appreciated. Thanks.
|
|
|
|
|
By "flat" do you mean without the 3D style?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
The only way I can think of is to not load the 3D library (CTL3D32.DLL). I'm sure there's a way to do it on a control-by-control basis but I've never been inclined to find out.
Another option is to play around with the other styles for that control and see if any of them render it non-3D.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi everyone.
i want to watch a special URL in the IE content
when user click it . i want to get the msg
and the url content, then i will to do some thing
but how can i make it?
for example:
there is a URL: http://hi.com/myprogram/
when user click it . i want to pop up the program
but i have no idea to do.
can anyone help me?
best regards
|
|
|
|
|
|
What steps should I do to read struct data in one application from another?
I'm trying to read a data structure in one application from another. I have the window handle of the application with me. And I also know the struct.
I need to get the structure pointer through USERDATA param of the window. In the application which owns the struct data places the address of struct data member in the window's USERDATA param by using SetWindowLong(*this,GWL_USERDATA,LONG(&st)) fn.
If a simple integer value is stored as USERDATA, I can read it by GetWindowLong(*pWnd,GWL_USERDATA) fn.
But if address of the structure data member is stored in it, I cannot read it in my application.
Should I use GlobalAlloc function for this purpose?
If so what are the necessary steps that I should do?
Please guide me!
- NS -
|
|
|
|
|
Are you writing both apps, or trying to hack into one ? If the former, then the WM_COPYDATA message is your best bet.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes. Both the applications are mine. But there will be more than one instances of the first one.
Your suggestion is good, no doubt. But if I can read the struct directly, it will be most suitable for me.
Can you suggest an idea?
Thank you.
- NS -
|
|
|
|
|
Nishad S wrote:
Your suggestion is good, no doubt. But if I can read the struct directly, it will be most suitable for me.
Then Shared Memory for Interprocess communication will be Best BET
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Well, definately not the hack you're pursuing now.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In general, you can not pass pointers between applications.
Each process has its own address space, the operating system maps the process specific address to a physical memory address. So process A address 0x00123456 may map to physical address 0x11111111, and process B address 0x00123456 may map to physical address 0x22222222. Don't even think about trying to get/pass physical address'.
You must pass the data.
As Christian said you can use WM_COPYDATA.
There are a number of other ways as well e.g. pipes, memory mapped files, ...
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thank you for the replay.
Can you give me brief explanation about GlobalAlloc(...)?
I'm thinking that it will allocate memory that can use different aplications if they get the handle. (For example clipboard data communication). Am I right?
|
|
|
|
|
No, GlobalAlloc() alone can not do what you want.
You could probably use the clipboard to do what you want but it would be a lot more work than using one of the other methods mentioned.
A handle is like a pointer in that it is specific to the application and can not be shared with another application (in general).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
VC++ 6, MFC, SP5, WinXP - Home .
I've spent the last few months writing an application for work (They found out I do some programming for fun and now it's part of my job ) Anyway, The application is done and runs fine on XP. Both the release version and debug version run well, debug shows no memory leaks or asserts (other then the asserts I want it to show.)
So anyway, I try to run it on Win 2K and the app crashes at start up. No chance for the main window to open or anything. The crash is not a GPF or a blue screen, just a small message box that states "Your program has done something I don't like and will close now. A log is being created. OK." - Well, that's not the actual message but the jest of it ...and it doesn't tell me where the darn log is!!! I know I took a lot of care to use API functions that would work all the way down to Win 95, so I'm kind of stummped. I even used some of the debugging code here on Codeproject to insert into the application during debug builds and it shows everything was A-OK.
Anyone have any ideas of where I can even start looking for the cause of this crash?
Thanks for any advice.
-- modified at 23:00 Tuesday 6th September, 2005
|
|
|
|
|
-- modified at 23:42 Tuesday 6th September, 2005
For the record, I deleted this because CP posted it twice....
|
|
|
|
|
If a log was created, it's probably in the system event log. My first step with problems like this is to create a global file object, and to use it to log how far the app gets before crashing, and work out what line is blowing up through a process of elimination.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the idea! Sort of like a debug output screen but written to a file. That it too simple!
And off the record, your other message was deleted because you were really listening to Iron Maiden again, right?
Thanks for the help!
Paul...
|
|
|
|
|