From be85a191e19ad0e702f4244d424fe7dd066a8f0c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Jan 2012 10:05:27 +0000 Subject: [PATCH] No changes, just minor wxMSW code cleanup: use WinStruct<>. Use WinStruct instead of the usual ZeroMemory() + cbSize setting fragment to initialize Win32 structs that need to be initialized in this way. No real changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/menu.cpp | 20 +++++--------------- src/msw/scrolbar.cpp | 4 +--- src/msw/textctrl.cpp | 4 +--- src/msw/window.cpp | 4 +--- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index b50e52e0cc..3b8566fd2d 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -190,9 +190,7 @@ void SetDefaultMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu), UINT WXUNUSED_IN_WINCE(id)) { #ifndef __WXWINCE__ - MENUITEMINFO mii; - wxZeroMemory(mii); - mii.cbSize = sizeof(MENUITEMINFO); + WinStruct mii; mii.fMask = MIIM_STATE; mii.fState = MFS_DEFAULT; @@ -210,9 +208,7 @@ void SetOwnerDrawnMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu), BOOL WXUNUSED_IN_WINCE(byPositon = FALSE)) { #ifndef __WXWINCE__ - MENUITEMINFO mii; - wxZeroMemory(mii); - mii.cbSize = sizeof(MENUITEMINFO); + WinStruct mii; mii.fMask = MIIM_FTYPE | MIIM_DATA; mii.fType = MFT_OWNERDRAW; mii.dwItemData = data; @@ -230,9 +226,7 @@ void SetOwnerDrawnMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu), #ifdef __WXWINCE__ UINT GetMenuState(HMENU hMenu, UINT id, UINT flags) { - MENUITEMINFO info; - wxZeroMemory(info); - info.cbSize = sizeof(info); + WinStruct info; info.fMask = MIIM_STATE; // MF_BYCOMMAND is zero so test MF_BYPOSITION if ( !::GetMenuItemInfo(hMenu, id, flags & MF_BYPOSITION ? TRUE : FALSE , & info) ) @@ -913,9 +907,7 @@ void wxMenu::SetTitle(const wxString& label) { // modify the title #ifdef __WXWINCE__ - MENUITEMINFO info; - wxZeroMemory(info); - info.cbSize = sizeof(info); + WinStruct info; info.fMask = MIIM_TYPE; info.fType = MFT_STRING; info.cch = m_title.length(); @@ -1269,9 +1261,7 @@ void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) } #ifdef __WXWINCE__ - MENUITEMINFO info; - wxZeroMemory(info); - info.cbSize = sizeof(info); + WinStruct info; info.fMask = MIIM_TYPE; info.fType = MFT_STRING; info.cch = label.length(); diff --git a/src/msw/scrolbar.cpp b/src/msw/scrolbar.cpp index ce238227db..33b0a0c581 100644 --- a/src/msw/scrolbar.cpp +++ b/src/msw/scrolbar.cpp @@ -156,9 +156,7 @@ void wxScrollBar::SetThumbPosition(int viewStart) int wxScrollBar::GetThumbPosition(void) const { - SCROLLINFO scrollInfo; - wxZeroMemory(scrollInfo); - scrollInfo.cbSize = sizeof(SCROLLINFO); + WinStruct scrollInfo; scrollInfo.fMask = SIF_POS; if ( !::GetScrollInfo(GetHwnd(), SB_CTL, &scrollInfo) ) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index ef2b7a8989..659cf21077 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2397,9 +2397,7 @@ bool wxTextCtrl::SetForegroundColour(const wxColour& colour) if ( IsRich() ) { // change the colour of everything - CHARFORMAT cf; - wxZeroMemory(cf); - cf.cbSize = sizeof(cf); + WinStruct cf; cf.dwMask = CFM_COLOR; cf.crTextColor = wxColourToRGB(colour); ::SendMessage(GetHwnd(), EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 6b6a0504c3..bf197f2e16 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -5794,9 +5794,7 @@ int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel), #ifndef __WXWINCE__ const HMENU hmenu = (HMENU)lParam; - MENUITEMINFO mii; - wxZeroMemory(mii); - mii.cbSize = sizeof(MENUITEMINFO); + WinStruct mii; // we could use MIIM_FTYPE here as we only need to know if the item is // ownerdrawn or not and not dwTypeData which MIIM_TYPE also returns, but -- 2.45.2