void wlog(const char* buffer){ char* buf; int hloglen=GetWindowTextLength(hlog)+1; int slen=strlen(buffer)+1; if(slen<30000){ buf= new char[2];//hloglen+slen+1]; buf = (char*)Mrealloc(buf,hloglen+slen+1); memset(buf,0,hloglen+slen+1); if((hloglen+slen)<30000)GetWindowText(hlog,buf,hloglen); else{ char* tmpbuf=new char[2];tmpbuf = (char*)Mrealloc(tmpbuf,hloglen+1);GetWindowText(hlog,&tmpbuf[0],hloglen); //int oldsize;oldsize=sizeof(globallog); globallog = (char*)Mrealloc(globallog,hloglen+globallogsize+1); memcpy(&globallog[globallogsize],tmpbuf,hloglen-1);globallogsize+=hloglen; } lstrcat(buf,buffer); SetWindowText(hlog, buf); Edit_Scroll(hlog,Edit_GetLineCount(hlog),0); int wlen=GetWindowTextLength(hlog); Edit_SetSel(hlog,wlen-1,wlen); Edit_SetSel(hlog,wlen,wlen); SetFocus(hlog); ShowCaret(hlog); delete[] buf; } }
static void writeScreen(const char *msg, uint len) { if (MainWindow == 0) return; wchar_t buff[MAXOUTBUF]; mbstowcs(buff, msg, ARRAY_SIZE(buff)); HWND hConsole = GetDlgItem(MainWindow, ID_LOG); uint maxlen = SendMessage(hConsole, EM_GETLIMITTEXT, 0, 0); if (len >= maxlen) // Message wont fit on screen. return; // Remove lines until there is space in screen log uint tl; for (;;) { tl = GetWindowTextLength(hConsole); if (tl + len < maxlen) break; uint linelen = SendMessage(hConsole, EM_LINELENGTH, 0, 0) + 2; Edit_SetSel(hConsole, 0, linelen); Edit_ReplaceSel(hConsole, ""); } // Paste message to screen log Edit_SetSel(hConsole, tl, tl); Edit_ReplaceSel(hConsole, buff); }
/* * SendMailInitialize: Initialize dialog to reflect settings in "reply" variable. */ void SendMailInitialize(HWND hDlg, MailInfo *reply) { HWND hRecipients; int i; /* Set recipients, separated by commas in list box */ hRecipients = GetDlgItem(hDlg, IDC_RECIPIENTS); WindowBeginUpdate(hRecipients); for (i=0; i < reply->num_recipients; i++) { if (i != 0) { Edit_SetSel(hRecipients, -1, -1); Edit_ReplaceSel(hRecipients, ", "); } Edit_SetSel(hRecipients, -1, -1); Edit_ReplaceSel(hRecipients, reply->recipients[i]); } WindowEndUpdate(hRecipients); /* Set subject */ SetDlgItemText(hDlg, IDC_SUBJECT, reply->subject); // Free memory for reply info SafeFree(reply); }
// insert text at last void editInsertTextAtLast(HWND i_hwnd, const tstring &i_text, size_t i_threshold) { if (i_text.empty()) return; size_t len = editGetTextBytes(i_hwnd); if (i_threshold < len) { Edit_SetSel(i_hwnd, 0, len / 3 * 2); Edit_ReplaceSel(i_hwnd, _T("")); editDeleteLine(i_hwnd, 0); len = editGetTextBytes(i_hwnd); } Edit_SetSel(i_hwnd, len, len); // \n -> \r\n Array<_TCHAR> buf(i_text.size() * 2 + 1); _TCHAR *d = buf.get(); const _TCHAR *str = i_text.c_str(); for (const _TCHAR *s = str; s < str + i_text.size(); ++ s) { if (*s == _T('\n')) *d++ = _T('\r'); *d++ = *s; } *d = _T('\0'); Edit_ReplaceSel(i_hwnd, buf.get()); }
void CPathEditUI::ShowEditWnd() { if (m_pWindow == NULL) { m_pWindow = new CPathEditWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); TCHAR text[MAX_PATH] = {0}; GetWindowText(m_pWindow->GetHWND(), text, MAX_PATH); LPTSTR lpt = StrRChr(text, NULL, _T('.')); if (lpt != NULL) { int nSize = lpt - text; Edit_SetSel(*m_pWindow, 0, nSize); } else { int nSize = GetWindowTextLength(*m_pWindow); if( nSize == 0 ) nSize = 1; Edit_SetSel(*m_pWindow, 0, nSize); } } }
void _uprintf(const char *format, ...) { char buf[4096], *p = buf; va_list args; int n; va_start(args, format); n = safe_vsnprintf(p, sizeof(buf)-3, format, args); // buf-3 is room for CR/LF/NUL va_end(args); p += (n < 0)?sizeof(buf)-3:n; while((p>buf) && (isspace((unsigned char)p[-1]))) *--p = '\0'; *p++ = '\r'; *p++ = '\n'; *p = '\0'; // Send output to Windows debug facility OutputDebugStringA(buf); // Send output to our log Window Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE); Edit_ReplaceSelU(hLog, buf); // Make sure the message scrolls into view // (Or see code commented in LogProc:WM_SHOWWINDOW for a less forceful scroll) SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0)); }
// TextCursor auf übergebene Position setzen void SetTextCursor (HWND hWin, char *pCmdLine) { short iEnd = 1, /* Cursor-Position x/y */ iStart = 1; char *pStrBeg = pCmdLine; // Position im String suchen pStrBeg = strstr (pStrBeg, "-p"); // bei Datei-Übergabe if (pStrBeg) { // Position OK pStrBeg += 2; iStart = atoi (pStrBeg); if (!iStart) iStart = 1; else { // nächsten Separator suchen while (*pStrBeg && *pStrBeg >= '0' && *pStrBeg <= '9') pStrBeg++; if (*pStrBeg == ',') iEnd = atoi (++pStrBeg); } } // korrigiere ggf. End-Pos. if (iEnd < iStart) iEnd = iStart; // Text markieren Edit_SetSel (hWin, --iStart, --iEnd); }
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); }
BOOL CALLBACK SavePlaylistDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { BOOL result = FALSE; static char* szName = NULL; switch (msg) { case WM_INITDIALOG: { HWND hwndName = GetDlgItem(hwnd, IDC_NAME); szName = (char*)lParam; SetFocus(hwndName); Edit_SetText(hwndName, szName); Edit_SetSel(hwndName, 0, -1); SetProp(hwndName, "oldproc", (HANDLE)GetWindowLong(hwndName, GWL_WNDPROC)); // Subclass the window so we can handle bad characters SetWindowLong(hwndName, GWL_WNDPROC, (DWORD)::EditWndProc); return FALSE; break; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDCANCEL: EndDialog(hwnd, FALSE); break; case IDOK: { HWND hwndName = GetDlgItem(hwnd, IDC_NAME); Edit_GetText(hwndName, szName, MAX_PATH); EndDialog(hwnd, TRUE); break; } } break; } } return result; }
// selects all text in an edit box if it's selected either // through a keyboard shortcut or a non-selecting mouse click // (or responds to Ctrl+Backspace as nowadays expected) bool ExtendedEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { UNUSED(lParam); static bool delayFocus = false; switch (message) { case WM_LBUTTONDOWN: delayFocus = GetFocus() != hwnd; return true; case WM_LBUTTONUP: if (delayFocus) { DWORD sel = Edit_GetSel(hwnd); if (LOWORD(sel) == HIWORD(sel)) PostMessage(hwnd, UWM_DELAYED_SET_FOCUS, 0, 0); delayFocus = false; } return true; case WM_KILLFOCUS: return false; // for easier debugging (make setting a breakpoint possible) case WM_SETFOCUS: if (!delayFocus) PostMessage(hwnd, UWM_DELAYED_SET_FOCUS, 0, 0); return true; case UWM_DELAYED_SET_FOCUS: Edit_SelectAll(hwnd); return true; case WM_KEYDOWN: if (VK_BACK != wParam || !IsCtrlPressed() || IsShiftPressed()) return false; PostMessage(hwnd, UWM_DELAYED_CTRL_BACK, 0, 0); return true; case UWM_DELAYED_CTRL_BACK: { ScopedMem<WCHAR> text(win::GetText(hwnd)); int selStart = LOWORD(Edit_GetSel(hwnd)), selEnd = selStart; // remove the rectangle produced by Ctrl+Backspace if (selStart > 0 && text[selStart - 1] == '\x7F') { memmove(text + selStart - 1, text + selStart, str::Len(text + selStart - 1) * sizeof(WCHAR)); win::SetText(hwnd, text); selStart = selEnd = selStart - 1; } // remove the previous word (and any spacing after it) for (; selStart > 0 && str::IsWs(text[selStart - 1]); selStart--); for (; selStart > 0 && !str::IsWs(text[selStart - 1]); selStart--); Edit_SetSel(hwnd, selStart, selEnd); SendMessage(hwnd, WM_CLEAR, 0, 0); } return true; default: return false; } }
long CALLBACK InterfaceAdminInputProc(HWND hwnd, UINT message, UINT wParam, LONG lParam) { char buf[200]; switch (message) { case WM_CHAR : if (wParam == '\r') { if (InMainLoop() && !GetQuit()) { /* make sure we've started already, so that session id is valid */ Edit_SetSel(hwnd,0,-1); Edit_GetText(hwnd,buf,sizeof buf); cprintf(console_session_id,"%s\n",buf); EnterServerLock(); TryAdminCommand(console_session_id,buf); LeaveServerLock(); } return 0; } if (wParam == '\t') { SetFocus(GetDlgItem(HWND_ADMIN,IDC_ADMIN_RESPONSE)); return 0; } } return CallWindowProc(lpfnDefAdminInputProc,hwnd,message,wParam,lParam); }
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 ); }
static void OnButtonBrowse() { ScopedMem<WCHAR> installDir(win::GetText(gHwndTextboxInstDir)); // strip a trailing "\SumatraPDF" if that directory doesn't exist (yet) if (!dir::Exists(installDir)) installDir.Set(path::GetDir(installDir)); WCHAR path[MAX_PATH]; BOOL ok = BrowseForFolder(gHwndFrame, installDir, _TR("Select the folder where SumatraPDF should be installed:"), path, dimof(path)); if (!ok) { SetFocus(gHwndButtonBrowseDir); return; } WCHAR *installPath = path; // force paths that aren't entered manually to end in ...\SumatraPDF // to prevent unintended installations into e.g. %ProgramFiles% itself if (!str::EndsWithI(path, L"\\" APP_NAME_STR)) installPath = path::Join(path, APP_NAME_STR); win::SetText(gHwndTextboxInstDir, installPath); Edit_SetSel(gHwndTextboxInstDir, 0, -1); SetFocus(gHwndTextboxInstDir); if (installPath != path) free(installPath); }
static INT_PTR CALLBACK Window_StopwatchExportDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { (void)lParam; // unused switch(msg) { case WM_INITDIALOG:{ wchar_t buf[128]; api.GetStr(L"Timers", L"SwExT", buf, _countof(buf), L""); SetDlgItemText(hDlg,IDC_SWE_TOTAL,buf); api.GetStr(L"Timers", L"SwExL", buf, _countof(buf), L""); SetDlgItemText(hDlg, IDC_SWE_LAP, buf); SendMessage(hDlg, WM_COMMAND,IDOK, 0); Edit_SetSel(GetDlgItem(hDlg,IDC_SWE_OUT), 0, -1); SetFocus(GetDlgItem(hDlg,IDC_SWE_OUT)); return FALSE;} case WM_DESTROY:{ break;} case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_SWE_EXPORT:{ wchar_t filename[MAX_PATH]; unsigned buflen = (unsigned)SendDlgItemMessageA(hDlg,IDC_SWE_OUT,WM_GETTEXTLENGTH,0,0); char* buf = malloc(buflen + 1); if(buf && buflen){ GetDlgItemTextA(hDlg, IDC_SWE_OUT, buf, buflen+1); *filename = '\0'; if(SaveFileDialog(hDlg,filename,_countof(filename))){ FILE* fp = _wfopen(filename, L"wb"); if(fp){ fwrite(buf, sizeof(buf[0]), buflen, fp); fclose(fp); } } } free(buf); break;} case IDOK:{ wchar_t buf[128]; GetDlgItemText(hDlg, IDC_SWE_TOTAL, buf, _countof(buf)); if(!*buf){ api.DelValue(L"Timers", L"SwExT"); SetDlgItemText(hDlg, IDC_SWE_TOTAL, L"\\n--------------------\\n\\t"); }else api.SetStr(L"Timers", L"SwExT", buf); GetDlgItemText(hDlg, IDC_SWE_LAP, buf, _countof(buf)); if(!*buf){ api.DelValue(L"Timers", L"SwExL"); SetDlgItemText(hDlg, IDC_SWE_LAP, L"Lap \\#\\f: \\l (\\t)\\n"); }else api.SetStr(L"Timers", L"SwExL", buf); export_text(hDlg); break;} case IDCANCEL: EndDialog(hDlg, TRUE); } return TRUE; } } return FALSE; }
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 current_path_to_edit (void) { int cur; HWND manpath = GetDlgItem(hMainWindow, IDC_MANPATH); cur = LOWORD(Edit_GetSel (manpath)); Edit_SetText (manpath, CurrentPath); Edit_SetSel (manpath, cur, cur); }
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 ); }
static void on_recent_select (void) { HWND edit = GetDlgItem(hMainWindow, IDC_TXT); const char *txt = recent_get_by_list (IDC_RECENT); Edit_SetText (edit, txt); Edit_SetSel (edit, 0, -1); SetFocus(edit); }
// // 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); }
static void console_addline(char *str) { HWND hCtrl; int index; hCtrl = GetDlgItem(hConsole,IDC_CONSOLEEDIT); index = GetWindowTextLength(hCtrl); Edit_SetSel(hCtrl,index,index); Edit_ReplaceSel(hCtrl,str); }
// delete a line void editDeleteLine(HWND i_hwnd, size_t i_n) { int len = Edit_LineLength(i_hwnd, i_n); if (len < 0) return; len += 2; int index = Edit_LineIndex(i_hwnd, i_n); Edit_SetSel(i_hwnd, index, index + len); Edit_ReplaceSel(i_hwnd, _T("")); }
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); }
/* This function writes the appropriate signature for the specified * topic. */ void FASTCALL SetEditSignature( HWND hwndEdit, PTL ptl ) { LPSTR lpszSignature; char * pszSig; pszSig = NULL; if( NULL == ptl ) pszSig = szGlobalSig; else { TOPICINFO topicinfo; Amdb_GetTopicInfo( ptl, &topicinfo ); if( topicinfo.szSigFile[ 0 ] ) pszSig = topicinfo.szSigFile; } if( NULL != pszSig ) if( NULL != ( lpszSignature = GetEditSignature( pszSig ) ) ) { DWORD dwSig1Sel; /* Save the caret position and append the signature to the end of the * current text. Then put the caret back where it was. */ dwSig1Sel = Edit_GetSel( hwndEdit ); if( fEditAtTop ) { Edit_SetSel( hwndEdit, 0, 0 ); Edit_ReplaceSel( hwndEdit, lpszSignature ); Edit_SetSel( hwndEdit, 0, 0 ); Edit_ScrollCaret( hwndEdit ); } else { Edit_SetSel( hwndEdit, USHRT_MAX, USHRT_MAX ); Edit_ReplaceSel( hwndEdit, lpszSignature ); Edit_SetSel( hwndEdit, LOWORD(dwSig1Sel), HIWORD(dwSig1Sel) ); } FreeMemory( &lpszSignature ); } }
//************************************************************************ void CBelongsScene::ToonInitDone() //************************************************************************ { STRING szName; ShowDlgItem(m_hWnd, IDC_EDIT, TRUE); UpdateWindow(GetDlgItem(m_hWnd, IDC_EDIT)); SetFocus(GetDlgItem(m_hWnd, IDC_EDIT)); //GetApp()->GetSettingString("Name", szName, "", FALSE); szName[0] = '\0'; if (lstrlen(szName)) { SetDlgItemText(m_hWnd, IDC_EDIT, szName); Edit_SetSel(GetDlgItem(m_hWnd, IDC_EDIT), 0, -1); Edit_SetSel(GetDlgItem(m_hWnd, IDC_EDIT), -1, 0); UpdateWindow(GetDlgItem(m_hWnd, IDC_EDIT)); PlayBelongsTo(NO); FORWARD_WM_COMMAND(m_hWnd, IDC_NEXT, m_hWnd, 0, PostMessage); } else { FNAME szFileName; GetPathName(szFileName, ENTER_NAME_WAVE); if (m_hSound) { MCIStop(m_hSound,YES); MCIClose(m_hSound); m_hSound = NULL; } m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szFileName, NULL); if (m_hSound) { if (!MCIPlay(m_hSound, m_hWnd)) { MCIClose(m_hSound); m_hSound = NULL; } } } }
void Dlg_CreateReport (HWND hwndEdit) { TCHAR szBuf[500]; // Line buffer int i, nVisLine; DWORD dwMin, dwMax; float rAvg, rStdDev; // Disable updates to prevent the edit box from scrolling. SetWindowRedraw(hwndEdit, FALSE); Dlg_IntervalStat(g_pdwTickSamples, g_nSamplesMax, &dwMin, &dwMax, &rAvg, &rStdDev); // Clear the report. Edit_SetText(hwndEdit, _TEXT("")); // Write the report. _stprintf(szBuf, _TEXT("Period (mS): %lu\r\n") _TEXT("Sample Size: %lu\r\n") _TEXT("\r\n") _TEXT("Interval Statistics\r\n") _TEXT(" Avg. Period: %.3f\r\n") _TEXT(" Min. Period: %lu\r\n") _TEXT(" Max. Period: %lu\r\n") _TEXT(" Standard Dev.: %.3f\r\n") _TEXT("\r\n") _TEXT("Timer Samples:"), g_uPeriod, g_nSamplesMax, rAvg, dwMin, dwMax, (double) rStdDev); Dlg_AppendEditText(hwndEdit, szBuf); _tcscpy(szBuf, _TEXT("\r\n")); for (i = 0; i < g_nSamplesMax; i++) { _ultot(g_pdwTickSamples[i], szBuf + 2, 10); Dlg_AppendEditText(hwndEdit, szBuf); } // Move caret to start of text. Edit_SetSel(hwndEdit, 0, 0); // Make first report line first visible line. nVisLine = Edit_GetFirstVisibleLine(hwndEdit); Edit_Scroll(hwndEdit, -nVisLine, 0); // Enable updates, and force update. SetWindowRedraw(hwndEdit, TRUE); InvalidateRect(hwndEdit, NULL, TRUE); }
void edit_info_append (const char *msg) { HWND hwndEditInfo; int len; hwndEditInfo = GetDlgItem (hwndDlg, IDC_EDT_INFO); len = GetWindowTextLength (hwndEditInfo); SetFocus (hwndEditInfo); Edit_SetSel (hwndEditInfo, len, len); Edit_ReplaceSel (hwndEditInfo, msg); }
INT_PTR WINAPI DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { hEdit = GetDlgItem(hDlg, IDC_EDITCTRL); OriginalProc = (WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, LONG(EditProc)); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BTNCUT: // Cut break; case IDC_BTNPASTE: // Paste break; case IDC_BTNCOPY: // Copy break; case IDC_BTNSELECTALL: // Select All //MessageBox(hDlg, TEXT("catch"), TEXT("info"), 0); //SendDlgItemMessage(hDlg, IDC_EDIT1, EM_SETSEL, 0, -1); //SendMessage(hEdit, EM_SETSEL, 1, -1); Edit_SetSel(hEdit, 0, -1); break; case IDC_BTNCLEAR: // Clear //Edit_SetSel(hEdit, 0, -1); SendDlgItemMessage(hDlg, IDC_EDITCTRL, WM_CLEAR, NULL, NULL); break; case IDC_BTNUNDO: // Undo if (SendDlgItemMessage(hDlg, IDC_EDITCTRL, EM_CANUNDO, NULL, NULL)) { SendDlgItemMessage(hDlg, IDC_EDITCTRL, WM_UNDO, NULL, NULL); } break; case IDOK: case IDCANCEL: SendMessage(hDlg, WM_CLOSE, NULL, NULL); break; default: return FALSE; } return TRUE; case WM_CLOSE: EndDialog(hDlg, 0); return TRUE; default: return FALSE; } return FALSE; }
LRESULT CALLBACK searchInputProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) { const char *txt; if (msg == WM_GETDLGCODE) return DLGC_WANTALLKEYS; switch (msg) { case WM_KEYDOWN: switch (wParam) { case VK_RETURN: //Do your stuff on_search_click (); return 0; break; //or return 0; if you don't want to pass it further to def proc //If not your key, skip to default: case VK_DOWN: txt = recent_current_decrement (); Edit_SetText (wnd, txt); Edit_SetSel (wnd, 0, -1); return 0; break; case VK_UP: txt = recent_current_increment (); Edit_SetText (wnd, txt); Edit_SetSel (wnd, 0, -1); return 0; break; case VK_TAB: SetFocus (GetNextDlgTabItem(hMainWindow, wnd, GetAsyncKeyState(VK_SHIFT) & 0x8000 ? TRUE : FALSE)); return 0; default: return CallWindowProc(oldsearchInputProc, wnd, msg, wParam, lParam); } default: //printf ("msg = 0x%X %X %X\n", msg, wParam, lParam); return CallWindowProc(oldsearchInputProc, wnd, msg, wParam, lParam); } return 0; }
/*----------------------------------------------------------------------------*\ \*----------------------------------------------------------------------------*/ void AppPrint(LPTSTR sz,...) { HWND hwndE = GetWindow(hwndApp, GW_CHILD); TCHAR ach[128]; va_list marker; va_start( marker, sz ); if (hwndE == NULL) { RECT rc; GetClientRect(hwndApp, &rc); hwndE = CreateWindow (TEXT("Edit"), TEXT(""), WS_VISIBLE | WS_CHILD | ES_MULTILINE | ES_READONLY | WS_VSCROLL | ES_AUTOVSCROLL, 0, 0, rc.right, rc.bottom, hwndApp, (HMENU)-1, hInstApp, NULL); SetWindowFont(hwndE, GetStockObject(ANSI_FIXED_FONT), TRUE); } if (sz == NULL) { Edit_SetSel(hwndE, 0, (UINT)-1); Edit_ReplaceSel(hwndE, TEXT("")); } else { wvsprintf (ach,(LPCTSTR)sz,marker); /* Format the string */ lstrcat(ach, TEXT("\r\n")); Edit_SetSel(hwndE, (UINT)-1, (UINT)-1); Edit_ReplaceSel(hwndE, ach); } va_end(marker); }