Beispiel #1
0
bool wxTextEntry::AutoCompleteFileNames()
{
#ifdef HAS_AUTOCOMPLETE
    typedef HRESULT (WINAPI *SHAutoComplete_t)(HWND, DWORD);
    static SHAutoComplete_t s_pfnSHAutoComplete = (SHAutoComplete_t)-1;
    static wxDynamicLibrary s_dllShlwapi;
    if ( s_pfnSHAutoComplete == (SHAutoComplete_t)-1 )
    {
        if ( !s_dllShlwapi.Load(wxT("shlwapi.dll"), wxDL_VERBATIM | wxDL_QUIET) )
        {
            s_pfnSHAutoComplete = NULL;
        }
        else
        {
            wxDL_INIT_FUNC(s_pfn, SHAutoComplete, s_dllShlwapi);
        }
    }

    if ( !s_pfnSHAutoComplete )
        return false;

    HRESULT hr = (*s_pfnSHAutoComplete)(GetEditHwnd(), SHACF_FILESYS_ONLY);
    if ( FAILED(hr) )
    {
        wxLogApiError(wxT("SHAutoComplete()"), hr);

        return false;
    }
    return true;
#else // !HAS_AUTOCOMPLETE
    return false;
#endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE
}
Beispiel #2
0
void wxTextEntry::GetSelection(long *from, long *to) const
{
    DWORD dwStart, dwEnd;
    ::SendMessage(GetEditHwnd(), EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);

    if ( from )
        *from = dwStart;
    if ( to )
        *to = dwEnd;
}
Beispiel #3
0
void wxTextEntry::GetSelection(long *from, long *to) const
{
    long dwPos;
    dwPos = (long)::WinSendMsg(GetEditHwnd(), EM_QUERYSEL, 0, 0);

    if ( from )
        *from = SHORT1FROMMP((MPARAM)dwPos);
    if ( to )
        *to = SHORT2FROMMP((MPARAM)dwPos);
}
Beispiel #4
0
void wxTextEntry::SetMaxLength(unsigned long len)
{
    if ( len >= 0x7fff )
    {
        // this will set it to a platform-specific maximum (32Kb under OS/2)
        len = 0x7fff;
    }

    ::WinSendMsg(GetEditHwnd(), EM_SETTEXTLIMIT, MPFROMSHORT(len), 0);
}
Beispiel #5
0
void wxTextEntry::DoSetSelection(long from, long to, int WXUNUSED(flags))
{
    // if from and to are both -1, it means (in wxWidgets) that all text should
    // be selected, translate this into Windows convention
    if ( (from == -1) && (to == -1) )
    {
        from = 0;
    }

    ::WinSendMsg(GetEditHwnd(), EM_SETSEL, MPFROM2SHORT((USHORT)from, (USHORT)to), 0);
}
Beispiel #6
0
void wxTextEntry::SetMaxLength(unsigned long len)
{
    if ( len >= 0xffff )
    {
        // this will set it to a platform-dependent maximum (much more
        // than 64Kb under NT)
        len = 0;
    }

    ::SendMessage(GetEditHwnd(), EM_LIMITTEXT, len, 0);
}
Beispiel #7
0
wxPoint wxTextEntry::DoGetMargins() const
{
#if !defined(__WXWINCE__)
    LRESULT lResult = ::SendMessage(GetEditHwnd(), EM_GETMARGINS,
                                    0, 0);
    int left = LOWORD(lResult);
    int top = -1;
    return wxPoint(left, top);
#else
    return wxPoint(-1, -1);
#endif
}
Beispiel #8
0
wxString wxTextEntry::GetHint() const
{
    if ( wxUxThemeEngine::GetIfActive() )
    {
        wchar_t buf[256];
        if ( ::SendMessage(GetEditHwnd(), EM_GETCUEBANNER,
                            (WPARAM)buf, WXSIZEOF(buf)) )
            return wxString(buf);
    }

    return wxTextEntryBase::GetHint();
}
Beispiel #9
0
long wxTextEntry::GetLastPosition() const
{
    WNDPARAMS                   vParams;

    vParams.fsStatus = WPM_CCHTEXT;
    if (::WinSendMsg( GetEditHwnd()
                     ,WM_QUERYWINDOWPARAMS
                     ,&vParams
                     ,0
                    ))
    {
        return vParams.cchText;
    }
    return 0;
}
Beispiel #10
0
void wxTextEntry::WriteText(const wxString& text)
{
    wxString newText = wxGetWindowText(GetEditHWND());
    long from, to;
    GetSelection(&from, &to);
    if (from > to){
      long swp = to;
      to = from;
      from = swp;
    }
    // Compose the new Text by replacing the selection of the old text
    newText.replace(from, to - from, text);
    // Set control to the new text
    ::WinSetWindowText(GetEditHwnd(), text.c_str());
}
Beispiel #11
0
bool wxTextEntry::SetHint(const wxString& hint)
{
    if ( wxUxThemeEngine::GetIfActive() )
    {
        // notice that this message always works with Unicode strings
        //
        // we always use TRUE for wParam to show the hint even when the window
        // has focus, otherwise there would be no way to show the hint for the
        // initially focused window
        if ( ::SendMessage(GetEditHwnd(), EM_SETCUEBANNER,
                             TRUE, (LPARAM)(const wchar_t *)hint.wc_str()) )
            return true;
    }

    return wxTextEntryBase::SetHint(hint);
}
Beispiel #12
0
bool wxTextEntry::DoSetMargins(const wxPoint& margins)
{
#if !defined(__WXWINCE__)
    bool res = true;

    if ( margins.x != -1 )
    {
        // left margin
        ::SendMessage(GetEditHwnd(), EM_SETMARGINS,
                      EC_LEFTMARGIN, MAKELONG(margins.x, 0));
    }

    if ( margins.y != -1 )
    {
        res = false;
    }

    return res;
#else
    return false;
#endif
}
Beispiel #13
0
void wxTextEntry::Copy()
{
    ::WinSendMsg(GetEditHwnd(), EM_COPY, 0, 0);
}
Beispiel #14
0
void wxTextEntry::Cut()
{
    ::SendMessage(GetEditHwnd(), WM_CUT, 0, 0);
}
Beispiel #15
0
void wxTextEntry::Paste()
{
    ::SendMessage(GetEditHwnd(), WM_PASTE, 0, 0);
}
Beispiel #16
0
void wxTextEntry::SetEditable(bool editable)
{
    ::WinSendMsg(GetEditHwnd(), EM_SETREADONLY, MPFROMLONG(!editable), 0);
}
Beispiel #17
0
bool wxTextEntry::IsEditable() const
{
    return (bool)LONGFROMMR(::WinSendMsg(GetEditHwnd(), EM_QUERYREADONLY, 0, 0));
}
Beispiel #18
0
void wxTextEntry::Undo()
{
    ::SendMessage(GetEditHwnd(), EM_UNDO, 0, 0);
}
Beispiel #19
0
bool wxTextEntry::CanUndo() const
{
    return ::SendMessage(GetEditHwnd(), EM_CANUNDO, 0, 0) != 0;
}
Beispiel #20
0
long wxTextEntry::GetLastPosition() const
{
    return ::SendMessage(GetEditHwnd(), EM_LINELENGTH, 0, 0);
}
Beispiel #21
0
bool wxTextEntry::AutoComplete(const wxArrayString& choices)
{
#ifdef HAS_AUTOCOMPLETE
    // if we had an old enumerator we must reuse it as IAutoComplete doesn't
    // free it if we call Init() again (see #10968) -- and it's also simpler
    if ( m_enumStrings )
    {
        m_enumStrings->ChangeStrings(choices);
        return true;
    }

    // create an object exposing IAutoComplete interface (don't go for
    // IAutoComplete2 immediately as, presumably, it might be not available on
    // older systems as otherwise why do we have both -- although in practice I
    // don't know when can this happen)
    IAutoComplete *pAutoComplete = NULL;
    HRESULT hr = CoCreateInstance
                 (
                    CLSID_AutoComplete,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IAutoComplete,
                    reinterpret_cast<void **>(&pAutoComplete)
                 );
    if ( FAILED(hr) )
    {
        wxLogApiError(wxT("CoCreateInstance(CLSID_AutoComplete)"), hr);
        return false;
    }

    // associate it with our strings
    m_enumStrings = new wxIEnumString(choices);
    m_enumStrings->AddRef();
    hr = pAutoComplete->Init(GetEditHwnd(), m_enumStrings, NULL, NULL);
    m_enumStrings->Release();
    if ( FAILED(hr) )
    {
        wxLogApiError(wxT("IAutoComplete::Init"), hr);
        return false;
    }

    // if IAutoComplete2 is available, set more user-friendly options
    IAutoComplete2 *pAutoComplete2 = NULL;
    hr = pAutoComplete->QueryInterface
                        (
                           IID_IAutoComplete2,
                           reinterpret_cast<void **>(&pAutoComplete2)
                        );
    if ( SUCCEEDED(hr) )
    {
        pAutoComplete2->SetOptions(ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST);
        pAutoComplete2->Release();
    }

    // the docs are unclear about when can we release it but it seems safe to
    // do it immediately, presumably the edit control itself keeps a reference
    // to the auto completer object
    pAutoComplete->Release();
    return true;
#else // !HAS_AUTOCOMPLETE
    wxUnusedVar(choices);

    return false;
#endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE
}
Beispiel #22
0
bool wxTextEntry::IsEditable() const
{
    return !(::GetWindowLong(GetEditHwnd(), GWL_STYLE) & ES_READONLY);
}
Beispiel #23
0
void wxTextEntry::Copy()
{
    ::SendMessage(GetEditHwnd(), WM_COPY, 0, 0);
}
Beispiel #24
0
void wxTextEntry::Cut()
{
    ::WinSendMsg(GetEditHwnd(), EM_CUT, 0, 0);
}
Beispiel #25
0
void wxTextEntry::SetEditable(bool editable)
{
    ::SendMessage(GetEditHwnd(), EM_SETREADONLY, !editable, 0);
}
Beispiel #26
0
void wxTextEntry::Paste()
{
    ::WinSendMsg(GetEditHwnd(), EM_PASTE, 0, 0);
}
Beispiel #27
0
void wxTextEntry::WriteText(const wxString& text)
{
    ::SendMessage(GetEditHwnd(), EM_REPLACESEL, 0, (LPARAM)text.wx_str());
}