static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct DlgProfData *dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); dat = (struct DlgProfData *)lParam; { HWND hwndCombo = GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS); // what, no plugins?! if (arDbPlugins.getCount() == 0) { EnableWindow(hwndCombo, FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_NODBDRIVERS), TRUE); } else { for (int i = 0; i < arDbPlugins.getCount(); i++) { DATABASELINK *p = arDbPlugins[i]; LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(p->szFullName)); SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)p); } } // default item SendMessage(hwndCombo, CB_SETCURSEL, 0, 0); // subclass the profile name box mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), ProfileNameValidate); } // decide if there is a default profile name given in the INI and if it should be used if (dat->pd->noProfiles || (shouldAutoCreate(dat->pd->szProfile) && _taccess(dat->pd->szProfile, 0))) { TCHAR *profile = _tcsrchr(dat->pd->szProfile, '\\'); if (profile) ++profile; else profile = dat->pd->szProfile; TCHAR *p = _tcsrchr(profile, '.'); TCHAR c = 0; if (p) { c = *p; *p = 0; } SetDlgItemText(hwndDlg, IDC_PROFILENAME, profile); if (c) *p = c; } // focus on the textbox PostMessage(hwndDlg, WM_FOCUSTEXTBOX, 0, 0); return TRUE; case WM_FOCUSTEXTBOX: SetFocus(GetDlgItem(hwndDlg, IDC_PROFILENAME)); break; case WM_INPUTCHANGED: // when input in the edit box changes SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); EnableWindow(dat->hwndOK, GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PROFILENAME)) > 0); break; case WM_SHOWWINDOW: if (wParam) { EnableWindow(dat->hwndSM, FALSE); SetWindowText(dat->hwndOK, TranslateT("&Create")); SendMessage(hwndDlg, WM_INPUTCHANGED, 0, 0); } break; case WM_NOTIFY: NMHDR *hdr = (NMHDR*)lParam; if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) { TCHAR szName[MAX_PATH]; LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0); if (curSel == CB_ERR) break; // should never happen GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF(szName)); if (szName[0] == 0) break; // profile placed in "profile_name" subfolder mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName); dat->pd->newProfile = 1; dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0); if (CreateProfile(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0) SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); } break; } return FALSE; }
LRESULT CALLBACK CounterDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static int init; COUNTEROBJ * st; st = (COUNTEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_COUNTER)) return(FALSE); switch( message ) { case WM_INITDIALOG: SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=4; lpsi.nMax=300; SetScrollInfo(GetDlgItem(hDlg,IDC_FONTSIZEBAR),SB_CTL,&lpsi, TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_FONTSIZEBAR), SB_CTL,st->fontsize, TRUE); SetDlgItemInt(hDlg, IDC_FONTSIZE, st->fontsize, FALSE); SetDlgItemText(hDlg, IDC_CAPTION, st->wndcaption); SetDlgItemInt(hDlg, IDC_RESETVALUE, (int)st->resetvalue,TRUE); switch (st->mode) { case 0: CheckDlgButton(hDlg, IDC_COUNTFT,TRUE); break; case 1: CheckDlgButton(hDlg, IDC_COUNTTF,TRUE); break; case 2: CheckDlgButton(hDlg, IDC_COUNTIV,TRUE); break; case 3: CheckDlgButton(hDlg, IDC_COUNTFREQ,TRUE); break; } CheckDlgButton(hDlg, IDC_SHOWCOUNTER,st->showcounter); CheckDlgButton(hDlg, IDC_INTEGER,st->integer); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COUNTFT: st->mode=0; break; case IDC_COUNTTF: st->mode=1; break; case IDC_COUNTIV: st->mode=2; break; case IDC_COUNTFREQ: st->mode=3; break; case IDC_RESETCOUNTER: st->countervalue=st->resetvalue; break; case IDC_RESETVALUE: st->resetvalue=(float)GetDlgItemInt(hDlg, IDC_RESETVALUE,NULL, 1); break; case IDC_FONTCOLOR: st->fontcolor=select_color(hDlg); InvalidateRect(hDlg,NULL,FALSE); InvalidateRect(st->displayWnd,NULL,TRUE); break; case IDC_BKCOLOR: st->bkcolor=select_color(hDlg); InvalidateRect(hDlg,NULL,FALSE); InvalidateRect(st->displayWnd,NULL,TRUE); break; case IDC_CAPTION: GetDlgItemText(hDlg,IDC_CAPTION,st->wndcaption,50); SetWindowText(st->displayWnd,st->wndcaption); break; case IDC_INTEGER: st->integer=IsDlgButtonChecked(hDlg,IDC_INTEGER); InvalidateRect(st->displayWnd,NULL,TRUE); break; case IDC_SHOWCOUNTER: { int i; i=IsDlgButtonChecked(hDlg,IDC_SHOWCOUNTER); if ((st->showcounter)&&(!i)&&(st->displayWnd)) { DestroyWindow(st->displayWnd); st->displayWnd=NULL; } if ((!st->showcounter)&&(i)) { if(!(st->displayWnd=CreateWindow("Counter_Class", "Counter", WS_THICKFRAME| WS_CLIPCHILDREN,st->left, st->top, st->right-st->left, st->bottom-st->top, NULL, NULL, hInst, NULL))) report_error("can't create Counter Window"); else { ShowWindow( st->displayWnd, TRUE ); UpdateWindow( st->displayWnd ); } } st->showcounter=i; } break; } return TRUE; case WM_HSCROLL: if (lParam == (long) GetDlgItem(hDlg,IDC_FONTSIZEBAR)) { int nNewPos=get_scrollpos(wParam,lParam); SetDlgItemInt(hDlg, IDC_FONTSIZE, nNewPos, TRUE); st->fontsize=nNewPos; if (st->font) DeleteObject(st->font); if (!(st->font = CreateFont(-MulDiv(st->fontsize, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"))) report_error("Font creation failed!"); InvalidateRect(st->displayWnd, NULL, TRUE); } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); case WM_PAINT: color_button(GetDlgItem(hDlg,IDC_FONTCOLOR),st->fontcolor); color_button(GetDlgItem(hDlg,IDC_BKCOLOR),st->bkcolor); break; } return FALSE; }
BOOL COptionTab10::OnInitDialog() { CPropertyPage::OnInitDialog(); EnableToolTips(true); // TOOL TIPS /* hide password */ CString st; GetDlgItemText(IDC_prox,st); if (st.Find('@')>=0) { m_ctl_pwdhide.SetCheck(1); OnPwdhide(); } else { m_ctl_pwdhide.SetCheck(0); OnPwdhide(); } if (LANG_T(-1)) { // Patcher en français SetDlgItemTextCP(this, IDC_proxyconfigure,LANG(LANG_I47b)); // "Configurer" SetDlgItemTextCP(this, IDC_ftpprox,LANG(LANG_I47c)); SetDlgItemTextCP(this, IDC_PWDHIDE,LANG_HIDEPWD); /* Hide password */ } // mode modif à la volée if (modify==1) { GetDlgItem(IDC_prox ) ->ModifyStyle(0,WS_DISABLED); GetDlgItem(IDC_portprox ) ->ModifyStyle(0,WS_DISABLED); GetDlgItem(IDC_proxyconfigure ) ->ModifyStyle(0,WS_DISABLED); GetDlgItem(IDC_proxtitle ) ->ModifyStyle(0,WS_DISABLED); GetDlgItem(IDC_ftpprox ) ->ModifyStyle(0,WS_DISABLED); } else { GetDlgItem(IDC_prox ) ->ModifyStyle(WS_DISABLED,0); GetDlgItem(IDC_portprox ) ->ModifyStyle(WS_DISABLED,0); GetDlgItem(IDC_proxyconfigure ) ->ModifyStyle(WS_DISABLED,0); GetDlgItem(IDC_proxtitle ) ->ModifyStyle(WS_DISABLED,0); GetDlgItem(IDC_ftpprox ) ->ModifyStyle(WS_DISABLED,0); } CString str; GetDlgItemText(IDC_prox,str); m_ctl_prox.ResetContent(); m_ctl_prox.AddString(""); HKEY phkResult; if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",0,KEY_READ,&phkResult)==ERROR_SUCCESS) { DWORD type=0; DWORD datasize=1000; char data[1024]; data[0]='\0'; if (RegQueryValueEx(phkResult,"ProxyServer",0,&type,(unsigned char*)&data,&datasize)==ERROR_SUCCESS) { if (datasize) { char* a=strchr(data,':'); if (a) *a='\0'; m_ctl_prox.AddString(data); } } RegCloseKey(phkResult); } SetDlgItemTextCP(this, IDC_prox,str); // Do not search for a proxy everytime CWinApp* pApp = AfxGetApp(); if (pApp->GetProfileInt("Interface","FirstProxySearch",0) != 1) { pApp->WriteProfileInt("Interface","FirstProxySearch",1); // Launch proxy name search int i=0; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="proxy") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="www") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="ns") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="web") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="ntserv") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="gate") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="gateway") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="firewall"),this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; WSAAsyncGetHostByName(this->m_hWnd,wm_ProxySearch+i,(ProxyDetectName[i]="cache") ,this->ProxyDetectBuff[i],sizeof(this->ProxyDetectBuff[i])); i++; } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CKrbAddRealm::OnChangeEditRealm() { if (!m_startup) GetDlgItemText(IDC_EDIT_REALM, m_newRealm); }
// edit weather settings // lParam = current contact INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; TCHAR str[256], str2[256], city[256], filter[256], *pfilter, *chop; char loc[512]; OPENFILENAME ofn; // common dialog box structure MCONTACT hContact; WIDATA *sData; CntSetWndDataType *wndData = NULL; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); wndData = ( CntSetWndDataType* )mir_alloc(sizeof(CntSetWndDataType)); wndData->hContact = hContact = lParam; wndData->hRename = LoadSkinnedIcon(SKINICON_OTHER_RENAME); wndData->hUserDetail = LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS); wndData->hFile = LoadSkinnedIcon(SKINICON_EVENT_FILE); wndData->hSrchAll = LoadSkinnedIcon(SKINICON_OTHER_SEARCHALL); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)wndData); // set button images SendDlgItemMessage(hwndDlg, IDC_GETNAME, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename); SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hUserDetail); SendDlgItemMessage(hwndDlg, IDC_BROWSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hFile); SendDlgItemMessage(hwndDlg, IDC_VIEW1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll); SendDlgItemMessage(hwndDlg, IDC_RESET1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename); SendDlgItemMessage(hwndDlg, IDC_VIEW2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll); SendDlgItemMessage(hwndDlg, IDC_RESET2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename); // make all buttons flat SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONSETASFLATBTN, TRUE, 0); // set tooltip for the buttons SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Get city name from ID"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Weather INI information"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Browse"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONADDTOOLTIP, (WPARAM) LPGENT("View webpage"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Reset to default"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONADDTOOLTIP, (WPARAM) LPGENT("View webpage"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Reset to default"), BATF_TCHAR); // save the handle for the contact WindowList_Add(hWindowList, hwndDlg, hContact); // start to get the settings // if the setting not exist, leave the dialog box blank if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) { SetDlgItemText(hwndDlg, IDC_ID, dbv.ptszVal); // check if the station is a default station CheckDlgButton(hwndDlg, IDC_DEFA, _tcscmp(dbv.ptszVal, opt.Default) != 0 ? BST_CHECKED : BST_UNCHECKED); db_free(&dbv); } if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { SetDlgItemText(hwndDlg, IDC_NAME, dbv.ptszVal); db_free(&dbv); } if ( !db_get_ts(hContact, WEATHERPROTONAME, "Log", &dbv)) { SetDlgItemText(hwndDlg, IDC_LOG, dbv.ptszVal); // if the log path is not empty, check the checkbox for external log if (dbv.ptszVal[0]) CheckDlgButton(hwndDlg, IDC_External, BST_CHECKED); db_free(&dbv); } // enable/disable the browse button depending on the value of external log checkbox EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)); // other checkbox options CheckDlgButton(hwndDlg, IDC_DPop, db_get_b(hContact, WEATHERPROTONAME, "DPopUp", FALSE) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DAutoUpdate, db_get_b(hContact, WEATHERPROTONAME, "DAutoUpdate", FALSE) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_Internal, db_get_b(hContact, WEATHERPROTONAME, "History", 0) ? BST_CHECKED : BST_UNCHECKED); if ( !db_get_ts(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) { SetDlgItemText(hwndDlg, IDC_IURL, dbv.ptszVal); db_free(&dbv); } if ( !db_get_ts(hContact, WEATHERPROTONAME, "MapURL", &dbv)) { SetDlgItemText(hwndDlg, IDC_MURL, dbv.ptszVal); db_free(&dbv); } // display the dialog box and free memory Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, WEATHERPROTONAME, "EditSetting_"); ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: wndData = (CntSetWndDataType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); hContact = wndData ? wndData->hContact : NULL; switch(LOWORD(wParam)) { case IDC_ID: // check if there are 2 parts in the ID (svc/id) seperated by "/" // if not, don't let user change the setting GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); chop = _tcsstr(str, _T("/")); if (chop == NULL) EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE); else EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE); break; case IDC_NAME: // check if station name is entered // if not, don't let user change the setting GetDlgItemText(hwndDlg, IDC_NAME, str, SIZEOF(str)); EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), str[0] != 0); break; case IDC_GETNAME: { // the button for getting station name from the internet // this function uses the ID search for add/find weather station if ( !CheckSearch()) return TRUE; // don't download if update is in progress // get the weather update data using the string in the ID field GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); GetSvc(str); WIDATA *sData = GetWIData(str); GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); GetID(str); // if ID search is available, do it if (sData->IDSearch.Available) { TCHAR *szData = NULL; // load the page mir_snprintf(loc, SIZEOF(loc), sData->IDSearch.SearchURL, str); str[0] = 0; if (InternetDownloadFile(loc, NULL, sData->UserAgent, &szData) == 0) { TCHAR *szInfo = szData; TCHAR* search = _tcsstr(szInfo, sData->IDSearch.NotFoundStr); // if the page is found (ie. valid ID), get the name of the city if (search == NULL) GetDataValue(&sData->IDSearch.Name, str, &szInfo); } // free memory mir_free(szData); NetlibHttpDisconnect(); } // give no station name but only ID if the search is unavailable if (str[0] != 0) SetDlgItemText(hwndDlg, IDC_NAME, str); break; } case IDC_External: // enable/disable the borwse button depending if the external log is enabled EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)); if ( !(BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) return TRUE; case IDC_BROWSE: // fall through // browse for the external log file GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str)); // Initialize OPENFILENAME memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwndDlg; ofn.lpstrFile = str; ofn.nMaxFile = SIZEOF(str); // set filters _tcscpy(filter, TranslateT("Text Files")); _tcscat(filter, _T(" (*.txt)")); pfilter = filter + _tcslen(filter)+1; _tcscpy(pfilter, _T("*.txt")); pfilter = pfilter + _tcslen(pfilter)+1; _tcscpy(pfilter, TranslateT("All Files")); _tcscat(pfilter, _T(" (*.*)")); pfilter = pfilter + _tcslen(pfilter)+1; _tcscpy(pfilter, _T("*.*")); pfilter = pfilter + _tcslen(pfilter)+1; *pfilter = '\0'; ofn.lpstrFilter = filter; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST; // Display a Open dialog box and put the file name on the dialog if (GetOpenFileName(&ofn)) SetDlgItemText(hwndDlg, IDC_LOG, ofn.lpstrFile); // if there is no log file specified, disable external logging EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), ofn.lpstrFile[0] != 0); break; case IDC_VIEW1: // view the page for more info GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str)); if (str[0] == 0) return TRUE; GetDlgItemText(hwndDlg, IDC_ID, str2, SIZEOF(str2)); OpenUrl(str, str2); break; case IDC_VIEW2: // view the page for weather map GetDlgItemText(hwndDlg, IDC_MURL, str, SIZEOF(str)); if (str[0] == 0) return TRUE; GetDlgItemText(hwndDlg, IDC_ID, str2, SIZEOF(str2)); OpenUrl(str, str2); break; case IDC_RESET1: // reset the more info url to service default GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); GetSvc(str); sData = GetWIData(str); SetDlgItemTextA(hwndDlg, IDC_IURL, sData->DefaultURL); break; case IDC_RESET2: // reset the weathe map url to service default GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); GetSvc(str); sData = GetWIData(str); SetDlgItemText(hwndDlg, IDC_MURL, sData->DefaultMap); break; case IDC_SVCINFO: // display the information of the ini file used by the weather station GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); GetSvc(str); GetINIInfo(str); break; case IDC_CHANGE: // temporary disable the protocol while applying the change // start writing the new settings to database GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); db_set_ts(hContact, WEATHERPROTONAME, "ID", str); if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFA)) { // if default station is set _tcscpy(opt.Default, str); opt.DefStn = hContact; db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); } GetDlgItemText(hwndDlg, IDC_NAME, city, SIZEOF(city)); db_set_ts(hContact, WEATHERPROTONAME, "Nick", city); mir_sntprintf(str2, SIZEOF(str2), TranslateT("Current weather information for %s."), city); if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) { GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str)); db_set_ts(hContact, WEATHERPROTONAME, "Log", str); } else db_unset(hContact, WEATHERPROTONAME, "Log"); GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str)); db_set_ts(hContact, WEATHERPROTONAME, "InfoURL", str); GetDlgItemText(hwndDlg, IDC_MURL, str, SIZEOF(str)); db_set_ts(hContact, WEATHERPROTONAME, "MapURL", str); db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE); db_set_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE); AvatarDownloaded(hContact); db_set_ts(hContact, WEATHERPROTONAME, "About", str2); db_set_b(hContact, WEATHERPROTONAME, "History", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Internal)); db_set_b(hContact, WEATHERPROTONAME, "Overwrite", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Overwrite)); db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)); db_set_b(hContact, WEATHERPROTONAME, "DPopUp", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DPop)); db_set_b(hContact, WEATHERPROTONAME, "DAutoUpdate", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DAutoUpdate)); // re-enable the protocol and update the data for the station db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); UpdateSingleStation(hContact, 0); case IDCANCEL: // fall through // remove the dialog from window list and close it DestroyWindow(hwndDlg); break; } break; case WM_CLOSE: // remove the dialog from window list and close it DestroyWindow(hwndDlg); break; case WM_DESTROY: wndData = (CntSetWndDataType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); Skin_ReleaseIcon(wndData->hFile); Skin_ReleaseIcon(wndData->hRename); Skin_ReleaseIcon(wndData->hSrchAll); Skin_ReleaseIcon(wndData->hUserDetail); mir_free(wndData); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); WindowList_Remove(hWindowList, hwndDlg); Utils_SaveWindowPosition(hwndDlg, NULL, WEATHERPROTONAME, "EditSetting_"); break; } return FALSE; }
BOOL CALLBACK PropertyDlgProc(HWND hDlg,UINT iMessage,WPARAM wParam,LPARAM lParam) { static DObject *Obj; LPMEASUREITEMSTRUCT lpmis; LPDRAWITEMSTRUCT lpdis; HBRUSH ColorBrush, OldBrush; COLORREF Color; int i; switch(iMessage) { case WM_INITDIALOG: if (FontNum==0) { ReEnum(); } for (i=0; i<FontNum; i++) { SendDlgItemMessage(hDlg,IDC_CBFONTFACE,CB_ADDSTRING,0,(LPARAM)logfont[i].lfFaceName); } for (i=0; i<sizeof(arColor)/sizeof(arColor[0]); i++) { SendDlgItemMessage(hDlg,IDC_CBLINECOLOR,CB_ADDSTRING,0,(LPARAM)arColor[i]); SendDlgItemMessage(hDlg,IDC_CBPLANECOLOR,CB_ADDSTRING,0,(LPARAM)arColor[i]); SendDlgItemMessage(hDlg,IDC_CBFONTCOLOR,CB_ADDSTRING,0,(LPARAM)arColor[i]); } SendDlgItemMessage(hDlg,IDC_SPLINEWIDTH,UDM_SETRANGE,0,MAKELONG(10,0)); Obj=(DObject *)lParam; SetDlgItemInt(hDlg,IDC_EDLINEWIDTH,Obj->LineWidth,FALSE); for (i=0; i<sizeof(arColor)/sizeof(arColor[0]); i++) { if (arColor[i] == Obj->LineColor) { break; } } SendDlgItemMessage(hDlg,IDC_CBLINECOLOR,CB_SETCURSEL,i,0); for (i=0; i<sizeof(arColor)/sizeof(arColor[0]); i++) { if (arColor[i] == Obj->PlaneColor) { break; } } SendDlgItemMessage(hDlg,IDC_CBPLANECOLOR,CB_SETCURSEL,i,0); SendDlgItemMessage(hDlg,IDC_SPFONTSIZE,UDM_SETRANGE,0,MAKELONG(72,6)); SetDlgItemInt(hDlg,IDC_EDFONTSIZE,Obj->FontSize,FALSE); for (i=0; i<sizeof(arColor)/sizeof(arColor[0]); i++) { if (arColor[i] == Obj->FontColor) { break; } } SendDlgItemMessage(hDlg,IDC_CBFONTCOLOR,CB_SETCURSEL,i,0); for (i=0; i<FontNum; i++) { if (lstrcmp(logfont[i].lfFaceName,Obj->FontFace) == 0) { break; } } SendDlgItemMessage(hDlg,IDC_CBFONTFACE,CB_SETCURSEL,i,0); if (Obj->Type != -1) { if (Obj->Type != DT_TEXT) { EnableWindow(GetDlgItem(hDlg,IDC_EDFONTSIZE),FALSE); EnableWindow(GetDlgItem(hDlg,IDC_CBFONTCOLOR),FALSE); EnableWindow(GetDlgItem(hDlg,IDC_CBFONTFACE),FALSE); } else { EnableWindow(GetDlgItem(hDlg,IDC_EDLINEWIDTH),FALSE); EnableWindow(GetDlgItem(hDlg,IDC_CBLINECOLOR),FALSE); } } return TRUE; return TRUE; case WM_MEASUREITEM: lpmis=(LPMEASUREITEMSTRUCT)lParam; lpmis->itemHeight=24; return TRUE; case WM_DRAWITEM: lpdis=(LPDRAWITEMSTRUCT)lParam; if (lpdis->itemState & ODS_SELECTED) { FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); } else { FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW)); } Color=(COLORREF)SendMessage(lpdis->hwndItem, CB_GETITEMDATA, lpdis->itemID, 0); if (Color == (COLORREF)-1) { ColorBrush=(HBRUSH)GetStockObject(NULL_BRUSH); } else { ColorBrush=CreateSolidBrush(Color); } OldBrush=(HBRUSH)SelectObject(lpdis->hDC, ColorBrush); Rectangle(lpdis->hDC,lpdis->rcItem.left+5,lpdis->rcItem.top+2, lpdis->rcItem.right-5, lpdis->rcItem.bottom-2); SelectObject(lpdis->hDC, OldBrush); if (Color == (COLORREF)-1) { SetTextAlign(lpdis->hDC,TA_CENTER); SetBkMode(lpdis->hDC,TRANSPARENT); TextOut(lpdis->hDC,(lpdis->rcItem.right+lpdis->rcItem.left)/2, lpdis->rcItem.top+4,"투명",4); } else { DeleteObject(ColorBrush); } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: Obj->LineWidth=GetDlgItemInt(hDlg,IDC_EDLINEWIDTH,NULL,FALSE); i=SendDlgItemMessage(hDlg,IDC_CBLINECOLOR,CB_GETCURSEL,0,0); Obj->LineColor=arColor[i]; i=SendDlgItemMessage(hDlg,IDC_CBPLANECOLOR,CB_GETCURSEL,0,0); Obj->PlaneColor=arColor[i]; i=SendDlgItemMessage(hDlg,IDC_CBFONTCOLOR,CB_GETCURSEL,0,0); Obj->FontColor=arColor[i]; Obj->FontSize=GetDlgItemInt(hDlg,IDC_EDFONTSIZE,NULL,FALSE); GetDlgItemText(hDlg,IDC_CBFONTFACE,Obj->FontFace,32); EndDialog(hDlg,IDOK); EndDialog(hDlg,IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg,IDCANCEL); return TRUE; } break; } return FALSE; }
INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) { RECT rc, pos; HWND button; HMENU hMenu, hMenu1; TCHAR str[4096]; switch (msg) { case WM_INITDIALOG: opt_startup = TRUE; // set windows position, make it top-most GetWindowRect(hdlg, &rc); SetWindowPos(hdlg, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE); TranslateDialogDefault(hdlg); // generate the display text for variable list _tcscpy(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set\n----------\n\\n\tnew line")); SetDlgItemText(hdlg, IDC_VARLIST, str); // make the more variable and other buttons flat SendDlgItemMessage(hdlg, IDC_MORE, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM1, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM2, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM3, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM4, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM5, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM6, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM7, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_TM8, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hdlg, IDC_RESET, BUTTONSETASFLATBTN, TRUE, 0); // load the settings LoadTextSettings(hdlg); opt_startup = FALSE; return TRUE; case WM_COMMAND: if (opt_startup) return TRUE; switch (LOWORD(wParam)) { case IDC_CTEXT: case IDC_BTITLE: case IDC_BTEXT: case IDC_NTEXT: case IDC_XTEXT: case IDC_ETEXT: case IDC_HTEXT: case IDC_BTITLE2: if (HIWORD(wParam) == EN_CHANGE) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); break; case IDC_MORE: // display custom variables list MoreVarList(); break; case IDC_TM1: case IDC_TM2: case IDC_TM3: case IDC_TM4: case IDC_TM5: case IDC_TM6: case IDC_TM7: case IDC_TM8: WEATHERINFO winfo; // display the menu button = GetDlgItem(hdlg, LOWORD(wParam)); GetWindowRect(button, &pos); hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMMENU)); hMenu1 = GetSubMenu(hMenu, 0); TranslateMenu(hMenu1); switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) { case ID_MPREVIEW: // show the preview in a message box, using the weather data from the default station winfo = LoadWeatherInfo(opt.DefStn); GetDisplay(&winfo, *var[LOWORD(wParam) - IDC_TM1], str); MessageBox(NULL, str, TranslateT("Weather Protocol Text Preview"), MB_OK | MB_TOPMOST); break; case ID_MRESET: unsigned varo = LOWORD(wParam) - IDC_TM1; // remove the old setting from db and free memory TCHAR* vartmp = *var[varo]; wfree(&vartmp); SetTextDefault(varname[varo]); SetDlgItemText(hdlg, cname[varo], *var[varo]); break; } DestroyMenu(hMenu); break; case IDC_RESET: // left click action selection menu button = GetDlgItem(hdlg, IDC_RESET); GetWindowRect(button, &pos); hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMENU)); hMenu1 = GetSubMenu(hMenu, 0); TranslateMenu(hMenu1); switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) { case ID_T1: // reset to the strings in memory, discard all changes LoadTextSettings(hdlg); break; case ID_T2: // reset to the default setting FreeTextVar(); SetTextDefault("CbBENHX"); LoadTextSettings(hdlg); break; } DestroyMenu(hMenu); break; } return TRUE; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: // save the option TCHAR textstr[MAX_TEXT_SIZE]; // free memory for old settings FreeTextVar(); // save new settings to memory GetDlgItemText(hdlg, IDC_CTEXT, textstr, SIZEOF(textstr)); wSetData(&opt.cText, textstr); GetDlgItemText(hdlg, IDC_BTEXT, textstr, SIZEOF(textstr)); wSetData(&opt.bText, textstr); GetDlgItemText(hdlg, IDC_BTITLE, textstr, SIZEOF(textstr)); wSetData(&opt.bTitle, textstr); GetDlgItemText(hdlg, IDC_ETEXT, textstr, SIZEOF(textstr)); wSetData(&opt.eText, textstr); GetDlgItemText(hdlg, IDC_NTEXT, textstr, SIZEOF(textstr)); wSetData(&opt.nText, textstr); GetDlgItemText(hdlg, IDC_HTEXT, textstr, SIZEOF(textstr)); wSetData(&opt.hText, textstr); GetDlgItemText(hdlg, IDC_XTEXT, textstr, SIZEOF(textstr)); wSetData(&opt.xText, textstr); GetDlgItemText(hdlg, IDC_BTITLE2, textstr, SIZEOF(textstr)); wSetData(&opt.sText, textstr); SaveOptions(); UpdateAllInfo(0, 0); break; } break; } return FALSE; }
void CKrb4AddToRealmHostList::OnChangeEditDefaultRealm() { if (!m_startup) GetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newRealm); }
void CKrb4AddToRealmHostList::OnChangeEditRealmHostname() { if (!m_startup) GetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_newHost); }
// // FUNCTION: BrowserDlgProc() // // PURPOSE: Browser dialog windows message handler. // // COMMENTS: // // The code for handling buttons and menu actions is here. // INT_PTR CALLBACK BrowserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { // Get the browser and other pointers since they are used a lot below HWND hwndBrowser = GetDlgItem(hwndDlg, IDC_BROWSER); nsIWebBrowserChrome *chrome = nullptr ; if (hwndBrowser) { chrome = (nsIWebBrowserChrome *) GetWindowLongPtr(hwndBrowser, GWLP_USERDATA); } nsCOMPtr<nsIWebBrowser> webBrowser; nsCOMPtr<nsIWebNavigation> webNavigation; if (chrome) { chrome->GetWebBrowser(getter_AddRefs(webBrowser)); webNavigation = do_QueryInterface(webBrowser); } // Test the message switch (uMsg) { case WM_INITDIALOG: return TRUE; case WM_INITMENU: UpdateUI(chrome); return TRUE; case WM_SYSCOMMAND: if (wParam == SC_CLOSE) { WebBrowserChromeUI::Destroy(chrome); return TRUE; } break; case WM_DESTROY: return TRUE; case WM_COMMAND: if (!webBrowser) { return TRUE; } // Test which command was selected switch (LOWORD(wParam)) { case IDC_ADDRESS: if (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE) { // User has changed the address field so enable the Go button EnableWindow(GetDlgItem(hwndDlg, IDC_GO), TRUE); } break; case IDC_GO: { TCHAR szURL[2048]; memset(szURL, 0, sizeof(szURL)); GetDlgItemText(hwndDlg, IDC_ADDRESS, szURL, sizeof(szURL) / sizeof(szURL[0]) - 1); webNavigation->LoadURI( NS_ConvertASCIItoUTF16(szURL).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nullptr, nullptr, nullptr); } break; case IDC_STOP: webNavigation->Stop(nsIWebNavigation::STOP_ALL); UpdateUI(chrome); break; case IDC_RELOAD: webNavigation->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); break; case IDM_EXIT: PostMessage(hwndDlg, WM_SYSCOMMAND, SC_CLOSE, 0); break; // File menu commands case MOZ_NewBrowser: OpenWebPage(gFirstURL); break; // Edit menu commands case MOZ_Cut: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->CutSelection(); } break; case MOZ_Copy: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->CopySelection(); } break; case MOZ_Paste: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->Paste(); } break; case MOZ_SelectAll: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->SelectAll(); } break; case MOZ_SelectNone: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->SelectNone(); } break; // Go menu commands case IDC_BACK: case MOZ_GoBack: webNavigation->GoBack(); UpdateUI(chrome); break; case IDC_FORWARD: case MOZ_GoForward: webNavigation->GoForward(); UpdateUI(chrome); break; // Help menu commands case MOZ_About: { TCHAR szAboutTitle[MAX_LOADSTRING]; TCHAR szAbout[MAX_LOADSTRING]; LoadString(ghInstanceApp, IDS_ABOUT_TITLE, szAboutTitle, MAX_LOADSTRING); LoadString(ghInstanceApp, IDS_ABOUT, szAbout, MAX_LOADSTRING); MessageBox(nullptr, szAbout, szAboutTitle, MB_OK); } break; } return TRUE; case WM_ACTIVATE: { nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(webBrowser)); if(focus) { switch (wParam) { case WA_ACTIVE: focus->Activate(); break; case WA_INACTIVE: focus->Deactivate(); break; default: break; } } } break; case WM_SIZE: { UINT newDlgWidth = LOWORD(lParam); UINT newDlgHeight = HIWORD(lParam); // TODO Reposition the control bar - for the moment it's fixed size // Reposition the status area. Status bar // gets any space that the fixed size progress bar doesn't use. int progressWidth; int statusWidth; int statusHeight; HWND hwndStatus = GetDlgItem(hwndDlg, IDC_STATUS); if (hwndStatus) { RECT rcStatus; GetWindowRect(hwndStatus, &rcStatus); statusHeight = rcStatus.bottom - rcStatus.top; } else statusHeight = 0; HWND hwndProgress = GetDlgItem(hwndDlg, IDC_PROGRESS); if (hwndProgress) { RECT rcProgress; GetWindowRect(hwndProgress, &rcProgress); progressWidth = rcProgress.right - rcProgress.left; } else progressWidth = 0; statusWidth = newDlgWidth - progressWidth; if (hwndStatus) SetWindowPos(hwndStatus, HWND_TOP, 0, newDlgHeight - statusHeight, statusWidth, statusHeight, SWP_NOZORDER); if (hwndProgress) SetWindowPos(hwndProgress, HWND_TOP, statusWidth, newDlgHeight - statusHeight, 0, 0, SWP_NOSIZE | SWP_NOZORDER); // Resize the browser area (assuming the browse is // sandwiched between the control bar and status area) RECT rcBrowser; POINT ptBrowser; GetWindowRect(hwndBrowser, &rcBrowser); ptBrowser.x = rcBrowser.left; ptBrowser.y = rcBrowser.top; ScreenToClient(hwndDlg, &ptBrowser); int browserHeight = newDlgHeight - ptBrowser.y - statusHeight; if (browserHeight < 1) { browserHeight = 1; } SetWindowPos(hwndBrowser, HWND_TOP, 0, 0, newDlgWidth, newDlgHeight - ptBrowser.y - statusHeight, SWP_NOMOVE | SWP_NOZORDER); } return TRUE; } return FALSE; }
void CIPFindDlg::OnBnClickedButtonStart() { UpdateData(TRUE); CString strMac; GetDlgItemText(IDC_EDIT_MAC, strMac); if (0 != strMac.GetLength() && !CheckMACAddr(strMac)) { MessageBox(MAC_ADDR_ERROR_MSG, MAC_ADDR_ERROR_TITLE); return; } GetDlgItem(IDC_BUTTON_START)->EnableWindow(false); CListCtrl *m_pList =(CListCtrl*)GetDlgItem(IDC_LIST_IPMAC); if (!m_pList) { AfxMessageBox(_T("Failed to get point of CListCtrl")); return ; } // Delete all items and update immediately m_pList->DeleteAllItems(); ASSERT(m_pList->GetItemCount() == 0); m_pList->SetRedraw(TRUE); m_pList->Invalidate(); m_pList->UpdateWindow(); // do find vtIpMac.swap(vector<st_ip_mac>()); IPFind(m_strFindIP, m_strFindMask, vtIpMac); int nItem; st_ip_mac ipmac; int len = vtIpMac.size(); USES_CONVERSION; if (FALSE == strMac.IsEmpty()) { strMac.MakeUpper(); strMac.Replace(_T(":"), _T("-")); string strMacFind = T2A(strMac); for (int i=0; i<len; i++) { if (0 == strMacFind.compare(vtIpMac.at(i).mac)) { nItem = m_pList->GetItemCount(); m_pList->InsertItem(nItem, A2T(vtIpMac.at(i).ip.c_str())); m_pList->SetItemText(nItem, 1, A2T(vtIpMac.at(i).mac.c_str())); } } } else { for (int i=0; i<len; i++) { nItem = m_pList->GetItemCount(); m_pList->InsertItem(nItem, A2T(vtIpMac.at(i).ip.c_str())); m_pList->SetItemText(nItem, 1, A2T(vtIpMac.at(i).mac.c_str())); } } GetDlgItem(IDC_BUTTON_START)->EnableWindow(true); }
LRESULT CALLBACK CFG_AddNewInstall_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { TCHAR szFile[360]; switch(uMsg) { case WM_INITDIALOG: { g_cfgScriptTmp.clear(); g_cfgFilterNameTmp.clear(); SetWindowText(hDlg,g_lang.GetString("TitleNewInstall")); SetDlgItemText(hDlg,IDC_BUTTON_EXE_CFG_OK,g_lang.GetString("Save")); SetDlgItemText(hDlg,IDC_BUTTON_CFG_EXE_CANCEL,g_lang.GetString("Cancel")); SetDlgItemText(hDlg,IDC_STATIC_ADDNEWINSTALL,g_lang.GetString("AddNewInstall")); SetDlgItemText(hDlg,IDC_STATIC_EXE,g_lang.GetString("ColumnExePath")); SetDlgItemText(hDlg,IDC_STATIC_COMMAND,g_lang.GetString("ColumnCommand")); SetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,"Default"); int gameID = CFG_GetGameID(g_currSelCfg); if(gm.GamesInfo[gameID].vGAME_INST_DEFAULT.size()>0) { SetDlgItemText(hDlg,IDC_EDIT_CMD,gm.GamesInfo[gameID].vGAME_INST_DEFAULT.at(0).szGAME_CMD.c_str()); } break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_BUTTON_EDIT_SCRIPT: DialogBoxParam(g_hInst, (LPCTSTR)IDD_DLG_EDIT_FILTER, hDlg, (DLGPROC)FilterEditor_Dlg,-1); g_cfgScriptTmp = g_EditorTI.sScript; g_cfgFilterNameTmp = g_EditorTI.sName; SetDlgItemText(hDlg,IDC_EDIT_SCRIPTNAME,g_cfgFilterNameTmp.c_str()); break; case IDC_BUTTON_CFG_EXE_CANCEL: EndDialog(hDlg,0); break; case IDC_BUTTON_EXE_CFG_OK: { int gameID = CFG_GetGameID(g_currSelCfg); TCHAR szTemp[MAX_PATH*2]; GAME_INSTALLATIONS gi; GetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,szTemp,MAX_PATH); if(strlen(szTemp)==0) { MessageBox(hDlg,g_lang.GetString("NoName"),"Error saving",MB_OK); return TRUE; } if(IsDlgButtonChecked(hDlg,IDC_CHECK_CONDITION)==BST_CHECKED) gi.bActiveScript=TRUE; else gi.bActiveScript=FALSE; gi.sFilterName = g_cfgFilterNameTmp; gi.sScript = g_cfgScriptTmp; gi.sName = szTemp; GetDlgItemText(hDlg,IDC_EDIT_PATH,szTemp,MAX_PATH*2); gi.szGAME_PATH = szTemp; GetDlgItemText(hDlg,IDC_EDIT_CMD,szTemp,MAX_PATH*2); gi.szGAME_CMD = szTemp; //USE below function for above code!!! //GetDlgItemTextToString(HWND hWnd,int nID, string &pOutString) GamesInfoCFG[gameID].vGAME_INST.push_back(gi); EndDialog(hDlg,0); } break; case IDC_BUTTON_ET_PATH: { OPENFILENAME ofn; memset(&ofn,0,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = NULL; ofn.lpstrFile = szFile; // Set lpstrFile[0] to '\0' so that GetOpenFileName does not // use the contents of szFile to initialize itself. // ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = "All\0*.*\0Executable\0*.exe\0"; ofn.nFilterIndex = 2; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; int gameID=-1; gameID = CFG_GetGameID(g_currSelCfg); if(gameID!=-1) { if(GamesInfoCFG[gameID].vGAME_INST.size()>0) ofn.lpstrInitialDir = GamesInfoCFG[gameID].vGAME_INST[CFG_editexeIdx].szGAME_PATH.c_str(); } ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if(GetOpenFileName(&ofn)) SetDlgItemText(hDlg,IDC_EDIT_PATH,ofn.lpstrFile); return TRUE; } } break; } } return FALSE; }
LRESULT CALLBACK CFG_EditInstall_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { TCHAR szFile[260]; switch(uMsg) { case WM_INITDIALOG: { CFG_editexeIdx = lParam; int gameID = CFG_GetGameID(g_currSelCfg); GAME_INSTALLATIONS gi; gi = GamesInfoCFG[gameID].vGAME_INST.at(lParam); g_cfgScriptTmp.clear(); g_cfgFilterNameTmp.clear(); g_EditorTI.sScript = gi.sScript; g_EditorTI.sName = gi.sFilterName; CheckDlgButton(hDlg,IDC_CHECK_CONDITION,gi.bActiveScript); SetDlgItemText(hDlg,IDC_EDIT_SCRIPTNAME,gi.sFilterName.c_str()); SetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,gi.sName.c_str()); SetDlgItemText(hDlg,IDC_EDIT_PATH,gi.szGAME_PATH.c_str()); SetDlgItemText(hDlg,IDC_EDIT_CMD,gi.szGAME_CMD.c_str()); // SetDlgItemText(hDlg,IDC_EDIT_CFG_MOD,gi.sMod.c_str()); // SetDlgItemText(hDlg,IDC_EDIT_CFG_VERSION,gi.sVersion.c_str()); break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_BUTTON_EDIT_SCRIPT: DialogBoxParam(g_hInst, (LPCTSTR)IDD_DLG_EDIT_FILTER, hDlg, (DLGPROC)FilterEditor_Dlg,-2); g_cfgScriptTmp = g_EditorTI.sScript; g_cfgFilterNameTmp = g_EditorTI.sName; SetDlgItemText(hDlg,IDC_EDIT_SCRIPTNAME,g_cfgFilterNameTmp.c_str()); break; case IDC_BUTTON_CFG_EXE_CANCEL: EndDialog(hDlg,0); break; case IDC_BUTTON_EXE_CFG_OK: { int gameID = CFG_GetGameID(g_currSelCfg); TCHAR szTemp[MAX_PATH*2]; GAME_INSTALLATIONS gi; GetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,szTemp,MAX_PATH); if(strlen(szTemp)==0) { MessageBox(hDlg,g_lang.GetString("NoName"),"Error saving",MB_OK); return TRUE; } if(IsDlgButtonChecked(hDlg,IDC_CHECK_CONDITION)==BST_CHECKED) gi.bActiveScript=TRUE; else gi.bActiveScript=FALSE; gi.sFilterName = g_cfgFilterNameTmp; gi.sScript = g_cfgScriptTmp; gi.sName = szTemp; GetDlgItemText(hDlg,IDC_EDIT_PATH,szTemp,MAX_PATH); gi.szGAME_PATH = szTemp; GetDlgItemText(hDlg,IDC_EDIT_CMD,szTemp,MAX_PATH*2); gi.szGAME_CMD = szTemp; GamesInfoCFG[gameID].vGAME_INST.at(CFG_editexeIdx) = gi; EndDialog(hDlg,0); } break; case IDC_BUTTON_ET_PATH: { OPENFILENAME ofn; memset(&ofn,0,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = NULL; ofn.lpstrFile = szFile; // Set lpstrFile[0] to '\0' so that GetOpenFileName does not // use the contents of szFile to initialize itself. // ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = "All\0*.*\0Executable\0*.exe\0"; ofn.nFilterIndex = 2; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; int gameID=-1; gameID = CFG_GetGameID(g_currSelCfg); if(gameID!=-1) { if(GamesInfoCFG[gameID].vGAME_INST.size()>0) ofn.lpstrInitialDir = GamesInfoCFG[gameID].vGAME_INST[CFG_editexeIdx].szGAME_PATH.c_str(); } ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if(GetOpenFileName(&ofn)) SetDlgItemText(hDlg,IDC_EDIT_PATH,ofn.lpstrFile); return TRUE; } } break; } } return FALSE; }
void TcompatibilityList::dlg2dlg(const char_t *newFileName) { char_t complist0[MAX_COMPATIBILITYLIST_LENGTH]; GetDlgItemText(m_hwnd, IDC_ED_COMPATIBILITYLIST, complist0, MAX_COMPATIBILITYLIST_LENGTH); cfg2dlgI(complist0, newFileName, _l("\r\n")); }
BOOL HandleCommandMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { int wmID, wmEvent; wmID = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmEvent) { case BN_CLICKED: switch (wmID) { case IDC_ADD: { SaveLocalizationText(); // save any current changes to the database plString buttonText; wchar_t buff[256]; GetDlgItemText(gEditDlg, IDC_ADD, buff, 256); buttonText = plString::FromWchar(buff); if (buttonText == "Add Element") { plAddElementDlg dlg(gCurrentPath); if (dlg.DoPick(gEditDlg)) { plString path = dlg.GetValue(); // path is age.set.name if (!pfLocalizationDataMgr::Instance().AddElement(path)) MessageBox(gEditDlg, L"Couldn't add new element because one already exists with that name!", L"Error", MB_ICONERROR | MB_OK); else { gCurrentPath = ""; plLocTreeView::ClearTreeView(gTreeView); plLocTreeView::FillTreeViewFromData(gTreeView, path); UpdateEditDlg(path); } } } else if (buttonText == "Add Localization") { plAddLocalizationDlg dlg(gCurrentPath); if (dlg.DoPick(gEditDlg)) { plString newLanguage = dlg.GetValue(); plString ageName, setName, elementName, elementLanguage; SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage); plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); if (!pfLocalizationDataMgr::Instance().AddLocalization(key, newLanguage)) MessageBox(gEditDlg, L"Couldn't add additional localization!", L"Error", MB_ICONERROR | MB_OK); else { plString path = plString::Format("%s.%s", key.c_str(), newLanguage.c_str()); gCurrentPath = ""; plLocTreeView::ClearTreeView(gTreeView); plLocTreeView::FillTreeViewFromData(gTreeView, path); UpdateEditDlg(path); } } } return FALSE; } case IDC_DELETE: { SaveLocalizationText(); // save any current changes to the database plString messageText = plString::Format("Are you sure that you want to delete %s?", gCurrentPath.c_str()); int res = MessageBoxW(gEditDlg, messageText.ToWchar(), L"Delete", MB_ICONQUESTION | MB_YESNO); if (res == IDYES) { plString buttonText; wchar_t buff[256]; GetDlgItemText(gEditDlg, IDC_DELETE, buff, 256); buttonText = plString::FromWchar(buff); if (buttonText == "Delete Element") { if (!pfLocalizationDataMgr::Instance().DeleteElement(gCurrentPath)) MessageBox(gEditDlg, L"Couldn't delete element!", L"Error", MB_ICONERROR | MB_OK); else { plString path = gCurrentPath; gCurrentPath = ""; plLocTreeView::ClearTreeView(gTreeView); plLocTreeView::FillTreeViewFromData(gTreeView, path); UpdateEditDlg(path); } } else if (buttonText == "Delete Localization") { plString ageName, setName, elementName, elementLanguage; SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage); plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); if (!pfLocalizationDataMgr::Instance().DeleteLocalization(key, elementLanguage)) MessageBox(gEditDlg, L"Couldn't delete localization!", L"Error", MB_ICONERROR | MB_OK); else { plString path = gCurrentPath; gCurrentPath = ""; plLocTreeView::ClearTreeView(gTreeView); plLocTreeView::FillTreeViewFromData(gTreeView, path); UpdateEditDlg(path); } } } } return FALSE; } } return (BOOL)DefWindowProc(hWnd, msg, wParam, lParam); }
/** * name: DlgProc_EditEMail() * desc: dialog procedure * * return: 0 or 1 **/ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { LPCBEXITEM cbi = (LPCBEXITEM)GetUserData(hDlg); switch (msg) { case WM_INITDIALOG: cbi = (LPCBEXITEM)lParam; if (!cbi) return FALSE; SetUserData(hDlg, lParam); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_EMAIL, TRUE)); if (db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1)) { SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); } if (*cbi->pszVal) SetWindowText(hDlg, LPGENT("Edit e-mail")); TranslateDialogDefault(hDlg); SendDlgItemMessage(hDlg, EDIT_CATEGORY, EM_LIMITTEXT, cbi->ccCat - 1, 0); SendDlgItemMessage(hDlg, EDIT_EMAIL, EM_LIMITTEXT, cbi->ccVal - 1, 0); SetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat); SetDlgItemText(hDlg, EDIT_EMAIL, cbi->pszVal); EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), !(cbi->wFlags & CBEXIF_CATREADONLY)); EnableWindow(GetDlgItem(hDlg, IDOK), *cbi->pszVal); // translate Userinfo buttons { TCHAR szButton[MAX_PATH]; HWND hBtn = GetDlgItem(hDlg, IDOK); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); hBtn = GetDlgItem(hDlg, IDCANCEL); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); } return TRUE; case WM_CTLCOLORSTATIC: SetBkColor((HDC)wParam, RGB(255, 255, 255)); return (INT_PTR)GetStockObject(WHITE_BRUSH); case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { if (HIWORD(wParam) == BN_CLICKED) { if (cbi->pszVal && cbi->ccVal > 0) GetDlgItemText(hDlg, EDIT_EMAIL, cbi->pszVal, cbi->ccVal); if (cbi->pszCat && cbi->ccCat > 0) GetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat, cbi->ccCat); } break; } case IDCANCEL: { if (HIWORD(wParam) == BN_CLICKED) EndDialog(hDlg, LOWORD(wParam)); break; } case EDIT_EMAIL: if (HIWORD(wParam) == EN_UPDATE) { TCHAR szText[MAXDATASIZE]; LPTSTR pszAdd, pszDot; if (PtrIsValid(cbi)) { GetWindowText((HWND)lParam, szText, _countof(szText)); EnableWindow(GetDlgItem(hDlg, IDOK), ((pszAdd = _tcschr(szText, '@')) && *(pszAdd + 1) != '.' && (pszDot = _tcschr(pszAdd, '.')) && *(pszDot + 1) && mir_tstrcmp(szText, cbi->pszVal))); } } break; } break; } return FALSE; }
/* * Function: Process WM_COMMAND messages */ static void kwin_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify) { char name[ANAME_SZ]; char realm[REALM_SZ]; char password[MAX_KPW_LEN]; HCURSOR hcursor; BOOL blogin; HMENU hmenu; char menuitem[MAX_K_NAME_SZ + 3]; char copyright[128]; int id; #ifdef KRB4 char instance[INST_SZ]; int lifetime; int krc; #endif #ifdef KRB5 long lifetime; krb5_error_code code; krb5_principal principal; krb5_creds creds; krb5_get_init_creds_opt opts; gic_data gd; #endif #ifdef KRB4 EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), krb_get_num_cred() > 0); #endif #ifdef KRB5 EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), k5_get_num_cred(1) > 0); #endif GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); trim(name); blogin = strlen(name) > 0; if (blogin) { GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); trim(realm); blogin = strlen(realm) > 0; } if (blogin) { GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password)); blogin = strlen(password) > 0; } EnableWindow(GetDlgItem(hwnd, IDD_LOGIN), blogin); id = (blogin) ? IDD_LOGIN : IDD_PASSWORD_CR2; SendMessage(hwnd, DM_SETDEFID, id, 0); if (codeNotify != BN_CLICKED && codeNotify != 0 && codeNotify != 1) return; /* FALSE */ /* * Check to see if this item is in a list of the ``recent hosts'' sort * of list, under the FILE menu. */ if (cid >= IDM_FIRST_LOGIN && cid < IDM_FIRST_LOGIN + FILE_MENU_MAX_LOGINS) { hmenu = GetMenu(hwnd); assert(hmenu != NULL); hmenu = GetSubMenu(hmenu, 0); assert(hmenu != NULL); if (!GetMenuString(hmenu, cid, menuitem, sizeof(menuitem), MF_BYCOMMAND)) return; /* TRUE */ if (menuitem[0]) kwin_init_name(hwnd, &menuitem[3]); return; /* TRUE */ } switch (cid) { case IDM_EXIT: if (isblocking) WSACancelBlockingCall(); WinHelp(hwnd, KERBEROS_HLP, HELP_QUIT, 0); PostQuitMessage(0); return; /* TRUE */ case IDD_PASSWORD_CR2: /* Make CR == TAB */ id = GetDlgCtrlID(GetFocus()); assert(id != 0); if (id == IDD_MAX_EDIT) PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwnd, IDD_MIN_EDIT), MAKELONG(1, 0)); else PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0); return; /* TRUE */ case IDD_LOGIN: if (isblocking) return; /* TRUE */ GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); trim(name); GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); trim(realm); GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password)); SetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, ""); /* nuke the password */ trim(password); #ifdef KRB4 GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); trim(instance); #endif hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); lifetime = cns_res.lifetime; start_blocking_hook(BLOCK_MAX_SEC); #ifdef KRB4 lifetime = (lifetime + 4) / 5; krc = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm, lifetime, password); #endif #ifdef KRB5 principal = NULL; /* * convert the name + realm into a krb5 principal string and parse it into a principal */ sprintf(menuitem, "%s@%s", name, realm); code = krb5_parse_name(k5_context, menuitem, &principal); if (code) goto errorpoint; /* * set the various ticket options. First, initialize the structure, then set the ticket * to be forwardable if desired, and set the lifetime. */ krb5_get_init_creds_opt_init(&opts); krb5_get_init_creds_opt_set_forwardable(&opts, forwardable); krb5_get_init_creds_opt_set_tkt_life(&opts, lifetime * 60); if (noaddresses) { krb5_get_init_creds_opt_set_address_list(&opts, NULL); } /* * get the initial creds using the password and the options we set above */ gd.hinstance = hinstance; gd.hwnd = hwnd; gd.id = ID_VARDLG; code = krb5_get_init_creds_password(k5_context, &creds, principal, password, gic_prompter, &gd, 0, NULL, &opts); if (code) goto errorpoint; /* * initialize the credential cache */ code = krb5_cc_initialize(k5_context, k5_ccache, principal); if (code) goto errorpoint; /* * insert the principal into the cache */ code = krb5_cc_store_cred(k5_context, k5_ccache, &creds); errorpoint: if (principal) krb5_free_principal(k5_context, principal); end_blocking_hook(); SetCursor(hcursor); kwin_set_default_focus(hwnd); if (code) { if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) MessageBox(hwnd, "Password incorrect", NULL, MB_OK | MB_ICONEXCLAMATION); else com_err(NULL, code, "while logging in"); } #endif /* KRB5 */ #ifdef KRB4 if (krc != KSUCCESS) { MessageBox(hwnd, krb_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION); return; /* TRUE */ } #endif kwin_save_name(hwnd); alerted = FALSE; switch (action) { case LOGIN_AND_EXIT: SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0)); break; case LOGIN_AND_MINIMIZE: ShowWindow(hwnd, SW_MINIMIZE); break; } return; /* TRUE */ case IDD_TICKET_DELETE: if (isblocking) return; /* TRUE */ #ifdef KRB4 krc = dest_tkt(); if (krc != KSUCCESS) MessageBox(hwnd, krb_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION); #endif #ifdef KRB5 code = k5_dest_tkt(); #endif kwin_set_default_focus(hwnd); alerted = FALSE; return; /* TRUE */ case IDD_CHANGE_PASSWORD: if (isblocking) return; /* TRUE */ password_dialog(hwnd); kwin_set_default_focus(hwnd); return; /* TRUE */ case IDM_OPTIONS: if (isblocking) return; /* TRUE */ opts_dialog(hwnd); return; /* TRUE */ case IDM_HELP_INDEX: WinHelp(hwnd, KERBEROS_HLP, HELP_INDEX, 0); return; /* TRUE */ case IDM_ABOUT: ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); if (isblocking) return; /* TRUE */ #ifdef KRB4 strcpy(copyright, " Kerberos 4 for Windows "); #endif #ifdef KRB5 strcpy(copyright, " Kerberos V5 for Windows "); #endif #ifdef _WIN32 strncat(copyright, "32-bit\n", sizeof(copyright) - 1 - strlen(copyright)); #else strncat(copyright, "16-bit\n", sizeof(copyright) - 1 - strlen(copyright)); #endif strncat(copyright, "\n Version 1.12\n\n", sizeof(copyright) - 1 - strlen(copyright)); #ifdef ORGANIZATION strncat(copyright, " For information, contact:\n", sizeof(copyright) - 1 - strlen(copyright)); strncat(copyright, ORGANIZATION, sizeof(copyright) - 1 - strlen(copyright)); #endif MessageBox(hwnd, copyright, KWIN_DIALOG_NAME, MB_OK); return; /* TRUE */ } return; /* FALSE */ }
/** * name: DlgProc_EditPhone() * desc: dialog procedure * * return: 0 or 1 **/ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { LPCBEXITEM cbi = (LPCBEXITEM)GetUserData(hDlg); static int noRecursion = 0; switch (msg) { case WM_INITDIALOG: { UINT i, item, countryCount; LPIDSTRLIST pCountries; HWND hCombo = GetDlgItem(hDlg, EDIT_COUNTRY); cbi = (LPCBEXITEM)lParam; if (!cbi) return FALSE; SetUserData(hDlg, lParam); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_PHONE, TRUE)); if (db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1)) { SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); } // translate Userinfo buttons { TCHAR szButton[MAX_PATH]; HWND hBtn; hBtn = GetDlgItem(hDlg, IDOK); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); hBtn = GetDlgItem(hDlg, IDCANCEL); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); } if (*cbi->pszVal) SetWindowText(hDlg, LPGENT("Edit phone number")); if (cbi->wFlags & CBEXIF_SMS) CheckDlgButton(hDlg, CHECK_SMS, BST_CHECKED); TranslateDialogDefault(hDlg); EnableWindow(GetDlgItem(hDlg, IDOK), *cbi->pszVal); SendDlgItemMessage(hDlg, EDIT_AREA, EM_LIMITTEXT, 31, 0); SendDlgItemMessage(hDlg, EDIT_NUMBER, EM_LIMITTEXT, 63, 0); SendDlgItemMessage(hDlg, EDIT_CATEGORY, EM_LIMITTEXT, cbi->ccCat - 1, 0); SendDlgItemMessage(hDlg, EDIT_PHONE, EM_LIMITTEXT, cbi->ccVal - 1, 0); GetCountryList(&countryCount, &pCountries); for (i = 0; i < countryCount; i++) { if (pCountries[i].nID == 0 || pCountries[i].nID == 0xFFFF) continue; item = SendMessage(hCombo, CB_ADDSTRING, NULL, (LPARAM)pCountries[i].ptszTranslated); SendMessage(hCombo, CB_SETITEMDATA, item, pCountries[i].nID); } SetDlgItemText(hDlg, EDIT_PHONE, cbi->pszVal); SetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat); EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), !(cbi->wFlags & CBEXIF_CATREADONLY)); } return TRUE; case WM_CTLCOLORSTATIC: SetBkColor((HDC)wParam, RGB(255, 255, 255)); return (INT_PTR)GetStockObject(WHITE_BRUSH); case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (HIWORD(wParam) == BN_CLICKED) { TCHAR szText[MAXDATASIZE]; int errorPos; if (!GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)) || !CheckPhoneSyntax(szText, cbi->pszVal, cbi->ccVal, errorPos) || errorPos > -1) { MsgErr(hDlg, TranslateT("The phone number should start with a + and consist of\nnumbers, spaces, brackets and hyphens only.")); break; } // save category string GetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat, cbi->ccCat); // save SMS flag if ((int)IsDlgButtonChecked(hDlg, CHECK_SMS) != ((cbi->wFlags & CBEXIF_SMS) == CBEXIF_SMS)) cbi->wFlags ^= CBEXIF_SMS; } //fall through case IDCANCEL: if (HIWORD(wParam) == BN_CLICKED) EndDialog(hDlg, wParam); break; case EDIT_COUNTRY: if (HIWORD(wParam) != CBN_SELCHANGE) break; case EDIT_AREA: case EDIT_NUMBER: if (LOWORD(wParam) != EDIT_COUNTRY && HIWORD(wParam) != EN_CHANGE) break; if (noRecursion) break; EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); { TCHAR szPhone[MAXDATASIZE], szArea[32], szData[64]; int nCurSel = SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETCURSEL, 0, 0); UINT nCountry = (nCurSel != CB_ERR) ? SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETITEMDATA, nCurSel, 0) : 0; GetDlgItemText(hDlg, EDIT_AREA, szArea, _countof(szArea)); GetDlgItemText(hDlg, EDIT_NUMBER, szData, _countof(szData)); mir_sntprintf(szPhone, _T("+%u (%s) %s"), nCountry, szArea, szData); noRecursion = 1; SetDlgItemText(hDlg, EDIT_PHONE, szPhone); noRecursion = 0; } break; case EDIT_PHONE: if (HIWORD(wParam) != EN_UPDATE) break; if (noRecursion) break; noRecursion = 1; { TCHAR szText[MAXDATASIZE], *pText = 0, *pArea, *pNumber; bool isValid = true; GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)); if (szText[0] != '+') isValid = false; if (isValid) { int country = _tcstol(szText + 1, &pText, 10); if (pText - szText > 4) isValid = false; else { int i; for (i = SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) { if (country == SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETITEMDATA, i, 0)) { SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_SETCURSEL, i, 0); break; } } if (i < 0) isValid = false; } } if (isValid) { pArea = pText + _tcscspn(pText, _T("0123456789")); pText = pArea + _tcsspn(pArea, _T("0123456789")); if (*pText) { *pText = '\0'; pNumber = pText + 1 + _tcscspn(pText + 1, _T("0123456789")); SetDlgItemText(hDlg, EDIT_NUMBER, pNumber); } SetDlgItemText(hDlg, EDIT_AREA, pArea); } if (!isValid) { SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_SETCURSEL, -1, 0); SetDlgItemText(hDlg, EDIT_AREA, _T("")); SetDlgItemText(hDlg, EDIT_NUMBER, _T("")); } } noRecursion = 0; EnableWindow(GetDlgItem(hDlg, IDOK), GetWindowTextLength(GetDlgItem(hDlg, EDIT_PHONE))); break; } break; } return FALSE; }
// weather options INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { TCHAR str[512]; switch (msg) { case WM_INITDIALOG: opt_startup = TRUE; TranslateDialogDefault(hdlg); // load settings _ltot(opt.UpdateTime, str, 10); SetDlgItemText(hdlg, IDC_UPDATETIME, str); SetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign); SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETRANGE32, 0, 999); SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETPOS, 0, opt.AvatarSize); SendDlgItemMessage(hdlg, IDC_AVATARSIZE, EM_LIMITTEXT, 3, 0); CheckDlgButton(hdlg, IDC_STARTUPUPD, opt.StartupUpdate ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_UPDATE, opt.AutoUpdate ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_PROTOCOND, !opt.NoProtoCondition ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_UPDCONDCHG, opt.UpdateOnlyConditionChanged ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_REMOVEOLD, opt.RemoveOldData ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_MAKEI, opt.MakeItalic ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_DISCONDICON, opt.DisCondIcon ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_DONOTAPPUNITS, opt.DoNotAppendUnit ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOFRAC, opt.NoFrac ? BST_CHECKED : BST_UNCHECKED); // load units switch (opt.tUnit) { // temperature case 1: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T1); break; case 2: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T2); break; } switch (opt.wUnit) { // wind case 1: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W1); break; case 2: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W2); break; case 3: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W3); break; case 4: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W4); break; } switch (opt.vUnit) { // visibility case 1: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V1); break; case 2: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V2); break; } switch (opt.pUnit) { // pressure case 1: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P1); break; case 2: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P2); break; case 3: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P3); break; case 4: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P4); break; } switch (opt.dUnit) { // pressure case 1: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D1); break; case 2: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D2); break; case 3: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D3); break; } switch (opt.eUnit) { // elev case 1: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E1); break; case 2: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E2); break; } opt_startup = FALSE; return 0; case WM_COMMAND: if (HIWORD(wparam) == BN_CLICKED && GetFocus() == (HWND)lparam) if (!opt_startup) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); if (!((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) && (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()))) if (!opt_startup) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); return 0; case WM_NOTIFY: switch (((LPNMHDR)lparam)->code) { case PSN_APPLY: // change the status for weather protocol if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL) { old_status = status; status = db_get_w(opt.DefStn, WEATHERPROTONAME, "StatusIcon", NOSTATUSDATA); ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status); } // get update time and remove the old timer GetDlgItemText(hdlg, IDC_UPDATETIME, str, SIZEOF(str)); opt.UpdateTime = (WORD)_ttoi(str); if (opt.UpdateTime < 1) opt.UpdateTime = 1; KillTimer(NULL, timerId); timerId = SetTimer(NULL, 0, opt.UpdateTime * 60000, (TIMERPROC)timerProc); // other general options GetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign, SIZEOF(opt.DegreeSign)); opt.StartupUpdate = IsDlgButtonChecked(hdlg, IDC_STARTUPUPD); opt.AutoUpdate = IsDlgButtonChecked(hdlg, IDC_UPDATE); opt.NoProtoCondition = BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_PROTOCOND); opt.DisCondIcon = IsDlgButtonChecked(hdlg, IDC_DISCONDICON); opt.UpdateOnlyConditionChanged = (BYTE)IsDlgButtonChecked(hdlg, IDC_UPDCONDCHG); opt.RemoveOldData = IsDlgButtonChecked(hdlg, IDC_REMOVEOLD); opt.MakeItalic = IsDlgButtonChecked(hdlg, IDC_MAKEI); opt.AvatarSize = GetDlgItemInt(hdlg, IDC_AVATARSIZE, NULL, FALSE); opt.DoNotAppendUnit = IsDlgButtonChecked(hdlg, IDC_DONOTAPPUNITS); opt.NoFrac = IsDlgButtonChecked(hdlg, IDC_NOFRAC); UpdateMenu(opt.AutoUpdate); // save the units if (IsDlgButtonChecked(hdlg, IDC_T1)) opt.tUnit = 1; if (IsDlgButtonChecked(hdlg, IDC_T2)) opt.tUnit = 2; if (IsDlgButtonChecked(hdlg, IDC_W1)) opt.wUnit = 1; if (IsDlgButtonChecked(hdlg, IDC_W2)) opt.wUnit = 2; if (IsDlgButtonChecked(hdlg, IDC_W3)) opt.wUnit = 3; if (IsDlgButtonChecked(hdlg, IDC_W4)) opt.wUnit = 4; if (IsDlgButtonChecked(hdlg, IDC_V1)) opt.vUnit = 1; if (IsDlgButtonChecked(hdlg, IDC_V2)) opt.vUnit = 2; if (IsDlgButtonChecked(hdlg, IDC_P1)) opt.pUnit = 1; if (IsDlgButtonChecked(hdlg, IDC_P2)) opt.pUnit = 2; if (IsDlgButtonChecked(hdlg, IDC_P3)) opt.pUnit = 3; if (IsDlgButtonChecked(hdlg, IDC_P4)) opt.pUnit = 4; if (IsDlgButtonChecked(hdlg, IDC_D1)) opt.dUnit = 1; if (IsDlgButtonChecked(hdlg, IDC_D2)) opt.dUnit = 2; if (IsDlgButtonChecked(hdlg, IDC_D3)) opt.dUnit = 3; if (IsDlgButtonChecked(hdlg, IDC_E1)) opt.eUnit = 1; if (IsDlgButtonChecked(hdlg, IDC_E2)) opt.eUnit = 2; // save the new weather options SaveOptions(); RedrawFrame(0, 0); return 1; } break; } return 0; }
BOOL CPPgWebServer::OnApply() { if(m_bModified) { CString sBuf; // get and check templatefile existance... GetDlgItem(IDC_TMPLPATH)->GetWindowText(sBuf); if ( IsDlgButtonChecked(IDC_WSENABLED) && !PathFileExists(sBuf)) { CString buffer; buffer.Format(GetResString(IDS_WEB_ERR_CANTLOAD),sBuf); AfxMessageBox(buffer,MB_OK); return FALSE; } thePrefs.SetTemplate(sBuf); theApp.webserver->ReloadTemplates(); uint16 oldPort=thePrefs.GetWSPort(); GetDlgItem(IDC_WSPASS)->GetWindowText(sBuf); if(sBuf != HIDDEN_PASSWORD) thePrefs.SetWSPass(sBuf); GetDlgItem(IDC_WSPASSLOW)->GetWindowText(sBuf); if(sBuf != HIDDEN_PASSWORD) thePrefs.SetWSLowPass(sBuf); GetDlgItem(IDC_WSPORT)->GetWindowText(sBuf); if (_tstoi(sBuf)!=oldPort) { thePrefs.SetWSPort(_tstoi(sBuf)); theApp.webserver->RestartServer(); } GetDlgItemText(IDC_WSTIMEOUT,sBuf); thePrefs.m_iWebTimeoutMins=_tstoi(sBuf); thePrefs.SetWSIsEnabled(IsDlgButtonChecked(IDC_WSENABLED)!=0); thePrefs.SetWSIsLowUserEnabled(IsDlgButtonChecked(IDC_WSENABLEDLOW)!=0); thePrefs.SetWebUseGzip(IsDlgButtonChecked(IDC_WS_GZIP)!=0); theApp.webserver->StartServer(); thePrefs.m_bAllowAdminHiLevFunc= (IsDlgButtonChecked(IDC_WS_ALLOWHILEVFUNC)!=0); // mobilemule GetDlgItem(IDC_MMPORT_FIELD)->GetWindowText(sBuf); if (_tstoi(sBuf)!= thePrefs.GetMMPort() ) { thePrefs.SetMMPort(_tstoi(sBuf)); theApp.mmserver->StopServer(); theApp.mmserver->Init(); } thePrefs.SetMMIsEnabled(IsDlgButtonChecked(IDC_MMENABLED)!=0); if (IsDlgButtonChecked(IDC_MMENABLED)) theApp.mmserver->Init(); else theApp.mmserver->StopServer(); GetDlgItem(IDC_MMPASSWORDFIELD)->GetWindowText(sBuf); if(sBuf != HIDDEN_PASSWORD) thePrefs.SetMMPass(sBuf); theApp.emuledlg->serverwnd->UpdateMyInfo(); SetModified(FALSE); SetTmplButtonState(); } return CPropertyPage::OnApply(); }
void CPreferences::OnBnClickedCancel() { GetDlgItemText(IDC_COMBO_DEFPREF, mLoadedPreferenceName); OnCancel(); }
void CPPgWebServer::SetTmplButtonState(){ CString buffer; GetDlgItemText(IDC_TMPLPATH,buffer); GetDlgItem(IDC_WSRELOADTMPL)->EnableWindow( thePrefs.GetWSIsEnabled() && (buffer.CompareNoCase(thePrefs.GetTemplate())==0)); }
INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { struct FileSendData *fsd = (struct FileSendData*)lParam; dat = (FileDlgData*)mir_calloc(sizeof(FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = fsd->hContact; dat->send = 1; dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->fs = NULL; dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), SendEditSubclassProc); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); if (fsd->ppFiles != NULL && fsd->ppFiles[0] != NULL) { int totalCount, i; for (totalCount = 0; fsd->ppFiles[totalCount]; totalCount++); dat->files = (TCHAR**)mir_alloc(sizeof(TCHAR*)*(totalCount + 1)); // Leaks for (i = 0; i < totalCount; i++) dat->files[i] = mir_tstrdup(fsd->ppFiles[i]); dat->files[totalCount] = NULL; SetFileListAndSizeControls(hwndDlg, dat); } TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_TO, contactName); char *szProto = GetContactProto(dat->hContact); if (szProto) { int hasName = 0; char buf[128]; CONTACTINFO ci = { sizeof(ci) }; ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch (ci.type) { case CNFT_ASCIIZ: hasName = 1; strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE); mir_free(ci.pszVal); break; case CNFT_DWORD: hasName = 1; mir_snprintf(buf, "%u", ci.dVal); break; } } if (hasName) SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } if (fsd->ppFiles == NULL) { EnableWindow(hwndDlg, FALSE); dat->closeIfFileChooseCancelled = 1; PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHOOSE, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDC_CHOOSE)); } } return TRUE; case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); case M_FILECHOOSEDONE: if (lParam != 0) { FilenameToFileList(hwndDlg, dat, (TCHAR*)lParam); mir_free((TCHAR*)lParam); dat->closeIfFileChooseCancelled = 0; } else if (dat->closeIfFileChooseCancelled) PostMessage(hwndDlg, WM_COMMAND, IDCANCEL, 0); EnableWindow(hwndDlg, TRUE); break; case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_CHOOSE: EnableWindow(hwndDlg, FALSE); forkthread(ChooseFilesThread, 0, hwndDlg); break; case IDOK: NotifyEventHooks(hDlgSucceeded, dat->hContact, (LPARAM)hwndDlg); EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); DestroyWindow(hwndDlg); return TRUE; case IDCANCEL: NotifyEventHooks(hDlgCanceled, dat->hContact, (LPARAM)hwndDlg); DestroyWindow(hwndDlg); return TRUE; case IDC_USERMENU: { RECT rc; GetWindowRect((HWND)lParam, &rc); HMENU hMenu = Menu_BuildContactMenu(dat->hContact); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); return TRUE; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); return TRUE; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); FreeFileDlgData(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); return TRUE; } return FALSE; }
INT_PTR CALLBACK ShellProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { int idx; PWSTR exePath; wchar_t addrString[16]; DWORD address; switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { int ccnt=GetDlgItemText(hwndDlg,IDC_ADDRESS,addrString,15); if(ccnt==0) address=0; else if(!StrToIntEx(addrString,STIF_SUPPORT_HEX,(int*)&address)) { MessageBox(hwndDlg,L"Function address must be a hex number.",0,0); break; } int len=GetWindowTextLength(GetDlgItem(hwndDlg,IDC_EXEPATH)); if(len==0) { MessageBox(hwndDlg,L"Please select the exe file",0,0); break; } exePath=new wchar_t[len+1]; if(exePath==0) { delete[] exePath; MessageBox(hwndDlg,L"Not enough memory",0,0); break; } GetDlgItemText(hwndDlg,IDC_EXEPATH,exePath,len+1); STARTUPINFO si; memset1(&si,0,sizeof(si)); si.cb=sizeof(si); PROCESS_INFORMATION pi; if(!CreateProcess(0,exePath,0,0,FALSE,CREATE_SUSPENDED,0,0,&si,&pi)) { delete[] exePath; MessageBox(hwndDlg,L"Can't start exe!",0,0); break; } delete[] exePath; int pathLen=256; wchar_t* dllPath=new wchar_t[pathLen]; int retlen=GetModuleFileName(0,dllPath,pathLen); while(GetLastError()==ERROR_INSUFFICIENT_BUFFER) { delete[] dllPath; pathLen*=2; dllPath=new wchar_t[pathLen]; retlen=GetModuleFileName(0,dllPath,pathLen); }; wchar_t* p=dllPath+retlen; for(;p>dllPath;p--) if(*p==L'\\') break; *(p+1)=L'\0'; lstrcat(dllPath,L"extractor.dll"); int rslt=InjectToProcess(pi.hProcess,pi.hThread,dllPath,(DecoprFunc)address); delete[] dllPath; if(rslt<0) { MessageBox(hwndDlg,L"Failed to inject process",0,0); break; } wchar_t pipeName[30]; wsprintf(pipeName,PIPE_NAME,pi.dwProcessId); HANDLE pipe=CreateNamedPipe(pipeName,PIPE_ACCESS_DUPLEX,PIPE_TYPE_BYTE|PIPE_READMODE_BYTE|PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,256,256,0,0); if(pipe==INVALID_HANDLE_VALUE) { MessageBox(hwndDlg,L"Faild to create pipe",0,0); TerminateProcess(pi.hProcess,0); break; } ResumeThread(pi.hThread); rslt=PipeComm(pipe,address); CloseHandle(pipe); if(rslt<0) { MessageBox(hwndDlg,L"Failed to communicated with sub process",0,0); break; } } // Fall through. case IDCANCEL: EndDialog(hwndDlg, wParam); return TRUE; case IDC_ADDRESS: if(HIWORD(wParam)==EN_CHANGE) { idx=SendDlgItemMessage(hwndDlg,IDC_GAMELIST,CB_GETCURSEL,0,0); if(idx<g_gameCount) { int cnt=GetDlgItemText(hwndDlg,IDC_ADDRESS,addrString,15); if(cnt==0) SendDlgItemMessage(hwndDlg,IDC_GAMELIST,CB_SETCURSEL,0,0); else if(idx!=CB_ERR && !(StrToIntEx(addrString,STIF_SUPPORT_HEX,(int*)&address) && address==g_gameList[idx].funcAddress)) SendDlgItemMessage(hwndDlg,IDC_GAMELIST,CB_SETCURSEL,-1,0); } } break; case IDC_GAMELIST: switch (HIWORD(wParam)) { case CBN_SELCHANGE: idx=SendDlgItemMessage(hwndDlg,IDC_GAMELIST,CB_GETCURSEL,0,0); if(idx==0) { SetDlgItemText(hwndDlg,IDC_ADDRESS,L""); } else if(idx!=CB_ERR && idx<g_gameCount) { wsprintf(addrString,L"0x%X",g_gameList[idx].funcAddress); SetDlgItemText(hwndDlg,IDC_ADDRESS,addrString); } break; } break; case IDC_BROWSE: if(SUCCEEDED(BasicFileOpen(&exePath))) { SetDlgItemText(hwndDlg,IDC_EXEPATH,exePath); CoTaskMemFree(exePath); } break; case IDC_ABOUT: MessageBox(hwndDlg,L"fxckBGI - an extractor for BGI engine.\n\tv" PRODUCT_VERSION L" by AmaF",L"About",MB_ICONINFORMATION); break; } break; case WM_INITDIALOG: g_hwnd=hwndDlg; HICON icon=LoadIcon(g_hInstance,(LPCWSTR)IDI_ICON1); SendMessage(hwndDlg,WM_SETICON,ICON_SMALL,(LPARAM)icon); for(int i=0;i<g_gameCount;i++) { SendDlgItemMessage(hwndDlg,IDC_GAMELIST,CB_ADDSTRING,0,(LPARAM)(g_gameList[i].gameName)); } SendDlgItemMessage(hwndDlg,IDC_GAMELIST,CB_SETCURSEL,0,0); return TRUE; } return FALSE; }
static BOOL CALLBACK AddCheatCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static int lbfocus; static HWND hwndLB; switch (uMsg) { case WM_VSCROLL: if (scrollnum > (CSTOD - 1)) { switch ((int)LOWORD(wParam)) { case SB_TOP: scrollindex = -32768; SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, (CSTOD - 1), 0); FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb); break; case SB_BOTTOM: scrollindex = scrollmax; SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, (CSTOD - 1), 0); FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb); break; case SB_LINEUP: if (scrollindex > -32768) { scrollindex--; SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_DELETESTRING, (CSTOD - 1), 0); FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768, cfcallbinsertt); } break; case SB_PAGEUP: scrollindex -= CSTOD; if (scrollindex < -32768) scrollindex = -32768; SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, (CSTOD - 1), 0); FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb); break; case SB_LINEDOWN: if (scrollindex < scrollmax) { scrollindex++; SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_DELETESTRING, 0, 0); FCEUI_CheatSearchGetRange(scrollindex + 32768 + (CSTOD - 1), scrollindex + 32768 + (CSTOD - 1), cfcallbinsert); } break; case SB_PAGEDOWN: scrollindex += CSTOD; if (scrollindex > scrollmax) scrollindex = scrollmax; SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, 0, 0); FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb); break; case SB_THUMBPOSITION: case SB_THUMBTRACK: scrollindex = (short int)HIWORD(wParam); SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1); SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, 0, 0); FCEUI_CheatSearchGetRange(32768 + scrollindex, 32768 + scrollindex + (CSTOD - 1), cfcallb); break; } } break; case WM_INITDIALOG: selcheat = -1; FixCheatSelButtons(hwndDlg, 0); acwin = hwndDlg; SetDlgItemText(hwndDlg, 110, (LPTSTR)U8ToStr(cheatval1)); SetDlgItemText(hwndDlg, 111, (LPTSTR)U8ToStr(cheatval2)); DoGet(); CheckRadioButton(hwndDlg, 115, 120, scheatmethod + 115); lbfocus = 0; hwndLB = 0; RedoCheatsLB(hwndDlg); break; case WM_VKEYTOITEM: if (lbfocus) { int real; real = SendDlgItemMessage(hwndDlg, 108, LB_GETCURSEL, 0, (LPARAM)(LPSTR)0); switch ((int)LOWORD(wParam)) { case VK_UP: /* mmmm....recursive goodness */ if (!real) SendMessage(hwndDlg, WM_VSCROLL, SB_LINEUP, 0); return(-1); break; case VK_DOWN: if (real == (CSTOD - 1)) SendMessage(hwndDlg, WM_VSCROLL, SB_LINEDOWN, 0); return(-1); break; case VK_PRIOR: SendMessage(hwndDlg, WM_VSCROLL, SB_PAGEUP, 0); break; case VK_NEXT: SendMessage(hwndDlg, WM_VSCROLL, SB_PAGEDOWN, 0); break; case VK_HOME: SendMessage(hwndDlg, WM_VSCROLL, SB_TOP, 0); break; case VK_END: SendMessage(hwndDlg, WM_VSCROLL, SB_BOTTOM, 0); break; } return(-2); } break; case WM_CLOSE: case WM_QUIT: goto gornk; case WM_COMMAND: switch (LOWORD(wParam)) { case 300: /* List box selection changed. */ if (HIWORD(wParam) == LBN_SELCHANGE) { char *s; uint32 a; uint8 v; int status; int c, type; selcheat = SendDlgItemMessage(hwndDlg, 300, LB_GETCURSEL, 0, (LPARAM)(LPSTR)0); if (selcheat < 0) { FixCheatSelButtons(hwndDlg, 0); break; } FixCheatSelButtons(hwndDlg, 1); FCEUI_GetCheat(selcheat, &s, &a, &v, &c, &status, &type); SetDlgItemText(hwndDlg, 200, (LPTSTR)s); SetDlgItemText(hwndDlg, 201, (LPTSTR)U16ToStr(a)); SetDlgItemText(hwndDlg, 202, (LPTSTR)U8ToStr(v)); SetDlgItemText(hwndDlg, 203, (c == -1) ? (LPTSTR)"" : (LPTSTR)IToStr(c)); CheckDlgButton(hwndDlg, 204, type ? BST_CHECKED : BST_UNCHECKED); } break; case 108: switch (HIWORD(wParam)) { case LBN_SELCHANGE: { char TempArray[32]; SendDlgItemMessage(hwndDlg, 108, LB_GETTEXT, SendDlgItemMessage(hwndDlg, 108, LB_GETCURSEL, 0, (LPARAM)(LPSTR)0), (LPARAM)(LPCTSTR)TempArray); TempArray[4] = 0; SetDlgItemText(hwndDlg, 201, (LPTSTR)TempArray); } break; case LBN_SETFOCUS: lbfocus = 1; break; case LBN_KILLFOCUS: lbfocus = 0; break; } break; } switch (HIWORD(wParam)) { case LBN_DBLCLK: if (selcheat >= 0) { if (LOWORD(wParam) == 300) FCEUI_ToggleCheat(selcheat); RedoCheatsLB(hwndDlg); SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0); } break; case BN_CLICKED: if (LOWORD(wParam) >= 115 && LOWORD(wParam) <= 120) scheatmethod = LOWORD(wParam) - 115; else switch (LOWORD(wParam)) { case 112: FCEUI_CheatSearchBegin(); DoGet(); break; case 113: FCEUI_CheatSearchEnd(scheatmethod, cheatval1, cheatval2); DoGet(); break; case 114: FCEUI_CheatSearchSetCurrentAsOriginal(); DoGet(); break; case 107: FCEUI_CheatSearchShowExcluded(); DoGet(); break; case 250: /* Add Cheat Button */ { int a, v, c, t; char name[257]; char temp[16]; GetDlgItemText(hwndDlg, 200, name, 256 + 1); GetDlgItemText(hwndDlg, 201, temp, 4 + 1); a = StrToU16(temp); GetDlgItemText(hwndDlg, 202, temp, 3 + 1); v = StrToU8(temp); GetDlgItemText(hwndDlg, 203, temp, 3 + 1); if (temp[0] == 0) c = -1; else c = StrToI(temp); t = (IsDlgButtonChecked(hwndDlg, 204) == BST_CHECKED) ? 1 : 0; FCEUI_AddCheat(name, a, v, c, t); RedoCheatsLB(hwndDlg); SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0); } break; case 253: /* Add GG Cheat Button */ { uint16 a; int c; uint8 v; char name[257]; GetDlgItemText(hwndDlg, 200, name, 256 + 1); if (FCEUI_DecodeGG(name, &a, &v, &c)) { FCEUI_AddCheat(name, a, v, c, 1); RedoCheatsLB(hwndDlg); SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0); } } break; case 251: /* Update Cheat Button */ if (selcheat >= 0) { int a, v, c, t; char name[257]; char temp[16]; GetDlgItemText(hwndDlg, 200, name, 256 + 1); GetDlgItemText(hwndDlg, 201, temp, 4 + 1); a = StrToU16(temp); GetDlgItemText(hwndDlg, 202, temp, 3 + 1); v = StrToU8(temp); GetDlgItemText(hwndDlg, 203, temp, 3 + 1); if (temp[0] == 0) c = -1; else c = StrToI(temp); t = (IsDlgButtonChecked(hwndDlg, 204) == BST_CHECKED) ? 1 : 0; FCEUI_SetCheat(selcheat, name, a, v, c, -1, t); RedoCheatsLB(hwndDlg); SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0); } break; case 252: /* Delete cheat button */ if (selcheat >= 0) { FCEUI_DelCheat(selcheat); SendDlgItemMessage(hwndDlg, 300, LB_DELETESTRING, selcheat, 0); FixCheatSelButtons(hwndDlg, 0); selcheat = -1; SetDlgItemText(hwndDlg, 200, (LPTSTR)""); SetDlgItemText(hwndDlg, 201, (LPTSTR)""); SetDlgItemText(hwndDlg, 202, (LPTSTR)""); SetDlgItemText(hwndDlg, 203, (LPTSTR)""); CheckDlgButton(hwndDlg, 204, BST_UNCHECKED); } break; case 106: gornk: EndDialog(hwndDlg, 0); acwin = 0; break; } break; case EN_CHANGE: { char TempArray[256]; GetDlgItemText(hwndDlg, LOWORD(wParam), TempArray, 256); switch (LOWORD(wParam)) { case 110: cheatval1 = StrToU8(TempArray); break; case 111: cheatval2 = StrToU8(TempArray); break; } } break; } } return 0; }
BOOL CEventPropertiesGestureDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { m_hDialog = hwndDlg; bool handled = false; BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled ); if ( handled ) return bret; switch(uMsg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(hwndDlg, &ps); DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent ); EndPaint(hwndDlg, &ps); return FALSE; } break; case WM_VSCROLL: { RECT rcOut; GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut ); InvalidateRect( hwndDlg, &rcOut, TRUE ); UpdateWindow( hwndDlg ); return FALSE; } break; case WM_INITDIALOG: { InitDialog( hwndDlg ); } return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { HWND control = GetControl( IDC_EVENTCHOICES ); if ( control ) { SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters ); } GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) ); if ( !g_Params.m_szName[ 0 ] ) { Q_strncpy( g_Params.m_szName, g_Params.m_szParameters, sizeof( g_Params.m_szName ) ); } char szTime[ 32 ]; GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) ); g_Params.m_flStartTime = atof( szTime ); GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) ); g_Params.m_flEndTime = atof( szTime ); // Parse tokens from tags ParseTags( &g_Params ); EndDialog( hwndDlg, 1 ); } break; case IDCANCEL: EndDialog( hwndDlg, 0 ); break; case IDC_CHECK_ENDTIME: { g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false; if ( !g_Params.m_bHasEndTime ) { ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE ); } else { ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE ); } } break; case IDC_CHECK_RESUMECONDITION: { g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false; } break; case IDC_EVENTCHOICES: { HWND control = (HWND)lParam; if ( control ) { SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters ); } } break; case IDC_ABSOLUTESTART: { g_Params.m_bUsesTag = false; UpdateTagRadioButtons( &g_Params ); } break; case IDC_RELATIVESTART: { g_Params.m_bUsesTag = true; UpdateTagRadioButtons( &g_Params ); } break; case IDC_CHECK_SYNCTOFOLLOWINGGESTURE: { g_Params.m_bSyncToFollowingGesture = SendMessage( GetControl( IDC_CHECK_SYNCTOFOLLOWINGGESTURE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false; } break; } return TRUE; } return FALSE; }
INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam) { INT_PTR bReturn; if ( DoMyControlProcessing( hdlg, message, wParam, lParam, &bReturn )) return bReturn; switch ( message ) { case WM_INITDIALOG: { TCHAR szMirandaPath[MAX_PATH]; szMirandaPath[ 0 ] = 0; { HIMAGELIST hIml; hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 3, 3); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILEGREEN))); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILEYELLOW))); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILERED))); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_BAD))); ListView_SetImageList(GetDlgItem(hdlg,IDC_DBLIST),hIml,LVSIL_SMALL); } ListView_SetExtendedListViewStyleEx(GetDlgItem(hdlg,IDC_DBLIST),LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT); { LV_COLUMN lvc; lvc.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT; lvc.cx = 205; lvc.fmt = LVCFMT_LEFT; lvc.pszText = TranslateT("Database"); ListView_InsertColumn( GetDlgItem(hdlg,IDC_DBLIST), 0, &lvc ); lvc.cx = 68; lvc.fmt = LVCFMT_RIGHT; lvc.pszText = TranslateT("Total size"); ListView_InsertColumn(GetDlgItem(hdlg,IDC_DBLIST), 1, &lvc ); lvc.pszText = TranslateT("Wasted"); ListView_InsertColumn(GetDlgItem(hdlg,IDC_DBLIST), 2, &lvc ); } { TCHAR *str2; GetModuleFileName(NULL,szMirandaPath,SIZEOF(szMirandaPath)); str2 = _tcsrchr(szMirandaPath,'\\'); if( str2 != NULL ) *str2=0; } { int i = 0; HKEY hKey; TCHAR szProfileDir[MAX_PATH]; DWORD cbData = SIZEOF(szMirandaPath); TCHAR szMirandaProfiles[MAX_PATH]; _tcscpy(szMirandaProfiles, szMirandaPath); _tcscat(szMirandaProfiles, _T("\\Profiles")); GetProfileDirectory(szMirandaPath,szProfileDir,SIZEOF(szProfileDir)); // search in profile dir (using ini file) if( lstrcmpi(szProfileDir,szMirandaProfiles) ) FindAdd(hdlg, szProfileDir, _T("[ini]\\")); FindAdd(hdlg, szMirandaProfiles, _T("[prf]\\")); // search in current dir (as DBTOOL) FindAdd(hdlg, szMirandaPath, _T("[ . ]\\")); // search in profile dir (using registry path + ini file) if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\miranda32.exe"),0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { if(RegQueryValueEx(hKey,_T("Path"),NULL,NULL,(PBYTE)szMirandaPath,&cbData) == ERROR_SUCCESS) { if( lstrcmp(szProfileDir,szMirandaPath) ) { GetProfileDirectory(szMirandaPath,szProfileDir,SIZEOF(szProfileDir)); FindAdd(hdlg, szProfileDir, _T("[reg]\\")); } } RegCloseKey(hKey); } // select if ( opts.filename[0] ) i = AddDatabaseToList( GetDlgItem( hdlg, IDC_DBLIST ), opts.filename, _T("") ); if ( i == -1 ) i = 0; ListView_SetItemState( GetDlgItem(hdlg,IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED ); } if ( opts.hFile != NULL && opts.hFile != INVALID_HANDLE_VALUE ) { CloseHandle( opts.hFile ); opts.hFile = NULL; } TranslateDialog( hdlg ); return TRUE; } case WZN_PAGECHANGING: GetDlgItemText( hdlg, IDC_FILE, opts.filename, SIZEOF(opts.filename)); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_FILE: if(HIWORD(wParam)==EN_CHANGE) EnableWindow(GetDlgItem(GetParent(hdlg),IDOK),GetWindowTextLength(GetDlgItem(hdlg,IDC_FILE))); break; case IDC_OTHER: { OPENFILENAME ofn={0}; TCHAR str[MAX_PATH]; // _T("Miranda Databases (*.dat)\0*.DAT\0All Files (*)\0*\0"); TCHAR *filter, *tmp, *tmp1, *tmp2; tmp1 = TranslateT("Miranda Databases (*.dat)"); tmp2 = TranslateT("All Files"); filter = tmp = (TCHAR*)_alloca((_tcslen(tmp1)+_tcslen(tmp2)+11)*sizeof(TCHAR)); tmp = addstring(tmp, tmp1); tmp = addstring(tmp, _T("*.DAT")); tmp = addstring(tmp, tmp2); tmp = addstring(tmp, _T("*")); *tmp = 0; GetDlgItemText( hdlg, IDC_FILE, str, SIZEOF( str )); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hdlg; ofn.hInstance = NULL; ofn.lpstrFilter = filter; ofn.lpstrDefExt = _T("dat"); ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.nMaxFile = SIZEOF(str); ofn.nMaxFileTitle = MAX_PATH; if ( GetOpenFileName( &ofn )) { int i; i = AddDatabaseToList( GetDlgItem(hdlg,IDC_DBLIST), str, _T("") ); if ( i == -1 ) i=0; ListView_SetItemState( GetDlgItem(hdlg,IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED ); } break; } case IDC_BACK: SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc); break; case IDOK: opts.hFile = CreateFile( opts.filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ); if ( opts.hFile == INVALID_HANDLE_VALUE ) { opts.hFile = NULL; opts.error = GetLastError(); SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, ( LPARAM )OpenErrorDlgProc ); } else SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc ); break; } break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case IDC_DBLIST: switch(((LPNMLISTVIEW)lParam)->hdr.code) { case LVN_ITEMCHANGED: { LV_ITEM lvi; lvi.iItem=ListView_GetNextItem(GetDlgItem(hdlg,IDC_DBLIST),-1,LVNI_SELECTED); if(lvi.iItem==-1) break; lvi.mask=LVIF_PARAM; ListView_GetItem(GetDlgItem(hdlg,IDC_DBLIST),&lvi); SetDlgItemText(hdlg,IDC_FILE,(TCHAR*)lvi.lParam); SendMessage(hdlg,WM_COMMAND,MAKEWPARAM(IDC_FILE,EN_CHANGE),(LPARAM)GetDlgItem(hdlg,IDC_FILE)); break; } } break; } break; case WM_DESTROY: { LV_ITEM lvi; lvi.mask=LVIF_PARAM; for(lvi.iItem=ListView_GetItemCount(GetDlgItem(hdlg,IDC_DBLIST))-1;lvi.iItem>=0;lvi.iItem--) { ListView_GetItem(GetDlgItem(hdlg,IDC_DBLIST),&lvi); free((char*)lvi.lParam); } } break; } return FALSE; }
INT_PTR CALLBACK k5_ccconfig_dlgproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { k5_ccc_dlg_data * d; switch(uMsg) { case WM_INITDIALOG: d = PMALLOC(sizeof(*d)); #ifdef DEBUG assert(d); #endif ZeroMemory(d, sizeof(*d)); k5_read_file_cc_data(&d->save); k5_copy_file_cc_data(&d->work, &d->save); d->node = (khui_config_node) lParam; #pragma warning(push) #pragma warning(disable: 4244) SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d); #pragma warning(pop) { LVCOLUMN lvc; HWND lv; wchar_t buf[256]; RECT r; lv = GetDlgItem(hwnd, IDC_CFG_FCLIST); #ifdef DEBUG assert(lv); #endif ZeroMemory(&lvc, sizeof(lvc)); lvc.mask = LVCF_TEXT | LVCF_WIDTH; LoadString(hResModule, IDS_CFG_FCTITLE, buf, ARRAYLENGTH(buf)); GetWindowRect(lv, &r); lvc.pszText = buf; lvc.cx = (r.right - r.left) * 9 / 10; ListView_InsertColumn(lv, 0, &lvc); } SendDlgItemMessage(hwnd, IDC_CFG_FCNAME, EM_SETLIMITTEXT, MAX_PATH - 1, 0); k5_ccc_update_ui(hwnd, d); break; case WM_COMMAND: d = (k5_ccc_dlg_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER); if (d == NULL) break; switch(wParam) { case MAKEWPARAM(IDC_CFG_ADD, BN_CLICKED): { wchar_t path[MAX_PATH]; wchar_t cpath[MAX_PATH]; khm_size i; GetDlgItemText(hwnd, IDC_CFG_FCNAME, cpath, ARRAYLENGTH(cpath)); PathCanonicalize(path, cpath); if (!*path) return TRUE; /* nothing to add */ for (i=0; i < d->work.n_file_ccs; i++) { if (!_wcsicmp(path, d->work.file_ccs[i].path)) { /* allow the user to correct case, as appropriate */ StringCbCopy(d->work.file_ccs[i].path, sizeof(d->work.file_ccs[i].path), path); k5_ccc_update_ui(hwnd, d); return TRUE; } } /* not there. we need to add. but check a few things first */ if (!PathFileExists(path)) { wchar_t title[64]; wchar_t text[128]; LoadString(hResModule, IDS_CFG_FCN_WARNING, title, ARRAYLENGTH(title)); LoadString(hResModule, IDS_CFG_FCN_W_NOTFOUND, text, ARRAYLENGTH(text)); #if _WIN32_WINNT >= 0x501 if (IS_COMMCTL6()) { EDITBALLOONTIP bt; bt.cbStruct = sizeof(bt); bt.pszTitle = title; bt.pszText = text; bt.ttiIcon = TTI_WARNING; SendDlgItemMessage(hwnd, IDC_CFG_FCNAME, EM_SHOWBALLOONTIP, 0, (LPARAM) &bt); } else { #endif MessageBox(hwnd, text, title, MB_OK | MB_ICONWARNING); #if _WIN32_WINNT >= 0x501 } #endif } else if (PathIsRelative(path)) { wchar_t title[64]; wchar_t text[128]; LoadString(hResModule, IDS_CFG_FCN_WARNING, title, ARRAYLENGTH(title)); LoadString(hResModule, IDS_CFG_FCN_W_RELATIVE, text, ARRAYLENGTH(text)); #if _WIN32_WINNT >= 0x501 if (IS_COMMCTL6()) { EDITBALLOONTIP bt; bt.cbStruct = sizeof(bt); bt.pszTitle = title; bt.pszText = text; bt.ttiIcon = TTI_WARNING; SendDlgItemMessage(hwnd, IDC_CFG_FCNAME, EM_SHOWBALLOONTIP, 0, (LPARAM) &bt); } else { #endif MessageBox(hwnd, text, title, MB_OK | MB_ICONWARNING); #if _WIN32_WINNT >= 0x501 } #endif } k5_add_file_cc(&d->work, path); k5_ccc_update_ui(hwnd, d); } return TRUE; case MAKEWPARAM(IDC_CFG_BROWSE, BN_CLICKED): { OPENFILENAME ofn; wchar_t path[MAX_PATH * 8]; wchar_t title[128]; ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(path, sizeof(path)); GetDlgItemText(hwnd, IDC_CFG_FCNAME, path, ARRAYLENGTH(path)); /* don't pass in invalid paths */ if (!PathFileExists(path)) *path = 0; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; ofn.lpstrFilter = L"All files\0*.*\0\0"; ofn.nFilterIndex = 1; ofn.lpstrFile = path; ofn.nMaxFile = ARRAYLENGTH(path); ofn.lpstrTitle = title; LoadString(hResModule, IDS_CFG_FCOPENTITLE, title, ARRAYLENGTH(title)); ofn.Flags = OFN_ALLOWMULTISELECT | OFN_DONTADDTORECENT | OFN_FORCESHOWHIDDEN | OFN_EXPLORER; if (GetOpenFileName(&ofn)) { wchar_t * p; wchar_t spath[MAX_PATH]; p = multi_string_next(path); if (p) { /* multi select */ for(;p && *p; p = multi_string_next(p)) { StringCbCopy(spath, sizeof(spath), path); PathAppend(spath, p); k5_add_file_cc(&d->work, spath); } } else { /* single select */ k5_add_file_cc(&d->work, path); } k5_ccc_update_ui(hwnd, d); } } return TRUE; case MAKEWPARAM(IDC_CFG_REMOVE, BN_CLICKED): { khm_size i; int lv_idx; HWND lv; wchar_t buf[MAX_PATH]; lv = GetDlgItem(hwnd, IDC_CFG_FCLIST); #ifdef DEBUG assert(lv); #endif lv_idx = -1; while((lv_idx = ListView_GetNextItem(lv, lv_idx, LVNI_SELECTED)) != -1) { ListView_GetItemText(lv, lv_idx, 0, buf, ARRAYLENGTH(buf)); for (i=0; i < d->work.n_file_ccs; i++) { if (!_wcsicmp(buf, d->work.file_ccs[i].path)) { k5_del_file_cc(&d->work, i); break; } } } k5_ccc_update_ui(hwnd, d); } return TRUE; case MAKEWPARAM(IDC_CFG_INCAPI, BN_CLICKED): case MAKEWPARAM(IDC_CFG_INCMSLSA, BN_CLICKED): k5_ccc_update_data(hwnd, &d->work); k5_ccc_update_ui(hwnd, d); return TRUE; } break; case WM_DESTROY: d = (k5_ccc_dlg_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER); if (d == NULL) break; k5_free_file_ccs(&d->work); k5_free_file_ccs(&d->save); PFREE(d); SetWindowLongPtr(hwnd, DWLP_USER, 0); return TRUE; case KHUI_WM_CFG_NOTIFY: d = (k5_ccc_dlg_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER); if (d == NULL) break; switch(HIWORD(wParam)) { case WMCFG_APPLY: if (k5_ccc_get_mod(d)) { k5_write_file_cc_data(&d->work); k5_copy_file_cc_data(&d->save, &d->work); khui_cfg_set_flags(d->node, KHUI_CNFLAG_APPLIED, KHUI_CNFLAG_APPLIED); k5_ccc_update_ui(hwnd, d); kmq_post_sub_msg(k5_sub, KMSG_CRED, KMSG_CRED_REFRESH, 0, 0); } break; } } return FALSE; }
BOOL CALLBACK Filesets_Create_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static LPSET_CREATE_PARAMS pscp = NULL; if (msg == WM_INITDIALOG) pscp = (LPSET_CREATE_PARAMS)lp; if (HandleColumnNotify (hDlg, msg, wp, lp, &gr.viewAggCreate)) return FALSE; if (AfsAppLib_HandleHelp (IDD_SET_CREATE, hDlg, msg, wp, lp)) return TRUE; if (pscp != NULL) { switch (msg) { case WM_INITDIALOG: FastList_SetTextCallback (GetDlgItem (hDlg, IDC_AGG_LIST), GetItemText, &gr.viewAggCreate); Filesets_Create_OnInitDialog (hDlg, pscp); break; case WM_CONTEXTMENU: HWND hList; hList = GetDlgItem (hDlg, IDC_AGG_LIST); POINT ptScreen; POINT ptClient; ptScreen.x = LOWORD(lp); ptScreen.y = HIWORD(lp); ptClient = ptScreen; ScreenToClient (hList, &ptClient); if (FL_HitTestForHeaderBar (hList, ptClient)) { HMENU hm = TaLocale_LoadMenu (MENU_COLUMNS); DisplayContextMenu (hm, ptScreen, hList); } break; case WM_ENDTASK: LPTASKPACKET ptp; if ((ptp = (LPTASKPACKET)lp) != NULL) { if (ptp->idTask == taskAGG_FIND_QUOTA_LIMITS) Filesets_Create_OnEndTask_FindQuotaLimits (hDlg, ptp, pscp); else if (ptp->idTask == taskAGG_ENUM_TO_LISTVIEW) Filesets_Create_OnEndTask_EnumAggregates (hDlg); else if (ptp->idTask == taskSVR_ENUM_TO_COMBOBOX) { EnableWindow (GetDlgItem (hDlg, IDC_SET_SERVER), TRUE); Filesets_Create_StartDisplay_Aggregates (hDlg, &pscp->lpiParent); } FreeTaskPacket (ptp); } break; case WM_COLUMNS_CHANGED: LPARAM lpSel; lpSel = FL_GetSelectedData (GetDlgItem (hDlg, IDC_AGG_LIST)); FL_RestoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAggCreate); Filesets_Create_OnSelectServer (hDlg, (LPIDENT*)&lpSel); break; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: if (pscp->lpiParent && pscp->lpiParent->fIsAggregate() && pscp->szName[0]) EndDialog (hDlg, LOWORD(wp)); break; case IDCANCEL: EndDialog (hDlg, LOWORD(wp)); break; case IDC_SET_SERVER: if (HIWORD(wp) == CBN_SELCHANGE) Filesets_Create_OnSelectServer (hDlg, &pscp->lpiParent); break; case IDC_SET_NAME: GetDlgItemText (hDlg, IDC_SET_NAME, pscp->szName, cchNAME); Filesets_Create_EnableOK (hDlg, pscp); break; case IDC_SET_QUOTA: if (HIWORD(wp) == SPN_UPDATE) { pscp->ckQuota = SP_GetPos (GetDlgItem (hDlg, IDC_SET_QUOTA)); if (gr.cbQuotaUnits == cb1MB) pscp->ckQuota *= ck1MB; } break; case IDC_SET_QUOTA_UNITS: if (HIWORD(wp) == CBN_SELCHANGE) { gr.cbQuotaUnits = (size_t)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SET_QUOTA_UNITS)); StartTask (taskAGG_FIND_QUOTA_LIMITS, hDlg, pscp->lpiParent); } break; case IDC_SET_CLONE: pscp->fCreateClone = IsDlgButtonChecked (hDlg, IDC_SET_CLONE); break; } break; case WM_DESTROY: FL_StoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAggCreate); pscp = NULL; break; case WM_NOTIFY: switch (((LPNMHDR)lp)->code) { case FLN_ITEMSELECT: LPIDENT lpi; if ((lpi = (LPIDENT)FL_GetSelectedData (GetDlgItem (hDlg, IDC_AGG_LIST))) != NULL) { pscp->lpiParent = lpi; StartTask (taskAGG_FIND_QUOTA_LIMITS, hDlg, pscp->lpiParent); Filesets_Create_EnableOK (hDlg, pscp); } break; } break; } } return FALSE; }
INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { SessionAnnounceDialogProc_arg* arg = (SessionAnnounceDialogProc_arg*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); CSametimeProto *proto; switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); arg = (SessionAnnounceDialogProc_arg*)lParam; proto = arg->proto; proto->debugLog(_T("SessionAnnounceDialogProc WM_INITDIALOG")); SendDlgItemMessage(hwndDlg, IDC_LST_ANTO, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); { LVCOLUMN lvc; // Initialize the LVCOLUMN structure. // The mask specifies that the format, width, text, and // subitem members of the structure are valid. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.iSubItem = 0; lvc.pszText = TranslateT("Recipients"); lvc.cx = 300; // width of column in pixels ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_LST_ANTO), 0, &lvc); } //enumerate plugins, fill in list { ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_LST_ANTO)); LVITEM lvI; // Some code to create the list-view control. // Initialize LVITEM members that are common to all items. lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_NORECOMPUTE;// | LVIF_IMAGE; lvI.iItem = 0; lvI.iSubItem = 0; for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) { if (db_get_b(hContact, proto->m_szModuleName, "ChatRoom", 0) == 0 && db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { lvI.lParam = (LPARAM)hContact; lvI.pszText = pcli->pfnGetContactDisplayName(hContact, 0); ListView_InsertItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI); lvI.iItem++; } } } } return 0; case WM_CLOSE: proto = arg->proto; proto->debugLog(_T("SessionAnnounceDialogProc WM_CLOSE")); mir_free(arg); DestroyWindow(hwndDlg); break; case WM_COMMAND: proto = arg->proto; if (HIWORD(wParam) == BN_CLICKED) { int size; switch (LOWORD(wParam)) { case IDC_BUT_SELALL: size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, true); return 0; case IDC_BUT_SELINV: size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, !ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)); return 0; case IDOK: proto->debugLog(_T("SessionAnnounceDialogProc IDOK BN_CLICKED")); { // build SendAnnouncementFunc_arg SendAnnouncementFunc_arg* safArg = (SendAnnouncementFunc_arg*)mir_calloc(sizeof(SendAnnouncementFunc_arg)); DBVARIANT dbv; LVITEM lvI = { 0 }; char id[1024]; mir_strcpy(id, "@U"); // documentation says prepend '@U' to usernames and '@G' to notes group names - but char *p = id + 2; // it's wrong - it works for a list of user id's with no prefix - so we'll do both // build recipient list safArg->recipients = 0; int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); int send_count = 0; for (int i = 0; i < size; i++) { if (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)) { lvI.iItem = i; lvI.iSubItem = 0; lvI.mask = LVIF_PARAM; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI); if (!db_get_utf((MCONTACT)lvI.lParam, proto->m_szModuleName, "stid", &dbv)) { safArg->recipients = g_list_prepend(safArg->recipients, _strdup(dbv.pszVal)); mir_strcpy(p, dbv.pszVal); safArg->recipients = g_list_prepend(safArg->recipients, _strdup(id)); send_count++; db_free(&dbv); } } } if (send_count > 0) { GetDlgItemText(hwndDlg, IDC_ED_ANMSG, safArg->msg, MAX_MESSAGE_SIZE); safArg->proto = proto; SendAnnouncementFunc sendAnnouncementFunc = arg->sendAnnouncementFunc; sendAnnouncementFunc(safArg); } // clean up recipient list if (safArg->recipients) { for (GList *rit = safArg->recipients; rit; rit = rit->next) { free(rit->data); } g_list_free(safArg->recipients); } mir_free(safArg); DestroyWindow(hwndDlg); } return 0; case IDCANCEL: DestroyWindow(hwndDlg); return 0; } } break; } return 0; }