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
This commit is contained in:
Vadim Zeitlin
2012-01-18 10:05:27 +00:00
parent 89041b2513
commit be85a191e1
4 changed files with 8 additions and 24 deletions

View File

@@ -190,9 +190,7 @@ void SetDefaultMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu),
UINT WXUNUSED_IN_WINCE(id)) UINT WXUNUSED_IN_WINCE(id))
{ {
#ifndef __WXWINCE__ #ifndef __WXWINCE__
MENUITEMINFO mii; WinStruct<MENUITEMINFO> mii;
wxZeroMemory(mii);
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE; mii.fMask = MIIM_STATE;
mii.fState = MFS_DEFAULT; mii.fState = MFS_DEFAULT;
@@ -210,9 +208,7 @@ void SetOwnerDrawnMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu),
BOOL WXUNUSED_IN_WINCE(byPositon = FALSE)) BOOL WXUNUSED_IN_WINCE(byPositon = FALSE))
{ {
#ifndef __WXWINCE__ #ifndef __WXWINCE__
MENUITEMINFO mii; WinStruct<MENUITEMINFO> mii;
wxZeroMemory(mii);
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_FTYPE | MIIM_DATA; mii.fMask = MIIM_FTYPE | MIIM_DATA;
mii.fType = MFT_OWNERDRAW; mii.fType = MFT_OWNERDRAW;
mii.dwItemData = data; mii.dwItemData = data;
@@ -230,9 +226,7 @@ void SetOwnerDrawnMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu),
#ifdef __WXWINCE__ #ifdef __WXWINCE__
UINT GetMenuState(HMENU hMenu, UINT id, UINT flags) UINT GetMenuState(HMENU hMenu, UINT id, UINT flags)
{ {
MENUITEMINFO info; WinStruct<MENUITEMINFO> info;
wxZeroMemory(info);
info.cbSize = sizeof(info);
info.fMask = MIIM_STATE; info.fMask = MIIM_STATE;
// MF_BYCOMMAND is zero so test MF_BYPOSITION // MF_BYCOMMAND is zero so test MF_BYPOSITION
if ( !::GetMenuItemInfo(hMenu, id, flags & MF_BYPOSITION ? TRUE : FALSE , & info) ) if ( !::GetMenuItemInfo(hMenu, id, flags & MF_BYPOSITION ? TRUE : FALSE , & info) )
@@ -913,9 +907,7 @@ void wxMenu::SetTitle(const wxString& label)
{ {
// modify the title // modify the title
#ifdef __WXWINCE__ #ifdef __WXWINCE__
MENUITEMINFO info; WinStruct<MENUITEMINFO> info;
wxZeroMemory(info);
info.cbSize = sizeof(info);
info.fMask = MIIM_TYPE; info.fMask = MIIM_TYPE;
info.fType = MFT_STRING; info.fType = MFT_STRING;
info.cch = m_title.length(); info.cch = m_title.length();
@@ -1269,9 +1261,7 @@ void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
} }
#ifdef __WXWINCE__ #ifdef __WXWINCE__
MENUITEMINFO info; WinStruct<MENUITEMINFO> info;
wxZeroMemory(info);
info.cbSize = sizeof(info);
info.fMask = MIIM_TYPE; info.fMask = MIIM_TYPE;
info.fType = MFT_STRING; info.fType = MFT_STRING;
info.cch = label.length(); info.cch = label.length();

View File

@@ -156,9 +156,7 @@ void wxScrollBar::SetThumbPosition(int viewStart)
int wxScrollBar::GetThumbPosition(void) const int wxScrollBar::GetThumbPosition(void) const
{ {
SCROLLINFO scrollInfo; WinStruct<SCROLLINFO> scrollInfo;
wxZeroMemory(scrollInfo);
scrollInfo.cbSize = sizeof(SCROLLINFO);
scrollInfo.fMask = SIF_POS; scrollInfo.fMask = SIF_POS;
if ( !::GetScrollInfo(GetHwnd(), SB_CTL, &scrollInfo) ) if ( !::GetScrollInfo(GetHwnd(), SB_CTL, &scrollInfo) )

View File

@@ -2397,9 +2397,7 @@ bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
if ( IsRich() ) if ( IsRich() )
{ {
// change the colour of everything // change the colour of everything
CHARFORMAT cf; WinStruct<CHARFORMAT> cf;
wxZeroMemory(cf);
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR; cf.dwMask = CFM_COLOR;
cf.crTextColor = wxColourToRGB(colour); cf.crTextColor = wxColourToRGB(colour);
::SendMessage(GetHwnd(), EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf); ::SendMessage(GetHwnd(), EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);

View File

@@ -5794,9 +5794,7 @@ int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel),
#ifndef __WXWINCE__ #ifndef __WXWINCE__
const HMENU hmenu = (HMENU)lParam; const HMENU hmenu = (HMENU)lParam;
MENUITEMINFO mii; WinStruct<MENUITEMINFO> mii;
wxZeroMemory(mii);
mii.cbSize = sizeof(MENUITEMINFO);
// we could use MIIM_FTYPE here as we only need to know if the item is // 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 // ownerdrawn or not and not dwTypeData which MIIM_TYPE also returns, but