Skip to content

Commit

Permalink
Bug fix; Various improvements
Browse files Browse the repository at this point in the history
Fixed TreeListView tooltip not disappearing when main window focus is lost.
Various optimizations.
  • Loading branch information
erickutcher committed Sep 9, 2024
1 parent 5438e78 commit a1dc02e
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 94 deletions.
8 changes: 4 additions & 4 deletions HTTP_Downloader/HTTP_Downloader.rc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ IDI_ICON_TRAY ICON "icon_tray.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,6,3
PRODUCTVERSION 1,0,6,3
FILEVERSION 1,0,6,4
PRODUCTVERSION 1,0,6,4
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -81,12 +81,12 @@ BEGIN
BEGIN
VALUE "Comments", "HTTP Downloader is made free under the GPLv3 license."
VALUE "FileDescription", "HTTP Downloader can download files through HTTP(S), FTP(S), and SFTP connections."
VALUE "FileVersion", "1, 0, 6, 3"
VALUE "FileVersion", "1, 0, 6, 4"
VALUE "InternalName", "HTTP Downloader"
VALUE "LegalCopyright", "Copyright � 2015-2024 Eric Kutcher"
VALUE "OriginalFilename", "HTTP_Downloader.exe"
VALUE "ProductName", "HTTP Downloader"
VALUE "ProductVersion", "1, 0, 6, 3"
VALUE "ProductVersion", "1, 0, 6, 4"
END
END
BLOCK "VarFileInfo"
Expand Down
6 changes: 6 additions & 0 deletions HTTP_Downloader/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version: 1.0.6.4
Released: 2024-09-09

Fixed TreeListView tooltip not disappearing when main window focus is lost.
Various optimizations.

Version: 1.0.6.3
Released: 2024-09-03

