void CPathEditWnd::Init( CPathEditUI* pOwner ) { m_pOwner = pOwner; RECT rcPos = CalPos(); UINT uStyle = WS_CHILD | ES_AUTOHSCROLL; if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD; Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos); HFONT hFont=NULL; int iFontIndex=m_pOwner->GetFont(); if (iFontIndex!=-1) hFont=m_pOwner->GetManager()->GetFont(iFontIndex); if (hFont==NULL) hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont; SetWindowFont(m_hWnd, hFont, TRUE); Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar()); if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar()); Edit_SetText(m_hWnd, m_pOwner->GetText()); Edit_SetModify(m_hWnd, FALSE); SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0)); Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true); Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true); //Styls LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE); styleValue |= pOwner->GetWindowStyls(); ::SetWindowLong(GetHWND(), GWL_STYLE, styleValue); ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE); ::SetFocus(m_hWnd); m_bInit = true; }
void CEditUI::SetPasswordChar(TCHAR cPasswordChar) { if( m_cPasswordChar == cPasswordChar ) return; m_cPasswordChar = cPasswordChar; if( m_pWindow != NULL ) Edit_SetPasswordChar(*m_pWindow, m_cPasswordChar); Invalidate(); }
void CEditWnd::Init(CEditUI* pOwner) { m_pOwner = pOwner; RECT rcPos = CalPos(); UINT uStyle = WS_CHILD | ES_AUTOHSCROLL; if (m_pOwner->IsPasswordMode()) uStyle |= ES_PASSWORD; Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos); SetWindowFont(m_hWnd, m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->hFont, TRUE); Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar()); if (m_pOwner->IsPasswordMode()) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar()); Edit_SetText(m_hWnd, m_pOwner->GetText()); Edit_SetModify(m_hWnd, FALSE); SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0)); Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true); Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true); ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE); ::SetFocus(m_hWnd); m_bInit = true; }
void CEditUI::SetPasswordModeEx(bool bPasswordMode) { // 当使用 TAB 切换时, 设置不起作用, 会显示明文 ... ??? if( m_bPasswordMode == bPasswordMode ) return; m_bPasswordMode = bPasswordMode; if( bPasswordMode && m_pWindow ) Edit_SetPasswordChar(*m_pWindow, m_cPasswordChar); Invalidate(); }
INT_PTR InputDialog::OnInitDialog() { Dialog::OnInitDialog(); m_commentCtrl = GetDlgItem(m_hwnd, IDC_STATIC_COMMENT); m_valueCtrl = GetDlgItem(m_hwnd, IDC_EDIT_INPUT); SetWindowText(m_commentCtrl, m_comment); SetWindowText(m_valueCtrl, m_value); if (m_password) { Edit_SetPasswordChar(::GetDlgItem(m_hwnd, IDC_EDIT_INPUT), (UINT)'*'); } return TRUE; }
/*! * \brief blah * * blah */ void DcxEdit::parseCommandRequest(TString &input) { const XSwitchFlags flags(input.gettok(3)); const int numtok = input.numtok( ); // xdid -r [NAME] [ID] [SWITCH] if (flags['r']) { this->m_tsText = ""; SetWindowTextW(this->m_Hwnd, L""); } // xdid -a [NAME] [ID] [SWITCH] [TEXT] if (flags['a'] && numtok > 3) { this->m_tsText += input.gettok(4, -1); SetWindowTextW(this->m_Hwnd, this->m_tsText.to_wchr(this->m_bUseUTF8)); } // xdid -c [NAME] [ID] [SWITCH] else if (flags['c'] && numtok > 2) { CopyToClipboard(this->m_Hwnd, this->m_tsText); } // xdid -d [NAME] [ID] [SWITCH] [N] else if (flags['d'] && numtok > 3) { if (this->isStyle(ES_MULTILINE)) { const int nLine = input.gettok( 4 ).to_int(); this->m_tsText.deltok(nLine, "\r\n"); SetWindowTextW(this->m_Hwnd, this->m_tsText.to_wchr(this->m_bUseUTF8)); } } // xdid -i [NAME] [ID] [SWITCH] [N] [TEXT] else if (flags['i'] && numtok > 4) { if (this->isStyle(ES_MULTILINE)) { const int nLine = input.gettok( 4 ).to_int(); this->m_tsText.instok(input.gettok(5, -1).to_chr(), nLine, "\r\n"); } else this->m_tsText = input.gettok(5, -1); SetWindowTextW(this->m_Hwnd, this->m_tsText.to_wchr(this->m_bUseUTF8)); } // xdid -j [NAME] [ID] [SWITCH] [0|1] else if (flags['j'] && numtok > 3) { const unsigned int i = input.gettok( 4 ).to_int(); if (i > 0) { this->addStyle(ES_PASSWORD); TCHAR c = Edit_GetPasswordChar(this->m_Hwnd); // XP actually uses the unicode `Black Circle` char U+25CF (9679) // The problem is getting the char set to a unicode (2-byte) one, so far it always sets to CF (207) if (c == 0) c = '*'; //(Dcx::XPPlusModule.isUseable()() ? '•' : '*'); Edit_SetPasswordChar(this->m_Hwnd, c); //SendMessage(this->m_Hwnd, CCM_SETUNICODEFORMAT, TRUE, NULL); //WCHAR c = (WCHAR)SendMessageW(this->m_Hwnd, EM_GETPASSWORDCHAR, NULL, NULL); //if (c == 0) // c = (Dcx::XPPlusModule.isUseable() ? 9679 : L'*'); //SendMessageW(this->m_Hwnd, EM_SETPASSWORDCHAR, (WPARAM)c, NULL); } else { this->removeStyle(ES_PASSWORD); Edit_SetPasswordChar(this->m_Hwnd, 0); } this->redrawWindow(); } // xdid -l [NAME] [ID] [SWITCH] [ON|OFF] else if (flags['l'] && numtok > 3) { const BOOL enabled = (input.gettok(4).to_int() > 0 ? TRUE : FALSE); SendMessage(this->m_Hwnd, EM_SETREADONLY, enabled, NULL); } // xdid -o [NAME] [ID] [SWITCH] [N] [TEXT] else if (flags['o'] && numtok > 3) { if (this->isStyle(ES_MULTILINE)) { const int nLine = input.gettok( 4 ).to_int(); this->m_tsText.puttok(input.gettok(5, -1).to_chr(), nLine, "\r\n"); } else this->m_tsText = input.gettok(4, -1); SetWindowTextW(this->m_Hwnd, this->m_tsText.to_wchr(this->m_bUseUTF8)); } // xdid -P [NAME] [ID] else if (flags['P'] && numtok > 1) { SendMessage(this->getHwnd(),WM_PASTE,NULL,NULL); } // xdid -q [NAME] [ID] [SWITCH] [SIZE] else if (flags['q'] && numtok > 3) { const int N = input.gettok( 4 ).to_int(); if (N > -1) Edit_LimitText(this->m_Hwnd, N); } // Used to prevent invalid flag message. // xdid -r [NAME] [ID] [SWITCH] else if (flags['r']) { } // xdid -t [NAME] [ID] [SWITCH] [FILENAME] else if (flags['t'] && numtok > 3) { char *contents = readFile(input.gettok(4, -1).to_chr()); if (contents != NULL) { this->m_tsText = contents; SetWindowTextW(this->m_Hwnd, this->m_tsText.to_wchr(this->m_bUseUTF8)); delete [] contents; } } // xdid -u [NAME] [ID] [SWITCH] [FILENAME] else if (flags['u'] && numtok > 3) { FILE *file = fopen(input.gettok(4, -1).to_chr(), "wb"); if (file != NULL) { fwrite(this->m_tsText.to_chr(), sizeof(char), this->m_tsText.len(), file); fflush(file); fclose(file); } } // xdid -S [NAME] [ID] [SWITCH] [START] [END] else if (flags['S'] && numtok > 3) { const int istart = input.gettok( 4 ).to_int(); int iend; if (numtok > 4) iend = input.gettok( 5 ).to_int(); else iend = istart; SendMessage(this->m_Hwnd, EM_SETSEL, istart, iend); SendMessage(this->m_Hwnd, EM_SCROLLCARET, NULL, NULL); } // xdid -E [NAME] [ID] [SWITCH] [CUE TEXT] else if (flags['E'] && numtok > 3) { this->m_tsCue = input.gettok(4, -1); Edit_SetCueBannerText(this->m_Hwnd,this->m_tsCue.to_wchr(this->m_bUseUTF8)); } // xdid -y [NAME] [ID] [SWITCH] [0|1] else if (flags['y'] && numtok > 3) { const int state = input.gettok(4).to_int(); this->m_bIgnoreRepeat = (state > 0 ? TRUE : FALSE); } else this->parseGlobalCommandRequest(input, flags); }
INT_PTR WINAPI DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static bool isShown = false; switch (msg) { case WM_INITDIALOG: { hEdit1 = GetDlgItem(hDlg, IDC_EDIT1); hPass = GetDlgItem(hDlg, IDC_PASSWORD); DWORD exStyle = GetWindowLong(hEdit1, GWL_EXSTYLE); DWORD style = GetWindowLong(hEdit1, GWL_STYLE); hEdit2 = CreateWindowEx ( exStyle, TEXT("EDIT"), TEXT(""), //style | WS_VSCROLL | WS_HSCROLL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN, 25, 80, 200, 150, hDlg, NULL, GetModuleHandle(0), NULL ); Edit_SetPasswordChar(hPass, TEXT('0')); SetFocus(hPass); if (!isShown) { ShowWindow(hEdit2, SW_HIDE); } } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PASSWORD: { if (HIWORD(wParam) == EN_CHANGE) { TCHAR text[256]; //SendMessage(hPass, WM_GETTEXT, 255, LPARAM(text)); //SendDlgItemMessage(hDlg, IDC_PASSWORD, WM_GETTEXT, 255, LPARAM(text)); //GetWindowText(hPass, text, 255); Edit_GetText(hPass, text, 255); if (lstrcmp(text, TEXT("123456")) == 0) { ShowWindow(hEdit2, SW_SHOW); } else { ShowWindow(hEdit2, SW_HIDE); } } } return TRUE; case IDOK: case IDCANCEL: SendMessage(hDlg, WM_CLOSE, NULL, NULL); return TRUE; default: return FALSE; } return TRUE; case WM_CLOSE: EndDialog(hDlg, 0); return TRUE; default: return FALSE; } return FALSE; }