Exemplo n.º 1
0
void display_error(HWND hwnd, DWORD error)	//@@ CONTEXT mit ausgeben -> display_error(HWND hwnd, const Exception& e)
{
	PTSTR msg;

	if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
		0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PTSTR)&msg, 0, NULL)) {
		LOG(FmtString(TEXT("display_error(%#x): %s"), error, msg));

		SetLastError(0);
		MessageBox(hwnd, msg, TEXT("ROS Explorer"), MB_OK);

		if (GetLastError() == ERROR_INVALID_WINDOW_HANDLE)
			MessageBox(0, msg, TEXT("ROS Explorer"), MB_OK);
	} else {
		LOG(FmtString(TEXT("Unknown Error %#x"), error));

		FmtString msg(TEXT("Unknown Error %#x"), error);

		SetLastError(0);
		MessageBox(hwnd, msg, TEXT("ROS Explorer"), MB_OK);

		if (GetLastError() == ERROR_INVALID_WINDOW_HANDLE)
			MessageBox(0, msg, TEXT("ROS Explorer"), MB_OK);
	}

	LocalFree(msg);
}
Exemplo n.º 2
0
BOOL RecursiveCreateDirectory(LPCTSTR path_in)
{
	TCHAR path[MAX_PATH], hole_path[MAX_PATH];

	_tcscpy(hole_path, path_in);

	int drv_len = 0;
	LPCTSTR d;

	for(d=hole_path; *d && *d!='/' && *d!='\\'; ++d) {
		++drv_len;

		if (*d == ':')
			break;
	}

	LPTSTR dir = hole_path + drv_len;

	int l;
	LPTSTR p = hole_path + (l=_tcslen(hole_path));

	while(--p>=hole_path && (*p=='/' || *p=='\\'))
		*p = '\0';

	WIN32_FIND_DATA w32fd;

	HANDLE hFind = FindFirstFile(hole_path, &w32fd);

	if (hFind == INVALID_HANDLE_VALUE) {
		_tcsncpy(path, hole_path, drv_len);
		int i = drv_len;

		for(p=dir; *p=='/'||*p=='\\'; p++)
			path[i++] = *p++;

		for(; i<l; i++) {
			memcpy(path, hole_path, i*sizeof(TCHAR));

			for(; hole_path[i] && hole_path[i]!='/' && hole_path[i]!='\\'; i++)
				path[i] = hole_path[i];

			path[i] = '\0';

			hFind = FindFirstFile(path, &w32fd);

			if (hFind != INVALID_HANDLE_VALUE)
				FindClose(hFind);
			else {
				LOG(FmtString(TEXT("CreateDirectory(\"%s\")"), path));

				if (!CreateDirectory(path, 0))
					return FALSE;
			}
		}
	} else
		FindClose(hFind);

	return TRUE;
}
Exemplo n.º 3
0
String MDIShellBrowserChild::jump_to_int(LPCTSTR url)
{
    String dir, fname;

    if (!_tcsnicmp(url, TEXT("shell://"), 8)) {
        if (_shellBrowser->jump_to_pidl(ShellPath(url+8)))
            return url;
    }

    if (SplitFileSysURL(url, dir, fname)) {

        ///@todo use fname

        if (_shellBrowser->jump_to_pidl(ShellPath(dir)))
            return FmtString(TEXT("file://%s"), (LPCTSTR)dir);
    }

    return String();
}
Exemplo n.º 4
0
void QuickLaunchBar::AddShortcuts()
{
	CONTEXT("QuickLaunchBar::AddShortcuts()");

	WaitCursor wait;

	try {
		TCHAR path[MAX_PATH];

		SpecialFolderFSPath app_data(CSIDL_APPDATA, _hwnd);	///@todo perhaps also look into CSIDL_COMMON_APPDATA ?

		_stprintf(path, TEXT("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data);

		RecursiveCreateDirectory(path);
		_dir = new ShellDirectory(GetDesktopFolder(), path, _hwnd);

		_dir->smart_scan(SORT_NAME);

		 // immediatelly extract the shortcut icons
		for(Entry*entry=_dir->_down; entry; entry=entry->_next)
			entry->_icon_id = entry->safe_extract_icon(ICF_NORMAL);
	} catch(COMException&) {
		return;
	}


	ShellFolder desktop_folder;
	WindowCanvas canvas(_hwnd);

	COLORREF bk_color = GetSysColor(COLOR_BTNFACE);
	HBRUSH bk_brush = GetSysColorBrush(COLOR_BTNFACE);

	AddButton(ID_MINIMIZE_ALL, g_Globals._icon_cache.get_icon(ICID_MINIMIZE).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_MINIMIZE_ALL), NULL);
	AddButton(ID_EXPLORE, g_Globals._icon_cache.get_icon(ICID_EXPLORER).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_TITLE), NULL);

	TBBUTTON sep = {0, -1, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0};
	SendMessage(_hwnd, TB_INSERTBUTTON, INT_MAX, (LPARAM)&sep);

	int cur_desktop = g_Globals._desktops._current_desktop;
	ResString desktop_fmt(IDS_DESKTOP_NUM);

	HDC hdc = CreateCompatibleDC(canvas);
	DWORD size = SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0);
	int cx = LOWORD(size);
	int cy = HIWORD(size);
	RECT rect = {0, 0, cx, cy};
	RECT textRect = {0, 0, cx-7, cy-7};

	for(int i=0; i<DESKTOP_COUNT; ++i) {
		HBITMAP hbmp = CreateCompatibleBitmap(canvas, cx, cy);
		HBITMAP hbmp_old = SelectBitmap(hdc, hbmp);

		FontSelection font(hdc, GetStockFont(ANSI_VAR_FONT));
		FmtString num_txt(TEXT("%d"), i+1);
		TextColor color(hdc, RGB(64,64,64));
		BkMode mode(hdc, TRANSPARENT);
		FillRect(hdc, &rect, GetSysColorBrush(COLOR_BTNFACE));
		DrawText(hdc, num_txt, num_txt.length(), &textRect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);

		SelectBitmap(hdc, hbmp_old);

		AddButton(ID_SWITCH_DESKTOP_1+i, hbmp, FmtString(desktop_fmt, i+1), NULL, cur_desktop==i?TBSTATE_ENABLED|TBSTATE_PRESSED:TBSTATE_ENABLED);
	}
	DeleteDC(hdc);

	for(Entry*entry=_dir->_down; entry; entry=entry->_next) {
		 // hide files like "desktop.ini"
		if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
			continue;

		 // hide subfolders
		if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
			HBITMAP hbmp = g_Globals._icon_cache.get_icon(entry->_icon_id).create_bitmap(bk_color, bk_brush, canvas);

			AddButton(_next_id++, hbmp, entry->_display_name, entry);	//entry->_etype==ET_SHELL? desktop_folder.get_name(static_cast<ShellEntry*>(entry)->_pidl): entry->_display_name);
		}
	}

	_btn_dist = LOWORD(SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0));
	_size = _entries.size() * _btn_dist;

	SendMessage(GetParent(_hwnd), PM_RESIZE_CHILDREN, 0, 0);
}
Exemplo n.º 5
0
Arquivo: httpd.c Projeto: tindzk/Jivai
def(void, OnRespond, bool persistent) {
	this->resp.len = 0;

	if (this->method == HTTP_Method_Get) {
		String_Append(&this->resp, $("Page requested via GET."));
	} else if (this->method == HTTP_Method_Post) {
		String_Append(&this->resp, $("Page requested via POST."));
	} else if (this->method == HTTP_Method_Head) {
		String_Append(&this->resp, $("Page requested via HEAD."));
	}

	if (this->method != HTTP_Method_Head) {
		String_Append(&this->resp,
			FmtString($(
				"<form action=\"/\" method=\"post\">"
				"<input type=\"text\" name=\"test\" /><br />"
				"<input type=\"text\" name=\"test2\" /><br />"
				"<input type=\"submit\" />"
				"</form>"
				"<br />"
				"You requested: %<br />"
				"test=%<br />"
				"test2=%<br />"
			),

			this->path.rd,
			this->paramTest.rd,
			this->paramTest2.rd));
	}

	String strLength = Integer_ToString(this->resp.len);

	String envelope = String_Format(
		$(
			"% 200 OK\r\n"
			"Content-Type: text/html; charset=utf-8\r\n"
			"%\r\n"
			"Content-Length: %\r\n"
			"\r\n"
		),

		HTTP_Version_ToString(this->version),

		persistent
			? $("Connection: Keep-Alive")
			: $("Connection: Close"),

		strLength.rd);

	String_Destroy(&strLength);

	SocketConnection_Write(this->conn, envelope.rd);

	size_t written = SocketConnection_Write(this->conn, this->resp.rd);
	String_Crop(&this->resp, written);

	SocketConnection_Flush(this->conn);

	String_Destroy(&envelope);

	this->paramTest.len  = 0;
	this->paramTest2.len = 0;

	/* You may want to change the value of this variable when the
	 * content length is unknown. If that's the case, you won't have
	 * no choice to indicate the end of the response but to close
	 * the connection.
	 */
	this->persistent = persistent;
}
Exemplo n.º 6
0
void NotifyIconConfig::create_name()
{
	_name = FmtString(TEXT("'%s' - '%s' - '%s'"), _tipText.c_str(), _windowTitle.c_str(), _modulePath.c_str());
}
USHORT FmtPtr(char **pcp,ULONG *pUserAddr,UINT mid, USHORT typeno,UINT sfx)
{
 UINT    read;
 UINT    size;
 signed  char  **dp;
 ULONG   UserAddr = *pUserAddr;
 char   *cp = *pcp;
 UINT    type;

 type = GetPtrType(mid,typeno);
 size = QtypeSize(mid,typeno);

 switch( type )
 {
  case PTR_0_32:
  case PTR_16_16:
   dp = ( signed char**)GetAppData( UserAddr, size, &read, sfx);
   if( !dp || (size != read) )
    {sprintf(cp,"Invalid Address");return(0);}

   if( type == PTR_0_32 )
   {
    sprintf(cp,fs1,*dp);
    *pUserAddr = (ULONG)*dp;
   }
   else /* case PTR_16_16 */
   {
    sprintf(cp,fs2, *((USHORT*)dp+1),*(USHORT*)dp);
    *pUserAddr = Data_SelOff2Flat( *((USHORT*)dp+1) , *(USHORT*)dp );
   }
   break;

  case PTR_0_16:
   /**************************************************************************/
   /* - Convert a BP Relative location of the near pointer to a flat address */
   /*   if the 0:16 pointer is a stack variable.                             */
   /* - Get 2 bytes of offset from the location.                             */
   /* - Format the 0:16 pointer.                                             */
   /* - Get the selector where the pointer was defined. Since the pointer is */
   /*   near, the target of the pointer has to have the same selector.       */
   /* - Form the flat address value of the pointer.                          */
   /*                                                                        */
   /**************************************************************************/
   if( TestBit(UserAddr,STACKADDRBIT) )
    UserAddr = StackBPRelToAddr( UserAddr , sfx );
   if ( UserAddr == 0 )
    {sprintf(cp,"Invalid Address");return(0);}

   dp = ( signed char**)GetAppData( UserAddr, size, &read, sfx);
   if( !dp || (size != read) )
    {sprintf(cp,"Invalid Address");return(0);}
   sprintf(cp,fs3, *(USHORT*)dp);

   {
    USHORT Sel;
    USHORT Off;

    Data_Flat2SelOff(UserAddr, &Sel,&Off);
    *pUserAddr = Data_SelOff2Flat( Sel, *(USHORT*)dp);
   }
 }

 /****************************************************************************/
 /* - If the typeno is primitive, then zero the model bits and return        */
 /*   the type of the pointer to the caller.                                 */
 /* - If the typeno is complex, then echo the typeno back to the caller.     */
 /*   What we return is irrelevant;however, we need to return something.     */
 /****************************************************************************/
 if( typeno < 512 )
   typeno &= (~MD_BITS);

 /****************************************************************************/
 /* Append strings to type char and type uchar pointers.                     */
 /****************************************************************************/
 if( typeno == TYPE_CHAR || typeno == TYPE_UCHAR )
 {
  char *cpend;
  extern UINT VideoCols;

  cpend = (*pcp-STGCOL-1) + VideoCols - 1;
  FmtString(cp+strlen(cp),cpend,*pUserAddr,sfx);
  typeno = 0;
 }
 else
  /***************************************************************************/
  /* Kill the \0 at the end of the string by converting to a space.          */
  /***************************************************************************/
  *(*pcp=strchr(cp,'\0')) = ' ';

 return(typeno);
}