void SelectProxy::ApplyChoice (SpellChecker *SpellCheckerInstance) { TCHAR *TBuf = 0; size_t BufSize = 0; BufSize = Edit_GetTextLength (HUserName) + 1; TBuf = new TCHAR [BufSize]; Edit_GetText (HUserName, TBuf, BufSize); SpellCheckerInstance->SetProxyUserName (TBuf); CLEAN_AND_ZERO_ARR (TBuf); BufSize = Edit_GetTextLength (HHostName) + 1; TBuf = new TCHAR [BufSize]; Edit_GetText (HHostName, TBuf, BufSize); SpellCheckerInstance->SetProxyHostName (TBuf); CLEAN_AND_ZERO_ARR (TBuf); BufSize = Edit_GetTextLength (HPassword) + 1; TBuf = new TCHAR [BufSize]; Edit_GetText (HPassword, TBuf, BufSize); SpellCheckerInstance->SetProxyPassword (TBuf); CLEAN_AND_ZERO_ARR (TBuf); SpellCheckerInstance->SetUseProxy (Button_GetCheck (HUseProxy)); SpellCheckerInstance->SetProxyAnonymous (Button_GetCheck (HProxyAnonymous)); SpellCheckerInstance->SetProxyType (ComboBox_GetCurSel (HProxyType)); TBuf = new TCHAR[DEFAULT_BUF_SIZE]; Edit_GetText (HPort, TBuf, DEFAULT_BUF_SIZE); TCHAR *EndPtr; int x = _tcstol (TBuf, &EndPtr, 10); SpellCheckerInstance->SetProxyPort (x); CLEAN_AND_ZERO_ARR (TBuf); GetDownloadDics ()->Refresh (); }
static void CLIB_DECL DetailsPrintf(const char *fmt, ...) { HWND hEdit; va_list marker; char buffer[2000]; char * s; long l; //RS 20030613 Different Ids for Property Page and Dialog // so see which one's currently instantiated hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS); if (hEdit == NULL) hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS_PROP); if (hEdit == NULL) { dprintf("audit detailsprintf() can't find any audit control"); return; } va_start(marker, fmt); vsprintf(buffer, fmt, marker); va_end(marker); s = ConvertToWindowsNewlines(buffer); l = Edit_GetTextLength(hEdit); Edit_SetSel(hEdit, Edit_GetTextLength(hEdit), Edit_GetTextLength(hEdit)); SendMessage( hEdit, EM_REPLACESEL, FALSE, (WPARAM)s ); }
INT_PTR CALLBACK DirectXDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { HWND hEdit; const char *directx_help = MAMEUINAME " requires DirectX version 3 or later, which is a set of operating\r\n" "system extensions by Microsoft for Windows 9x, NT and 2000.\r\n\r\n" "Visit Microsoft's DirectX web page at http://www.microsoft.com/directx\r\n" "download DirectX, install it, and then run " MAMEUINAME " again.\r\n"; switch (Msg) { case WM_INITDIALOG: hEdit = GetDlgItem(hDlg, IDC_DIRECTX_HELP); Edit_SetSel(hEdit, Edit_GetTextLength(hEdit), Edit_GetTextLength(hEdit)); Edit_ReplaceSel(hEdit, directx_help); return 1; case WM_COMMAND: if (LOWORD(wParam) == IDB_WEB_PAGE) ShellExecute(GetMainWindow(), NULL, TEXT("http://www.microsoft.com/directx"), NULL, NULL, SW_SHOWNORMAL); if (LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDB_WEB_PAGE) EndDialog(hDlg, 0); return 1; } return 0; }
// Append a message to the result display. static void appendMsg(HWND win, const char *msg) { char *newMsg; long len; // There's no easy way to append text to a text box. We'll insert an // extra character (a newline) each time text is added. When text is // added later, we'll select the extra character and replace the selection // with the new text. // Add a newline to the message. newMsg = (char *)malloc(strlen(msg) + 2 + 1); if (NULL == newMsg) { return; } strcpy(newMsg, msg); strcat(newMsg, "\r\n"); len = Edit_GetTextLength(GetDlgItem(win, IDC_RESULT_EDT)); if (len > 0) { // Select the last character. Edit_SetSel(GetDlgItem(win, IDC_RESULT_EDT), len, len); // Replace the selection with the new message. Edit_ReplaceSel(GetDlgItem(win, IDC_RESULT_EDT), newMsg); } else { // Just add the message. Edit_SetText(GetDlgItem(win, IDC_RESULT_EDT), newMsg); } free(newMsg); }
static void TabLogAdd( LPTSTR str ) { int size; size = Edit_GetTextLength( g_hLogEdit ); Edit_SetSel( g_hLogEdit,size, size ); Edit_ReplaceSel( g_hLogEdit, str ); Edit_ScrollCaret( g_hLogEdit ); }
void SaveState() { int len = Edit_GetTextLength( hwAnswer ); char *str = new char[ len+1 ]; Edit_GetText( hwAnswer, str, len+1 ); ex.set_answer( curr, str ); delete [] str; }
static void append_output_window_real(const char *astring) { int len; len=Edit_GetTextLength(logoutput_win); Edit_SetSel(logoutput_win,len,len); Edit_ReplaceSel(logoutput_win,astring); Edit_ScrollCaret(logoutput_win); }
static void EnableDisableOKButton (HWND hwnd) { if (Edit_GetTextLength (GetDlgItem (hwnd, IDC_STARTTIME)) == 0 || CAListBox_GetSelCount(GetDlgItem (hwnd, IDC_CDDSNUMBER)) == 0 || ComboBox_GetCurSel(GetDlgItem (hwnd, IDC_DBNUMBER)) == CB_ERR ) EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); else EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); }
// // Console window // void ConsoleTabWindow::print(TCHAR *buf, BOOL force_display) { int cr; TCHAR *p; if (force_display) goto display; if (_filesave) { if (_logfile == INVALID_HANDLE_VALUE && !_open_log_file()) { _filesave = FALSE; _set_check(IDC_CONS_FILESAVE, _filesave); EnableWindow(_filename_edit, _filesave); goto display; } DWORD cnt; char c; for (int i = 0; *buf != TEXT('\0'); buf++) { c = *buf & 0x7f; WriteFile(_logfile, &c, 1, &cnt, 0); } FlushFileBuffers(_logfile); return; } display: // count number of '\n' for (cr = 0, p = buf; p = wcschr(p, TEXT('\n')); cr++, p++) continue; // total length of new buffer ('\n' -> "\r\n" + '\0') size_t sz = (wcslen(buf) + cr + 1) * sizeof(TCHAR); p = reinterpret_cast <TCHAR *>(malloc(sz)); if (p == NULL) return; // convert newlines TCHAR *d = p; while (*buf != TEXT('\0')) { TCHAR c = *buf++; if (c == TEXT('\n')) *d++ = TEXT('\r'); *d++ = c; } *d = TEXT('\0'); // append the text and scroll int end = Edit_GetTextLength(_edit); Edit_SetSel(_edit, end, end); Edit_ReplaceSel(_edit, p); Edit_ScrollCaret(_edit); UpdateWindow(_edit); free(p); }
void Dlg_AppendEditText (HWND hwndEdit, LPCTSTR lpszLine) { int nLen; // Move caret to end of text nLen = Edit_GetTextLength(hwndEdit); Edit_SetSel(hwndEdit, nLen, nLen); // Insert text Edit_ReplaceSel(hwndEdit, lpszLine); }
INT_PTR CALLBACK ProxyAuthDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { LPCSTR proxy_type; connection_t *c; char fmt[32]; switch (msg) { case WM_INITDIALOG: /* Set connection for this dialog and show it */ c = (connection_t *) lParam; SetProp(hwndDlg, cfgProp, (HANDLE) c); if (c->state == resuming) ForceForegroundWindow(hwndDlg); else SetForegroundWindow(hwndDlg); break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_EDT_PROXY_USER: if (HIWORD(wParam) == EN_UPDATE) { int len = Edit_GetTextLength((HWND) lParam); EnableWindow(GetDlgItem(hwndDlg, IDOK), (len ? TRUE : FALSE)); } break; case IDOK: c = (connection_t *) GetProp(hwndDlg, cfgProp); proxy_type = (c->proxy_type == http ? "HTTP" : "SOCKS"); snprintf(fmt, sizeof(fmt), "username \"%s Proxy\" \"%%s\"", proxy_type); ManagementCommandFromInput(c, fmt, hwndDlg, ID_EDT_PROXY_USER); snprintf(fmt, sizeof(fmt), "password \"%s Proxy\" \"%%s\"", proxy_type); ManagementCommandFromInput(c, fmt, hwndDlg, ID_EDT_PROXY_PASS); EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; } break; case WM_CLOSE: EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; case WM_NCDESTROY: RemoveProp(hwndDlg, cfgProp); break; } return FALSE; }
void Dlg_OnCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) { TCHAR szPathname[MAX_PATH]; switch (id) { case IDCANCEL: EndDialog(hWnd, id); break; case IDC_FILENAME: EnableWindow(GetDlgItem(hWnd, IDC_REVERSE), Edit_GetTextLength(hWndCtl) > 0); break; case IDC_REVERSE: GetDlgItemText(hWnd, IDC_FILENAME, szPathname, _countof(szPathname)); // Make copy of input file so that we don't destroy it if (!CopyFile(szPathname, FILENAME, FALSE)) { chMB("New file could not be created."); break; } BOOL bIsTextUnicode; if (FileReverse(FILENAME, &bIsTextUnicode)) { SetDlgItemText(hWnd, IDC_TEXTTYPE, bIsTextUnicode ? TEXT("Unicode") : TEXT("ANSI")); // Spawn Notepad to see the fruits of our labors. STARTUPINFO si = { sizeof(si) }; PROCESS_INFORMATION pi; TCHAR sz[] = TEXT("Notepad ") FILENAME; if (CreateProcess(NULL, sz, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } } break; case IDC_FILESELECT: OPENFILENAME ofn = { OPENFILENAME_SIZE_VERSION_400 }; ofn.hwndOwner = hWnd; ofn.lpstrFile = szPathname; ofn.lpstrFile[0] = 0; ofn.nMaxFile = _countof(szPathname); ofn.lpstrTitle = TEXT("Select file for reversing"); ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST; GetOpenFileName(&ofn); SetDlgItemText(hWnd, IDC_FILENAME, ofn.lpstrFile); SetFocus(GetDlgItem(hWnd, IDC_REVERSE)); break; } }
/* * DialogProc for OpenVPN username/password auth dialog windows */ INT_PTR CALLBACK UserAuthDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { connection_t *c; switch (msg) { case WM_INITDIALOG: /* Set connection for this dialog and show it */ c = (connection_t *) lParam; SetProp(hwndDlg, cfgProp, (HANDLE) c); if (c->state == resuming) ForceForegroundWindow(hwndDlg); else SetForegroundWindow(hwndDlg); break; case WM_COMMAND: c = (connection_t *) GetProp(hwndDlg, cfgProp); switch (LOWORD(wParam)) { case ID_EDT_AUTH_USER: if (HIWORD(wParam) == EN_UPDATE) { int len = Edit_GetTextLength((HWND) lParam); EnableWindow(GetDlgItem(hwndDlg, IDOK), (len ? TRUE : FALSE)); } break; case IDOK: ManagementCommandFromInput(c, "username \"Auth\" \"%s\"", hwndDlg, ID_EDT_AUTH_USER); ManagementCommandFromInput(c, "password \"Auth\" \"%s\"", hwndDlg, ID_EDT_AUTH_PASS); EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; case IDCANCEL: EndDialog(hwndDlg, LOWORD(wParam)); StopOpenVPN(c); return TRUE; } break; case WM_CLOSE: EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; case WM_NCDESTROY: RemoveProp(hwndDlg, cfgProp); break; } return FALSE; }
void OnMenuFind(WindowInfo *win) { if (win->IsChm()) { win->dm->AsChmEngine()->FindInCurrentPage(); return; } if (!win->IsDocLoaded() || !NeedsFindUI(win)) return; // copy any selected text to the find bar, if it's still empty if (win->dm->textSelection->result.len > 0 && Edit_GetTextLength(win->hwndFindBox) == 0) { ScopedMem<WCHAR> selection(win->dm->textSelection->ExtractText(L" ")); str::NormalizeWS(selection); if (!str::IsEmpty(selection.Get())) { win::SetText(win->hwndFindBox, selection); Edit_SetModify(win->hwndFindBox, TRUE); } } // Don't show a dialog if we don't have to - use the Toolbar instead if (gGlobalPrefs->toolbarVisible && !win->fullScreen && !win->presentation) { if (GetFocus() == win->hwndFindBox) SendMessage(win->hwndFindBox, WM_SETFOCUS, 0, 0); else SetFocus(win->hwndFindBox); return; } ScopedMem<WCHAR> previousFind(win::GetText(win->hwndFindBox)); WORD state = (WORD)SendMessage(win->hwndToolbar, TB_GETSTATE, IDM_FIND_MATCH, 0); bool matchCase = (state & TBSTATE_CHECKED) != 0; ScopedMem<WCHAR> findString(Dialog_Find(win->hwndFrame, previousFind, &matchCase)); if (!findString) return; win::SetText(win->hwndFindBox, findString); Edit_SetModify(win->hwndFindBox, TRUE); bool matchCaseChanged = matchCase != (0 != (state & TBSTATE_CHECKED)); if (matchCaseChanged) { if (matchCase) state |= TBSTATE_CHECKED; else state &= ~TBSTATE_CHECKED; SendMessage(win->hwndToolbar, TB_SETSTATE, IDM_FIND_MATCH, state); win->dm->textSearch->SetSensitive(matchCase); } FindTextOnThread(win); }
char *StringConfigControl::GetPszValue() { int i_size; char *psz_result; TCHAR *psz_string; i_size = Edit_GetTextLength( textctrl ); psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) ); Edit_GetText( textctrl, psz_string, i_size + 1 ); psz_result = strdup( _TOMB(psz_string) ); free( psz_string ); return psz_result; }
// Text des Edit-Fenster ins Clipboard kopieren BOOL CopyTextToClipBoard (HWND hMainWnd, HWND hEditWnd) { DWORD dwLen = 0; HGLOBAL hBuffer = 0; void FAR*pBuffer = NULL; BOOL bRet = TRUE; // Länge des Textes bestimmen dwLen = Edit_GetTextLength (hEditWnd) + 1; if (!dwLen) // kein Text gefunden return FALSE; // Speicher anfordern hBuffer = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT | GMEM_SHARE, dwLen); if (!hBuffer) { MessageBox (hMainWnd, "Nicht genügend Speicher.", "TriasED", MB_OK | MB_ICONHAND); return FALSE; } pBuffer = GlobalLock (hBuffer); if (!pBuffer) { GlobalFree (hBuffer); MessageBox (hMainWnd, "Fehler beim Verriegeln des Speichers.", "TriasED", MB_OK | MB_ICONHAND); return FALSE; } // Editor-Text lesen Edit_GetText (hEditWnd, pBuffer, LOWORD (dwLen)); GlobalUnlock (hBuffer); // Speicher entriegeln // Text kopieren if (bRet = OpenClipboard (hMainWnd)) { if (bRet = EmptyClipboard ()) { // Clipboard "leeren" hBuffer = SetClipboardData (CF_TEXT, hBuffer); // Daten kopieren bRet = hBuffer ? TRUE : FALSE; // freigeben der Daten mit CloseClipboard () } else GlobalFree (hBuffer); // Speicher freigeben } else GlobalFree (hBuffer); // Speicher freigeben CloseClipboard (); // Clipboard schließen // ggf. Fehlermeldung ausgeben if (bRet == FALSE) MessageBox (hMainWnd, "Fehler beim Kopieren der Daten.", "TriasED", MB_OK | MB_ICONHAND); return bRet; }
/* * MailRecipientsReceived: Server has translated recipient names into given object * numbers (in the same order). Now send the mail message. */ void MailRecipientsReceived(WORD num_objects, ID *objs) { int i, len, chars; HWND hEdit; char buf[MAXMAIL + MAX_SUBJECT + 20]; Bool names_legal; if (hSendMailDlg == NULL || info == NULL) return; if (num_objects != info->num_recipients) { debug(("Mismatch in # of recipients (got %d, expected %d)\n", num_objects, info->num_recipients)); SafeFree(info); return; } // Verify that object numbers are legal names_legal = True; for (i=0; i < num_objects; i++) if (objs[i] == 0) { ClientError(hInst, hSendMailDlg, IDS_BADNAME, info->recipients[i]); SetDlgItemText(hSendMailDlg, IDC_SENDMAILMSG, ""); names_legal = False; break; } if (names_legal) { /* Get subject and text, and send the message */ chars = sprintf(buf, "%s", GetString(hInst, IDS_SUBJECT)); len = GetDlgItemText(hSendMailDlg, IDC_SUBJECT, buf + chars, MAX_SUBJECT); buf[chars + len] = '\n'; chars += len + 1; hEdit = GetDlgItem(hSendMailDlg, IDC_MAILEDIT); len = Edit_GetTextLength(hEdit); Edit_GetText(hEdit, buf + chars, len + 1); SendMail(num_objects, objs, buf); SendMessage(hSendMailDlg, WM_CLOSE, 0, 0); } else EnableWindow(GetDlgItem(hSendMailDlg, IDC_OK), TRUE); SafeFree(info); info = NULL; }
void getStrFieldData(HWND hwnd, SQLWCHAR **param, int idc) { x_free(*param); *param= NULL; int len = Edit_GetTextLength(GetDlgItem(hwnd,idc)); if (len>0) { *param= (SQLWCHAR *)myodbc_malloc((len + 1) * sizeof(SQLWCHAR), MYF(0)); if (*param) Edit_GetText(GetDlgItem(hwnd,idc), *param, len+1); } }
static void EnableDisableOKButton (HWND hwnd) { HWND hwndObjectType = GetDlgItem (hwnd, IDC_LOCATE_OBJECTTYPE); HWND hwndDatabase = GetDlgItem (hwnd, IDC_LOCATE_DATABASE); HWND hwndLDatabase = GetDlgItem (hwnd, IDC_LOCATE_LDATABASE); int nSel; if (Edit_GetTextLength (GetDlgItem (hwnd, IDC_LOCATE_FIND)) == 0) EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); else EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); if ((nSel = ComboBox_GetCurSel (hwndObjectType)) != CB_ERR) { nSel = Obj4locate() [nSel]; switch (nSel) { case OT_DATABASE: case OT_USER: case OT_GROUP: case OT_ROLE: case OT_LOCATION: ComboBox_SetCurSel (hwndDatabase, -1); EnableWindow (hwndDatabase, FALSE); EnableWindow (hwndLDatabase, FALSE); break; default: { int idx; EnableWindow (hwndDatabase, TRUE); EnableWindow (hwndLDatabase, TRUE); idx = ComboBox_GetCurSel (hwndDatabase); if (idx != CB_ERR) EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); else EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); //if (ComboBox_GetCount (hwndDatabase) > 0) //{ // ComboBox_SetCurSel (hwndDatabase, 0); //} break; } } } }
BOOL FASTCALL CmdSignatureDlg_SaveSig( HWND hwnd, int index ) { char sz[ _MAX_FNAME ]; HWND hwndList; register int c; HNDFILE fh; hwndList = GetDlgItem( hwnd, IDD_LIST ); ComboBox_GetLBText( hwndList, index, sz ); for( c = 0; sz[ c ]; ++c ) if( !ValidFileNameChr( sz[ c ] ) ) { wsprintf( lpTmpBuf, GS( IDS_STR136 ), sz[ c ] ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION ); return( FALSE ); } lstrcat( sz, ".sig" ); if( ( fh = Ameol2_CreateFile( sz, DSD_SIG, 0 ) ) == HNDFILE_ERROR ) fMessageBox( hwnd, 0, GS( IDS_STR137 ), MB_OK|MB_ICONEXCLAMATION ); else { WORD wSize; LPSTR lpText; HWND hwndEdit; INITIALISE_PTR(lpText); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); wSize = Edit_GetTextLength( hwndEdit ) + 1; if( !fNewMemory( &lpText, wSize ) ) OutOfMemoryError( hwnd, FALSE, FALSE ); else { Edit_GetText( hwndEdit, lpText, wSize ); if( Amfile_Write( fh, lpText, wSize ) == wSize ) { FreeMemory( &lpText ); Amfile_Close( fh ); return( TRUE ); } FreeMemory( &lpText ); DiskWriteError( hwnd, sz, FALSE, FALSE ); } Amfile_Close( fh ); Amfile_Delete( sz ); } return( FALSE ); }
float FloatConfigControl::GetFloatValue() { float f_value; int i_size = Edit_GetTextLength( textctrl ); TCHAR *psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) ); Edit_GetText( textctrl, psz_string, i_size + 1 ); if( _tscanf( psz_string, _T("%f"), &f_value ) == 1 ) { free( psz_string ); return f_value; } free( psz_string ); return 0.0; }
void getUnsignedFieldData(HWND hwnd, unsigned int *param, int idc) { *param = 0U; int len = Edit_GetTextLength(GetDlgItem(hwnd,idc)); if(len>0) { SQLWCHAR *tmp1= (SQLWCHAR *)myodbc_malloc((len + 1) * sizeof(SQLWCHAR), MYF(0)); if (tmp1) { Edit_GetText(GetDlgItem(hwnd,idc), tmp1, len+1); *param = _wtol(tmp1); x_free(tmp1); } } }
char *GetFieldStrVal(int Dialog, int Field, char* (*allocator)(size_t)) { int rc; size_t len= Edit_GetTextLength(GetDlgItem(hwndTab[Dialog], Field)); char *p; if (allocator) { p= allocator(len * sizeof(char) + 2); } else { p= (char *)MADB_CALLOC(len * sizeof(char) + 2); } if (p) rc= Edit_GetText(GetDlgItem(hwndTab[Dialog], Field), p, len+1); return p; }
void SetPage(HWND hDlg, int value) { MADB_Dsn *Dsn= (MADB_Dsn *)GetWindowLongPtr(GetParent(hwndTab[0]), DWLP_USER); unsigned int new_page= GetNextActiveTab(CurrentPage, value); /* Save if last page or all following pages are disabled */ if (value > 0 && (CurrentPage == LASTPAGE || new_page== CurrentPage)) { GetDialogFields(); if (Dsn->isPrompt || SaveDSN(hDlg, Dsn)) { SendMessage(hwndMain, WM_DESTROY, 0, 0); } return; } ShowWindow(hwndTab[CurrentPage != (unsigned int)(-1) ? CurrentPage : 0], SW_HIDE); CurrentPage= new_page; ShowWindow(hwndTab[CurrentPage], SW_SHOW); DisableControls(Dsn); /* Disabling prev button if needed*/ new_page= GetNextActiveTab(CurrentPage, -1); EnableWindow(GetDlgItem(hwndTab[CurrentPage], PB_PREV), (CurrentPage != new_page) ? TRUE : FALSE); /* Switching caption of the Next/Finish button if needed*/ new_page= GetNextActiveTab(CurrentPage, 1); SendMessage(GetDlgItem(hwndTab[CurrentPage], PB_NEXT), WM_SETTEXT, 0, (CurrentPage == new_page) ? (LPARAM)"Finish" : (LPARAM)"Next >"); SetFocus(hwndTab[CurrentPage]); /* If not a prompt - disable finish button in case of empty DS name(for prompt it may be empty/invalid) TODO: I think it rather has to check if the name is valid DS name */ if (Dsn->isPrompt == MAODBC_CONFIG && CurrentPage == new_page) { EnableWindow(GetDlgItem(hwndTab[CurrentPage], PB_NEXT), Edit_GetTextLength(GetDlgItem(hwndTab[0], txtDsnName)) ? TRUE : FALSE); } }
static BOOL SaveFile(void) { BOOL bSuccess; HANDLE hEditBuffer; HCURSOR hSaveCursor; PSTR pEditBuffer; int IOStatus, length; FILE *fp; if ((fp = fopen(FileName, "w")) == NULL) { sprintf(buf, "Cannot write to %s.", FileName); WarningBox(buf); return(FALSE); } hSaveCursor = SetCursor(hHourGlass); length = Edit_GetTextLength(hEditWnd); hEditBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, length + 1); if (! hEditBuffer) { WarningBox("Not enough memory."); return FALSE; } pEditBuffer = LocalLock(hEditBuffer); GetWindowText(hEditWnd, pEditBuffer, length + 1); IOStatus = fwrite(pEditBuffer, 1, length, fp); fclose(fp); SetCursor(hSaveCursor); if (IOStatus != length) { sprintf(buf, "Error writing to %s.", FileName); WarningBox(buf); bSuccess = FALSE; } else { bSuccess = TRUE; bChanges = FALSE; } LocalUnlock(hEditBuffer); LocalFree(hEditBuffer); return(bSuccess); }
/* This function handles the WM_COMMAND message. */ void FASTCALL NewSig_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_EDIT: if( codeNotify == EN_CHANGE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { LPSTR lpText; HWND hwndEdit; register int c; lpText = (LPSTR)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); Edit_GetText( hwndEdit, lpText, 9 ); for( c = 0; lpText[ c ]; ++c ) if( !ValidFileNameChr( lpText[ c ] ) ) { wsprintf( lpTmpBuf, GS( IDS_STR136 ), lpText[ c ] ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION ); break; } if( lpText[ c ] ) { SetFocus( hwndEdit ); Edit_SetSel( hwndEdit, c, c + 1 ); Edit_ScrollCaret( hwndEdit ); break; } } case IDCANCEL: EndDialog( hwnd, id == IDOK ); break; } }
void SwitchTcpOrPipe(HWND hwnd, BOOL usePipe) { /* groups of fields to enable/disable*/ const int switchedFields[SWITCHED_GROUPS][MAX_GROUP_COTROLS]= {{IDC_EDIT_server, IDC_EDIT_port}, {IDC_EDIT_socket, 0}}; /* Default value for enabled empty field */ const LPCWSTR defaultValues[SWITCHED_GROUPS][MAX_GROUP_COTROLS]= {{NULL, NULL}, {L"MySQL", NULL}}; /* Can't be sure that usePipe contains 1 as TRUE*/ long activeIndex= usePipe ? 1L : 0L; for (long i= 0; i < SWITCHED_GROUPS; ++i) for (long j= 0; j < MAX_GROUP_COTROLS && switchedFields[i][j] != 0; ++j) { HWND control= GetDlgItem(hwnd, switchedFields[i][j]); EnableWindow(control, i == activeIndex); if (defaultValues[i][j] != NULL) { if (i == activeIndex) { if (Edit_GetTextLength(control) == 0) { /* remember that we set that value */ Edit_SetText(control, defaultValues[i][j]); controlWithDefValue= switchedFields[i][j]; } } else if (controlWithDefValue == switchedFields[i][j]) { /* we don't want to store the value we set instead of user */ Edit_SetText(control,L""); } } } }
/* This function handles the WM_COMMAND message. */ void FASTCALL NewBlinkEntryDlg_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_EDIT: if( codeNotify == EN_CHANGE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { LPSTR lpText; HWND hwndEdit; lpText = (LPSTR)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); Edit_GetText( hwndEdit, lpText, 40 ); } case IDCANCEL: EndDialog( hwnd, id == IDOK ); break; } }
void text_convert_to(HWND hdlgP, int id) { HWND hctl = GetDlgItem(hdlgP, IDC_ET_INTEGRATE_TEXT); int len = Edit_GetTextLength(hctl); tmalloc_free_lock lock(len + 1); Edit_GetText(hctl, lock.buf, lock.len); std::string str(ansi_2_utf8(lock.buf)); std::stringstream err; try { help::parse_text(str); } catch (game::error& e) { err << e.message; } catch (utils::invalid_utf8_exception&) { err << _("Encounter unknown format character!"); } if (!err.str().empty()) { err << "\n\n"; err << _("Exist grammar error, don't execute converting!"); MessageBox(NULL, utf8_2_ansi(err.str().c_str()), "Error", MB_OK | MB_ICONWARNING); return; } if (id == IDM_CONVERT_NORMAL) { // \\n\r\n to \r\n replace_all_distinct(str, null_str, "\\n\r\n", "\r\n"); } else if (id == IDM_CONVERT_POEDIT) { // \r\n to \\n\r\n replace_all_distinct(str, "\\n", "\r\n", "\\n\r\n"); } else { return; } Edit_SetText(GetDlgItem(hdlgP, IDC_ET_INTEGRATE_TEXT), utf8_2_ansi(str)); }
static void CLIB_DECL DetailsPrintf(const char *fmt, ...) { HWND hEdit; va_list marker; char buffer[2000]; TCHAR* t_s; int textLength; //RS 20030613 Different Ids for Property Page and Dialog // so see which one's currently instantiated hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS); if (hEdit == NULL) hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS_PROP); if (hEdit == NULL) { dprintf("audit detailsprintf() can't find any audit control\n"); return; } va_start(marker, fmt); vsprintf(buffer, fmt, marker); va_end(marker); t_s = tstring_from_utf8(ConvertToWindowsNewlines(buffer)); if( !t_s || _tcscmp(TEXT(""), t_s) == 0) return; textLength = Edit_GetTextLength(hEdit); Edit_SetSel(hEdit, textLength, textLength); SendMessage( hEdit, EM_REPLACESEL, FALSE, (WPARAM)(LPCTSTR)win_tstring_strdup(t_s) ); osd_free(t_s); }