Ejemplo n.º 1
0
	int sqlQueryCallback(void *arg, int argc, char **argv, char **azColName)
	{
		HWND hRes = static_cast<HWND>(arg);
		
		std::ostringstream ss;
		int len = GetWindowTextLengthW(hRes);
		if(len < 4096)
		{
			if(len > 0)
			{
				wchar_t* prev = new wchar_t[len+2];
				GetWindowTextW(hRes, prev, len+1);
				utfstring wPrev(prev);
				delete [] prev;
				ss << wPrev.toUTF8() << "\r\n";
			}
		}
		else
			return SQLITE_TOOBIG;

		for(int i=0; i<argc; i++)
		{
			if(azColName[i])
				ss << azColName[i] << ": " << argv[i] << "\r\n";
		}

		utfstring ws(ss.str().c_str());
		SetWindowText(hRes, ws.toUTF16());

		return SQLITE_OK;
	}
Ejemplo n.º 2
0
static INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HWND hEdit;

    switch(uMsg)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam)) {
            case IDOK:
                memset(globals.wszMachineName, 0, sizeof(WCHAR[MAX_LOAD_STRING]));
                hEdit = GetDlgItem(hDlgWnd, IDC_MACHINE);

                if (GetWindowTextLengthW(hEdit)>0)
                    GetWindowTextW(hEdit, globals.wszMachineName, MAX_LOAD_STRING);

                EndDialog(hDlgWnd, IDOK);
                return TRUE;
            case IDCANCEL:
                EndDialog(hDlgWnd, IDCANCEL);
                return TRUE;
            }
    }

    return FALSE;
}
Ejemplo n.º 3
0
static void
starlog_log(Starlog *s)
{
	const size_t MAX_BYTES = 1024;
	unsigned short *log = NULL;
	DWORD textlen, loglen;
	SYSTEMTIME t;

	GetLocalTime(&t);
	textlen = GetWindowTextLengthW(s->edit_log);
	if(!textlen) {
		return;
	}
	log = HeapAlloc(GetProcessHeap(), 0, sizeof(char)*MAX_BYTES);
	loglen = wsprintfW(log, L"~~~ %02d.%02d.%04d %02d:%02d:%02d ~~~\r\n",
		t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond);
	loglen += GetWindowTextW(s->edit_log, &log[loglen],
		sizeof(short)*(MAX_BYTES-loglen));
	log[loglen] = '\r';
	log[loglen+1] = '\n';
	log[loglen+2] = 0;
	if(loglen) {
		HANDLE fd = CreateFile(".\\star.log",
			FILE_APPEND_DATA, FILE_SHARE_READ,
			NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(fd==INVALID_HANDLE_VALUE) {
			return;
		}
		DWORD n = lstrlenW(log);
		WriteFile(fd, log, n*sizeof(short), &n, 0);
		CloseHandle(fd);
	}
	HeapFree(GetProcessHeap(), 0, log);
}
Ejemplo n.º 4
0
VOID DIALOG_EditWrap(VOID)
{
    BOOL modify = FALSE;
    static const WCHAR editW[] = { 'e','d','i','t',0 };
    DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL |
                    ES_AUTOVSCROLL | ES_MULTILINE;
    RECT rc;
    DWORD size;
    LPWSTR pTemp;

    size = GetWindowTextLengthW(Globals.hEdit) + 1;
    pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
    if (!pTemp)
    {
        ShowLastError();
        return;
    }
    GetWindowTextW(Globals.hEdit, pTemp, size);
    modify = SendMessageW(Globals.hEdit, EM_GETMODIFY, 0, 0);
    DestroyWindow(Globals.hEdit);
    GetClientRect(Globals.hMainWnd, &rc);
    if( Globals.bWrapLongLines ) dwStyle |= WS_HSCROLL | ES_AUTOHSCROLL;
    Globals.hEdit = CreateWindowExW(WS_EX_CLIENTEDGE, editW, NULL, dwStyle,
                         0, 0, rc.right, rc.bottom, Globals.hMainWnd,
                         NULL, Globals.hInstance, NULL);
    SendMessageW(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
    SetWindowTextW(Globals.hEdit, pTemp);
    SendMessageW(Globals.hEdit, EM_SETMODIFY, modify, 0);
    SetFocus(Globals.hEdit);
    HeapFree(GetProcessHeap(), 0, pTemp);
    
    Globals.bWrapLongLines = !Globals.bWrapLongLines;
    CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP,
        MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED));
}
Ejemplo n.º 5
0
/**
 * Returns:
 *   TRUE  - User agreed to close (both save/don't save)
 *   FALSE - User cancelled close by selecting "Cancel"
 */
