View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000455 | Far Manager | _Common | public | 2008-01-05 22:59 | 2008-01-09 10:38 |
Reporter | samlyukov | Assigned To | vskirdin | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Fixed in Version | 1.80 alpha 1 | ||||
Summary | 0000455: Fix in GetWindowText | ||||
Description | сабж | ||||
Tags | No tags attached. | ||||
Build | 406 | ||||
2008-01-05 22:59
|
GetWindowText.diff (4,481 bytes)
Index: plist.cpp =================================================================== --- plist.cpp (revision 1425) +++ plist.cpp (working copy) @@ -49,7 +49,6 @@ { VMenu ProcList(UMSG(MProcessListTitle),NULL,0,ScrY-4); ProcList.SetFlags(VMENU_WRAPMODE); -// ProcList.SetHelp("TaskList"); ProcList.SetPosition(-1,-1,0,0); if (!EnumWindows(EnumWindowsProc,(LPARAM)&ProcList)) return; @@ -100,27 +99,30 @@ HWND ProcWnd=(HWND)ProcList.GetUserData(NULL,0); if (ProcWnd!=NULL) { - string strWinTitle; - - wchar_t *lpwszTitle = strWinTitle.GetBuffer (NM*2); - - GetWindowTextW(ProcWnd, lpwszTitle, NM*2); - - strWinTitle.ReleaseBuffer (); - + wchar_t *lpwszTitle=0; + int LenTitle=GetWindowTextLengthW(ProcWnd); + if (LenTitle) + { + lpwszTitle=(wchar_t *)xf_malloc((LenTitle+1)*sizeof(wchar_t)); + if (lpwszTitle!=NULL && (LenTitle=GetWindowTextW(ProcWnd,lpwszTitle,LenTitle+1))) + lpwszTitle[LenTitle]=0; + } DWORD ProcID; GetWindowThreadProcessId(ProcWnd,&ProcID); if (Message(MSG_WARNING,2,UMSG(MKillProcessTitle),UMSG(MAskKillProcess), - strWinTitle,UMSG(MKillProcessWarning),UMSG(MKillProcessKill),UMSG(MCancel))==0) + lpwszTitle?lpwszTitle:L"",UMSG(MKillProcessWarning),UMSG(MKillProcessKill),UMSG(MCancel))==0) if (KillProcess(ProcID)) { Sleep(500); ProcList.Hide(); ShowProcessList(); + if (lpwszTitle) xf_free(lpwszTitle); return; } else Message(MSG_WARNING|MSG_ERRORTYPE,1,UMSG(MKillProcessTitle),UMSG(MCannotKillProcess),UMSG(MOk)); + + if (lpwszTitle) xf_free(lpwszTitle); } } break; @@ -163,7 +165,7 @@ { // ����� 21 if(Opt.Policies.DisabledOptions&FFPOL_KILLTASK) - return FALSE; + return(FALSE); HANDLE hProcess; BOOL bRet; @@ -187,21 +189,22 @@ if (IsWindowVisible(hwnd) || IsIconic(hwnd) && (GetWindowLongW(hwnd,GWL_STYLE) & WS_DISABLED)==0) { - string strTitle; - - wchar_t *lpwszTitle = strTitle.GetBuffer (NM*2); - - GetWindowTextW (hwnd, lpwszTitle, NM*2); - - strTitle.ReleaseBuffer (); - - if ( !strTitle.IsEmpty() ) + int LenTitle=GetWindowTextLengthW(hwnd); + if (LenTitle) { - MenuItemEx ListItem; - - ListItem.Clear (); - ListItem.strName = strTitle; - ProcList->SetUserData((void*)hwnd,sizeof(hwnd),ProcList->AddItem(&ListItem)); + wchar_t *lpwszTitle=(wchar_t *)xf_malloc((LenTitle+1)*sizeof(wchar_t)); + if (lpwszTitle!=NULL) + { + if (LenTitle=GetWindowTextW(hwnd,lpwszTitle,LenTitle+1)) + { + lpwszTitle[LenTitle]=0; + MenuItemEx ListItem; + ListItem.Clear(); + ListItem.strName=lpwszTitle; + ProcList->SetUserData((void*)hwnd,sizeof(hwnd),ProcList->AddItem(&ListItem)); + } + xf_free(lpwszTitle); + } } } return(TRUE); Index: iswind.cpp =================================================================== --- iswind.cpp (revision 1425) +++ iswind.cpp (working copy) @@ -76,28 +76,25 @@ BOOL CALLBACK IsWindowedEnumProc2(HWND hwnd,LPARAM FARTitl) { - int Len=GetWindowTextLengthW(hwnd); - if (!Len) - return(TRUE); - - wchar_t *Title=(wchar_t *)xf_malloc((Len+1)*sizeof(wchar_t)); - - if (!Title) - return(TRUE); - - int LenTitle=GetWindowTextW(hwnd, Title, Len); - + int LenTitle=GetWindowTextLengthW(hwnd); if (LenTitle) { - Title[LenTitle]=0; - if(wcsstr(Title,(const wchar_t *)FARTitl)) + wchar_t *lpwszTitle=(wchar_t *)xf_malloc((LenTitle+1)*sizeof(wchar_t)); + if (lpwszTitle!=NULL) { - hFarWnd=hwnd; - xf_free(Title); - return(FALSE); + if (LenTitle=GetWindowTextW(hwnd, lpwszTitle, LenTitle+1)) + { + lpwszTitle[LenTitle]=0; + if (wcsstr(lpwszTitle,(const wchar_t *)FARTitl)) + { + hFarWnd=hwnd; + xf_free(lpwszTitle); + return(FALSE); + } + } + xf_free(lpwszTitle); } } - xf_free(Title); return(TRUE); } |
|
на счет GetWindowTextLength согласен, но вот уход от класса string - не согласен |
|
в данном конкретном случае вызывать класс будет больно уж громоздко. |
|
Вопросы: 1. Зачем убрал в plist.cpp вот это: ProcList.SetHelp("TaskList"); 2. В iswind.cpp может скобок добавить в if: if (LenTitle=GetWindowTextW(hwnd, lpwszTitle, LenTitle+1)) ы? |
|
первый вопрос отпал ;-) |
|
после 406 |
|
да, можно и скобок ;-) |
Date Modified | Username | Field | Change |
---|---|---|---|
2008-01-05 22:59 | samlyukov | New Issue | |
2008-01-05 22:59 | samlyukov | File Added: GetWindowText.diff | |
2008-01-06 01:16 | vskirdin | Note Added: 0001101 | |
2008-01-06 02:33 | samlyukov | Note Added: 0001102 | |
2008-01-09 09:56 | vskirdin | Status | new => assigned |
2008-01-09 09:56 | vskirdin | Assigned To | => vskirdin |
2008-01-09 10:02 | vskirdin | Note Added: 0001103 | |
2008-01-09 10:04 | vskirdin | Note Added: 0001104 | |
2008-01-09 10:06 | vskirdin | Note Added: 0001105 | |
2008-01-09 10:06 | vskirdin | Status | assigned => feedback |
2008-01-09 10:17 | samlyukov | Status | feedback => resolved |
2008-01-09 10:17 | samlyukov | Resolution | open => fixed |
2008-01-09 10:17 | samlyukov | Note Added: 0001107 | |
2008-01-09 10:38 | vskirdin | Build | => 406 |
2008-01-09 10:38 | vskirdin | Status | resolved => closed |
2008-01-09 10:38 | vskirdin | Fixed in Version | => 1.80 alpha 1 |