本文整理匯總了C++中GetBuddyHwnd函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetBuddyHwnd函數的具體用法?C++ GetBuddyHwnd怎麽用?C++ GetBuddyHwnd使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetBuddyHwnd函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: wxGetClientRect
void wxSpinCtrl::DoGetClientSize(int *x, int *y) const
{
RECT spinrect = wxGetClientRect(GetHwnd());
RECT textrect = wxGetClientRect(GetBuddyHwnd());
RECT ctrlrect;
UnionRect(&ctrlrect,&textrect, &spinrect);
if ( x )
*x = ctrlrect.right - ctrlrect.left;
if ( y )
*y = ctrlrect.bottom - ctrlrect.top;
}
示例2: GetWindowRect
// get total size of the control
void wxSpinCtrl::DoGetSize(int *x, int *y) const
{
RECT spinrect, textrect, ctrlrect;
GetWindowRect(GetHwnd(), &spinrect);
GetWindowRect(GetBuddyHwnd(), &textrect);
UnionRect(&ctrlrect,&textrect, &spinrect);
if ( x )
*x = ctrlrect.right - ctrlrect.left;
if ( y )
*y = ctrlrect.bottom - ctrlrect.top;
}
示例3: GetSize
bool wxSpinCtrl::Reparent(wxWindowBase *newParent)
{
// Reparenting both the updown control and its buddy does not seem to work:
// they continue to be connected somehow, but visually there is no feedback
// on the buddy edit control. To avoid this problem, we reparent the buddy
// window normally, but we recreate the updown control and reassign its
// buddy.
if ( !wxWindowBase::Reparent(newParent) )
return false;
newParent->GetChildren().DeleteObject(this);
// preserve the old values
const wxSize size = GetSize();
int value = GetValue();
const wxRect btnRect = wxRectFromRECT(wxGetWindowRect(GetHwnd()));
// destroy the old spin button
UnsubclassWin();
if ( !::DestroyWindow(GetHwnd()) )
wxLogLastError(wxT("DestroyWindow"));
// create and initialize the new one
if ( !wxSpinButton::Create(GetParent(), GetId(),
btnRect.GetPosition(), btnRect.GetSize(),
GetWindowStyle(), GetName()) )
return false;
SetValue(value);
SetRange(m_min, m_max);
SetInitialSize(size);
// associate it with the buddy control again
::SetParent(GetBuddyHwnd(), GetHwndOf(GetParent()));
(void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)GetBuddyHwnd(), 0);
return true;
}
示例4: wxCHECK_MSG
int wxChoice::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into choice"));
wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
int n = (int)::SendMessage(GetBuddyHwnd(), LB_INSERTSTRING, pos, (LPARAM)item.c_str());
if ( n == LB_ERR )
{
wxLogLastError(wxT("SendMessage(LB_INSERTSTRING)"));
}
return n;
}
示例5: wxUpdateEditLayoutDirection
void wxSpinCtrl::SetLayoutDirection(wxLayoutDirection dir)
{
#ifndef __WXWINCE__
// Buddy text field is plain EDIT control so we need to set its layout
// direction in a specific way.
wxUpdateEditLayoutDirection(GetBuddyHwnd(), dir);
#endif // !__WXWINCE__
wxSpinButton::SetLayoutDirection(dir);
// Reposition the child windows according to the new layout.
SetSize(-1, -1, -1, -1, wxSIZE_AUTO | wxSIZE_FORCE);
}
示例6: GetFont
bool wxSpinCtrl::SetFont(const wxFont& font)
{
if ( !wxWindowBase::SetFont(font) )
{
// nothing to do
return false;
}
WXHANDLE hFont = GetFont().GetResourceHandle();
(void)::SendMessage(GetBuddyHwnd(), WM_SETFONT, (WPARAM)hFont, TRUE);
return true;
}
示例7: AdjustSpaceLimit
bool wxTextCtrl::AdjustSpaceLimit()
{
unsigned int limit = ::SendMessage(GetBuddyHwnd(), EM_GETLIMITTEXT, 0, 0);
// HACK: we try to automatically extend the limit for the amount of text
// to allow (interactively) entering more than 64Kb of text under
// Win9x but we shouldn't reset the text limit which was previously
// set explicitly with SetMaxLength()
//
// we could solve this by storing the limit we set in wxTextCtrl but
// to save space we prefer to simply test here the actual limit
// value: we consider that SetMaxLength() can only be called for
// values < 32Kb
if ( limit < 0x8000 )
{
// we've got more text than limit set by SetMaxLength()
return false;
}
unsigned int len = ::GetWindowTextLength(GetBuddyHwnd());
if ( len >= limit )
{
limit = len + 0x8000; // 32Kb
if ( limit > 0xffff )
{
// this will set it to a platform-dependent maximum (much more
// than 64Kb under NT)
limit = 0;
}
::SendMessage(GetBuddyHwnd(), EM_LIMITTEXT, limit, 0L);
}
// we changed the limit
return true;
}
示例8: SetValue
void wxSpinCtrl::SetValue(int val)
{
wxSpinButton::SetValue(val);
// normally setting the value of the spin button is enough as it updates
// its buddy control automatically ...
if ( wxGetWindowText(m_hwndBuddy).empty() )
{
// ... but sometimes it doesn't, notably when the value is 0 and the
// text control is currently empty, the spin button seems to be happy
// to leave it like this, while we really want to always show the
// current value in the control, so do it manually
::SetWindowText(GetBuddyHwnd(), wxString::Format(_T("%d"), val));
}
m_oldValue = GetValue();
}
示例9: AdoptAttributesFromHWND
// Make sure the window style (etc.) reflects the HWND style (roughly)
void wxTextCtrl::AdoptAttributesFromHWND()
{
wxWindow::AdoptAttributesFromHWND();
long style = ::GetWindowLong(GetBuddyHwnd(), GWL_STYLE);
if (style & ES_MULTILINE)
m_windowStyle |= wxTE_MULTILINE;
if (style & ES_PASSWORD)
m_windowStyle |= wxTE_PASSWORD;
if (style & ES_READONLY)
m_windowStyle |= wxTE_READONLY;
if (style & ES_WANTRETURN)
m_windowStyle |= wxTE_PROCESS_ENTER;
if (style & ES_CENTER)
m_windowStyle |= wxTE_CENTRE;
if (style & ES_RIGHT)
m_windowStyle |= wxTE_RIGHT;
}
示例10: GetBestSpinnerSize
void wxTextCtrl::DoMoveWindow(int x, int y, int width, int height)
{
int widthBtn = GetBestSpinnerSize(IsVertical(GetWindowStyle())).x / 2;
int widthText = width - widthBtn - MARGIN_BETWEEN;
if ( widthText <= 0 )
{
wxLogDebug(_T("not enough space for wxSpinCtrl!"));
}
if ( !::MoveWindow(GetBuddyHwnd(), x, y, widthText, height, TRUE) )
{
wxLogLastError(wxT("MoveWindow(buddy)"));
}
x += widthText + MARGIN_BETWEEN;
if ( !::MoveWindow(GetHwnd(), x, y, widthBtn, height, TRUE) )
{
wxLogLastError(wxT("MoveWindow"));
}
}
示例11: wxGetCharSize
wxSize wxTextCtrl::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetBuddyHwnd(), &cx, &cy, GetFont());
int wText = DEFAULT_ITEM_WIDTH;
int hText = cy;
if ( m_windowStyle & wxTE_MULTILINE )
{
hText *= wxMax(GetNumberOfLines(), 5);
}
//else: for single line control everything is ok
// we have to add the adjustments for the control height only once, not
// once per line, so do it after multiplication above
hText += EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) - cy;
return wxSize(wText, hText);
}
示例12: SetEditable
void wxTextCtrl::SetEditable(bool editable)
{
::SendMessage(GetBuddyHwnd(), EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
}
示例13: SetWindowStyle
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
style |= wxBORDER_SIMPLE;
SetWindowStyle(style);
WXDWORD exStyle = 0;
WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
wxSize sizeText(size), sizeBtn(size);
sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x / 2;
if ( sizeText.x == wxDefaultCoord )
{
// DEFAULT_ITEM_WIDTH is the default width for the text control
sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x;
}
sizeText.x -= sizeBtn.x + MARGIN_BETWEEN;
if ( sizeText.x <= 0 )
{
wxLogDebug(_T("not enough space for wxSpinCtrl!"));
}
wxPoint posBtn(pos);
posBtn.x += sizeText.x + MARGIN_BETWEEN;
// we need to turn '\n's into "\r\n"s for the multiline controls
wxString valueWin;
if ( m_windowStyle & wxTE_MULTILINE )
{
valueWin = wxTextFile::Translate(value, wxTextFileType_Dos);
}
else // single line
{
valueWin = value;
}
// we must create the list control before the spin button for the purpose
// of the dialog navigation: if there is a static text just before the spin
// control, activating it by Alt-letter should give focus to the text
// control, not the spin and the dialog navigation code will give focus to
// the next control (at Windows level), not the one after it
// create the text window
m_hwndBuddy = (WXHWND)::CreateWindowEx
(
exStyle, // sunken border
_T("EDIT"), // window class
valueWin, // no window title
msStyle, // style (will be shown later)
pos.x, pos.y, // position
0, 0, // size (will be set later)
GetHwndOf(parent), // parent
(HMENU)-1, // control id
wxGetInstance(), // app instance
NULL // unused client data
);
if ( !m_hwndBuddy )
{
wxLogLastError(wxT("CreateWindow(buddy text window)"));
return false;
}
// initialize wxControl
if ( !CreateControl(parent, id, posBtn, sizeBtn, style, validator, name) )
return false;
// now create the real HWND
WXDWORD spiner_style = WS_VISIBLE |
UDS_ALIGNRIGHT |
UDS_EXPANDABLE |
UDS_NOSCROLL;
if ( !IsVertical(style) )
spiner_style |= UDS_HORZ;
if ( style & wxSP_WRAP )
spiner_style |= UDS_WRAP;
if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, _T(""), 0) )
return false;
// subclass the text ctrl to be able to intercept some events
wxSetWindowUserData(GetBuddyHwnd(), this);
m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(),
wxBuddyTextCtrlWndProc);
// set up fonts and colours (This is nomally done in MSWCreateControl)
InheritAttributes();
//.........這裏部分代碼省略.........
示例14: return
int wxChoice::GetSelection() const
{
return (int)::SendMessage(GetBuddyHwnd(), LB_GETCURSEL, 0, 0);
}
示例15: Free
void wxChoice::Clear()
{
Free();
::SendMessage(GetBuddyHwnd(), LB_RESETCONTENT, 0, 0);
}