BOOL DoCloseFile(void)
{
    int nResult;
    static const WCHAR empty_strW[] = { 0 };

    nResult=GetWindowTextLengthW(Globals.hEdit);
    if (SendMessageW(Globals.hEdit, EM_GETMODIFY, 0, 0) &&
        (nResult || Globals.szFileName[0]))
    {
        /* prompt user to save changes */
        nResult = AlertFileNotSaved(Globals.szFileName);
        switch (nResult) {
            case IDYES:     return DIALOG_FileSave();

            case IDNO:      break;

            case IDCANCEL:  return(FALSE);

            default:        return(FALSE);
        } /* switch */
    } /* if */

    SetFileNameAndEncoding(empty_strW, ENCODING_ANSI);

    UpdateWindowCaption();
    return(TRUE);
}
Ejemplo n.º 6
0
void NFOView::CopySelectedText(void)
{
    DWORD selStart;
    DWORD selEnd;
    SendMessage(_handle, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);

    if (selEnd > selStart)
    {
        int textLength = GetWindowTextLengthW(_handle);
        if (textLength > 0)
        {
            HGLOBAL selTextHandle;
            selTextHandle = GlobalAlloc(GHND, sizeof(wchar_t)*(selEnd - selStart + 1));

            // copy selected text to memory
            wchar_t* selText = (wchar_t*)GlobalLock(selTextHandle);
            memcpy(selText, _nfoText.c_str()+selStart, (selEnd-selStart)*sizeof(wchar_t));
            GlobalUnlock(selTextHandle);

            // copy to clipboard
            if (!OpenClipboard(_handle))
            { 
                return;
            }
            EmptyClipboard();
            SetClipboardData(CF_UNICODETEXT, selTextHandle);
            CloseClipboard();
        }
    }
    
    // deselect text after copy
    SendMessage(_handle, EM_SETSEL, (WPARAM)-1, (LPARAM)0);
}
Ejemplo n.º 7
0
static LPWSTR
GetStringFromDialog(PCREATE_DATA Data,
                    UINT id)
{
    HWND hwnd;
    LPWSTR lpString = NULL;
    INT iLen = 0;

    hwnd = GetDlgItem(Data->hSelf,
                      id);
    if (hwnd)
    {
        iLen = GetWindowTextLengthW(hwnd);
        if (iLen)
        {
            lpString = (LPWSTR)HeapAlloc(ProcessHeap,
                                         0,
                                         (iLen + 1) * sizeof(WCHAR));
            if (lpString)
            {
                GetWindowTextW(hwnd,
                               lpString,
                               iLen + 1);
            }
        }
    }

    return lpString;
}
Ejemplo n.º 8
0
int GetWindowTextUTF8(HWND hWnd, LPTSTR lpString, int nMaxCount)
{
  if (!lpString) return 0;
  if (nMaxCount>0 AND_IS_NOT_WIN9X)
  {
    int alloc_size=nMaxCount;

    // prevent large values of nMaxCount from allocating memory unless the underlying text is big too
    if (alloc_size > 512)  
    {
      int l=GetWindowTextLengthW(hWnd);
      if (l>=0 && l < 512) alloc_size=1000;
    }

    {
      WIDETOMB_ALLOC(wbuf, alloc_size);
      if (wbuf)
      {
        GetWindowTextW(hWnd,wbuf,(int) (wbuf_size/sizeof(WCHAR)));

        if (!WideCharToMultiByte(CP_UTF8,0,wbuf,-1,lpString,nMaxCount,NULL,NULL) && GetLastError()==ERROR_INSUFFICIENT_BUFFER)
          lpString[nMaxCount-1]=0;

        WIDETOMB_FREE(wbuf);

        return (int)strlen(lpString);
      }
    }
  }
  return GetWindowTextA(hWnd,lpString,nMaxCount);
}
Ejemplo n.º 9
0
void
win_copy_title(void)
{
  int len = GetWindowTextLengthW(wnd);
  wchar title[len + 1];
  len = GetWindowTextW(wnd, title, len + 1);
  win_copy(title, 0, len + 1);
}
Ejemplo n.º 10
0
        String Win32Window::GetTitle()
        {
            int l = GetWindowTextLengthW(hWnd);
            if (l == 0) return String();

            Utf16String titleW = Utf16String::Create(l);
            l = GetWindowText(hWnd, titleW.Ptr(), l);

            return Unicode::Utf16To8(titleW);
        }
