mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
ANS/UNC utilities for ostringstream; more CONTEXT information
svn path=/trunk/; revision=6766
This commit is contained in:
parent
5a5723bad2
commit
963f962bc6
5 changed files with 105 additions and 33 deletions
|
@ -70,6 +70,8 @@ ShellChildWndInfo::ShellChildWndInfo(LPCTSTR path, const ShellPath& root_shell_p
|
|||
FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
|
||||
: ChildWindow(hwnd)
|
||||
{
|
||||
CONTEXT("FileChildWindow::FileChildWindow()");
|
||||
|
||||
TCHAR drv[_MAX_DRIVE+1];
|
||||
Entry* entry;
|
||||
|
||||
|
@ -147,6 +149,8 @@ FileChildWindow::~FileChildWindow()
|
|||
|
||||
void FileChildWindow::set_curdir(Entry* entry, HWND hwnd)
|
||||
{
|
||||
CONTEXT("FileChildWindow::set_curdir()");
|
||||
|
||||
_path[0] = TEXT('\0');
|
||||
|
||||
_left->_cur = entry;
|
||||
|
@ -243,6 +247,8 @@ void FileChildWindow::collapse_entry(Pane* pane, Entry* dir)
|
|||
|
||||
FileChildWindow* FileChildWindow::create(HWND hmdiclient, const FileChildWndInfo& info)
|
||||
{
|
||||
CONTEXT("FileChildWindow::create()");
|
||||
|
||||
MDICREATESTRUCT mcs;
|
||||
|
||||
mcs.szClass = CLASSNAME_WINEFILETREE;
|
||||
|
@ -336,14 +342,14 @@ LRESULT FileChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
Pane* pane = GetFocus()==_left_hwnd? _left: _right;
|
||||
|
||||
switch(LOWORD(wparam)) {
|
||||
case ID_WINDOW_NEW:
|
||||
case ID_WINDOW_NEW: {CONTEXT("PM_DISPATCH_COMMAND ID_WINDOW_NEW");
|
||||
if (_root._entry->_etype == ET_SHELL)
|
||||
FileChildWindow::create(GetParent(_hwnd)/*_hmdiclient*/, ShellChildWndInfo(_path,DesktopFolderPath()));
|
||||
else
|
||||
FileChildWindow::create(GetParent(_hwnd)/*_hmdiclient*/, FileChildWndInfo(_path));
|
||||
break;
|
||||
break;}
|
||||
|
||||
case ID_REFRESH: {
|
||||
case ID_REFRESH: {CONTEXT("ID_REFRESH");
|
||||
bool expanded = _left->_cur->_expanded;
|
||||
|
||||
scan_entry(_left->_cur, _hwnd);
|
||||
|
@ -352,9 +358,9 @@ LRESULT FileChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
expand_entry(_left->_cur);
|
||||
break;}
|
||||
|
||||
case ID_ACTIVATE:
|
||||
case ID_ACTIVATE: {CONTEXT("ID_ACTIVATE");
|
||||
activate_entry(pane, _hwnd);
|
||||
break;
|
||||
break;}
|
||||
|
||||
default:
|
||||
return pane->command(LOWORD(wparam));
|
||||
|
|
|
@ -286,7 +286,7 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
case PM_FRM_GET_MENUINFO:
|
||||
return (LPARAM)&_menu_info;
|
||||
|
||||
case PM_OPEN_WINDOW: {
|
||||
case PM_OPEN_WINDOW: {CONTEXT("PM_OPEN_WINDOW");
|
||||
TCHAR buffer[MAX_PATH];
|
||||
LPCTSTR path;
|
||||
ShellPath shell_path = DesktopFolderPath();
|
||||
|
@ -307,6 +307,9 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
path = buffer;
|
||||
}
|
||||
|
||||
{
|
||||
OBJ_CONTEXT("create ShellChildWndInfo", path);
|
||||
|
||||
// Shell Namespace as default view
|
||||
ShellChildWndInfo create_info(path, shell_path);
|
||||
|
||||
|
@ -319,7 +322,8 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
create_info._open_mode = (OPEN_WINDOW_MODE)wparam;
|
||||
|
||||
// FileChildWindow::create(_hmdiclient, create_info);
|
||||
return (LRESULT)ShellBrowserChild::create(_hmdiclient, create_info);}
|
||||
return (LRESULT)ShellBrowserChild::create(_hmdiclient, create_info);
|
||||
}}
|
||||
|
||||
case PM_GET_CONTROLWINDOW:
|
||||
if (wparam == FCW_STATUS)
|
||||
|
|
|
@ -62,31 +62,6 @@ LPWSTR wcscpyn(LPWSTR dest, LPCWSTR source, size_t count)
|
|||
}
|
||||
|
||||
|
||||
Context Context::s_main("-NO-CONTEXT-");
|
||||
Context* Context::s_current = &Context::s_main;
|
||||
|
||||
String Context::toString() const
|
||||
{
|
||||
FmtString str(TEXT("%hs"), _ctx);
|
||||
|
||||
if (!_obj.empty())
|
||||
str.appendf(TEXT("\nObject: %s"), (LPCTSTR)_obj);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
String Context::getStackTrace() const
|
||||
{
|
||||
// evtl. besser ostringstream verwenden
|
||||
String str = TEXT("Context Trace:\n");
|
||||
|
||||
for(const Context*p=this; p!=&s_main; p=p->_last)
|
||||
str.appendf(TEXT("ctx=%hs obj=%s\n"), p->_ctx, (LPCTSTR)p->_obj);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
String COMException::toString() const
|
||||
{
|
||||
TCHAR msg[4*BUFFER_LEN];
|
||||
|
@ -95,7 +70,7 @@ String COMException::toString() const
|
|||
p += _stprintf(p, TEXT("%s\nContext: %s"), super::ErrorMessage(), (LPCTSTR)_ctx.toString());
|
||||
|
||||
if (_file)
|
||||
p += _stprintf(p, TEXT("\nLocation: %hs(%d)"), _file, _line);
|
||||
p += _stprintf(p, TEXT("\nLocation: %hs:%d"), _file, _line);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <shellapi.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
DWORD WINAPI Thread::ThreadProc(void* para)
|
||||
|
@ -110,6 +111,38 @@ void display_error(HWND hwnd, DWORD error) //@@ CONTEXT mit ausgeben -> display_
|
|||
}
|
||||
|
||||
|
||||
Context Context::s_main("-NO-CONTEXT-");
|
||||
Context* Context::s_current = &Context::s_main;
|
||||
|
||||
String Context::toString() const
|
||||
{
|
||||
String str = _ctx;
|
||||
|
||||
if (!_obj.empty())
|
||||
str.appendf(TEXT("\nObject: %s"), (LPCTSTR)_obj);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
String Context::getStackTrace() const
|
||||
{
|
||||
ostringstream str;
|
||||
|
||||
str << "Context Trace:\n";
|
||||
|
||||
for(const Context*p=this; p!=&s_main; p=p->_last) {
|
||||
str << "- " << p->_ctx;
|
||||
|
||||
if (!p->_obj.empty())
|
||||
str << " obj=" << ANS(p->_obj);
|
||||
|
||||
str << '\n';
|
||||
}
|
||||
|
||||
return str.str();
|
||||
}
|
||||
|
||||
|
||||
BOOL time_to_filetime(const time_t* t, FILETIME* ftime)
|
||||
{
|
||||
struct tm* tm = gmtime(t);
|
||||
|
|
|
@ -498,10 +498,12 @@ struct String
|
|||
|
||||
#ifdef UNICODE
|
||||
String(LPCSTR s) {assign(s);}
|
||||
String(const string& other) {assign(other.c_str());}
|
||||
String& operator=(LPCSTR s) {assign(s); return *this;}
|
||||
void assign(LPCSTR s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));}
|
||||
#else
|
||||
String(LPCWSTR s) {assign(s);}
|
||||
String(const wstring& other) {assign(other.c_str());}
|
||||
String& operator=(LPCWSTR s) {assign(s); return *this;}
|
||||
void assign(LPCWSTR s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, -1, b, BUFFER_LEN, 0, 0));}
|
||||
#endif
|
||||
|
@ -554,6 +556,7 @@ struct String
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct FmtString : public String
|
||||
{
|
||||
FmtString(LPCTSTR fmt, ...)
|
||||
|
@ -567,6 +570,57 @@ struct FmtString : public String
|
|||
};
|
||||
|
||||
|
||||
#ifdef UNICODE
|
||||
|
||||
struct ANS
|
||||
{
|
||||
ANS(LPCWSTR s)
|
||||
{
|
||||
int l = wcslen(s) + 1;
|
||||
_str = (LPSTR) malloc(2*l);
|
||||
WideCharToMultiByte(CP_ACP, 0, s, -1, _str, 2*l, 0, 0);
|
||||
}
|
||||
|
||||
~ANS()
|
||||
{
|
||||
free(_str);
|
||||
}
|
||||
|
||||
operator LPCSTR() {return _str;}
|
||||
|
||||
protected:
|
||||
LPSTR _str;
|
||||
};
|
||||
|
||||
#define UNC(x) ((LPCWSTR)(x))
|
||||
|
||||
#else
|
||||
|
||||
#define ANS(x) ((LPCSTR)(x))
|
||||
|
||||
struct UNC
|
||||
{
|
||||
UNC(LPCSTR s)
|
||||
{
|
||||
int l = strlen(s) + 1;
|
||||
_str = (LPWSTR) malloc(2*l);
|
||||
MultiByteToWideChar(CP_ACP, 0, s, -1, _str, l);
|
||||
}
|
||||
|
||||
~UNC()
|
||||
{
|
||||
free(_str);
|
||||
}
|
||||
|
||||
operator LPCWSTR() {return _str;}
|
||||
|
||||
protected:
|
||||
LPWSTR _str;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/// link dynamicly to functions by using GetModuleHandle() and GetProcAddress()
|
||||
template<typename FCT> struct DynamicFct
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue