From 2840393bf5378c012577c4764dc4cbd162f85d4e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 8 Jun 2012 21:02:06 +0000 Subject: GetWindowLong -> GetWindowLongPtr git-svn-id: http://svn.miranda-ng.org/main/trunk@364 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/Docking.cpp | 2 +- src/modules/clist/clcutils.cpp | 2 +- src/modules/clist/clui.cpp | 2 +- src/modules/clist/protocolorder.cpp | 2 +- src/modules/database/profilemanager.cpp | 4 +- src/modules/plugins/newplugins.cpp | 114 ++++++++++++++++++++------------ src/modules/srfile/filexferdlg.cpp | 2 +- src/modules/userinfo/userinfo.cpp | 4 +- 8 files changed, 79 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/modules/clist/Docking.cpp b/src/modules/clist/Docking.cpp index df9e9508a5..4c32b7335e 100644 --- a/src/modules/clist/Docking.cpp +++ b/src/modules/clist/Docking.cpp @@ -131,7 +131,7 @@ static void Docking_SetSize(HWND hwnd, LPRECT rc, bool query, bool move) static bool Docking_IsWindowVisible(HWND hwnd) { - LONG style = GetWindowLong(hwnd, GWL_STYLE); + LONG style = GetWindowLongPtr(hwnd, GWL_STYLE); return style & WS_VISIBLE && !(style & WS_MINIMIZE); } diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index 7e376fb27d..40b923d78e 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -95,7 +95,7 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, struct ClcCo pt1, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT); if (h != hwndTemp) { - if (!hwndParent || !(GetWindowLong(hwndTemp, GWL_STYLE) & BS_GROUPBOX)) + if (!hwndParent || !(GetWindowLongPtr(hwndTemp, GWL_STYLE) & BS_GROUPBOX)) return -1; } } diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp index f82872711d..ad35aeb3bf 100644 --- a/src/modules/clist/clui.cpp +++ b/src/modules/clist/clui.cpp @@ -810,7 +810,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 0; case WM_SETTINGCHANGE: - if (wParam == SPI_SETWORKAREA && (GetWindowLong(hwnd, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && + if (wParam == SPI_SETWORKAREA && (GetWindowLongPtr(hwnd, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && !CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0)) { RECT rc; diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp index 546ae01d03..471c8530f5 100644 --- a/src/modules/clist/protocolorder.cpp +++ b/src/modules/clist/protocolorder.cpp @@ -175,7 +175,7 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetWindowLongPtr(hwndProtoOrder, GWLP_USERDATA, (LONG_PTR)dat); dat->dragging=0; - SetWindowLong(hwndProtoOrder, GWL_STYLE, GetWindowLong(hwndProtoOrder, GWL_STYLE) | TVS_NOHSCROLL); + SetWindowLongPtr(hwndProtoOrder, GWL_STYLE, GetWindowLongPtr(hwndProtoOrder, GWL_STYLE) | TVS_NOHSCROLL); { HIMAGELIST himlCheckBoxes = ImageList_Create( GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), ILC_COLOR32|ILC_MASK, 2, 2 ); ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK); diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 87b1e505f6..fcb7d246f5 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -67,7 +67,7 @@ struct ProfileEnumData { extern TCHAR mirandabootini[MAX_PATH]; -char **GetSeviceModePluginsList(void); +char **GetServiceModePluginsList(void); void SetServiceModePlugin( int idx ); static void ThemeDialogBackground(HWND hwnd) @@ -603,7 +603,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, } // service mode combobox { - char **list = GetSeviceModePluginsList(); + char **list = GetServiceModePluginsList(); if ( !list ) { ShowWindow( GetDlgItem(hwndDlg, IDC_SM_LABEL ), FALSE ); ShowWindow( GetDlgItem(hwndDlg, IDC_SM_COMBO ), FALSE ); diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 46430ad9ce..6c84809932 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef int (__cdecl * Miranda_Plugin_Load) ( PLUGINLINK * ); typedef int (__cdecl * Miranda_Plugin_Unload) ( void ); // version control -typedef PLUGININFO * (__cdecl * Miranda_Plugin_Info) ( DWORD mirandaVersion ); typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_InfoEx) ( DWORD mirandaVersion ); // prototype for databases typedef DATABASELINK * (__cdecl * Database_Plugin_Info) ( void * reserved ); @@ -43,7 +42,6 @@ typedef struct { // can all be NULL HINSTANCE hInst; Miranda_Plugin_Load Load; Miranda_Plugin_Unload Unload; - Miranda_Plugin_Info Info; Miranda_Plugin_InfoEx InfoEx; Miranda_Plugin_Interfaces Interfaces; Database_Plugin_Info DbInfo; @@ -244,8 +242,7 @@ static int checkPI( BASIC_PLUGIN_INFO* bpi, PLUGININFOEX* pi ) } if ( !bHasValidInfo ) - if ( bpi->Info && pi->cbSize != sizeof(PLUGININFO)) - return FALSE; + return FALSE; if ( pi->shortName == NULL || pi->description == NULL || pi->author == NULL || pi->authorEmail == NULL || pi->copyright == NULL || pi->homepage == NULL ) @@ -278,17 +275,12 @@ static int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, // loaded, check for exports bpi->Load = (Miranda_Plugin_Load) GetProcAddress(h, "Load"); bpi->Unload = (Miranda_Plugin_Unload) GetProcAddress(h, "Unload"); - bpi->Info = (Miranda_Plugin_Info) GetProcAddress(h, "MirandaPluginInfo"); bpi->InfoEx = (Miranda_Plugin_InfoEx) GetProcAddress(h, "MirandaPluginInfoEx"); bpi->Interfaces = (Miranda_Plugin_Interfaces) GetProcAddress(h, "MirandaPluginInterfaces"); // if they were present - if ( bpi->Load && bpi->Unload && ( bpi->Info || ( bpi->InfoEx && bpi->Interfaces ))) { - PLUGININFOEX* pi = 0; - if (bpi->InfoEx) - pi = bpi->InfoEx(mirandaVersion); - else - pi = (PLUGININFOEX*)bpi->Info(mirandaVersion); + if ( bpi->Load && bpi->Unload && bpi->InfoEx && bpi->Interfaces ) { + PLUGININFOEX* pi = bpi->InfoEx(mirandaVersion); { // similar to the above hack but these plugins are checked for a valid interface first (in case there are updates to the plugin later) TCHAR* p = _tcsrchr(plugin, '\\'); @@ -520,7 +512,7 @@ static BOOL scanPluginsDir (WIN32_FIND_DATA * fd, TCHAR * path, WPARAM, LPARAM) continue; p->pclass |= (PCLASS_SERVICE); if ( pluginListSM != NULL ) p->nextclass = pluginListSM; - pluginListSM=p; + pluginListSM = p; if (pluginList_crshdmp == NULL && lstrcmpi(fd->cFileName, _T("svc_crshdmp.dll")) == 0) { pluginList_crshdmp = p; p->pclass |= PCLASS_LAST; @@ -608,7 +600,7 @@ int UnloadPlugin(TCHAR* buf, int bufLen) // // Service plugins functions -char **GetSeviceModePluginsList(void) +char **GetServiceModePluginsList(void) { int i = 0; char **list = NULL; @@ -648,10 +640,9 @@ int LoadServiceModePlugin(void) p->pclass |= PCLASS_LOADED; if ( CallService( MS_SERVICEMODE_LAUNCH, 0, 0 ) != CALLSERVICE_NOTFOUND ) return 1; - else { - MessageBox(NULL, TranslateT("Unable to load plugin in Service Mode!"), p->pluginname, 0); - return -1; - } + + MessageBox(NULL, TranslateT("Unable to load plugin in Service Mode!"), p->pluginname, 0); + return -1; } Plugin_Uninit( p ); return -1; @@ -681,6 +672,7 @@ void UnloadNewPlugins(void) typedef struct { + HINSTANCE hInst; int flags; char* author; char* authorEmail; @@ -695,7 +687,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l { TCHAR buf[MAX_PATH]; mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName); - HINSTANCE gModule = GetModuleHandle(buf); + HINSTANCE hInst = GetModuleHandle(buf); CharLower(fd->cFileName); @@ -708,17 +700,26 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l int isdb = pi.pluginInfo->replacesDefaultModule == DEFMOD_DB; PluginListItemData* dat = (PluginListItemData*)mir_alloc( sizeof( PluginListItemData )); + dat->hInst = hInst; HWND hwndList = (HWND)lParam; LVITEM it = { 0 }; it.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; - it.pszText = fd->cFileName; it.iImage = ( pi.pluginInfo->flags & 1 ) ? 0 : 1; + it.pszText = fd->cFileName; it.lParam = (LPARAM)dat; int iRow = SendMessage( hwndList, LVM_INSERTITEM, 0, (LPARAM)&it ); if ( isPluginOnWhiteList(fd->cFileName) ) ListView_SetItemState(hwndList, iRow, !isdb ? 0x2000 : 0x3000, LVIS_STATEIMAGEMASK); if ( iRow != -1 ) { + it.mask = LVIF_IMAGE; + it.iItem = iRow; + it.iSubItem = 1; + it.iImage = ( hInst != NULL ) ? 2 : 3; + ListView_SetItem( hwndList, &it ); + + ListView_SetItemText(hwndList, iRow, 2, fd->cFileName); + dat->flags = pi.pluginInfo->replacesDefaultModule; dat->author = mir_strdup( pi.pluginInfo->author ); dat->authorEmail = mir_strdup( pi.pluginInfo->authorEmail ); @@ -731,7 +732,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l memset( &dat->uuid, 0, sizeof(dat->uuid)); TCHAR *shortNameT = mir_a2t(pi.pluginInfo->shortName); - ListView_SetItemText(hwndList, iRow, 1, shortNameT); + ListView_SetItemText(hwndList, iRow, 3, shortNameT); mir_free(shortNameT); DWORD unused, verInfoSize = GetFileVersionInfoSize(buf, &unused); @@ -750,13 +751,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l LOBYTE(HIWORD(pi.pluginInfo->version)), HIBYTE(LOWORD(pi.pluginInfo->version)), LOBYTE(LOWORD(pi.pluginInfo->version))); - ListView_SetItemText(hwndList, iRow, 2, buf); - - it.mask = LVIF_IMAGE; - it.iItem = iRow; - it.iSubItem = 3; - it.iImage = ( gModule != NULL ) ? 2 : 3; - ListView_SetItem( hwndList, &it ); + ListView_SetItemText(hwndList, iRow, 4, buf); } else mir_free( dat ); FreeLibrary(pi.hInst); @@ -779,12 +774,40 @@ static void RemoveAllItems( HWND hwnd ) lvi.iItem ++; } } +static LRESULT CALLBACK PluginListWndProc(HWND hwnd,UINT msg, WPARAM wParam, LPARAM lParam) +{ + LVHITTESTINFO hi; + + switch (msg) { + case WM_LBUTTONDOWN: + hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam); + ListView_SubItemHitTest(hwnd, &hi); + if ( hi.iSubItem == 1 ) { + LVITEM lvi; + lvi.mask = LVIF_PARAM; + lvi.iItem = hi.iItem; + if ( !ListView_GetItem( hwnd, &lvi )) + break; + + PluginListItemData* dat = ( PluginListItemData* )lvi.lParam; + if (dat->hInst == NULL); + } + break; + } + + WNDPROC wnProc = ( WNDPROC )GetWindowLongPtr(hwnd, GWLP_USERDATA); + return CallWindowProc(wnProc, hwnd, msg, wParam, lParam); +} + INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { HWND hwndList=GetDlgItem(hwndDlg, IDC_PLUGLIST); + SetWindowLongPtr(hwndList, GWLP_USERDATA, (LONG_PTR)GetWindowLongPtr(hwndList, GWLP_WNDPROC)); + SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc); + LVCOLUMN col; HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_UNICODE ); @@ -796,22 +819,25 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar TranslateDialogDefault(hwndDlg); col.mask = LVCF_TEXT | LVCF_WIDTH; - col.pszText = TranslateT("Plugin"); - col.cx = 70;//max = 140; + col.pszText = _T(""); + col.cx = 40; ListView_InsertColumn(hwndList, 0, &col); - col.pszText = TranslateT("Name"); - col.cx = 70;//max = 220; + col.pszText = _T(""); + col.cx = 20; ListView_InsertColumn(hwndList, 1, &col); - col.pszText = TranslateT("Version"); + col.pszText = TranslateT("Plugin"); col.cx = 70; ListView_InsertColumn(hwndList, 2, &col); - col.pszText = _T(""); - col.cx = 20; + col.pszText = TranslateT("Name"); + col.cx = 70;//max = 220; ListView_InsertColumn(hwndList, 3, &col); - //ListView_InsertColumn(hwndList, 4, &col); + + col.pszText = TranslateT("Version"); + col.cx = 70; + ListView_InsertColumn(hwndList, 4, &col); // XXX: Won't work on windows 95 without IE3+ or 4.70 ListView_SetExtendedListViewStyleEx( hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT ); @@ -821,17 +847,17 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar { int w, max; - ListView_SetColumnWidth( hwndList, 0, LVSCW_AUTOSIZE ); // dll name - w = ListView_GetColumnWidth( hwndList, 0 ); - if (w > 140) { - ListView_SetColumnWidth( hwndList, 0, 140 ); - w = 140; + ListView_SetColumnWidth( hwndList, 2, LVSCW_AUTOSIZE ); // dll name + w = ListView_GetColumnWidth( hwndList, 2 ); + if (w > 110) { + ListView_SetColumnWidth( hwndList, 2, 110 ); + w = 110; } - max = w<140? 220+140-w:220; - ListView_SetColumnWidth( hwndList, 1, LVSCW_AUTOSIZE ); // short name - w = ListView_GetColumnWidth( hwndList, 1 ); + max = w < 110 ? 199+110-w:199; + ListView_SetColumnWidth( hwndList, 3, LVSCW_AUTOSIZE ); // short name + w = ListView_GetColumnWidth( hwndList, 3 ); if (w > max) - ListView_SetColumnWidth( hwndList, 1, max ); + ListView_SetColumnWidth( hwndList, 3, max ); } return TRUE; } diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp index fa72e91f10..cedc49638f 100644 --- a/src/modules/srfile/filexferdlg.cpp +++ b/src/modules/srfile/filexferdlg.cpp @@ -618,7 +618,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR fts = &dat->transferStatus; bool firstTime = false; - if ((GetWindowLong(GetDlgItem(hwndDlg, IDC_ALLFILESPROGRESS), GWL_STYLE) & WS_VISIBLE) == 0) + if ((GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_ALLFILESPROGRESS), GWL_STYLE) & WS_VISIBLE) == 0) { SetFtStatus(hwndDlg, ( fts->flags & PFTS_SENDING ) ? LPGENT("Sending...") : LPGENT("Receiving..."), FTS_PROGRESS); SetFilenameControls(hwndDlg, dat, fts); diff --git a/src/modules/userinfo/userinfo.cpp b/src/modules/userinfo/userinfo.cpp index 9a8daf0266..38947bec2b 100644 --- a/src/modules/userinfo/userinfo.cpp +++ b/src/modules/userinfo/userinfo.cpp @@ -184,8 +184,8 @@ static void CreateDetailsTabs( HWND hwndDlg, struct DetailsData* dat, struct Det } TabCtrl_SetCurSel(hwndTab,sel); - LONG style = GetWindowLong(hwndTab, GWL_STYLE); - SetWindowLong(hwndTab, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP); + LONG style = GetWindowLongPtr(hwndTab, GWL_STYLE); + SetWindowLongPtr(hwndTab, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP); } static void CreateDetailsPageWindow( HWND hwndDlg, struct DetailsData* dat, struct DetailsPageData* ppg ) -- cgit v1.2.3