Click here to Skip to main content
15,118,063 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: HRESULT variable returning negative value Pin
Richard MacCutchan30-Jun-19 11:14
mveRichard MacCutchan30-Jun-19 11:14 
AnswerRe: HRESULT variable returning negative value Pin
Stefan_Lang30-Jun-19 23:09
mveStefan_Lang30-Jun-19 23:09 
PraiseRe: HRESULT variable returning negative value Pin
Member 144995631-Jul-19 5:05
MemberMember 144995631-Jul-19 5:05 
GeneralRe: HRESULT variable returning negative value Pin
Stefan_Lang1-Jul-19 22:31
mveStefan_Lang1-Jul-19 22:31 
GeneralRe: HRESULT variable returning negative value Pin
Member 144995632-Jul-19 7:29
MemberMember 144995632-Jul-19 7:29 
QuestionHook stops application Pin
Mark_G0027-Jun-19 6:34
MemberMark_G0027-Jun-19 6:34 
AnswerRe: Hook stops application Pin
leon de boer27-Jun-19 8:13
Memberleon de boer27-Jun-19 8:13 
GeneralRe: Hook stops application Pin
Mark_G0028-Jun-19 4:23
MemberMark_G0028-Jun-19 4:23 
Thank you for your reply!

Are you sure about this? I'm using "SetWindowsHookEx" to set the hook, so Windows knows it anyway and the console is also a window. Please correct me, if I'm wrong.

I made one mistake. I think using GetWindowTextLength & GetWindowText are not a good idea in the hook. The application is waiting for the hook and the hook is waiting to get an answer from the application now. I removed it and the app does not freezing anymore.

The handle and message in "CWPSTRUCT* pCwp = (CWPSTRUCT*)lParam;" are good, but I'm having a hard time getting the string from the message.

WM_SETTEXT message ::: lParam = A pointer to a null-terminated string that is the window text. In this case this should be pCwp->lParam It looks like the pointer address is different from the one I see in Spy++, but I'm not sure if I even convert it right.

I tried this to get the pointer address as string, but it seems to be wrong
wsprintf(tcTemp, L"0x%08p", pCwp->lParam);
wStrTemp = tcTemp;
std::string strHexParam = std::string(wStrTemp.begin(), wStrTemp.end());

I tried this to get the message string, but it's not working as well
LPCTSTR lpszString = (LPCTSTR)pCwp->lParam;
COPYDATASTRUCT cds;
cds.dwData = 0;
cds.cbData = sizeof(TCHAR)* (wcslen(lpszString) + 1);
cds.lpData = (PVOID)lpszString;

GeneralRe: Hook stops application Pin
Victor Nijegorodov28-Jun-19 5:50
MemberVictor Nijegorodov28-Jun-19 5:50 
GeneralRe: Hook stops application Pin
Mark_G0028-Jun-19 7:41
MemberMark_G0028-Jun-19 7:41 
GeneralRe: Hook stops application Pin
Victor Nijegorodov28-Jun-19 8:45
MemberVictor Nijegorodov28-Jun-19 8:45 
GeneralRe: Hook stops application Pin
Mark_G0028-Jun-19 10:03
MemberMark_G0028-Jun-19 10:03 
GeneralRe: Hook stops application Pin
leon de boer28-Jun-19 21:59
Memberleon de boer28-Jun-19 21:59 
GeneralRe: Hook stops application Pin
Mark_G0029-Jun-19 4:36
MemberMark_G0029-Jun-19 4:36 
QuestionImporting enhanced metafile from ms word to MFC problem Pin
zakomed24-Jun-19 4:55
Memberzakomed24-Jun-19 4:55 
QuestionCStringList on heap Pin
_Flaviu19-Jun-19 0:38
Member_Flaviu19-Jun-19 0:38 
QuestionRe: CStringList on heap Pin
CPallini19-Jun-19 3:19
mveCPallini19-Jun-19 3:19 
AnswerRe: CStringList on heap Pin
_Flaviu19-Jun-19 20:36
Member_Flaviu19-Jun-19 20:36 
GeneralRe: CStringList on heap Pin
CPallini20-Jun-19 5:49
mveCPallini20-Jun-19 5:49 
AnswerRe: CStringList on heap Pin
Maximilien19-Jun-19 4:43
MemberMaximilien19-Jun-19 4:43 
GeneralRe: CStringList on heap Pin
_Flaviu19-Jun-19 20:38
Member_Flaviu19-Jun-19 20:38 
GeneralRe: CStringList on heap Pin
Richard MacCutchan19-Jun-19 22:07
mveRichard MacCutchan19-Jun-19 22:07 
GeneralRe: CStringList on heap Pin
Stefan_Lang20-Jun-19 0:20
mveStefan_Lang20-Jun-19 0:20 
GeneralRe: CStringList on heap Pin
jschell23-Jun-19 6:54
Memberjschell23-Jun-19 6:54 
GeneralRe: CStringList on heap Pin
Stefan_Lang23-Jun-19 22:02
mveStefan_Lang23-Jun-19 22:02 

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.