/************************************************************************ * FD16_MapOfnStruct16 [internal] * map a 16 bits structure to an Unicode one */ static void FD16_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open) { OPENFILENAMEA ofnA; /* first convert to linear pointers */ memset(&ofnA, 0, sizeof(OPENFILENAMEA)); ofnA.lStructSize = sizeof(OPENFILENAMEA); ofnA.hwndOwner = HWND_32(ofn16->hwndOwner); ofnA.hInstance = HINSTANCE_32(ofn16->hInstance); if (ofn16->lpstrFilter) ofnA.lpstrFilter = MapSL(ofn16->lpstrFilter); if (ofn16->lpstrCustomFilter) ofnA.lpstrCustomFilter = MapSL(ofn16->lpstrCustomFilter); ofnA.nMaxCustFilter = ofn16->nMaxCustFilter; ofnA.nFilterIndex = ofn16->nFilterIndex; ofnA.lpstrFile = MapSL(ofn16->lpstrFile); ofnA.nMaxFile = ofn16->nMaxFile; ofnA.lpstrFileTitle = MapSL(ofn16->lpstrFileTitle); ofnA.nMaxFileTitle = ofn16->nMaxFileTitle; ofnA.lpstrInitialDir = MapSL(ofn16->lpstrInitialDir); ofnA.lpstrTitle = MapSL(ofn16->lpstrTitle); ofnA.Flags = ofn16->Flags; ofnA.nFileOffset = ofn16->nFileOffset; ofnA.nFileExtension = ofn16->nFileExtension; ofnA.lpstrDefExt = MapSL(ofn16->lpstrDefExt); if (HIWORD(ofn16->lpTemplateName)) ofnA.lpTemplateName = MapSL(ofn16->lpTemplateName); else ofnA.lpTemplateName = (LPSTR) ofn16->lpTemplateName; /* ressource number */ /* now calls the 32 bits Ansi to Unicode version to complete the job */ FD31_MapOfnStructA(&ofnA, ofnW, open); }
static void CFn_CHOOSEFONT16to32W(LPCHOOSEFONT16 chf16, LPCHOOSEFONTW chf32w) { int len; if (chf16->Flags & CF_ENABLETEMPLATE) { len = MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpTemplateName), -1, NULL, 0); chf32w->lpTemplateName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpTemplateName), -1, (LPWSTR)chf32w->lpTemplateName, len); } if (chf16->Flags & CF_USESTYLE) { len = MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpszStyle), -1, NULL, 0); chf32w->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpszStyle), -1, chf32w->lpszStyle, len); } chf32w->lStructSize=sizeof(CHOOSEFONTW); chf32w->hwndOwner=HWND_32(chf16->hwndOwner); chf32w->hDC=HDC_32(chf16->hDC); chf32w->iPointSize=chf16->iPointSize; chf32w->Flags=chf16->Flags; chf32w->rgbColors=chf16->rgbColors; chf32w->lCustData=chf16->lCustData; chf32w->lpfnHook=NULL; chf32w->hInstance=HINSTANCE_32(chf16->hInstance); chf32w->nFontType=chf16->nFontType; chf32w->nSizeMax=chf16->nSizeMax; chf32w->nSizeMin=chf16->nSizeMin; FONT_LogFont16To32W(MapSL(chf16->lpLogFont), chf32w->lpLogFont); }
/************************************************************************* * SHELL_Execute16 [Internal] */ static UINT_PTR SHELL_Execute16(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) { UINT ret; char sCmd[MAX_PATH]; WideCharToMultiByte(CP_ACP, 0, lpCmd, -1, sCmd, MAX_PATH, NULL, NULL); ret = WinExec16(sCmd, (UINT16)psei->nShow); psei_out->hInstApp = HINSTANCE_32(ret); return ret; }
/****************************************************************************** * OleMetaFilePictFromIconAndLabel (OLE2.56) * * Returns a global memory handle to a metafile which contains the icon and * label given. * I guess the result of that should look somehow like desktop icons. * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex. * This code might be wrong at some places. */ HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( HICON16 hIcon, LPCOLESTR16 lpszLabel, LPCOLESTR16 lpszSourceFile, UINT16 iIconIndex ) { METAFILEPICT16 *mf16; HGLOBAL16 hmf16; HMETAFILE hmf; INT mfSize; HDC hdc; if (!hIcon) { if (lpszSourceFile) { HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile); /* load the icon at index from lpszSourceFile */ hIcon = HICON_16(LoadIconA(HINSTANCE_32(hInstance), (LPCSTR)(DWORD)iIconIndex)); FreeLibrary16(hInstance); } else return 0; } FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", hIcon, lpszLabel, lpszSourceFile, iIconIndex); hdc = CreateMetaFileW(NULL); DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */ TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */ hmf = CloseMetaFile(hdc); hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16)); mf16 = (METAFILEPICT16 *)GlobalLock16(hmf16); mf16->mm = MM_ANISOTROPIC; mf16->xExt = 20; /* FIXME: bogus */ mf16->yExt = 20; /* dito */ mfSize = GetMetaFileBitsEx(hmf, 0, 0); mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize); if(mf16->hMF) { GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF)); GlobalUnlock16(mf16->hMF); } return hmf16; }
/*********************************************************************** * CallNextHookEx (USER.293) */ LRESULT WINAPI CallNextHookEx16( HHOOK hhook, INT16 code, WPARAM16 wparam, LPARAM lparam ) { struct hook16_queue_info *info; LRESULT ret = 0; if (!(info = get_user_thread_info()->hook16_info)) return 0; switch (info->id) { case WH_MSGFILTER: { MSG16 *msg16 = MapSL(lparam); MSG msg32; map_msg_16_to_32( msg16, &msg32 ); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&msg32 ); break; } case WH_GETMESSAGE: { MSG16 *msg16 = MapSL(lparam); MSG msg32; map_msg_16_to_32( msg16, &msg32 ); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&msg32 ); map_msg_32_to_16( &msg32, msg16 ); break; } case WH_CALLWNDPROC: { CWPSTRUCT16 *cwp16 = MapSL(lparam); LRESULT result; struct wndproc_hook_params params; params.hhook = hhook; params.code = code; params.wparam = wparam; ret = WINPROC_CallProc16To32A( wndproc_hook_callback, cwp16->hwnd, cwp16->message, cwp16->wParam, cwp16->lParam, &result, ¶ms ); break; } case WH_CBT: switch (code) { case HCBT_CREATEWND: { CBT_CREATEWNDA cbtcw32; CREATESTRUCTA cs32; CBT_CREATEWND16 *cbtcw16 = MapSL(lparam); CREATESTRUCT16 *cs16 = MapSL( (SEGPTR)cbtcw16->lpcs ); cbtcw32.lpcs = &cs32; cbtcw32.hwndInsertAfter = WIN_Handle32( cbtcw16->hwndInsertAfter ); cs32.lpCreateParams = (LPVOID)cs16->lpCreateParams; cs32.hInstance = HINSTANCE_32(cs16->hInstance); cs32.hMenu = HMENU_32(cs16->hMenu); cs32.hwndParent = WIN_Handle32(cs16->hwndParent); cs32.cy = cs16->cy; cs32.cx = cs16->cx; cs32.y = cs16->y; cs32.x = cs16->x; cs32.style = cs16->style; cs32.lpszName = MapSL( cs16->lpszName ); cs32.lpszClass = MapSL( cs16->lpszClass ); cs32.dwExStyle = cs16->dwExStyle; ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&cbtcw32 ); cbtcw16->hwndInsertAfter = HWND_16( cbtcw32.hwndInsertAfter ); break; } case HCBT_ACTIVATE: { CBTACTIVATESTRUCT16 *cas16 = MapSL(lparam); CBTACTIVATESTRUCT cas32; cas32.fMouse = cas16->fMouse; cas32.hWndActive = WIN_Handle32(cas16->hWndActive); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&cas32 ); break; } case HCBT_CLICKSKIPPED: { MOUSEHOOKSTRUCT16 *ms16 = MapSL(lparam); MOUSEHOOKSTRUCT ms32; ms32.pt.x = ms16->pt.x; ms32.pt.y = ms16->pt.y; /* wHitTestCode may be negative, so convince compiler to do correct sign extension. Yay. :| */ ms32.wHitTestCode = (INT)(INT16)ms16->wHitTestCode; ms32.dwExtraInfo = ms16->dwExtraInfo; ms32.hwnd = WIN_Handle32( ms16->hwnd ); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&ms32 ); break; } case HCBT_MOVESIZE: { RECT16 *rect16 = MapSL(lparam); RECT rect32; rect32.left = rect16->left; rect32.top = rect16->top; rect32.right = rect16->right; rect32.bottom = rect16->bottom; ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&rect32 ); break; } } break; case WH_MOUSE: { MOUSEHOOKSTRUCT16 *ms16 = MapSL(lparam); MOUSEHOOKSTRUCT ms32; ms32.pt.x = ms16->pt.x; ms32.pt.y = ms16->pt.y; /* wHitTestCode may be negative, so convince compiler to do correct sign extension. Yay. :| */ ms32.wHitTestCode = (INT)((INT16)ms16->wHitTestCode); ms32.dwExtraInfo = ms16->dwExtraInfo; ms32.hwnd = WIN_Handle32(ms16->hwnd); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&ms32 ); break; } case WH_SHELL: case WH_KEYBOARD: ret = CallNextHookEx( hhook, code, wparam, lparam ); break; case WH_HARDWARE: case WH_FOREGROUNDIDLE: case WH_CALLWNDPROCRET: case WH_SYSMSGFILTER: case WH_JOURNALRECORD: case WH_JOURNALPLAYBACK: default: FIXME("\t[%i] 16to32 translation unimplemented\n", info->id); ret = CallNextHookEx( hhook, code, wparam, lparam ); break; } return ret; }