Ignore:
Timestamp:
Jul 29, 2006, 6:43:07 AM (19 years ago)
Author:
bird
Message:

Two classes (CPMScreen and CPMKeyState) + the hook dll left (and debugging of course).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/synergy/lib/platform/CPMUtil.cpp

    r2751 r2752  
    22 * synergy -- mouse and keyboard sharing utility
    33 * Copyright (C) 2004 Chris Schoeneman
     4 * Copyright (C) 2006 Knut St. Osmundsen
    45 *
    56 * This package is free software; you can redistribute it and/or
     
    1314 */
    1415
    15 #include "CMSWindowsUtil.h"
     16#include "CPMUtil.h"
    1617#include "CStringUtil.h"
    1718#include <stdio.h>
    1819
    1920//
    20 // CMSWindowsUtil
     21// CPMUtil
    2122//
    2223
    2324CString
    24 CMSWindowsUtil::getString(HINSTANCE instance, DWORD id)
     25CPMUtil::getString(HMODULE hmod, ULONG id)
    2526{
    26         char buffer[1024];
    27         int size = static_cast<int>(sizeof(buffer) / sizeof(buffer[0]));
    28         char* msg = buffer;
     27        char szBuf[1024];
    2928
    3029        // load string
    31         int n = LoadString(instance, id, msg, size);
    32         msg[n] = '\0';
    33         if (n < size) {
    34                 return msg;
     30        LONG cch = WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), hmod, id, sizeof(szBuf), (PSZ)szBuf);
     31        if(cch < 0) {
     32                szBuf[cch] = '\0';
     33                char *psz = szBuf;
     34                return psz;
    3535        }
    36 
    37         // not enough buffer space.  keep trying larger buffers until
    38         // we get the whole string.
    39         msg = NULL;
    40         do {
    41                 size <<= 1;
    42                 delete[] msg;
    43                 char* msg = new char[size];
    44                 n = LoadString(instance, id, msg, size);
    45         } while (n == size);
    46         msg[n] = '\0';
    47 
    48         CString result(msg);
    49         delete[] msg;
    50         return result;
     36        return "";
    5137}
    5238
    5339CString
    54 CMSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id)
     40CPMUtil::getErrorString(HMODULE hmod, ULONG error, ULONG id)
    5541{
     42#if 1
     43        char szMsg[80];
     44        snprintf(szMsg, sizeof(szMsg), "sys error %#lx (%d)\n", error, error);
     45        char *pszMsg = szMsg;
     46        return CString(pszMsg);
     47
     48#else
    5649        char* buffer;
    5750        if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
     
    7366                return result;
    7467        }
     68#endif
    7569}
     70
     71HAB CPMUtil::getHAB(void)
     72{
     73    return WinQueryAnchorBlock(HWND_DESKTOP);
     74}
     75
Note: See TracChangeset for help on using the changeset viewer.