Ejemplo n.º 11
0
void
win_prefix_title(const char * prefix)
{
  int len = GetWindowTextLengthW(wnd);
  wchar ptitle[strlen(prefix) + len + 1];
  int plen = cs_mbstowcs(ptitle, prefix, lengthof(ptitle));
  wchar * title = & ptitle[plen];
  len = GetWindowTextW(wnd, title, len + 1);
  SetWindowTextW(wnd, ptitle);
}
void MyGetWindowText(ScriptValue &s, ScriptValue *args) {
	int len = GetWindowTextLengthW((HWND)args[0].intVal);
	if (len > 0) {
		len += 200;
		wchar_t *temp = (wchar_t*) malloc(sizeof(wchar_t) * len);
		int len2 = GetWindowTextW((HWND)args[0].intVal, temp, len);
		CreateStringValue(s, temp, len2);
		free(temp);
	}
}
Ejemplo n.º 13
0
void
win_save_title(void)
{
  int len = GetWindowTextLengthW(wnd);
  wchar *title = newn(wchar, len + 1);
  GetWindowTextW(wnd, title, len + 1);
  delete(titles[titles_i]);
  titles[titles_i++] = title;
  if (titles_i == lengthof(titles))
    titles_i = 0;
}
Ejemplo n.º 14
0
static BOOL IPADDRESS_IsBlank (IPADDRESS_INFO *infoPtr)
{
    int i;

    TRACE("\n");

    for (i = 0; i < 4; i++)
        if (GetWindowTextLengthW (infoPtr->Part[i].EditHwnd)) return FALSE;

    return TRUE;
}
Ejemplo n.º 15
0
static
HFONT
SetLrgFont(PMAP infoPtr)
{
    LOGFONTW lf;
    HFONT hFont = NULL;
    HDC hdc;
    HWND hCombo;
    LPWSTR lpFontName;
    INT Len;

    hCombo = GetDlgItem(infoPtr->hParent,
                        IDC_FONTCOMBO);

    Len = GetWindowTextLengthW(hCombo);

    if (Len != 0)
    {
        lpFontName = HeapAlloc(GetProcessHeap(),
                               0,
                               (Len + 1) * sizeof(WCHAR));

        if (lpFontName)
        {
            SendMessageW(hCombo,
                         WM_GETTEXT,
                         Len + 1,
                         (LPARAM)lpFontName);

            ZeroMemory(&lf,
                       sizeof(lf));

            hdc = GetDC(infoPtr->hLrgWnd);
            lf.lfHeight = GetDeviceCaps(hdc,
                                        LOGPIXELSY) / 2;
            ReleaseDC(infoPtr->hLrgWnd,
                      hdc);

            lf.lfCharSet =  DEFAULT_CHARSET;
            wcsncpy(lf.lfFaceName,
                    lpFontName,
                    sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]));

            hFont = CreateFontIndirectW(&lf);

            HeapFree(GetProcessHeap(),
                     0,
                     lpFontName);
        }
    }

    return hFont;
}
Ejemplo n.º 16
0
NzString NzWindowImpl::GetTitle() const
{
	unsigned int titleSize = GetWindowTextLengthW(m_handle);
	if (titleSize == 0)
		return NzString();

	titleSize++; // Caractère nul

	std::unique_ptr<wchar_t[]> wTitle(new wchar_t[titleSize]);
	GetWindowTextW(m_handle, wTitle.get(), titleSize);

	return NzString::Unicode(wTitle.get());
}
Ejemplo n.º 17
0
String Window::getWindowText(HWND hWnd)
{
  int wsize = GetWindowTextLengthW(hWnd);
  wchar_t* buf = new wchar_t[wsize + 1];
  GetWindowTextW(hWnd, buf, wsize + 1);
  int size = WideCharToMultiByte(CP_UTF8, 0, buf, wsize, NULL, 0, NULL, NULL);
  String str;
  str.resize(size);
  WideCharToMultiByte(CP_UTF8, 0, buf, wsize, str.getBuffer(), size, NULL, NULL);
  str.setLength(size);
  delete[] buf;
  return str;
}
Ejemplo n.º 18
0
static void EnableOKButton(HWND hwnd){
	switch(m_DlgId){
		case DLG_LOGIN_MAIN:
			if(GetWindowTextLengthW(GetDlgItem(hwnd, IDC_EDT_PWRD_MAIN)) > 0)
				EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
			else
				EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
			break;
		case DLG_LOGIN_CREATE:
			if(GetWindowTextLengthW(GetDlgItem(hwnd, IDC_EDT_PWRD_MAIN)) > 0 && GetWindowTextLengthW(GetDlgItem(hwnd, IDC_EDT_PWRD_SECOND)) > 0)
				EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
			else
				EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
			break;
		case DLG_LOGIN_CHANGE:
			if(GetWindowTextLengthW(GetDlgItem(hwnd, IDC_EDT_PWRD_MAIN)) > 0 && GetWindowTextLengthW(GetDlgItem(hwnd, IDC_EDT_PWRD_SECOND)) > 0 && GetWindowTextLengthW(GetDlgItem(hwnd, IDC_EDT_PWRD_NEW)) > 0)
				EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
			else
				EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
			break;
	}
}
Ejemplo n.º 19
0
std::string ZLWin32ApplicationWindow::TextEditParameter::internalValue() const {
	int len = GetWindowTextLengthW(myComboBox);
	if (len == 0) {
		return "";
	}
	static ZLUnicodeUtil::Ucs2String buffer;
	buffer.assign(len + 1, '\0');
	GetWindowTextW(myComboBox, (WCHAR*)::wchar(buffer), len + 1);
	buffer.pop_back();
	std::string text;
	ZLUnicodeUtil::ucs2ToUtf8(text, buffer);
	return text;
}
Ejemplo n.º 20
0
/**********************************************************************
 * AtlAxWin class window procedure
 */
static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
    if ( wMsg == WM_CREATE )
    {
            DWORD len = GetWindowTextLengthW( hWnd ) + 1;
            WCHAR *ptr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
            if (!ptr)
                return 1;
            GetWindowTextW( hWnd, ptr, len );
            AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
            HeapFree( GetProcessHeap(), 0, ptr );
            return 0;
    }
    return DefWindowProcW( hWnd, wMsg, wParam, lParam );
}
Ejemplo n.º 21
0
bool CWindow::GetText(UString &s)
{
  if (g_IsNT)
  {
    s.Empty();
    int length = GetWindowTextLengthW(_window);
    if (length == 0)
      return (::GetLastError() == ERROR_SUCCESS);
    length = GetWindowTextW(_window, s.GetBuffer(length), length + 1);
    s.ReleaseBuffer();
    if (length == 0)
      return (::GetLastError() == ERROR_SUCCESS);
    return true;
  }
  CSysString sysString;
  bool result = GetText(sysString);
  s = GetUnicodeString(sysString);
  return result;
}
Ejemplo n.º 22
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, 
    WPARAM wParam, LPARAM lParam) {

    static HWND hwndEdit;
    HWND hwndButton;

    switch(msg) {

        case WM_CREATE:

            hwndEdit = CreateWindowW(L"Edit", NULL, 
                WS_CHILD | WS_VISIBLE | WS_BORDER,
                50, 50, 150, 20, hwnd, (HMENU) ID_EDIT,
                 NULL, NULL);

            hwndButton = CreateWindowW(L"button", L"Set title",
                WS_VISIBLE | WS_CHILD, 50, 100, 80, 25,
                hwnd, (HMENU) ID_BUTTON, NULL, NULL);

            break;

        case WM_COMMAND:	

            if (HIWORD(wParam) == BN_CLICKED) {

                int len = GetWindowTextLengthW(hwndEdit) + 1;
                wchar_t text[len];

                GetWindowTextW(hwndEdit, text, len);
                SetWindowTextW(hwnd, text);
            }

            break;

        case WM_DESTROY:
            PostQuitMessage(0);
            break;
    }

    return DefWindowProcW(hwnd, msg, wParam, lParam);
}
Ejemplo n.º 23
0
void ConsoleDialog::runStatement()
{
	assert(m_console != NULL);
	if (m_console)
	{
		
		HWND hText = ::GetDlgItem(_hSelf, IDC_INPUT);
		size_t length = GetWindowTextLengthW(hText);
		TCHAR *buffer = new TCHAR[length + 1];
		GetWindowText(hText, buffer, length + 1);
		historyAdd(buffer);
		std::shared_ptr<char> charBuffer = WcharMbcsConverter::tchar2char(buffer);
		delete [] buffer;

		writeText(m_prompt.size(), m_prompt.c_str());
		writeText(strlen(charBuffer.get()), charBuffer.get());
		writeText(1, "\n");
		SetWindowText(hText, _T(""));
		m_console->runStatement(charBuffer.get());
	}
}
Ejemplo n.º 24
0
VDStringW VDGetWindowTextW32(HWND hwnd) {
	union {
		wchar_t w[256];
		char a[512];
	} buf;

	if (VDIsWindowsNT()) {
		int len = GetWindowTextLengthW(hwnd);

		if (len > 255) {
			vdblock<wchar_t> tmp(len + 1);
			len = GetWindowTextW(hwnd, tmp.data(), tmp.size());

			VDStringW text(tmp.data(), len);
			return text;
		} else if (len > 0) {
			len = GetWindowTextW(hwnd, buf.w, 256);

			VDStringW text(buf.w, len);
			return text;
		}
	} else {
		int len = GetWindowTextLengthA(hwnd);

		if (len > 511) {
			vdblock<char> tmp(len + 1);
			len = GetWindowTextA(hwnd, tmp.data(), tmp.size());

			VDStringW text(VDTextAToW(tmp.data(), len));
			return text;
		} else if (len > 0) {
			len = GetWindowTextA(hwnd, buf.a, 512);

			VDStringW text(VDTextAToW(buf.a, len));
			return text;
		}
	}

	return VDStringW();
}
Ejemplo n.º 25
0
extern
VOID
ChangeMapFont(HWND hDlg)
{
    HWND hCombo;
    HWND hMap;
    LPWSTR lpFontName;
    INT Len;

    hCombo = GetDlgItem(hDlg, IDC_FONTCOMBO);

    Len = GetWindowTextLengthW(hCombo);

    if (Len != 0)
    {
        lpFontName = HeapAlloc(GetProcessHeap(),
                               0,
                               (Len + 1) * sizeof(WCHAR));

        if (lpFontName)
        {
            SendMessageW(hCombo,
                         WM_GETTEXT,
                         Len + 1,
                         (LPARAM)lpFontName);

            hMap = GetDlgItem(hDlg, IDC_FONTMAP);

            SendMessageW(hMap,
                         FM_SETFONT,
                         0,
                         (LPARAM)lpFontName);
        }

        HeapFree(GetProcessHeap(),
                 0,
                 lpFontName);
    }
}
Ejemplo n.º 26
0
	const CString	CWindow::GetTitle() const{
		int iLen = GetWindowTextLengthW(this->m_hWindow);
		if(iLen == 0){
			return L"";
		}

		if(iLen < 0){
			throw Exception::CWindowException(GetLastError(),
				L"Failed to get window title.", CR_INFO());
		}

		CString result;
		result.Resize(iLen+1);

		if(!GetWindowTextW(this->m_hWindow, &result[0], iLen + 1)){
			throw Exception::CWindowException(GetLastError(),
				L"Failed to get window title.", CR_INFO());
		}

		result = result.Trim();
		return result;
	}
Ejemplo n.º 27
0
static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    WCHAR* valueData;
    HWND hwndValue;
    int len;

    switch(uMsg) {
    case WM_INITDIALOG:
        SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName);
        SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, stringValueData);
	CheckRadioButton(hwndDlg, IDC_DWORD_HEX, IDC_DWORD_DEC, isDecimal ? IDC_DWORD_DEC : IDC_DWORD_HEX);
        return TRUE;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_DWORD_HEX:
	    if (isDecimal && change_dword_base(hwndDlg, TRUE)) isDecimal = FALSE;
	break;
        case IDC_DWORD_DEC:
	    if (!isDecimal && change_dword_base(hwndDlg, FALSE)) isDecimal = TRUE;
	break;
        case IDOK:
            if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
                len = GetWindowTextLengthW(hwndValue);
                if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(WCHAR)))) {
                    stringValueData = valueData;
                    if (!GetWindowTextW(hwndValue, stringValueData, len + 1))
                        *stringValueData = 0;
                }
            }
            /* Fall through */
        case IDCANCEL:
            EndDialog(hwndDlg, wParam);
            return TRUE;
        }
    }
    return FALSE;
}
Ejemplo n.º 28
0
	INT_PTR CALLBACK sqlCmdWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		switch(uMsg)
		{
		case WM_INITDIALOG:
			{
				return (INT_PTR)TRUE;
			}
		case WM_COMMAND:
			{
				switch(LOWORD(wParam))
				{
				case IDCLOSE:
					EndDialog(hWnd, 0);
					break;
				case IDC_CLEAR:
					SetDlgItemText(hWnd, IDC_SCRIPT, 0);
					break;
				case IDC_EXECUTE:
					{
						SetDlgItemText(hWnd, IDC_RESULT, 0);

						int len = GetWindowTextLengthW(GetDlgItem(hWnd, IDC_SCRIPT));
						wchar_t* sql = new wchar_t[len+2];
						GetDlgItemTextW(hWnd, IDC_SCRIPT, sql, len+1);
						utfstring str(sql);
						PluginController::getInstance().dtb->executeSQL(str.toUTF8(), sqlQueryCallback, GetDlgItem(hWnd, IDC_RESULT));
						delete [] sql;
					}
					break;
				}
				return (INT_PTR)TRUE;
			}
		}
		return (INT_PTR)FALSE;
	}