Expand Down
8 changes: 4 additions & 4 deletions HTTP_Downloader/dm_version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
16778755
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.3/HTTP_Downloader_DM_32.zip
16778755
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.3/HTTP_Downloader_DM_64.zip
16778756
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.4/HTTP_Downloader_DM_32.zip
16778756
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.4/HTTP_Downloader_DM_64.zip
55 changes: 14 additions & 41 deletions HTTP_Downloader/drag_and_drop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,45 +624,20 @@ HRESULT STDMETHODCALLTYPE DragEnter( IDropTarget *This, IDataObject *pDataObj, D
_This->m_ClipFormat = 0;

FORMATETC fetc;
fetc.cfFormat = ( CLIPFORMAT )CF_HTML;
fetc.ptd = NULL;
fetc.dwAspect = DVASPECT_CONTENT;
fetc.lindex = -1;
fetc.tymed = TYMED_HGLOBAL;

// See if the data is unicode text.
if ( pDataObj->QueryGetData( &fetc ) == S_OK )
UINT clip_formats[ 4 ] = { CF_HTML, CF_UNICODETEXT, CF_HDROP, CF_TEXT };
for ( char i = 0; i < 4; ++i )
{
_This->m_ClipFormat = CF_HTML;
}
else
{
fetc.cfFormat = CF_UNICODETEXT;

// See if the data is unicode text.
fetc.cfFormat = ( CLIPFORMAT )clip_formats[ i ];
if ( pDataObj->QueryGetData( &fetc ) == S_OK )
{
_This->m_ClipFormat = CF_UNICODETEXT;
}
else
{
fetc.cfFormat = CF_HDROP;

// See if the data is a list of files.
if ( pDataObj->QueryGetData( &fetc ) == S_OK )
{
_This->m_ClipFormat = CF_HDROP;
}
else
{
fetc.cfFormat = CF_TEXT;
_This->m_ClipFormat = clip_formats[ i ];

// See if the data is ascii text.
if ( pDataObj->QueryGetData( &fetc ) == S_OK )
{
_This->m_ClipFormat = CF_TEXT;
}
}
break;
}
}

Expand Down Expand Up @@ -721,14 +696,12 @@ HRESULT STDMETHODCALLTYPE Drop( IDropTarget *This, IDataObject *pDataObj, DWORD
{
_IDropTarget *_This = ( _IDropTarget * )This;

CLIPFORMAT cfFormat = ( CLIPFORMAT )_This->m_ClipFormat;

if ( cfFormat != 0 )
if ( _This->m_ClipFormat != 0 )
{
PositionCursor( _This->m_hWnd, pt );

FORMATETC fetc;
fetc.cfFormat = cfFormat;
fetc.cfFormat = ( CLIPFORMAT )_This->m_ClipFormat;
fetc.ptd = NULL;
fetc.dwAspect = DVASPECT_CONTENT;
fetc.lindex = -1;
Expand All @@ -740,7 +713,7 @@ HRESULT STDMETHODCALLTYPE Drop( IDropTarget *This, IDataObject *pDataObj, DWORD
{
PVOID data = GlobalLock( stgm.hGlobal );

if ( data != NULL && cfFormat == CF_HTML )
if ( data != NULL && _This->m_ClipFormat == CF_HTML )
{
// Reallocate the data buffer since it doesn't include a NULL terminator. (STUPID!!!)
size_t data_size = GlobalSize( stgm.hGlobal );
Expand All @@ -766,15 +739,15 @@ HRESULT STDMETHODCALLTYPE Drop( IDropTarget *This, IDataObject *pDataObj, DWORD

_ReleaseStgMedium( &stgm );

fetc.cfFormat = cfFormat = CF_UNICODETEXT;
_This->m_ClipFormat = fetc.cfFormat = CF_UNICODETEXT;

if ( pDataObj->GetData( &fetc, &stgm ) == S_OK )
{
data = GlobalLock( stgm.hGlobal );
}
else
{
fetc.cfFormat = cfFormat = CF_TEXT;
_This->m_ClipFormat = fetc.cfFormat = CF_TEXT;

if ( pDataObj->GetData( &fetc, &stgm ) == S_OK )
{
Expand All @@ -786,7 +759,7 @@ HRESULT STDMETHODCALLTYPE Drop( IDropTarget *This, IDataObject *pDataObj, DWORD

if ( data != NULL )
{
if ( cfFormat == CF_HDROP )
if ( _This->m_ClipFormat == CF_HDROP )
{
HandleFileList( ( HDROP )data );
}
Expand All @@ -795,15 +768,15 @@ HRESULT STDMETHODCALLTYPE Drop( IDropTarget *This, IDataObject *pDataObj, DWORD
// g_hWnd_add_urls might be NULL. We just want to make sure we're not dropping something into its URL edit control (g_hWnd_edit_add).
if ( cfg_drag_and_drop_action != DRAG_AND_DROP_ACTION_NONE && ( g_hWnd_add_urls == NULL || _GetParent( _This->m_hWnd ) != g_hWnd_add_urls ) )
{
HandleAddInfo( cfFormat, data );
HandleAddInfo( _This->m_ClipFormat, data );
}
else
{
_SendMessageW( ( g_hWnd_add_urls != NULL ? g_hWnd_add_urls : g_hWnd_main ), WM_PROPAGATE, cfFormat, ( LPARAM )data );
_SendMessageW( ( g_hWnd_add_urls != NULL ? g_hWnd_add_urls : g_hWnd_main ), WM_PROPAGATE, _This->m_ClipFormat, ( LPARAM )data );
}
}

if ( cfFormat == CF_HTML )
if ( _This->m_ClipFormat == CF_HTML )
{
GlobalFree( data );
}
Expand Down
2 changes: 1 addition & 1 deletion HTTP_Downloader/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
#define CURRENT_VERSION_A 1
#define CURRENT_VERSION_B 0
#define CURRENT_VERSION_C 6
#define CURRENT_VERSION_D 3
#define CURRENT_VERSION_D 4

#define CURRENT_VERSION ( ( CURRENT_VERSION_A << 24 ) | \
( CURRENT_VERSION_B << 16 ) | \
Expand Down
55 changes: 22 additions & 33 deletions HTTP_Downloader/treelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,6 @@ void ClearDrag()
}
}

void ClearTooltip( HWND hWnd, HWND hWnd_tooltip )
{
if ( _SendMessageW( hWnd_tooltip, TTM_GETCURRENTTOOL, 0, NULL ) != 0 )
{
g_tlv_is_tracking = FALSE;

g_tlv_last_tooltip_item = -1;

TOOLINFO tti;
_memzero( &tti, sizeof( TOOLINFO ) );
tti.cbSize = sizeof( TOOLINFO );
tti.hwnd = hWnd;
tti.uId = ( UINT_PTR )hWnd;
//tti.lpszText = NULL;
_SendMessageW( hWnd_tooltip, TTM_TRACKACTIVATE, FALSE, ( LPARAM )&tti );
}
}

int TLV_GetParentIndex( TREELISTNODE *tln, int index )
{
if ( tln != NULL && tln->parent != NULL && index > 0 )
Expand Down Expand Up @@ -5226,8 +5208,6 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
{
ClearDrag();

ClearTooltip( hWnd, g_hWnd_tlv_tooltip );

// If the base selected node is NULL, then so is the focused node. The opposite is not necessarily true.
if ( g_base_selected_node == NULL )
{
Expand Down Expand Up @@ -5544,8 +5524,6 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM

ClearDrag();

ClearTooltip( hWnd, g_hWnd_tlv_tooltip );

SCROLLINFO si;
_memzero( &si, sizeof( SCROLLINFO ) );
si.cbSize = sizeof( SCROLLINFO );
Expand Down Expand Up @@ -5654,13 +5632,30 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM

_SendMessageW( g_hWnd_tlv_tooltip, TTM_SETTOOLINFO, 0, ( LPARAM )&tti );
_SendMessageW( g_hWnd_tlv_tooltip, TTM_TRACKACTIVATE, TRUE, ( LPARAM )&tti );

g_tlv_is_tracking = FALSE;
}
}
}
break;

case WM_MOUSELEAVE:
{
if ( g_tlv_is_tracking == TRUE && !g_is_dragging )
{
g_tlv_is_tracking = FALSE;

g_tlv_last_tooltip_item = -1;

TOOLINFO tti;
_memzero( &tti, sizeof( TOOLINFO ) );
tti.cbSize = sizeof( TOOLINFO );
tti.hwnd = hWnd;
tti.uId = ( UINT_PTR )hWnd;
//tti.lpszText = NULL;
_SendMessageW( g_hWnd_tlv_tooltip, TTM_TRACKACTIVATE, FALSE, ( LPARAM )&tti );
}
}
break;

case WM_MOUSEMOVE:
{
// Allow the lasso selection if we're not in the edit mode, or we've dragged from outside of the item list.
Expand Down Expand Up @@ -5690,7 +5685,7 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM

TRACKMOUSEEVENT tmi;
tmi.cbSize = sizeof( TRACKMOUSEEVENT );
tmi.dwFlags = TME_HOVER;
tmi.dwFlags = TME_HOVER | TME_LEAVE;
tmi.hwndTrack = hWnd;
tmi.dwHoverTime = 2000;
g_tlv_is_tracking = _TrackMouseEvent( &tmi );
Expand All @@ -5704,8 +5699,6 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
{
_SetFocus( hWnd );

ClearTooltip( hWnd, g_hWnd_tlv_tooltip );

HandleMouseClick( hWnd, ( msg == WM_LBUTTONDOWN ? false : true ) );
}
break;
Expand Down Expand Up @@ -6196,10 +6189,6 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
HandleCommand( hWnd, MENU_OPEN_DIRECTORY );
}
}
else// if ( msg == WM_KILLFOCUS )
{
ClearTooltip( hWnd, g_hWnd_tlv_tooltip );
}

return 0;
}
Expand Down Expand Up @@ -6721,7 +6710,7 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
if ( cfg_show_toolbar )
{
RECT rc;
_GetClientRect( hWnd, &rc );
_GetWindowRect( hWnd, &rc );

HDC hDC = _GetWindowDC( hWnd );
HPEN line_color;
Expand All @@ -6740,7 +6729,7 @@ LRESULT CALLBACK TreeListViewWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
_DeleteObject( old_color );

_MoveToEx( hDC, 0, 0, NULL );
_LineTo( hDC, rc.right + _GetSystemMetrics( SM_CXVSCROLL ), 0 );
_LineTo( hDC, rc.right - rc.left, 0 );
_DeleteObject( line_color );

_ReleaseDC( hWnd, hDC );
Expand Down
8 changes: 4 additions & 4 deletions HTTP_Downloader/version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
16778755
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.3/HTTP_Downloader_32.zip
16778755
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.3/HTTP_Downloader_64.zip
16778756
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.4/HTTP_Downloader_32.zip
16778756
https://github.com/erickutcher/httpdownloader/releases/download/v1.0.6.4/HTTP_Downloader_64.zip
14 changes: 7 additions & 7 deletions HTTP_Downloader/wnd_proc_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,9 +1492,9 @@ LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
{
case NM_RCLICK:
{
NMITEMACTIVATE *nmitem = ( NMITEMACTIVATE * )lParam;
NMMOUSE *nmm = ( NMMOUSE * )lParam;

if ( nmitem->hdr.hwndFrom == g_hWnd_toolbar || nmitem->hdr.hwndFrom == g_hWnd_status )
if ( nmm->hdr.hwndFrom == g_hWnd_toolbar || nmm->hdr.hwndFrom == g_hWnd_status )
{
POINT p;
_GetCursorPos( &p );
Expand All @@ -1506,17 +1506,17 @@ LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam

case NM_CLICK:
{
NMMOUSE *nm = ( NMMOUSE * )lParam;
NMMOUSE *nmm = ( NMMOUSE * )lParam;

// Change the format of the panel if Ctrl is held while clicking the panel.
if ( GetKeyState( VK_CONTROL ) & 0x8000 )
{
if ( nm->hdr.hwndFrom == g_hWnd_status )
if ( nmm->hdr.hwndFrom == g_hWnd_status )
{
wchar_t status_bar_buf[ 128 ];
unsigned char buf_length;

if ( nm->dwItemSpec == 1 )
if ( nmm->dwItemSpec == 1 )
{
if ( cfg_t_status_down_speed >= SIZE_FORMAT_AUTO )
{
Expand All @@ -1539,7 +1539,7 @@ LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
_SendMessageW( g_hWnd_status, SB_SETTIPTEXT, 1, ( LPARAM )status_bar_buf );
_SendMessageW( g_hWnd_status, SB_SETTEXT, MAKEWPARAM( 1, 0 ), ( LPARAM )status_bar_buf );
}
else if ( nm->dwItemSpec == 2 )
else if ( nmm->dwItemSpec == 2 )
{
if ( cfg_t_status_downloaded >= SIZE_FORMAT_AUTO )
{
Expand All @@ -1560,7 +1560,7 @@ LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
_SendMessageW( g_hWnd_status, SB_SETTIPTEXT, 2, ( LPARAM )status_bar_buf );
_SendMessageW( g_hWnd_status, SB_SETTEXT, MAKEWPARAM( 2, 0 ), ( LPARAM )status_bar_buf );
}
else if ( nm->dwItemSpec == 3 )
else if ( nmm->dwItemSpec == 3 )
{
buf_length = ( unsigned char )( ST_L_Global_download_speed_limit_ > 102 ? 102 : ST_L_Global_download_speed_limit_ ); // Let's not overflow. 128 - ( ' ' + 22 + '/' + 's' + NULL ) = 102 remaining bytes for our string.
_wmemcpy_s( status_bar_buf, 128, ST_V_Global_download_speed_limit_, buf_length );
Expand Down

0 comments on commit a1dc02e

Please sign in to comment.