本文整理汇总了C++中SubclassWin函数的典型用法代码示例。如果您正苦于以下问题:C++ SubclassWin函数的具体用法?C++ SubclassWin怎么用?C++ SubclassWin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SubclassWin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHwndOf
bool wxWindow::LoadNativeDialog (
wxWindow* pParent
, const wxString& rsName
)
{
HWND hWndOwner;
if (pParent)
hWndOwner = GetHwndOf(pParent);
else
hWndOwner = HWND_DESKTOP;
SetName(rsName);
wxWndHook = this;
m_hWnd = ::WinLoadDlg( HWND_DESKTOP
,hWndOwner
,(PFNWP)wxDlgProc
,NULL
,(ULONG)131 // Caption dialog from the resource file
,(PVOID)this
);
wxWndHook = NULL;
if (!m_hWnd)
return FALSE;
SubclassWin(GetHWND());
if (pParent)
pParent->AddChild(this);
else
wxTopLevelWindows.Append(this);
return TRUE;
} // end of wxWindow::LoadNativeDialog
示例2: SubclassWin
bool wxNonOwnedWindow::Create(wxWindow *parent, WXWindow nativeWindow)
{
if ( parent )
parent->AddChild(this);
SubclassWin(nativeWindow);
return true;
}
示例3: SetName
bool wxBitmapCheckBox::Create(
wxWindow* pParent
, wxWindowID vId
, const wxBitmap* pLabel
, const wxPoint& rPos
, const wxSize& rSize
, long lStyle
, const wxValidator& rValidator
, const wxString& rsName
)
{
SetName(rsName);
#if wxUSE_VALIDATORS
SetValidator(rValidator);
#endif
if (pParent)
pParent->AddChild(this);
SetBackgroundColour(pParent->GetBackgroundColour()) ;
SetForegroundColour(pParent->GetForegroundColour()) ;
m_windowStyle = lStyle;
if (vId == -1)
m_windowId = NewControlId();
else
m_windowId = vId;
int nX = rPos.x;
int nY = rPos.y;
int nWidth = rSize.x;
int nHeight = rSize.y;
m_nCheckWidth = -1 ;
m_nCheckHeight = -1 ;
// long msStyle = CHECK_FLAGS;
HWND hButton = 0; // TODO: Create the bitmap checkbox
m_hWnd = (WXHWND)hButton;
//
// Subclass again for purposes of dialog editing mode
//
SubclassWin((WXHWND)hButton);
SetSize( nX
,nY
,nWidth
,nHeight
);
::WinShowWindow(hButton, TRUE);
return TRUE;
} // end of wxBitmapCheckBox::Create
示例4: GetMDIWindowMenu
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
{
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
CLIENTCREATESTRUCT ccs;
m_windowStyle = style;
m_parent = parent;
ccs.hWindowMenu = GetMDIWindowMenu(parent);
ccs.idFirstChild = wxFIRST_MDI_CHILD;
DWORD msStyle = MDIS_ALLCHILDSTYLES | WS_VISIBLE | WS_CHILD |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
if ( style & wxHSCROLL )
msStyle |= WS_HSCROLL;
if ( style & wxVSCROLL )
msStyle |= WS_VSCROLL;
#if defined(__WIN95__)
DWORD exStyle = WS_EX_CLIENTEDGE;
#else
DWORD exStyle = 0;
#endif
wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::CreateWindowEx
(
exStyle,
wxT("MDICLIENT"),
NULL,
msStyle,
0, 0, 0, 0,
GetWinHwnd(parent),
NULL,
wxGetInstance(),
(LPSTR)(LPCLIENTCREATESTRUCT)&ccs);
if ( !m_hWnd )
{
wxLogLastError(wxT("CreateWindowEx(MDI client)"));
return false;
}
SubclassWin(m_hWnd);
return true;
}
示例5: wxColour
bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
m_imageList = NULL;
m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
// GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
m_foregroundColour = *wxBLACK ;
SetName(name);
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style;
SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
SetParent(parent);
if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
m_windowId = (id < 0 ? NewControlId() : id);
// Create the toolbar control.
HWND hWndTabCtrl = 0;
// TODO: create tab control
m_hWnd = (WXHWND) hWndTabCtrl;
if (parent) parent->AddChild(this);
SubclassWin((WXHWND) hWndTabCtrl);
return false;
}
示例6: WXUNUSED
bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), wxMenuBar* menuBar)
{
SetMenuBar(menuBar);
if (m_menuBar)
m_menuBar->SetToolBar(this);
#if defined(WINCE_WITHOUT_COMMANDBAR)
// Create the menubar.
SHMENUBARINFO mbi;
memset (&mbi, 0, sizeof (SHMENUBARINFO));
mbi.cbSize = sizeof (SHMENUBARINFO);
mbi.hwndParent = (HWND) GetParent()->GetHWND();
#ifdef __SMARTPHONE__
mbi.nToolBarId = 5002;
#else
mbi.nToolBarId = 5000;
#endif
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR;
mbi.hInstRes = wxGetInstance();
if (!SHCreateMenuBar(&mbi))
{
wxFAIL_MSG( _T("SHCreateMenuBar failed") );
return false;
}
SetHWND((WXHWND) mbi.hwndMB);
#else
HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId());
SetHWND((WXHWND) hWnd);
#endif
// install wxWidgets window proc for this window
SubclassWin(m_hWnd);
if (menuBar)
menuBar->Create();
return true;
}
示例7: wxCHECK_MSG
bool
wxNativeWindow::Create(wxWindow* parent,
wxWindowID winid,
wxNativeWindowHandle hwnd)
{
wxCHECK_MSG( hwnd, false, wxS("Invalid null HWND") );
wxCHECK_MSG( parent, false, wxS("Must have a valid parent") );
wxASSERT_MSG( ::GetParent(hwnd) == GetHwndOf(parent),
wxS("The native window has incorrect parent") );
const wxRect r = wxRectFromRECT(wxGetWindowRect(hwnd));
// Skip wxWindow::Create() which would try to create a new HWND, we don't
// want this as we already have one.
if ( !CreateBase(parent, winid,
r.GetPosition(), r.GetSize(),
0, wxDefaultValidator, wxS("nativewindow")) )
return false;
parent->AddChild(this);
SubclassWin(hwnd);
if ( winid == wxID_ANY )
{
// We allocated a new ID to the control, use it at Windows level as
// well because we assume that our and MSW IDs are the same in many
// places and it seems prudent to avoid breaking this assumption.
SetId(GetId());
}
else // We used a fixed ID.
{
// For the same reason as above, check that it's the same as the one
// used by the native HWND.
wxASSERT_MSG( ::GetWindowLong(hwnd, GWL_ID) == winid,
wxS("Mismatch between wx and native IDs") );
}
InheritAttributes();
return true;
}
示例8: SubclassWin
bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle hwnd)
{
if ( !::IsWindow(hwnd) )
{
// strictly speaking, the fact that IsWindow() returns true doesn't
// mean that the window handle is valid -- it could be being deleted
// right now, for example
//
// but if it returns false, the handle is definitely invalid
return false;
}
// make this HWND really a wxWindow
SubclassWin(hwnd);
// inherit the other attributes we can from the native HWND
AdoptAttributesFromHWND();
return true;
}
示例9: WXUNUSED
bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(size),
wxMenuBar *menuBar)
{
SetMenuBar(menuBar);
if (m_menuBar)
m_menuBar->SetToolBar(this);
HWND hwndParent = GetHwndOf(GetParent());
wxCHECK_MSG( hwndParent, false, wxT("should have valid parent HWND") );
#if defined(WINCE_WITHOUT_COMMANDBAR)
// create the menubar.
WinStruct<SHMENUBARINFO> mbi;
mbi.hwndParent = hwndParent;
mbi.nToolBarId = wxIDM_SHMENU;
mbi.hInstRes = wxGetInstance();
if ( !SHCreateMenuBar(&mbi) )
{
wxFAIL_MSG( wxT("SHCreateMenuBar failed") );
return false;
}
SetHWND((WXHWND) mbi.hwndMB);
#else
HWND hWnd = CommandBar_Create(wxGetInstance(), hwndParent, GetId());
SetHWND((WXHWND) hWnd);
#endif
// install wxWidgets window proc for this window
SubclassWin(m_hWnd);
if (menuBar)
menuBar->Create();
return true;
}
示例10: SetName
bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxString& name)
{
SetName(name);
wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::CreateDialog((HINSTANCE) wxGetInstance(),
name.c_str(),
parent ? (HWND)parent->GetHWND() : 0,
(DLGPROC)wxDlgProc);
if ( !m_hWnd )
return false;
SubclassWin(GetHWND());
if ( parent )
parent->AddChild(this);
else
wxTopLevelWindows.Append(this);
// Enumerate all children
HWND hWndNext;
hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD);
if (hWndNext)
CreateWindowFromHWND(this, (WXHWND) hWndNext);
while (hWndNext != (HWND) NULL)
{
hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT);
if (hWndNext)
CreateWindowFromHWND(this, (WXHWND) hWndNext);
}
return true;
}
示例11: CreateFrame
bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
const wxString& title,
const wxPoint& pos,
const wxSize& size)
{
#ifdef __WXMICROWIN__
// no dialogs support under MicroWin yet
return CreateFrame(title, pos, size);
#else // !__WXMICROWIN__
// static cast is valid as we're only ever called for dialogs
wxWindow * const
parent = static_cast<wxDialog *>(this)->GetParentForModalDialog();
m_hWnd = (WXHWND)::CreateDialogIndirect
(
wxGetInstance(),
(DLGTEMPLATE*)dlgTemplate,
parent ? GetHwndOf(parent) : NULL,
(DLGPROC)wxDlgProc
);
if ( !m_hWnd )
{
wxFAIL_MSG(wxT("Failed to create dialog. Incorrect DLGTEMPLATE?"));
wxLogSysError(wxT("Can't create dialog using memory template"));
return false;
}
#if !defined(__WXWINCE__)
// For some reason, the system menu is activated when we use the
// WS_EX_CONTEXTHELP style, so let's set a reasonable icon
if ( HasExtraStyle(wxWS_EX_CONTEXTHELP) )
{
wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame);
if ( winTop )
{
wxIcon icon = winTop->GetIcon();
if ( icon.IsOk() )
{
::SendMessage(GetHwnd(), WM_SETICON,
(WPARAM)TRUE,
(LPARAM)GetHiconOf(icon));
}
}
}
#endif // !__WXWINCE__
if ( !title.empty() )
{
::SetWindowText(GetHwnd(), title.t_str());
}
SubclassWin(m_hWnd);
#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
// move the dialog to its initial position without forcing repainting
int x, y, w, h;
(void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);
if ( x == (int)CW_USEDEFAULT )
{
// Let the system position the window, just set its size.
::SetWindowPos(GetHwnd(), 0,
0, 0, w, h,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
else // Move the window to the desired location and set its size too.
{
if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) )
{
wxLogLastError(wxT("MoveWindow"));
}
}
#endif // !__WXWINCE__
#ifdef __SMARTPHONE__
// Work around title non-display glitch
Show(false);
#endif
return true;
#endif // __WXMICROWIN__/!__WXMICROWIN__
}
示例12: MSWGetStyle
bool wxControl::MSWCreateControl(const wxChar *classname,
WXDWORD style,
const wxPoint& pos,
const wxSize& size,
const wxString& label,
WXDWORD exstyle)
{
// if no extended style given, determine it ourselves
if ( exstyle == (WXDWORD)-1 )
{
exstyle = 0;
(void) MSWGetStyle(GetWindowStyle(), &exstyle);
}
// all controls should have this style
style |= WS_CHILD;
// create the control visible if it's currently shown for wxWidgets
if ( m_isShown )
{
style |= WS_VISIBLE;
}
// choose the position for the control: we have a problem with default size
// here as we can't calculate the best size before the control exists
// (DoGetBestSize() may need to use m_hWnd), so just choose the minimal
// possible but non 0 size because 0 window width/height result in problems
// elsewhere
int x = pos.x == wxDefaultCoord ? 0 : pos.x,
y = pos.y == wxDefaultCoord ? 0 : pos.y,
w = size.x == wxDefaultCoord ? 1 : size.x,
h = size.y == wxDefaultCoord ? 1 : size.y;
// ... and adjust it to account for a possible parent frames toolbar
AdjustForParentClientOrigin(x, y);
m_hWnd = (WXHWND)::CreateWindowEx
(
exstyle, // extended style
classname, // the kind of control to create
label, // the window name
style, // the window style
x, y, w, h, // the window position and size
GetHwndOf(GetParent()), // parent
(HMENU)GetId(), // child id
wxGetInstance(), // app instance
NULL // creation parameters
);
if ( !m_hWnd )
{
#ifdef __WXDEBUG__
wxFAIL_MSG(wxString::Format
(
_T("CreateWindowEx(\"%s\", flags=%08x, ex=%08x) failed"),
classname, (unsigned int)style, (unsigned int)exstyle
));
#endif // __WXDEBUG__
return false;
}
// install wxWidgets window proc for this window
SubclassWin(m_hWnd);
// set up fonts and colours
InheritAttributes();
if (!m_hasFont)
SetFont(GetDefaultAttributes().font);
// set the size now if no initial size specified
SetInitialBestSize(size);
return true;
}
示例13: SetName
bool wxBitmapButton::Create( wxWindow* pParent,
wxWindowID vId,
const wxBitmap& rBitmap,
const wxPoint& rPos,
const wxSize& rSize,
long lStyle,
const wxValidator& rValidator,
const wxString& rsName )
{
m_bitmaps[State_Normal] = rBitmap;
SetName(rsName);
#if wxUSE_VALIDATORS
SetValidator(rValidator);
#endif
pParent->AddChild(this);
m_backgroundColour = pParent->GetBackgroundColour() ;
m_foregroundColour = pParent->GetForegroundColour() ;
m_windowStyle = lStyle;
if (lStyle & wxBU_AUTODRAW)
{
m_marginX = wxDEFAULT_BUTTON_MARGIN;
m_marginY = wxDEFAULT_BUTTON_MARGIN;
}
int nX = rPos.x;
int nY = rPos.y;
int nWidth = rSize.x;
int nHeight = rSize.y;
if (vId == wxID_ANY)
m_windowId = NewControlId();
else
m_windowId = vId;
if (nWidth == wxDefaultCoord && rBitmap.IsOk())
nWidth = rBitmap.GetWidth() + 4 * m_marginX;
if (nHeight == wxDefaultCoord && rBitmap.IsOk())
nHeight = rBitmap.GetHeight() + 4 * m_marginY;
ULONG ulOS2Style = WS_VISIBLE | WS_TABSTOP | BS_USERBUTTON;
if (m_windowStyle & wxCLIP_SIBLINGS)
ulOS2Style |= WS_CLIPSIBLINGS;
m_hWnd = (WXHWND)::WinCreateWindow( GetHwndOf(pParent)
,WC_BUTTON
,(PSZ)wxEmptyString
,ulOS2Style
,0, 0, 0, 0
,GetHwndOf(pParent)
,HWND_TOP
,m_windowId
,NULL
,NULL
);
//
//Subclass again for purposes of dialog editing mode
//
SubclassWin(m_hWnd);
SetFont(*wxSMALL_FONT);
SetSize( nX
,nY
,nWidth
,nHeight
);
return true;
} // end of wxBitmapButton::Create
示例14: wxColour
bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
m_imageList = NULL;
m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
m_foregroundColour = *wxBLACK ;
SetName(name);
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style;
SetParent(parent);
if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
m_windowId = (id < 0 ? NewControlId() : id);
long tabStyle = WS_CHILD | WS_VISIBLE;
if (m_windowStyle & wxTC_MULTILINE)
tabStyle |= TCS_MULTILINE;
if (m_windowStyle & wxTC_RIGHTJUSTIFY)
tabStyle |= TCS_RIGHTJUSTIFY;
if (m_windowStyle & wxTC_FIXEDWIDTH)
tabStyle |= TCS_FIXEDWIDTH;
if (m_windowStyle & wxTC_OWNERDRAW)
tabStyle |= TCS_OWNERDRAWFIXED;
if (m_windowStyle & wxBORDER)
tabStyle |= WS_BORDER;
#ifndef __WXWINCE__
tabStyle |= TCS_TOOLTIPS;
#endif
// Create the toolbar control.
HWND hWndTabCtrl = CreateWindowEx(0L, // No extended styles.
WC_TABCONTROL, // Class name for the tab control
wxEmptyString, // No default text.
tabStyle, // Styles and defaults.
x, y, width, height, // Standard size and position.
(HWND) parent->GetHWND(), // Parent window
(HMENU)m_windowId, // ID.
wxGetInstance(), // Current instance.
NULL ); // No class data.
m_hWnd = (WXHWND) hWndTabCtrl;
if (parent) parent->AddChild(this);
SubclassWin((WXHWND) hWndTabCtrl);
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
return true;
}
示例15: SetName
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
m_mdiParent = parent;
SetName(name);
if ( id != wxID_ANY )
m_windowId = id;
else
m_windowId = NewControlId();
if ( parent )
{
parent->AddChild(this);
}
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
MDICREATESTRUCT mcs;
wxString className =
wxApp::GetRegisteredClassName(wxT("wxMDIChildFrame"), COLOR_WINDOW);
if ( !(style & wxFULL_REPAINT_ON_RESIZE) )
className += wxApp::GetNoRedrawClassSuffix();
mcs.szClass = className.wx_str();
mcs.szTitle = title.wx_str();
mcs.hOwner = wxGetInstance();
if (x != wxDefaultCoord)
mcs.x = x;
else
mcs.x = CW_USEDEFAULT;
if (y != wxDefaultCoord)
mcs.y = y;
else
mcs.y = CW_USEDEFAULT;
if (width != wxDefaultCoord)
mcs.cx = width;
else
mcs.cx = CW_USEDEFAULT;
if (height != wxDefaultCoord)
mcs.cy = height;
else
mcs.cy = CW_USEDEFAULT;
DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN;
if (style & wxMINIMIZE_BOX)
msflags |= WS_MINIMIZEBOX;
if (style & wxMAXIMIZE_BOX)
msflags |= WS_MAXIMIZEBOX;
if (style & wxRESIZE_BORDER)
msflags |= WS_THICKFRAME;
if (style & wxSYSTEM_MENU)
msflags |= WS_SYSMENU;
if ((style & wxMINIMIZE) || (style & wxICONIZE))
msflags |= WS_MINIMIZE;
if (style & wxMAXIMIZE)
msflags |= WS_MAXIMIZE;
if (style & wxCAPTION)
msflags |= WS_CAPTION;
mcs.style = msflags;
mcs.lParam = 0;
wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()),
WM_MDICREATE, 0, (LPARAM)&mcs);
if ( !m_hWnd )
{
wxLogLastError(wxT("WM_MDICREATE"));
return false;
}
SubclassWin(m_hWnd);
parent->AddMDIChild(this);
return true;
}