/* DlgProcRemoveConnect * * Dialog box procedure for WNetDisconnectDialog() function. Construct a * list of all connected and remembered resources, and allow the user to * select one to attempt to delete. */ static BOOL CALLBACK DlgProcRemoveConnect( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { HWND hListBoxWnd = GetDlgItem(hDlg,IDC_NETUI_DISCONLIST); // FONT HANDLING STUFF // set font size, weight, and color per the table gs_rgTextDescRemoveConn static void* s_pvFontManager; ULONG ulFontMgrRetVal; if (SHRunFontManager(gs_rgTextDescRemoveConn, ARRAYSIZEOF(gs_rgTextDescRemoveConn), &s_pvFontManager, message, hDlg, wParam, lParam, &ulFontMgrRetVal) == CTLTEXT_EXIT ) { return (BOOL)ulFontMgrRetVal; } switch( message ) { case WM_INITDIALOG: { DWORD Status, BufSize, NumElements; NETRESOURCE *pNetRes; HANDLE hEnum; DWORD dwScope = RESOURCE_CONNECTED; StartEnum: // Populate listbox with list of resources. Since we don't automatically // try to connect our remebered resources, we have to enumerate connected // and remembered resources separately. if ((Status = pfnWNetOpenEnum(dwScope,RESOURCETYPE_ANY, 0, // Doesn't matter NULL,&hEnum)) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: Error %u in WNetOpenEnum(%d)"), GetLastError(),dwScope)); return FALSE; } while (Status == ERROR_SUCCESS) { DWORD iRet; WCHAR StrBuf[100]; // First, call with 0 buffer to determine needed size (this is not very efficient, // but we want a separate buffer for each NETRESOURCE struct). BufSize = 0; pNetRes = NULL; NumElements = 1; Status = pfnWNetEnumResource(hEnum,&NumElements,pNetRes,&BufSize); if (Status == ERROR_NO_MORE_ITEMS) break; else if (Status != ERROR_MORE_DATA) { DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: WNetEnumResource(0) returned %u\r\n"),Status)); } else DEBUGMSG(ZONE_DISCONN,(DBGTEXT("DlgProcRemoveConnect: Using buffer size %u"),BufSize)); if ((pNetRes = LocalAlloc(0,BufSize)) == NULL) { DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: LocalAlloc(%d) failed"),BufSize)); Status = ERROR_NOT_ENOUGH_MEMORY; break; } NumElements = 1; Status = pfnWNetEnumResource(hEnum,&NumElements,pNetRes,&BufSize); if (Status != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: Error %u in WNetEnumResource()"), GetLastError())); break; } // Use TAB to separate local, remote names wsprintf(StrBuf,L"%s\t%s",pNetRes->lpLocalName? pNetRes->lpLocalName : L"(none)",pNetRes->lpRemoteName); // If remembered resource is also connected, we'll get duplicated entries if (ListBox_FindString(hListBoxWnd,0,StrBuf) != LB_ERR) { DEBUGMSG(ZONE_DISCONN,(DBGTEXT("Entry %s already added to listbox"),StrBuf)); LocalFree(pNetRes); continue; } DEBUGMSG(ZONE_DISCONN,(DBGTEXT("Adding entry %s to listbox"),StrBuf)); iRet = ListBox_AddString(hListBoxWnd,StrBuf); if ((iRet == LB_ERR) || (iRet == LB_ERRSPACE)) { DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: Error adding string to listbox: %d"),iRet)); LocalFree(pNetRes); continue; } ListBox_SetItemData(hListBoxWnd,iRet,pNetRes); } pfnWNetCloseEnum(hEnum); if (Status != ERROR_NO_MORE_ITEMS) { // Some error occurred, clean up DisconnectDialogDone(hDlg,FALSE); return FALSE; } // List both connected and remembered resources if (dwScope == RESOURCE_CONNECTED) { dwScope = RESOURCE_REMEMBERED; goto StartEnum; } ListBox_SetCurSel(hListBoxWnd,0); return FALSE; } case WM_COMMAND: switch( LOWORD( wParam ) ) { case IDCANCEL: // Clean up DisconnectDialogDone(hDlg, FALSE); break; case IDOK: { BOOL bRet = TRUE; NETRESOURCE *pNetRes; int Index; Index = ListBox_GetCurSel(hListBoxWnd); pNetRes = (NETRESOURCE *)ListBox_GetItemData(hListBoxWnd,Index); if (((LRESULT)pNetRes == LB_ERR) || (pNetRes == NULL)) { DEBUGMSG(ZONE_ERROR,(DBGTEXT("!DisconnectDlgDone: LB_GETITEMDATA returned err or NULL: %d"), GetLastError())); } else { // Disconnect selected resource DISCDLGSTRUCT DlgStruct; DlgStruct.cbStructure = sizeof(DlgStruct); DlgStruct.hwndOwner = hDlg; DlgStruct.lpLocalName = pNetRes->lpLocalName; DlgStruct.lpRemoteName= pNetRes->lpRemoteName; DlgStruct.dwFlags = DISC_UPDATE_PROFILE; DEBUGMSG(ZONE_DISCONN,(DBGTEXT("Got Selection %s -> %s"), pNetRes->lpLocalName,pNetRes->lpRemoteName)); if (pfnWNetDisconnectDialog1(&DlgStruct) != ERROR_SUCCESS) bRet = FALSE; } // Clean up DisconnectDialogDone(hDlg, bRet); break; } } case WM_DESTROY: return( FALSE ); default: return( FALSE ); } }
INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static bool bDlgInit = false; //some controls send WM_COMMAND before or during WM_INITDIALOG static HANDLE hhkFontsReload = 0; static OPTTREE_OPTION *skinOptions = NULL; static int skinOptionsCount = 0; if (skinOptions) { int index = -1; OptTree_ProcessMessage(hwndDlg, msg, wParam, lParam, &index, IDC_SKIN_LIST_OPT, skinOptions, skinOptionsCount); if (index != -1) { if (lstrcmp(skinOptions[index].pszSettingName, _T("Skin options")) == 0) { const PopupSkin *skin = 0; if (skin = skins.getSkin(PopupOptions.SkinPack)) { skin->setFlag(skinOptions[index].Data, skinOptions[index].bState ? true : false); } } else if (lstrcmp(skinOptions[index].pszSettingName, _T("Global settings")) == 0) { switch (skinOptions[index].dwFlag) { case (1 << 0): PopupOptions.DisplayTime = skinOptions[index].bState; break; case (1 << 1): PopupOptions.DropShadow = skinOptions[index].bState; break; case (1 << 2): PopupOptions.EnableFreeformShadows = skinOptions[index].bState; break; case (1 << 3): PopupOptions.EnableAeroGlass = skinOptions[index].bState; break; case (1 << 4): PopupOptions.UseWinColors = skinOptions[index].bState; break; case (1 << 5): PopupOptions.UseMText = skinOptions[index].bState; break; } } updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); return FALSE; } } switch (msg) { case WM_INITDIALOG: { HWND hCtrl = NULL; DWORD dwIndex = 0; //Skin List hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST); ListBox_ResetContent(hCtrl); LPTSTR Temp = NULL; for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) { dwIndex = ListBox_AddString(hCtrl, sl->name); ListBox_SetItemData(hCtrl, dwIndex, sl->name); } ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack)); //Skin List reload button SendMessage(GetDlgItem(hwndDlg, IDC_BTN_RELOAD), BUTTONSETASFLATBTN, TRUE, 0); SendMessage(GetDlgItem(hwndDlg, IDC_BTN_RELOAD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_OPT_RELOAD,0)); SendMessage(GetDlgItem(hwndDlg, IDC_BTN_RELOAD), BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0); //Skin Option List SkinOptionList_Update (skinOptions, &skinOptionsCount, hwndDlg); //PreviewBox mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox); updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); //hooks hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER); TranslateDialogDefault(hwndDlg); bDlgInit = true; } return TRUE; case WM_USER: updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); return TRUE; case WM_COMMAND: { HWND hCtrl = NULL; UINT idCtrl = LOWORD(wParam); switch (HIWORD(wParam)) { case BN_KILLFOCUS: //Button controls case BN_SETFOCUS: //Button controls return TRUE; break; case BN_CLICKED: //Button controls switch(idCtrl) { case IDC_PREVIEW: PopupPreview(); break; case IDC_BTN_RELOAD: { LPTSTR Temp = NULL; DWORD dwIndex = 0; TCHAR szNewSkin[128]; LPTSTR pszOldSkin = mir_tstrdup(PopupOptions.SkinPack); skins.load(_T("")); hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST); ListBox_ResetContent(hCtrl); for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) { dwIndex = ListBox_AddString(hCtrl, sl->name); ListBox_SetItemData(hCtrl, dwIndex, sl->name); } ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack)); //make shure we have select skin (ListBox_SetCurSel may be fail) ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin); if (lstrcmp(pszOldSkin, szNewSkin) != 0) { mir_free(PopupOptions.SkinPack); PopupOptions.SkinPack = mir_tstrdup(szNewSkin); } mir_free(pszOldSkin); const PopupSkin *skin = 0; if (skin = skins.getSkin(PopupOptions.SkinPack)) { //update Skin Option List from reload SkinPack bDlgInit = false; bDlgInit = SkinOptionList_Update (skinOptions, &skinOptionsCount, hwndDlg); } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); }//end IDC_BTN_RELOAD: break; case IDC_GETSKINS: CallService(MS_UTILS_OPENURL,0,(LPARAM)"http://miranda-ng.org/"); break; }//end switch(idCtrl) updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); break; case CBN_SELCHANGE: //combo box controls switch(idCtrl) { case IDC_SKINLIST: { //Skin list change mir_free(PopupOptions.SkinPack); PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage( hwndDlg, IDC_SKINLIST, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL,0,0), 0)); const PopupSkin *skin = 0; if (skin = skins.getSkin(PopupOptions.SkinPack)) { mir_free(PopupOptions.SkinPack); PopupOptions.SkinPack = mir_tstrdup(skin->getName()); //update Skin Option List bDlgInit = false; bDlgInit = SkinOptionList_Update (skinOptions, &skinOptionsCount, hwndDlg); } updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; }//end switch(idCtrl) break; }//end switch (HIWORD(wParam)) break; }// end WM_COMMAND return FALSE; case WM_NOTIFY: if (!bDlgInit) return FALSE; switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_RESET: LoadOption_Skins(); return TRUE; case PSN_APPLY: { //skin pack db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack); //skin options const PopupSkin *skin = 0; if (skin = skins.getSkin(PopupOptions.SkinPack)) skin->saveOpts(); skins.freeAllButActive(); //more Skin options db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime); db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow); db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows); db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass); db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText); }//end PSN_APPLY: return TRUE; }//switch (((LPNMHDR)lParam)->code) break; }//end switch (((LPNMHDR)lParam)->idFrom) return FALSE; case WM_DESTROY: if (wndPreview) { delete wndPreview; wndPreview = NULL; gPreviewOk = false; } if (hhkFontsReload) UnhookEvent(hhkFontsReload); if (skinOptions) { for (int i=0; i < skinOptionsCount; ++i) { mir_free(skinOptions[i].pszOptionName); mir_free(skinOptions[i].pszSettingName); } mir_free(skinOptions); skinOptions = NULL; skinOptionsCount = 0; } return TRUE; }//end switch (msg) return FALSE; }
/* * LookCommand: Handle WM_COMMAND messages. */ void LookCommand(HWND hDlg, int ctrl_id, HWND hwndCtl, UINT codeNotify) { int index, num_entries, i, amount, currentAmount; list_type selection; object_node *obj; char buf[MAXNAME + 1], temp[16]; switch(ctrl_id) { case IDC_ITEMFIND: if (codeNotify == EN_UPDATE) { /* Go to object in list that user has named */ Edit_GetText(info->hwndFind, buf, MAXNAME); index = ListBox_FindString(info->hwndListBox, -1, buf); if (index != LB_ERR) if (info->flags & LD_MULTIPLESEL) ListBox_SetCaretIndex(info->hwndListBox, index); else ListBox_SetCurSel(info->hwndListBox, index); } break; case IDC_ALL: /* In multiple selection box only, select all objects. If we require that * user give amounts, don't select amount objects */ num_entries = ListBox_GetCount(info->hwndListBox); ListBox_SetSel(info->hwndListBox, TRUE, -1); WindowBeginUpdate(info->hwndQuanList); // Select all for number items for (i=0; i < num_entries; i++) { info->selected[i] = True; obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i); if (IsNumberObj(obj->id)) amount = obj->amount; else amount = 1; obj->temp_amount = amount; ListBox_DeleteString(info->hwndQuanList,i); sprintf(temp, "%d", amount); ListBox_InsertString(info->hwndQuanList,i,temp); ListBox_SetItemData(info->hwndQuanList,i,amount); } WindowEndUpdate(info->hwndQuanList); break; case IDC_ITEMLIST: switch (codeNotify) { case LBN_DBLCLK: /* Look at item */ index = ListBox_GetCaretIndex(info->hwndListBox); if (index != LB_ERR) { obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index); RequestLook(obj->id); SetDescParams(hDlg, DESC_NONE); ListBox_SetSel(info->hwndListBox, FALSE, index); info->selected[index] = False; } break; case LBN_SELCHANGE: #if 0 LookSelChange(hwndCtl); #else index = ListBox_GetCurSel(info->hwndListBox); obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index); WindowBeginUpdate(info->hwndQuanList); ListBox_DeleteString(info->hwndQuanList,index); if (ListBox_GetSel(info->hwndListBox,index)) { if (IsNumberObj(obj->id)) amount = obj->amount; else amount = 1; sprintf(temp, "%d", amount); } else { amount = 0; strcpy(temp," "); } ListBox_InsertString(info->hwndQuanList,index,temp); ListBox_SetItemData(info->hwndQuanList,index,amount); ListBox_SetSel(info->hwndListBox,amount > 0,index); info->selected[index] = (amount > 0); obj->temp_amount = amount; ListBox_SetSel(info->hwndQuanList,FALSE,index); WindowEndUpdate(info->hwndQuanList); #endif break; } break; case IDC_QUANLIST: if (codeNotify == LBN_SELCHANGE) { char temp[16]; index = (int)ListBox_GetCurSel(info->hwndQuanList); obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index); currentAmount = (int)ListBox_GetItemData(info->hwndQuanList, index); amount = currentAmount; if (ListBox_GetItemData(info->hwndQuanList, index) > 0) { if (IsNumberObj(obj->id)) { MEASUREITEMSTRUCT m; int startAmount = currentAmount; if (currentAmount == 0) startAmount = obj->amount; /* Place amount dialog just beneath selected item */ ItemListMeasureItem(info->hwndQuanList, &m); // Force highlight on (we are editing it) ListBox_SetSel(info->hwndListBox,TRUE,index); if(InputNumber(hDlg,info->hwndQuanList, 0,(index - ListBox_GetTopIndex(info->hwndQuanList) + 1) * (m.itemHeight - 1), &amount,startAmount,1,obj->amount)) { ListBox_DeleteString(info->hwndQuanList,index); if (amount > 0) { sprintf(temp, "%d", amount); ListBox_InsertString(info->hwndQuanList, index, temp); } else { ListBox_InsertString(info->hwndQuanList,index," "); } ListBox_SetItemData(info->hwndQuanList, index, amount); } else amount = currentAmount; // reset highlight based on quantity - off if zero, on otherwise ListBox_SetSel(info->hwndListBox, (ListBox_GetItemData(info->hwndQuanList,index) > 0), index); } else { ListBox_DeleteString(info->hwndQuanList,index); if (currentAmount == 0) { amount = 1; strcpy(temp,"1"); } else { amount = 0; strcpy(temp," "); } ListBox_InsertString(info->hwndQuanList,index,temp); ListBox_SetItemData(info->hwndQuanList,index,amount); } } ListBox_SetSel(info->hwndListBox,amount > 0,index); info->selected[index] = (amount > 0); obj->temp_amount = amount; ListBox_SetCurSel(info->hwndQuanList,-1); } break; case IDOK: /* Get user's selection(s) */ num_entries = ListBox_GetCount(info->hwndListBox); selection = NULL; for (i = 0; i < num_entries; i++) { /* If item is selected, add to selection list, else free */ obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i); if (ListBox_GetSel(info->hwndListBox, i) > 0) selection = list_add_item(selection, obj); else ObjectDestroyAndFree(obj); } LookDialogRetval = selection; EndDialog(hDlg, IDOK); break; case IDCANCEL: LookListFreeContents(info->hwndListBox); LookDialogRetval = NULL; EndDialog(hDlg, IDCANCEL); break; } }