Ejemplo n.º 29
0
static BOOL IPADDRESS_GotoNextField (IPADDRESS_INFO *infoPtr, int cur, int sel)
{
    TRACE("\n");

    if(cur >= -1 && cur < 4) {
	IPADDRESS_ConstrainField(infoPtr, cur);

	if(cur < 3) {
	    IPPART_INFO *next = &infoPtr->Part[cur + 1];
	    int start = 0, end = 0;
            SetFocus (next->EditHwnd);
	    if (sel != POS_DEFAULT) {
		if (sel == POS_RIGHT)
		    start = end = GetWindowTextLengthW(next->EditHwnd);
		else if (sel == POS_SELALL)
		    end = -1;
	        SendMessageW(next->EditHwnd, EM_SETSEL, start, end);
	    }
	    return TRUE;
	}

    }
    return FALSE;
}
Ejemplo n.º 30
0
/*
Author      : mah
Date        : 13.06.2002
Description :
        Constructs InputBox window
*/
BOOL CInputBox::DoModal(LPCWSTR szCaption, LPCWSTR szPrompt)
{
	RECT r;
	GetWindowRect(GetDesktopWindow(), &r);

	m_hWndInputBox = CreateWindowExW(WS_EX_TOOLWINDOW,
                L"InputBox",
                szCaption,
                WS_POPUPWINDOW | WS_CAPTION | WS_TABSTOP,
                (r.right - INPUTBOX_WIDTH) / 2, (r.bottom - INPUTBOX_HEIGHT) / 2,
                INPUTBOX_WIDTH, INPUTBOX_HEIGHT,
                m_hWndParent,
                NULL,
                m_hInst,
                NULL);
    if(m_hWndInputBox == NULL)
        return FALSE;


    SetWindowTextW(m_hWndPrompt, szPrompt);

    SetForegroundWindow(m_hWndInputBox);
    BringWindowToTop(m_hWndInputBox);

	EnableWindow(m_hWndParent, FALSE);

    ShowWindow(m_hWndInputBox, SW_SHOW);
    UpdateWindow(m_hWndInputBox);

    BOOL ret = 0;

	MSG msg;

    HWND hWndFocused;

    while (GetMessage(&msg, NULL, 0, 0))
    {
		if (msg.message == WM_KEYDOWN)
		{
			if (msg.wParam == VK_ESCAPE)
            {
				SendMessage(m_hWndInputBox, WM_DESTROY, 0, 0);
                ret = 0;
            }
			if (msg.wParam == VK_RETURN)
            {
                int nCount = GetWindowTextLengthW(m_hWndEdit);
                nCount++;
                if (Text)
                {
                    delete[] Text;
                    Text = NULL;
                }
                Text = new WCHAR[nCount];
                GetWindowTextW(m_hWndEdit, Text, nCount);
			    SendMessage(m_hWndInputBox, WM_DESTROY, 0, 0);
                ret = 1;
            }
			if (msg.wParam == VK_TAB)
            {
                hWndFocused = GetFocus();
                if (hWndFocused == m_hWndEdit) SetFocus(m_hWndOK);
                if (hWndFocused == m_hWndOK) SetFocus(m_hWndCancel);
                if (hWndFocused == m_hWndCancel) SetFocus(m_hWndEdit);
            }

		}
        TranslateMessage(&msg);
		DispatchMessage(&msg);
    }

	return ret;
}