c++ - How to get CEdit (or CWnd) text in debug time -


when debug project, , cedit object's text changed, want see new value. watch window doesn't display text member.
text stored?

edit: forgot write use visual c++ 6.0 ('98 edition)

the tree of cedit in watch window seems this:

m_editbox |   + [cwnd]     |     + ccmdtarget     + classcwnd   + m_hwnd     + wndtop   + wndbottom   + wndtopmost   + wndnotopmost   + m_hwndowner   - m_nflags   - m_pfnsuper   - m_nmsgdraglist   - m_nmodalresult   + m_pdroptarget   + m_pctrlcont   + m_pctrlsite   + _messageentries   + messagemap + cwnd   |   + ccmdtarget   + m_hwnd   + m_hwndowner   - m_nflags   - m_pfnsuper   - m_nmodalresult   + m_pdroptarget   - m_pctrlcont   - m_pctrlsite 

to answer question window's text stored upfront: don't know, , neither given window. information have ask window manager instead.

all information pertaining window stored in internal structure maintained window manager. window manager implemented win32k.sys , consequently internal structures reside in kernel memory. hwnd serves index table controlled window manager. though table entries mapped read-only user-space memory tedious information want.

so far, bad. not lost yet. can still information need.

the easiest option use spy++ (spyxx.exe). ships part visual studio , helps in retrieving window specific information, among other aspects show window's text. given requirements go spy -> find window... (or press [ctrl]+f) , enter window's handle (in hex without 0x-prefix). information not automatically refresh. need click refresh button manually.

if want real-time information inside visual studio's debugger have write debugger expression evaluation addin. expression evaluators not officially supported microsoft. such there no official documentation. how write custom native visualizer dll visual studio 2012 debugger? provides helpful information if want go down route. expression evaluator displaying window's text entry this:

hwndeeaddin.h:

// hwndeeaddin.h : main header file natvisaddin dll //  #if !defined( inc_hwndeeaddin_h_ ) #define inc_hwndeeaddin_h_  #pragma once  #define win32_lean_and_mean             // exclude rarely-used stuff windows headers #include <windows.h>   #define addin_api extern "c" __declspec(dllexport)  /* debughelper structure used within */ typedef struct tagdebughelper {   dword dwversion;   bool (winapi *readdebuggeememory)( struct tagdebughelper *pthis, dword dwaddr, dword nwant, void* pwhere, dword *ngot );   // here when dwversion >= 0x20000   unsigned __int64 (winapi *getrealaddress)( struct tagdebughelper *pthis );   bool (winapi *readdebuggeememoryex)( struct tagdebughelper *pthis, unsigned __int64 qwaddr, dword nwant, void* pwhere, dword *ngot );   int (winapi *getprocessortype)( struct tagdebughelper *pthis ); } debughelper;  /* exported functions */ addin_api hresult winapi addin_hwnd( dword dwaddress, debughelper *phelper, int nbase, bool bunistrings, char *presult, size_t maxresult, dword reserved );  #endif  // !defined( inc_hwndeeaddin_h_ ) 

hwndeeaddin.cpp:

#include "hwndeeaddin.h"  #include <strsafe.h>   addin_api hresult winapi addin_hwnd( dword dwaddress, debughelper* phelper, int /*nbase*/, bool bunistrings, char *presult, size_t maxresult, dword /*reserved*/ ) {   hresult hr = e_fail;    hwnd hwnd = reinterpret_cast< hwnd >( dwaddress );   if ( hwnd != null )   {     bool bgotwindowtext = false;      char asciiwindowtext[ 128 ] = { 8 };     if ( iswindowunicode( hwnd ) )     {       wchar buffer[ 128 ] = { 0 };       if ( getwindowtextw( hwnd, buffer, arraysize( buffer ) ) )       {         if ( widechartomultibyte( cp_thread_acp, 0x0, buffer, -1, asciiwindowtext, arraysize( asciiwindowtext ), null, null ) > 0 )         {           bgotwindowtext = true;         }       }     }     else     {       if ( getwindowtexta( hwnd, asciiwindowtext, arraysize( asciiwindowtext ) ) )       {         bgotwindowtext = true;       }     }      if ( bgotwindowtext )     {       hr = stringcbprintfa( presult, maxresult, "{ptext=\"%s\"}", asciiwindowtext );     }   }    return hr; } 

to register addin in visual studio 2010 , above have copy .dll alongside following file %userprofile%\documents\visual studio 2012\visualizers.

hwndeeaddin.natvis:

<?xml version="1.0" encoding="utf-8"?> <autovisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">    <!-- place file , addin-dll folder: %userprofile%\my documents\visual studio 2012\visualizers\ -->    <type name="hwnd__">     <displaystring legacyaddin="hwndeeaddin.dll" export="_addin_hwnd@28"></displaystring>   </type>  </autovisualizer> 

in visual studio versions prior 2010 have edit autoexp.dat adding following entry [autoexpand] section:

hwnd__ = $addin(hwndeeaddin.dll,_addin_hwnd@28) 

the .dll must in devenv.exe directory or on path. otherwise have use qualified path name. additional information visual studio expression evaluators prior vs 2010 can found @ customizing visual studio debugger display of data.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -