d3d10core: Make some device_parent_*() functions static.
[wine] / dlls / user32 / dde_misc.c
index 049deae..3cbbae8 100644 (file)
@@ -103,7 +103,7 @@ LPARAM WINAPI PackDDElParam(UINT msg, UINT_PTR uiLo, UINT_PTR uiHi)
         return uiHi;
 
     default:
-        return MAKELPARAM(uiLo, uiHi);
+        return MAKELONG(uiLo, uiHi);
     }
 }
 
@@ -348,8 +348,8 @@ UINT WDML_Initialize(LPDWORD pidInst, PFNCALLBACK pfnCallback,
     UINT                       ret;
     WNDCLASSEXW                        wndclass;
 
-    TRACE("(%p,%p,0x%x,%d)\n",
-         pidInst, pfnCallback, afCmd, ulRes);
+    TRACE("(%p,%p,0x%x,%d,0x%x)\n",
+         pidInst, pfnCallback, afCmd, ulRes, bUnicode);
 
     if (ulRes)
     {
@@ -817,6 +817,25 @@ UINT WINAPI DdeGetLastError(DWORD idInst)
     return error_code;
 }
 
+/******************************************************************
+ *             WDML_SetAllLastError
+ *
+ *
+ */
+static void    WDML_SetAllLastError(DWORD lastError)
+{
+    DWORD              threadID;
+    WDML_INSTANCE*     pInstance;
+    threadID = GetCurrentThreadId();
+    pInstance = WDML_InstanceList;
+    while (pInstance)
+    {
+       if (pInstance->threadID == threadID)
+           pInstance->lastError = lastError;
+       pInstance = pInstance->next;
+    }
+}
+
 /* ================================================================
  *
  *                     String management
@@ -999,6 +1018,14 @@ static int        WDML_QueryString(WDML_INSTANCE* pInstance, HSZ hsz, LPVOID ptr, DWORD
        cchMax = MAX_BUFFER_LEN;
     }
 
+    /* if there is no input windows returns a NULL string */
+    if (hsz == NULL)
+    {
+       CHAR *t_ptr = ptr;
+       *t_ptr = '\0';
+       return 1;
+    }
+
     switch (codepage)
     {
     case CP_WINANSI:
@@ -1101,7 +1128,9 @@ HSZ WINAPI DdeCreateStringHandleA(DWORD idInst, LPCSTR psz, INT codepage)
     TRACE("(%d,%s,%d)\n", idInst, debugstr_a(psz), codepage);
 
     pInstance = WDML_GetInstance(idInst);
-    if (pInstance)
+    if (pInstance == NULL)
+       WDML_SetAllLastError(DMLERR_INVALIDPARAMETER);
+    else
     {
        if (codepage == 0) codepage = CP_WINANSI;
        hsz = WDML_CreateString(pInstance, psz, codepage);
@@ -1128,7 +1157,9 @@ HSZ WINAPI DdeCreateStringHandleW(DWORD idInst, LPCWSTR psz, INT codepage)
     HSZ                        hsz = 0;
 
     pInstance = WDML_GetInstance(idInst);
-    if (pInstance)
+    if (pInstance == NULL)
+       WDML_SetAllLastError(DMLERR_INVALIDPARAMETER);
+    else
     {
        if (codepage == 0) codepage = CP_WINUNICODE;
        hsz = WDML_CreateString(pInstance, psz, codepage);
@@ -1259,15 +1290,24 @@ INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
 HDDEDATA WINAPI DdeCreateDataHandle(DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD cbOff,
                                     HSZ hszItem, UINT wFmt, UINT afCmd)
 {
-    /* For now, we ignore idInst, hszItem.
+
+    /* Other than check for validity we will ignore for now idInst, hszItem.
      * The purpose of these arguments still need to be investigated.
      */
 
+    WDML_INSTANCE*             pInstance;
     HGLOBAL                    hMem;
     LPBYTE                     pByte;
     DDE_DATAHANDLE_HEAD*       pDdh;
     WCHAR psz[MAX_BUFFER_LEN];
 
+    pInstance = WDML_GetInstance(idInst);
+    if (pInstance == NULL)
+    {
+        WDML_SetAllLastError(DMLERR_INVALIDPARAMETER);
+        return NULL;
+    }
+
     if (!GetAtomNameW(HSZ2ATOM(hszItem), psz, MAX_BUFFER_LEN))
     {
         psz[0] = HSZ2ATOM(hszItem);
@@ -1287,7 +1327,7 @@ HDDEDATA WINAPI DdeCreateDataHandle(DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD c
        return 0;
     }
 
-    pDdh = (DDE_DATAHANDLE_HEAD*)GlobalLock(hMem);
+    pDdh = GlobalLock(hMem);
     if (!pDdh)
     {
         GlobalFree(hMem);
@@ -1401,7 +1441,7 @@ LPBYTE WINAPI DdeAccessData(HDDEDATA hData, LPDWORD pcbDataSize)
 
     TRACE("(%p,%p)\n", hData, pcbDataSize);
 
-    pDdh = (DDE_DATAHANDLE_HEAD*)GlobalLock(hMem);
+    pDdh = GlobalLock(hMem);
     if (pDdh == NULL)
     {
        ERR("Failed on GlobalLock(%p)\n", hMem);
@@ -1449,7 +1489,7 @@ BOOL WDML_IsAppOwned(HDDEDATA hData)
     DDE_DATAHANDLE_HEAD*       pDdh;
     BOOL                        ret = FALSE;
 
-    pDdh = (DDE_DATAHANDLE_HEAD*)GlobalLock(hData);
+    pDdh = GlobalLock(hData);
     if (pDdh != NULL)
     {
         ret = pDdh->bAppOwned;
@@ -1471,7 +1511,7 @@ BOOL WDML_IsAppOwned(HDDEDATA hData)
  *     2          16   clipboard format
  *     4          ?    data to be used
  */
-HDDEDATA        WDML_Global2DataHandle(HGLOBAL hMem, WINE_DDEHEAD* p)
+HDDEDATA        WDML_Global2DataHandle(WDML_CONV* pConv, HGLOBAL hMem, WINE_DDEHEAD* p)
 {
     DDEDATA*    pDd;
     HDDEDATA   ret = 0;
@@ -1492,7 +1532,7 @@ HDDEDATA        WDML_Global2DataHandle(HGLOBAL hMem, WINE_DDEHEAD* p)
                 /* fall thru */
             case 0:
             case CF_TEXT:
-                ret = DdeCreateDataHandle(0, pDd->Value, size, 0, 0, pDd->cfFormat, 0);
+                ret = DdeCreateDataHandle(pConv->instance->instanceID, pDd->Value, size, 0, 0, pDd->cfFormat, 0);
                 break;
             case CF_BITMAP:
                 if (size >= sizeof(BITMAP))
@@ -1507,7 +1547,7 @@ HDDEDATA        WDML_Global2DataHandle(HGLOBAL hMem, WINE_DDEHEAD* p)
                                                  bmp->bmPlanes, bmp->bmBitsPixel,
                                                  pDd->Value + sizeof(BITMAP))))
                         {
-                            ret = DdeCreateDataHandle(0, (LPBYTE)&hbmp, sizeof(hbmp),
+                            ret = DdeCreateDataHandle(pConv->instance->instanceID, (LPBYTE)&hbmp, sizeof(hbmp),
                                                       0, 0, CF_BITMAP, 0);
                         }
                         else ERR("Can't create bmp\n");
@@ -1538,7 +1578,7 @@ HGLOBAL WDML_DataHandle2Global(HDDEDATA hDdeData, BOOL fResponse, BOOL fRelease,
     HGLOBAL                     hMem = 0;
 
     dwSize = GlobalSize((HGLOBAL)hDdeData) - sizeof(DDE_DATAHANDLE_HEAD);
-    pDdh = (DDE_DATAHANDLE_HEAD*)GlobalLock((HGLOBAL)hDdeData);
+    pDdh = GlobalLock((HGLOBAL)hDdeData);
     if (dwSize && pDdh)
     {
         WINE_DDEHEAD*    wdh = NULL;
@@ -1658,9 +1698,10 @@ void WDML_RemoveServer(WDML_INSTANCE* pInstance, HSZ hszService, HSZ hszTopic)
                pConvNext = pConv->next;
                if (DdeCmpStringHandles(pConv->hszService, hszService) == 0)
                {
+                    HWND client = pConv->hwndClient, server = pConv->hwndServer;
                    WDML_RemoveConv(pConv, WDML_SERVER_SIDE);
                    /* don't care about return code (whether client window is present or not) */
-                   PostMessageW(pConv->hwndClient, WM_DDE_TERMINATE, (WPARAM)pConv->hwndServer, 0);
+                   PostMessageW(client, WM_DDE_TERMINATE, (WPARAM)server, 0);
                }
            }
            if (pServer == pInstance->servers)
@@ -1751,7 +1792,7 @@ WDML_CONV*        WDML_AddConv(WDML_INSTANCE* pInstance, WDML_SIDE side,
     pConv->next = pInstance->convs[side];
     pInstance->convs[side] = pConv;
 
-    TRACE("pConv->wStatus %04x\n", pConv->wStatus);
+    TRACE("pConv->wStatus %04x pInstance(%p)\n", pConv->wStatus, pInstance);
 
     return pConv;
 }