- This topic has 93 replies, 3 voices, and was last updated 18 years ago by
method.
-
AuthorPosts
-
July 9, 2006 at 4:38 am #188663
BattleStar-Galactica
Memberdo you know how to declare a function for your class?
example like this in your myclassdlg.h
public: int GetPosByNick(CString szNick); and in your file example myclassdlg.ccp int myclassdlg::GetPosByNick(CString szNick) { HWND hList=NULL; // List View identifier HWND parent,child; parent=NULL; child=NULL; parent = ::FindWindow("My Window Class",NULL); child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); hList=::FindWindowEx(child,0,"SysListView32",NULL); HWND hwnd=parent; HWND listview=hList; int count=(int)::SendMessage(listview, LVM_GETITEMCOUNT, 0, 0); int i; LVITEM lvi, *_lvi; char item[512]; char *_item; unsigned long pid; HANDLE process; GetWindowThreadProcessId(listview, &pid); process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid); _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; for(i=0; i
and in your button click do like this
HWND listview=NULL; // List View identifier HWND parent,child; parent=NULL; child=NULL; parent = ::FindWindow("My Window Class",NULL); child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); listview=::FindWindowEx(child,0,"SysListView32",NULL); //UpdateData(true);//update content of textbox to m_nick variable //::AfxMessageBox(m_nick); int pos=-1; pos =GetPosByNick("yournicktohighlighthere"); LVITEM lvi, *_lvi; unsigned long pid; HANDLE process; GetWindowThreadProcessId(listview, &pid); process=OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, pid); if(process) { _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); lvi.mask = LVIF_STATE; lvi.state =15; lvi.stateMask = LVIS_SELECTED | LVIS_FOCUSED; if(pos==-1) pos=0; WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); ::SendMessage(listview, LVM_SETITEMSTATE, (WPARAM)pos, (LPARAM)_lvi); VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); } ::CloseHandle(process);
that’s it, that’s all hope is clear for you
July 9, 2006 at 4:23 pm #188662method
Membernano i made a new mfc project and just dragged a button and edit box . Now what should i do next? How and where to place your code ? i attached a pic.Thanks
July 9, 2006 at 4:39 pm #188661BattleStar-Galactica
Memberin your file FindUserDlg.h
add these lines
public: int GetPosByNick(CString szNick); and in FindUserDlg.ccp add these lines int FindUserDlg::GetPosByNick(CString szNick) { HWND hList=NULL; // List View identifier HWND parent,child; parent=NULL; child=NULL; parent = ::FindWindow("My Window Class",NULL); child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); hList=::FindWindowEx(child,0,"SysListView32",NULL); HWND hwnd=parent; HWND listview=hList; int count=(int)::SendMessage(listview, LVM_GETITEMCOUNT, 0, 0); int i; LVITEM lvi, *_lvi; char item[512]; char *_item; unsigned long pid; HANDLE process; GetWindowThreadProcessId(listview, &pid); process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid); _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; for(i=0; i<count; i++)="" {="" lvi.isubitem="2;" lvi.psztext="_item;" writeprocessmemory(process,="" _lvi,="" &lvi,="" sizeof(lvitem),="" null);="" ::sendmessage(listview,="" lvm_getitemtext,="" (wparam)i,="" (lparam)_lvi);="" readprocessmemory(process,="" _item,="" item,="" 512,="" _subitem,="" subitem,="" if(item="=szNick)" virtualfreeex(process,="" 0,="" mem_release);="" ::closehandle(process);="" return="" i;="" }="" -1;="" }<="" pre="">
and other snippet code put them in button click
July 9, 2006 at 4:49 pm #188660BattleStar-Galactica
Membertry to get vs2005 and I can do some demo for whatever you want if i can. It’s too hard for me to help you like now.
July 9, 2006 at 10:55 pm #188659method
MemberNano thank u for u nice explantion. In few days i will install visual studio 2005 express edtion. My hardrive is full i can not install it now. I tried your code and i got the following compile error:
Configuration: FindUser - Win32 Debug Compiling... FindUser.cpp c:visualcfinduserfinduserdlg.h(12) : error C2143: syntax error : missing ';' before 'public' FindUserDlg.cpp c:visualcfinduserfinduserdlg.h(12) : error C2143: syntax error : missing ';' before 'public' C:visualCFindUserFindUserDlg.cpp(15) : error C2653: 'FindUserDlg' : is not a class or namespace name Generating Code... Error executing cl.exe. FindUser.exe - 3 error(s), 0 warning(s)
i doubleed clickd on the button and placed the shown code there:
Here are the errors :
next error
how to use value of textbox instead of yournicktohighlighthere
pos =GetPosByNick(“yournicktohighlighthere”);
July 10, 2006 at 12:30 am #188658BattleStar-Galactica
Memberthe content of your finduserdlg.h must similar like thic pic
July 10, 2006 at 12:43 am #188657method
MemberI changed the content of finduserdlg.h and now i got one error:
error :
Configuration: FindUser - Win32 Debug Compiling... FindUser.cpp FindUserDlg.cpp C:visualCFindUserFindUserDlg.cpp(15) : error C2653: 'FindUserDlg' : is not a class or namespace name Generating Code... Error executing cl.exe. FindUser.exe - 1 error(s), 0 warning(s)
pointing at :
int FindUserDlg::GetPosByNick(CString szNick) {
in FindUserDlg.cpp : implementation file
error pic:
finduserdlg.h content
// FindUserDlg.h : header file // #if !defined(AFX_FINDUSERDLG_H__8EF5BE4C_79B2_4F61_B376_E2A019C98B9C__INCLUDED_) #define AFX_FINDUSERDLG_H__8EF5BE4C_79B2_4F61_B376_E2A019C98B9C__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////////////// // CFindUserDlg dialog class CFindUserDlg : public CDialog { // Construction public: CFindUserDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CFindUserDlg) enum { IDD = IDD_FINDUSER_DIALOG }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFindUserDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: HICON m_hIcon; // Generated message map functions //{{AFX_MSG(CFindUserDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnButton1(); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: int GetPosByNick(CString szNick); ======== placed it here }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_FINDUSERDLG_H__8EF5BE4C_79B2_4F61_B376_E2A019C98B9C__INCLUDED_)
July 10, 2006 at 2:11 am #188656BattleStar-Galactica
Memberseem you dont know how to declare a function for your class, i think is better for you is reading a tutorial on net how to declare it.
July 10, 2006 at 5:35 pm #188655method
Member@nanomachine007 wrote:
seem you dont know how to declare a function for your class, i think is better for you is reading a tutorial on net how to declare it.
I fixed the problem. I dragged a edit box to my form and i want to use its value instead of Name in pos =GetPosByNick(“Name”);
i be happy if u tell me how to use editbox input value instead of current name value .Thanks
void CFindUserDlg::OnButton1() { // TODO: Add your control notification handler code here HWND listview=NULL; // List View identifier HWND parent,child; parent=NULL; child=NULL; parent = ::FindWindow("My Window Class",NULL); child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); listview=::FindWindowEx(child,0,"SysListView32",NULL); //UpdateData(true);//update content of textbox to m_nick variable //::AfxMessageBox(m_nick); int pos=-1; pos =GetPosByNick("Name");
Nano finally i installed visual studio 2005 express . Now i open your project and want to test it but i do not find execute button? Furthermore, after compile i do not see the .exe file ? i check debug and release folder and there is not there?!!!
July 10, 2006 at 10:41 pm #188654BattleStar-Galactica
Memberif u use my demo code, u just uncomment this like and is all ok
//UpdateData(true);//update content of textbox to m_nick variable
change to
UpdateData(true);//update content of textbox to m_nick variable
and change pos =GetPosByNick(“Name”);
to
pos =GetPosByNick(m_nick);
July 10, 2006 at 10:47 pm #188653BattleStar-Galactica
Memberclick on green icon rectangular just left word debug you can see the result of that code. I use vs2005 but professional version i dont know if there are different between them 🙄
btw if you want link your variable to your control you have to check to function DataExchange something like that.
Edit control your variable for that type is an instance of CEdit or CString. u just check help online about that. I never ask help when i’am learning mfc or other just read more documentation.
button control your variable must be an instance of CButtonand after go to procedure dataexchange and link them for example like this
DDX_control(pDX,IDC_EDIT1,yourvariableforEditControlHere);
then after you can interact with your control by your variable with procedure UpdateData
in our case I linked the Edit control with an instance of CString.
July 11, 2006 at 12:08 am #188652method
Member@nanomachine007 wrote:
if u use my demo code, u just uncomment this like and is all ok
//UpdateData(true);//update content of textbox to m_nick variable
change to
UpdateData(true);//update content of textbox to m_nick variable
and change pos =GetPosByNick(“Name”);
to
pos =GetPosByNick(m_nick);
man i change my editbox/textbox name to m_nick and now it only goes select the first postion item. It does not highlight the name i enter in edit/textbox!! could u tell me what i am dong wrong. I did what u told me.Thanks
code:
void CFindUserDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HWND listview=NULL; // List View identifier
HWND parent,child;
parent=NULL;
child=NULL;
parent = ::FindWindow("My Window Class",NULL);
child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL);
child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL);
child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL);
child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL);
listview=::FindWindowEx(child,0,"SysListView32",NULL);
UpdateData(true);//update content of textbox to m_nick variable
//::AfxMessageBox(m_nick);
int pos=-1;
pos =GetPosByNick("m_nick");
....
....July 11, 2006 at 12:12 am #188651BattleStar-Galactica
Memberm_nick is not a name for edit control in my demo.
m_nick is a variable i used to link with my edit control. let i check my demo what’s wrong with my demo ❓ ❓ ❓ ❓
July 11, 2006 at 12:17 am #188650BattleStar-Galactica
Membermy demo is working good, i have just tested and i can select the nick i put in textbox
i dont know what’s wrong with you lol
July 11, 2006 at 12:20 am #188649method
Member@nanomachine007 wrote:
my demo is working good, i have just tested and i can select the nick i put in textbox
i dont know what’s wrong with you lol
man the problem is with the edit/textbox if i put any name instead of m_nick it goes finds that an higlights it . But it seems it can not get the value of textbox/editbox!! could u tell me what is wrong with my edit/textbo? did u give me the UpdateData functon code ? may be that is missing
-
AuthorPosts
Related
- You must be logged in to reply to this topic.