diff --git a/controls/menu.c b/controls/menu.c index ed17b43b9f9..8b0968ce46e 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -551,7 +551,7 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags ) POPUPMENU *menu; UINT i; - if (((*hmenu)==0xffff) || (!(menu = MENU_GetMenu(*hmenu)))) return NULL; + if ((*hmenu == (HMENU)0xffff) || (!(menu = MENU_GetMenu(*hmenu)))) return NULL; if (wFlags & MF_BYPOSITION) { if (*nPos >= menu->nItems) return NULL; @@ -1789,7 +1789,7 @@ static BOOL MENU_SetItemData( MENUITEM *item, UINT flags, UINT_PTR id, } } else if (IS_BITMAP_ITEM(flags)) - item->text = (LPWSTR)(HBITMAP)LOWORD(str); + item->text = (LPWSTR)HBITMAP_32(LOWORD(str)); else item->text = NULL; if (flags & MF_OWNERDRAW) @@ -3827,7 +3827,7 @@ BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu ) lpmenu->hWnd = hWnd; lpmenu->Height = 0; /* Make sure we recalculate the size */ } - SetWindowLongA( hWnd, GWL_ID, hMenu ); + SetWindowLongA( hWnd, GWL_ID, (LONG_PTR)hMenu ); if (IsWindowVisible(hWnd)) SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | @@ -3909,10 +3909,10 @@ void WINAPI EndMenu(void) */ HMENU16 WINAPI LookupMenuHandle16( HMENU16 hmenu, INT16 id ) { - HMENU hmenu32 = hmenu; + HMENU hmenu32 = HMENU_32(hmenu); UINT id32 = id; if (!MENU_FindItem( &hmenu32, &id32, MF_BYCOMMAND )) return 0; - else return hmenu32; + else return HMENU_16(hmenu32); } @@ -3964,7 +3964,7 @@ HMENU WINAPI LoadMenuW( HINSTANCE instance, LPCWSTR name ) */ HMENU16 WINAPI LoadMenuIndirect16( LPCVOID template ) { - HMENU16 hMenu; + HMENU hMenu; WORD version, offset; LPCSTR p = (LPCSTR)template; @@ -3984,7 +3984,7 @@ HMENU16 WINAPI LoadMenuIndirect16( LPCVOID template ) DestroyMenu( hMenu ); return 0; } - return hMenu; + return HMENU_16(hMenu); } @@ -3993,7 +3993,7 @@ HMENU16 WINAPI LoadMenuIndirect16( LPCVOID template ) */ HMENU WINAPI LoadMenuIndirectA( LPCVOID template ) { - HMENU16 hMenu; + HMENU hMenu; WORD version, offset; LPCSTR p = (LPCSTR)template; diff --git a/dlls/user/dde/client.c b/dlls/user/dde/client.c index 245cfdcf118..3eda3cff84d 100644 --- a/dlls/user/dde/client.c +++ b/dlls/user/dde/client.c @@ -659,7 +659,7 @@ static WDML_XACT* WDML_ClientQueueExecute(WDML_CONV* pConv, LPCVOID pData, DWORD pXAct->hMem = WDML_BuildExecuteCommand(pConv, pData, cbData); } - pXAct->lParam = pXAct->hMem; + pXAct->lParam = (LPARAM)pXAct->hMem; return pXAct; } @@ -682,7 +682,7 @@ static WDML_QUEUE_STATE WDML_HandleExecuteReply(WDML_CONV* pConv, MSG* msg, WDML UnpackDDElParam(WM_DDE_ACK, msg->lParam, &uiLo, &uiHi); FreeDDElParam(WM_DDE_ACK, msg->lParam); - if (uiHi != pXAct->hMem) + if ((HANDLE)uiHi != pXAct->hMem) { return WDML_QS_PASS; } @@ -735,7 +735,7 @@ static WDML_XACT* WDML_ClientQueuePoke(WDML_CONV* pConv, LPCVOID pData, DWORD cb } } - pXAct->lParam = PackDDElParam(WM_DDE_POKE, pXAct->hMem, atom); + pXAct->lParam = PackDDElParam(WM_DDE_POKE, (UINT)pXAct->hMem, atom); return pXAct; } @@ -869,10 +869,7 @@ static WDML_QUEUE_STATE WDML_HandleIncomingData(WDML_CONV* pConv, MSG* msg, HDDE if (hDdeDataOut != (HDDEDATA)DDE_FACK || wdh.fRelease) { - if (uiLo) - { - GlobalFree(uiLo); - } + if (uiLo) GlobalFree((HANDLE)uiLo); } DdeFreeDataHandle(hDdeDataIn); diff --git a/dlls/user/dde/ddeml16.c b/dlls/user/dde/ddeml16.c index 78c03db16a5..98c3a0c00e6 100644 --- a/dlls/user/dde/ddeml16.c +++ b/dlls/user/dde/ddeml16.c @@ -120,8 +120,8 @@ HDDEDATA WDML_InvokeCallback16(PFNCALLBACK pfn, UINT uType, UINT uFmt, d1 = dwData1; break; } - ret = WDML_CallTo16_long_llllllll((FARPROC16)pfn, uType, uFmt, hConv, - hsz1, hsz2, hdata, d1, dwData2); + ret = (HDDEDATA)WDML_CallTo16_long_llllllll((FARPROC16)pfn, uType, uFmt, (LONG)hConv, + (LONG)hsz1, (LONG)hsz2, (LONG)hdata, d1, dwData2); switch (uType) { case XTYP_CONNECT: diff --git a/dlls/user/dde/misc.c b/dlls/user/dde/misc.c index 59f14319669..5bb75b25464 100644 --- a/dlls/user/dde/misc.c +++ b/dlls/user/dde/misc.c @@ -2049,7 +2049,7 @@ UINT WINAPI DdeQueryConvInfo(HCONV hConv, DWORD id, LPCONVINFO lpConvInfo) } else if ((DWORD)hConv & 1) { - pConv = WDML_GetConv((DWORD)hConv & ~1, FALSE); + pConv = WDML_GetConv((HCONV)((DWORD)hConv & ~1), FALSE); if (pConv != NULL) { FIXME("Request on remote conversation information is not implemented yet\n"); diff --git a/dlls/user/dde/server.c b/dlls/user/dde/server.c index f4e8fc2ed49..33dee61fd7b 100644 --- a/dlls/user/dde/server.c +++ b/dlls/user/dde/server.c @@ -794,7 +794,7 @@ static WDML_QUEUE_STATE WDML_ServerHandleExecute(WDML_CONV* pConv, WDML_XACT* pX case DDE_FNOTPROCESSED: break; } - WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, fBusy, fAck, pXAct->hMem, 0, 0); + WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, fBusy, fAck, (UINT)pXAct->hMem, 0, 0); return WDML_QS_HANDLED; } diff --git a/dlls/user/message.c b/dlls/user/message.c index 888b44a9ce2..9232eaae759 100644 --- a/dlls/user/message.c +++ b/dlls/user/message.c @@ -1173,7 +1173,7 @@ static BOOL post_dde_message( DWORD dest_tid, struct packed_message *data, const if (HIWORD(uiHi)) { /* uiHi should contain a hMem from WM_DDE_EXECUTE */ - HGLOBAL h = dde_get_pair( uiHi ); + HGLOBAL h = dde_get_pair( (HANDLE)uiHi ); if (h) { /* send back the value of h on the other side */ @@ -1279,8 +1279,8 @@ static BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM if (!buffer || !*buffer) return FALSE; uiLo = *lparam; memcpy( &hMem, *buffer, size ); - uiHi = hMem; - TRACE("recv dde-ack %u mem=%x[%lx]\n", uiLo, uiHi, GlobalSize( uiHi )); + uiHi = (UINT)hMem; + TRACE("recv dde-ack %u mem=%x[%lx]\n", uiLo, uiHi, GlobalSize( hMem )); } else { @@ -1306,7 +1306,7 @@ static BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM } else return FALSE; } - uiLo = hMem; + uiLo = (UINT)hMem; *lparam = PackDDElParam( message, uiLo, uiHi ); break; @@ -1320,14 +1320,14 @@ static BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM memcpy( ptr, *buffer, size ); GlobalUnlock( hMem ); TRACE( "exec: pairing c=%08lx s=%08lx\n", *lparam, (DWORD)hMem ); - if (!dde_add_pair( *lparam, hMem )) + if (!dde_add_pair( (HGLOBAL)*lparam, hMem )) { GlobalFree( hMem ); return FALSE; } } } else return FALSE; - *lparam = hMem; + *lparam = (LPARAM)hMem; break; } return TRUE; diff --git a/include/cursoricon.h b/include/cursoricon.h index 51cbd0d5c5a..db720839901 100644 --- a/include/cursoricon.h +++ b/include/cursoricon.h @@ -84,6 +84,6 @@ typedef struct #define CID_WIN32 0x0004 #define CID_NONSHARED 0x0008 -extern void CURSORICON_FreeModuleIcons( HMODULE hModule ); +extern void CURSORICON_FreeModuleIcons( HMODULE16 hModule ); #endif /* __WINE_CURSORICON_H */ diff --git a/include/user.h b/include/user.h index 51e4d4328f4..7ae1da803e5 100644 --- a/include/user.h +++ b/include/user.h @@ -150,10 +150,13 @@ extern HPALETTE WINAPI SelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBackgro extern DWORD USER16_AlertableWait; /* HANDLE16 <-> HANDLE conversions */ -#define HCURSOR_16(h32) (LOWORD(h32)) -#define HICON_16(h32) (LOWORD(h32)) +#define HCURSOR_16(h32) (LOWORD(h32)) +#define HICON_16(h32) (LOWORD(h32)) +#define HINSTANCE_16(h32) (LOWORD(h32)) -#define HCURSOR_32(h16) ((HCURSOR)(ULONG_PTR)(h16)) -#define HICON_32(h16) ((HICON)(ULONG_PTR)(h16)) +#define HCURSOR_32(h16) ((HCURSOR)(ULONG_PTR)(h16)) +#define HICON_32(h16) ((HICON)(ULONG_PTR)(h16)) +#define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16)) +#define HMODULE_32(h16) ((HMODULE)(ULONG_PTR)(h16)) #endif /* __WINE_USER_H */ diff --git a/windows/class.c b/windows/class.c index 009cf6f1465..8e4eeb24f48 100644 --- a/windows/class.c +++ b/windows/class.c @@ -298,7 +298,7 @@ void CLASS_FreeModuleClasses( HMODULE16 hModule ) for (ptr = firstClass; ptr; ptr = next) { next = ptr->next; - if (ptr->hInstance == hModule) CLASS_FreeClass( ptr ); + if (ptr->hInstance == HINSTANCE_32(hModule)) CLASS_FreeClass( ptr ); } USER_Unlock(); } @@ -331,13 +331,13 @@ static CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE hinstance ) if (class->style & CS_GLOBALCLASS) continue; if (class->atomName == atom) { - if (hinstance==class->hInstance || hinstance==0xffff) + if (hinstance==class->hInstance || hinstance == (HINSTANCE)0xffff) { TRACE("-- found local %p\n", class); return class; } if (class->hInstance == 0) tclass = class; - else if(class->hInstance == hUser) + else if(class->hInstance == HINSTANCE_32(hUser)) { user_class = class; } @@ -494,7 +494,7 @@ CLASS *CLASS_AddWindow( ATOM atom, HINSTANCE inst, WINDOWPROCTYPE type, INT *winExtra, WNDPROC *winproc, DWORD *style, struct tagDCE **dce ) { CLASS *class; - if (type == WIN_PROC_16) inst = GetExePtr(inst); + if (type == WIN_PROC_16) inst = HINSTANCE_32(GetExePtr(HINSTANCE_16(inst))); if (!(class = CLASS_FindClassByAtom( atom, inst ))) return NULL; class->cWindows++; @@ -533,7 +533,7 @@ ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc ) ATOM atom; CLASS *classPtr; int iSmIconWidth, iSmIconHeight; - HINSTANCE16 hInstance=GetExePtr(wc->hInstance); + HINSTANCE hInstance = HINSTANCE_32(GetExePtr(wc->hInstance)); if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0; if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style, @@ -555,7 +555,7 @@ ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc ) iSmIconHeight = GetSystemMetrics(SM_CYSMICON); classPtr->hIcon = HICON_32(wc->hIcon); - classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON, + classPtr->hIconSm = CopyImage(classPtr->hIcon, IMAGE_ICON, iSmIconWidth, iSmIconHeight, LR_COPYFROMRESOURCE); classPtr->hCursor = HCURSOR_32(wc->hCursor); @@ -660,7 +660,7 @@ ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc ) { ATOM atom; CLASS *classPtr; - HINSTANCE16 hInstance = GetExePtr( wc->hInstance ); + HINSTANCE hInstance = HINSTANCE_32(GetExePtr( wc->hInstance )); if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0; if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style, @@ -758,7 +758,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc ) */ BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance ) { - return UnregisterClassA( className, GetExePtr( hInstance ) ); + return UnregisterClassA( className, HINSTANCE_32(GetExePtr( hInstance )) ); } /*********************************************************************** @@ -1107,14 +1107,14 @@ INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count ) /*********************************************************************** * GetClassInfo (USER.404) */ -BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc ) +BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc ) { ATOM atom; CLASS *classPtr; + HINSTANCE hInstance = HINSTANCE_32(GetExePtr( hInst16 )); TRACE("%x %s %p\n",hInstance, debugstr_a(MapSL(name)), wc); - hInstance = GetExePtr( hInstance ); if (!(atom = GlobalFindAtomA( MapSL(name) )) || !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))) return FALSE; @@ -1125,7 +1125,7 @@ BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 ); wc->cbClsExtra = (INT16)classPtr->cbClsExtra; wc->cbWndExtra = (INT16)classPtr->cbWndExtra; - wc->hInstance = classPtr->style & CS_GLOBALCLASS ? GetModuleHandle16("USER") : (HINSTANCE16)classPtr->hInstance; + wc->hInstance = classPtr->style & CS_GLOBALCLASS ? GetModuleHandle16("USER") : HINSTANCE_16(classPtr->hInstance); wc->hIcon = HICON_16(classPtr->hIcon); wc->hCursor = HCURSOR_16(classPtr->hCursor); wc->hbrBackground = HBRUSH_16(classPtr->hbrBackground); @@ -1219,14 +1219,14 @@ BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the * same in Win16 as in Win32. --AJ */ -BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc ) +BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc ) { ATOM atom; CLASS *classPtr; + HINSTANCE hInstance = HINSTANCE_32(GetExePtr( hInst16 )); TRACE("%x %s %p\n",hInstance,debugstr_a( MapSL(name) ), wc); - hInstance = GetExePtr( hInstance ); if (!(atom = GlobalFindAtomA( MapSL(name) )) || !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) || (hInstance != classPtr->hInstance)) return FALSE; @@ -1234,7 +1234,7 @@ BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 ); wc->cbClsExtra = (INT16)classPtr->cbClsExtra; wc->cbWndExtra = (INT16)classPtr->cbWndExtra; - wc->hInstance = (HINSTANCE16)classPtr->hInstance; + wc->hInstance = HINSTANCE_16(classPtr->hInstance); wc->hIcon = HICON_16(classPtr->hIcon); wc->hIconSm = HICON_16(classPtr->hIconSm); wc->hCursor = HCURSOR_16(classPtr->hCursor); diff --git a/windows/clipboard.c b/windows/clipboard.c index 419080f75f5..fb089303ebb 100644 --- a/windows/clipboard.c +++ b/windows/clipboard.c @@ -57,6 +57,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard); #define CF_REGFORMATBASE 0xC000 +#define HGDIOBJ_32(handle16) ((HGDIOBJ)(ULONG_PTR)(handle16)) + /************************************************************************** * Clipboard context global variables */ @@ -207,7 +209,7 @@ void CLIPBOARD_DeleteRecord(LPWINE_CLIPFORMAT lpFormat, BOOL bChange) if (lpFormat->hData32) DeleteObject(lpFormat->hData32); if (lpFormat->hData16) - DeleteObject(lpFormat->hData16); + DeleteObject(HGDIOBJ_32(lpFormat->hData16)); } else if( lpFormat->wFormatID == CF_METAFILEPICT ) { diff --git a/windows/cursoricon.c b/windows/cursoricon.c index 4fb6940bea9..77c0a397df5 100644 --- a/windows/cursoricon.c +++ b/windows/cursoricon.c @@ -263,14 +263,10 @@ static INT CURSORICON_DelSharedIcon( HICON hIcon ) /********************************************************************** * CURSORICON_FreeModuleIcons */ -void CURSORICON_FreeModuleIcons( HMODULE hModule ) +void CURSORICON_FreeModuleIcons( HMODULE16 hMod16 ) { ICONCACHE **ptr = &IconAnchor; - - if ( HIWORD( hModule ) ) - hModule = MapHModuleLS( hModule ); - else - hModule = GetExePtr( hModule ); + HMODULE hModule = HMODULE_32(GetExePtr( hMod16 )); EnterCriticalSection( &IconCrst ); @@ -761,9 +757,9 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name, /* Normalize hInstance (must be uniquely represented for icon cache) */ if ( HIWORD( hInstance ) ) - hInstance = MapHModuleLS( hInstance ); + hInstance = HINSTANCE_32(MapHModuleLS( hInstance )); else - hInstance = GetExePtr( hInstance ); + hInstance = HINSTANCE_32(GetExePtr( HINSTANCE_16(hInstance) )); /* Get directory resource ID */ diff --git a/windows/dce.c b/windows/dce.c index 338dbc687da..f745a8a2271 100644 --- a/windows/dce.c +++ b/windows/dce.c @@ -39,13 +39,14 @@ #include "wine/debug.h" #include "windef.h" #include "wingdi.h" +#include "wownt32.h" #include "wine/winbase16.h" #include "wine/winuser16.h" WINE_DEFAULT_DEBUG_CHANNEL(dc); static DCE *firstDCE; -static HDC defaultDCstate; +static HDC16 defaultDCstate; static void DCE_DeleteClipRgn( DCE* ); static INT DCE_ReleaseDC( DCE* ); @@ -89,7 +90,7 @@ DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type ) HeapFree( GetProcessHeap(), 0, dce ); return 0; } - if (!defaultDCstate) defaultDCstate = GetDCState16( dce->hDC ); + if (!defaultDCstate) defaultDCstate = GetDCState16( HDC_16(dce->hDC) ); /* store DCE handle in DC hook data field */ @@ -107,7 +108,7 @@ DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type ) if (style & WS_CLIPCHILDREN) dce->DCXflags |= DCX_CLIPCHILDREN; if (style & WS_CLIPSIBLINGS) dce->DCXflags |= DCX_CLIPSIBLINGS; } - SetHookFlags16(dce->hDC,DCHF_INVALIDATEVISRGN); + SetHookFlags16( HDC_16(dce->hDC), DCHF_INVALIDATEVISRGN ); } else dce->DCXflags = DCX_CACHE | DCX_DCEEMPTY; @@ -223,7 +224,7 @@ static void DCE_DeleteClipRgn( DCE* dce ) /* make it dirty so that the vis rgn gets recomputed next time */ dce->DCXflags |= DCX_DCEDIRTY; - SetHookFlags16( dce->hDC, DCHF_INVALIDATEVISRGN ); + SetHookFlags16( HDC_16(dce->hDC), DCHF_INVALIDATEVISRGN ); } @@ -243,8 +244,8 @@ static INT DCE_ReleaseDC( DCE* dce ) if (dce->DCXflags & DCX_CACHE) { /* make the DC clean so that SetDCState doesn't try to update the vis rgn */ - SetHookFlags16( dce->hDC, DCHF_VALIDATEVISRGN ); - SetDCState16( dce->hDC, defaultDCstate ); + SetHookFlags16( HDC_16(dce->hDC), DCHF_VALIDATEVISRGN ); + SetDCState16( HDC_16(dce->hDC), defaultDCstate ); dce->DCXflags &= ~DCX_DCEBUSY; if (dce->DCXflags & DCX_DCEDIRTY) { @@ -323,7 +324,7 @@ BOOL DCE_InvalidateDCE(HWND hwnd, const RECT* pRectUpdate) TRACE("\tfixed up %p dce [%04x]\n", dce, dce->hwndCurrent); dce->DCXflags |= DCX_DCEDIRTY; - SetHookFlags16(dce->hDC, DCHF_INVALIDATEVISRGN); + SetHookFlags16( HDC_16(dce->hDC), DCHF_INVALIDATEVISRGN ); bRet = TRUE; } } @@ -510,7 +511,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) dce->DCXflags &= ~DCX_DCEDIRTY; hdc = dce->hDC; - if (bUpdateVisRgn) SetHookFlags16( hdc, DCHF_INVALIDATEVISRGN ); /* force update */ + if (bUpdateVisRgn) SetHookFlags16( HDC_16(hdc), DCHF_INVALIDATEVISRGN ); /* force update */ if (!USER_Driver.pGetDC( hwnd, hdc, hrgnClip, flags )) hdc = 0; @@ -588,7 +589,7 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam ) TRACE("hDC = %04x, %i\n", hDC, code); if (!dce) return 0; - assert(dce->hDC == hDC); + assert( HDC_16(dce->hDC) == hDC ); /* Grab the windows lock before doing anything else */ USER_Lock(); @@ -604,7 +605,7 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam ) { /* Dirty bit has been cleared by caller, set it again so that * pGetDC recomputes the visible region. */ - SetHookFlags16( dce->hDC, DCHF_INVALIDATEVISRGN ); + SetHookFlags16( hDC, DCHF_INVALIDATEVISRGN ); USER_Driver.pGetDC( dce->hwndCurrent, dce->hDC, dce->hClipRgn, dce->DCXflags ); } else /* non-fatal but shouldn't happen */ diff --git a/windows/dialog.c b/windows/dialog.c index a61cdb916f6..4315226d6aa 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -407,12 +407,12 @@ static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info, /*********************************************************************** - * DIALOG_CreateControls + * DIALOG_CreateControls16 * * Create the control windows for a dialog. */ -static BOOL DIALOG_CreateControls( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate, - HINSTANCE hInst, BOOL win32 ) +static BOOL DIALOG_CreateControls16( HWND hwnd, LPCSTR template, + const DLG_TEMPLATE *dlgTemplate, HINSTANCE16 hInst ) { DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd ); DLG_CONTROL_INFO info; @@ -422,62 +422,93 @@ static BOOL DIALOG_CreateControls( HWND hwnd, LPCSTR template, const DLG_TEMPLAT TRACE(" BEGIN\n" ); while (items--) { - if (!win32) - { - HINSTANCE16 instance; - SEGPTR segptr; + HINSTANCE16 instance = hInst; + SEGPTR segptr; - template = DIALOG_GetControl16( template, &info ); - if (HIWORD(info.className) && !strcmp( info.className, "EDIT") && - !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT)) + template = DIALOG_GetControl16( template, &info ); + if (HIWORD(info.className) && !strcmp( info.className, "EDIT") && + !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT)) + { + if (!dlgInfo->hDialogHeap) { + dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000); if (!dlgInfo->hDialogHeap) { - dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000); - if (!dlgInfo->hDialogHeap) - { - ERR("Insufficient memory to create heap for edit control\n" ); - continue; - } - LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff); + ERR("Insufficient memory to create heap for edit control\n" ); + continue; } - instance = dlgInfo->hDialogHeap; + LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff); } - else instance = (HINSTANCE16)hInst; + instance = dlgInfo->hDialogHeap; + } - segptr = MapLS( info.data ); - hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY, - info.className, info.windowName, - info.style | WS_CHILD, - MulDiv(info.x, dlgInfo->xBaseUnit, 4), - MulDiv(info.y, dlgInfo->yBaseUnit, 8), - MulDiv(info.cx, dlgInfo->xBaseUnit, 4), - MulDiv(info.cy, dlgInfo->yBaseUnit, 8), - HWND_16(hwnd), (HMENU16)info.id, - instance, (LPVOID)segptr )); - UnMapLS( segptr ); - } - else + segptr = MapLS( info.data ); + hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY, + info.className, info.windowName, + info.style | WS_CHILD, + MulDiv(info.x, dlgInfo->xBaseUnit, 4), + MulDiv(info.y, dlgInfo->yBaseUnit, 8), + MulDiv(info.cx, dlgInfo->xBaseUnit, 4), + MulDiv(info.cy, dlgInfo->yBaseUnit, 8), + HWND_16(hwnd), (HMENU16)info.id, + instance, (LPVOID)segptr )); + UnMapLS( segptr ); + + if (!hwndCtrl) return FALSE; + + /* Send initialisation messages to the control */ + if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT, + (WPARAM)dlgInfo->hUserFont, 0 ); + if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) { - template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info, - dlgTemplate->dialogEx ); - /* Is this it? */ - if (info.style & WS_BORDER) - { - info.style &= ~WS_BORDER; - info.exStyle |= WS_EX_CLIENTEDGE; - } - hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, - (LPCWSTR)info.className, - (LPCWSTR)info.windowName, - info.style | WS_CHILD, - MulDiv(info.x, dlgInfo->xBaseUnit, 4), - MulDiv(info.y, dlgInfo->yBaseUnit, 8), - MulDiv(info.cx, dlgInfo->xBaseUnit, 4), - MulDiv(info.cy, dlgInfo->yBaseUnit, 8), - hwnd, (HMENU)info.id, - hInst, (LPVOID)info.data ); + /* If there's already a default push-button, set it back */ + /* to normal and use this one instead. */ + if (hwndDefButton) + SendMessageA( hwndDefButton, BM_SETSTYLE, + BS_PUSHBUTTON,FALSE ); + hwndDefButton = hwndCtrl; + dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID ); } + } + TRACE(" END\n" ); + return TRUE; +} + + +/*********************************************************************** + * DIALOG_CreateControls32 + * + * Create the control windows for a dialog. + */ +static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, + const DLG_TEMPLATE *dlgTemplate, HINSTANCE hInst ) +{ + DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd ); + DLG_CONTROL_INFO info; + HWND hwndCtrl, hwndDefButton = 0; + INT items = dlgTemplate->nbItems; + + TRACE(" BEGIN\n" ); + while (items--) + { + template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info, + dlgTemplate->dialogEx ); + /* Is this it? */ + if (info.style & WS_BORDER) + { + info.style &= ~WS_BORDER; + info.exStyle |= WS_EX_CLIENTEDGE; + } + hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, + (LPCWSTR)info.className, + (LPCWSTR)info.windowName, + info.style | WS_CHILD, + MulDiv(info.x, dlgInfo->xBaseUnit, 4), + MulDiv(info.y, dlgInfo->yBaseUnit, 8), + MulDiv(info.cx, dlgInfo->xBaseUnit, 4), + MulDiv(info.cy, dlgInfo->yBaseUnit, 8), + hwnd, (HMENU)info.id, + hInst, (LPVOID)info.data ); if (!hwndCtrl) return FALSE; /* Send initialisation messages to the control */ @@ -697,6 +728,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, DIALOGINFO * dlgInfo; BOOL ownerEnabled = TRUE; BOOL win32Template = (procType != WIN_PROC_16); + BOOL res; /* Parse dialog template */ @@ -722,7 +754,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, if (template.menuName) { - if (!win32Template) dlgInfo->hMenu = LoadMenu16( hInst, template.menuName ); + if (!win32Template) dlgInfo->hMenu = HMENU_32(LoadMenu16( HINSTANCE_16(hInst), template.menuName )); else dlgInfo->hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName ); } @@ -813,7 +845,8 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, hwnd = WIN_Handle32( CreateWindowEx16(template.exStyle, template.className, template.caption, template.style & ~WS_VISIBLE, rect.left, rect.top, rect.right, rect.bottom, - HWND_16(owner), dlgInfo->hMenu, hInst, NULL )); + HWND_16(owner), HMENU_16(dlgInfo->hMenu), + HINSTANCE_16(hInst), NULL )); else hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className, (LPCWSTR)template.caption, @@ -848,8 +881,12 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, /* Create controls */ - if (DIALOG_CreateControls( hwnd, dlgTemplate, &template, - hInst, win32Template )) + if (win32Template) + res = DIALOG_CreateControls32( hwnd, dlgTemplate, &template, hInst ); + else + res = DIALOG_CreateControls16( hwnd, dlgTemplate, &template, HINSTANCE_16(hInst) ); + + if (res) { HWND hwndPreInitFocus; @@ -973,8 +1010,8 @@ HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst, HWND16 owner, DLGPROC16 dlgProc, LPARAM param ) { - return HWND_16( DIALOG_CreateIndirect( hInst, dlgTemplate, WIN_Handle32(owner), - (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE )); + return HWND_16( DIALOG_CreateIndirect( HINSTANCE_32(hInst), dlgTemplate, WIN_Handle32(owner), + (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE )); } @@ -1083,7 +1120,7 @@ INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template, if ((data = LockResource16( hmem ))) { HWND owner = WIN_Handle32(owner16); - hwnd = DIALOG_CreateIndirect( hInst, data, owner, + hwnd = DIALOG_CreateIndirect( HINSTANCE_32(hInst), data, owner, (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE ); if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner ); GlobalUnlock16( hmem ); @@ -1146,7 +1183,7 @@ INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate, LPCVOID ptr; if (!(ptr = GlobalLock16( dlgTemplate ))) return -1; - hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, (DLGPROC)dlgProc, + hwnd = DIALOG_CreateIndirect( HINSTANCE_32(hInst), ptr, owner, (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE ); GlobalUnlock16( dlgTemplate ); if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); diff --git a/windows/mdi.c b/windows/mdi.c index c92db69b0b0..d8b260eacf4 100644 --- a/windows/mdi.c +++ b/windows/mdi.c @@ -1120,9 +1120,9 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild ) if ( (menuInfo.fType & MFT_BITMAP) && (LOWORD(menuInfo.dwTypeData)!=0) && - (LOWORD(menuInfo.dwTypeData)!=hBmpClose) ) + (LOWORD(menuInfo.dwTypeData)!=HBITMAP_16(hBmpClose)) ) { - DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData)); + DeleteObject(HBITMAP_32(LOWORD(menuInfo.dwTypeData))); } if(TWEAK_WineLook > WIN31_LOOK) @@ -1245,7 +1245,7 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, else { LPCLIENTCREATESTRUCT16 ccs = MapSL((SEGPTR)cs->lpCreateParams); - ci->hWindowMenu = ccs->hWindowMenu; + ci->hWindowMenu = HMENU_32(ccs->hWindowMenu); ci->idFirstChild = ccs->idFirstChild; } WIN_ReleasePtr( wndPtr ); diff --git a/windows/struct32.c b/windows/struct32.c index 9eed6d47595..a9b2fe0fd47 100644 --- a/windows/struct32.c +++ b/windows/struct32.c @@ -91,8 +91,8 @@ void STRUCT32_CREATESTRUCT32Ato16( const CREATESTRUCTA* from, CREATESTRUCT16* to ) { to->lpCreateParams = from->lpCreateParams; - to->hInstance = (HINSTANCE16)from->hInstance; - to->hMenu = (HMENU16)from->hMenu; + to->hInstance = HINSTANCE_16(from->hInstance); + to->hMenu = HMENU_16(from->hMenu); to->hwndParent = HWND_16(from->hwndParent); to->cy = from->cy; to->cx = from->cx; @@ -106,8 +106,8 @@ void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from, CREATESTRUCTA *to ) { to->lpCreateParams = from->lpCreateParams; - to->hInstance = (HINSTANCE)from->hInstance; - to->hMenu = (HMENU)from->hMenu; + to->hInstance = HINSTANCE_32(from->hInstance); + to->hMenu = HMENU_32(from->hMenu); to->hwndParent = WIN_Handle32(from->hwndParent); to->cy = from->cy; to->cx = from->cx; @@ -121,7 +121,7 @@ void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from, void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA* from, MDICREATESTRUCT16* to ) { - to->hOwner = (HINSTANCE16)from->hOwner; + to->hOwner = HINSTANCE_16(from->hOwner); to->x = from->x; to->y = from->y; to->cx = from->cx; @@ -133,7 +133,7 @@ void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA* from, void STRUCT32_MDICREATESTRUCT16to32A( const MDICREATESTRUCT16* from, MDICREATESTRUCTA *to ) { - to->hOwner = (HINSTANCE)from->hOwner; + to->hOwner = HINSTANCE_32(from->hOwner); to->x = from->x; to->y = from->y; to->cx = from->cx; diff --git a/windows/syscolor.c b/windows/syscolor.c index 30ddc020f01..1c9d28f577a 100644 --- a/windows/syscolor.c +++ b/windows/syscolor.c @@ -30,11 +30,12 @@ #include "sysmetrics.h" #include "winbase.h" #include "winuser.h" -#include "wine/debug.h" +#include "wownt32.h" #include "winreg.h" #include "local.h" #include "user.h" #include "gdi.h" /* sic */ +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(syscolor); @@ -123,7 +124,7 @@ static HPEN SysColorPens[NUM_SYS_COLORS]; * For a description of the GDI object magics and their flags, * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though). */ -static void SYSCOLOR_MakeObjectSystem( HGDIOBJ handle, BOOL set) +static void SYSCOLOR_MakeObjectSystem( HGDIOBJ16 handle, BOOL set) { static WORD heap_sel = 0; LPWORD ptr; @@ -151,19 +152,19 @@ static void SYSCOLOR_SetColor( int index, COLORREF color ) SysColors[index] = color; if (SysColorBrushes[index]) { - SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], FALSE); + SYSCOLOR_MakeObjectSystem( HBRUSH_16(SysColorBrushes[index]), FALSE); DeleteObject( SysColorBrushes[index] ); } SysColorBrushes[index] = CreateSolidBrush( color ); - SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], TRUE); + SYSCOLOR_MakeObjectSystem( HBRUSH_16(SysColorBrushes[index]), TRUE); if (SysColorPens[index]) { - SYSCOLOR_MakeObjectSystem(SysColorPens[index], FALSE); + SYSCOLOR_MakeObjectSystem( HPEN_16(SysColorPens[index]), FALSE); DeleteObject( SysColorPens[index] ); } SysColorPens[index] = CreatePen( PS_SOLID, 1, color ); - SYSCOLOR_MakeObjectSystem(SysColorPens[index], TRUE); + SYSCOLOR_MakeObjectSystem( HPEN_16(SysColorPens[index]), TRUE); } diff --git a/windows/win.c b/windows/win.c index be96d6b06aa..cbac6f1bb23 100644 --- a/windows/win.c +++ b/windows/win.c @@ -793,7 +793,7 @@ BOOL WIN_CreateDesktopWindow(void) wine_server_call( req ); pWndDesktop->dwStyle = reply->old_style; pWndDesktop->dwExStyle = reply->old_ex_style; - pWndDesktop->hInstance = (ULONG_PTR)reply->old_instance; + pWndDesktop->hInstance = (HINSTANCE)reply->old_instance; pWndDesktop->userdata = (ULONG_PTR)reply->old_user_data; pWndDesktop->wIDmenu = reply->old_id; } @@ -1154,7 +1154,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom, if (HIWORD(cs->hInstance)) cs->hMenu = LoadMenuA(cs->hInstance,menuName); else - cs->hMenu = LoadMenu16(cs->hInstance,menuName); + cs->hMenu = HMENU_32(LoadMenu16(HINSTANCE_16(cs->hInstance),menuName)); if (cs->hMenu) SetMenu( hwnd, cs->hMenu ); } @@ -1250,7 +1250,7 @@ HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className, /* Create the window */ cs.lpCreateParams = data; - cs.hInstance = (HINSTANCE)instance; + cs.hInstance = HINSTANCE_32(instance); cs.hMenu = HMENU_32(menu); cs.hwndParent = WIN_Handle32( parent ); cs.style = style; diff --git a/windows/winproc.c b/windows/winproc.c index fd0f9bbe06c..6e30009dad6 100644 --- a/windows/winproc.c +++ b/windows/winproc.c @@ -1079,7 +1079,7 @@ void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam } } -static HANDLE convert_handle_16_to_32(HANDLE16 src, unsigned int flags) +static UINT convert_handle_16_to_32(HANDLE16 src, unsigned int flags) { HANDLE dst; UINT sz = GlobalSize16(src); @@ -1093,7 +1093,7 @@ static HANDLE convert_handle_16_to_32(HANDLE16 src, unsigned int flags) GlobalUnlock16(src); GlobalUnlock(dst); - return dst; + return (UINT)dst; } /********************************************************************** @@ -1187,7 +1187,7 @@ INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pms dis->itemState = dis16->itemState; dis->hwndItem = (dis->CtlType == ODT_MENU) ? (HWND)HMENU_32(dis16->hwndItem) : WIN_Handle32( dis16->hwndItem ); - dis->hDC = dis16->hDC; + dis->hDC = HDC_32(dis16->hDC); dis->itemData = dis16->itemData; CONV_RECT16TO32( &dis16->rcItem, &dis->rcItem ); *plparam = (LPARAM)dis; @@ -1240,7 +1240,7 @@ INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pms if((LOWORD(*plparam) & MF_POPUP) && (LOWORD(*plparam) != 0xFFFF)) { HMENU hmenu=HMENU_32(HIWORD(*plparam)); - UINT Pos=MENU_FindSubMenu( &hmenu, wParam16); + UINT Pos=MENU_FindSubMenu( &hmenu, HMENU_32(wParam16)); if(Pos==0xFFFF) Pos=0; /* NO_SELECTED_ITEM */ *pwparam32 = MAKEWPARAM( Pos, LOWORD(*plparam) ); } @@ -1367,7 +1367,7 @@ INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pms { HANDLE16 lo16; ATOM hi; - HANDLE lo32 = 0; + UINT lo32 = 0; *pwparam32 = (WPARAM)WIN_Handle32(wParam16); lo16 = LOWORD(*plparam); @@ -1686,18 +1686,18 @@ LRESULT WINPROC_UnmapMsg16To32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return result; } -static HANDLE16 convert_handle_32_to_16(HANDLE src, unsigned int flags) +static HANDLE16 convert_handle_32_to_16(UINT src, unsigned int flags) { HANDLE16 dst; - UINT sz = GlobalSize(src); + UINT sz = GlobalSize((HANDLE)src); LPSTR ptr16, ptr32; if (!(dst = GlobalAlloc16(flags, sz))) return 0; - ptr32 = GlobalLock(src); + ptr32 = GlobalLock((HANDLE)src); ptr16 = GlobalLock16(dst); if (ptr16 != NULL && ptr32 != NULL) memcpy(ptr16, ptr32, sz); - GlobalUnlock(src); + GlobalUnlock((HANDLE)src); GlobalUnlock16(dst); return dst; @@ -2149,7 +2149,7 @@ INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32, case WM_DDE_DATA: case WM_DDE_POKE: { - unsigned lo32, hi; + UINT lo32, hi; HANDLE16 lo16 = 0; *pwparam16 = HWND_16((HWND)wParam32); @@ -2170,7 +2170,7 @@ INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32, UnpackDDElParam(msg32, *plparam, &lo, &hi); if (GlobalGetAtomNameA((ATOM)hi, buf, sizeof(buf)) > 0) flag |= 1; - if (GlobalSize(hi) != 0) flag |= 2; + if (GlobalSize((HANDLE)hi) != 0) flag |= 2; switch (flag) { case 0: