Exemplo n.º 1
0
static LRESULT CALLBACK BaseBar_WindowProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
    LPBASEBARINFO lpbi = (LPBASEBARINFO)GetProp(hwnd, (LPCTSTR)MAKEWORD(s_hBaseBarAtom, 0));//GetWindowLong(hwnd, GWL_USERDATA);

    switch (uMessage)
    {
    case WM_CREATE:
    {
        LPCREATESTRUCT lpcs    = (LPCREATESTRUCT)lParam;
        DWORD          dwStyle = RBS_VERTICALGRIPPER | RBS_REGISTERDROP | RBS_AUTOSIZE | RBS_VARHEIGHT | RBS_DBLCLKTOGGLE | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE;
        REBARBANDINFO  rbBand;
        TBBUTTON tbb;

        if (lpcs->lpszName)
            lpbi->pszTitle = String_Duplicate(lpcs->lpszName);

        lpbi->dwAlign = BaseBar_GetAlign(hwnd);
        lpbi->dwAllowableAligns = CCS_LEFT | CCS_RIGHT | CCS_TOP | CCS_BOTTOM;

        if (lpbi->dwAlign == CCS_LEFT || lpbi->dwAlign == CCS_RIGHT)
            dwStyle |= CCS_VERT;

        if (!(lpbi->hwndRebar = CreateWindowEx(0, REBARCLASSNAME, NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | dwStyle,
            0, 0, 0, 0, hwnd, (HMENU) REBARID, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL)))
            return (0);

        SendMessage(lpbi->hwndRebar, RB_SETBKCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE));

        ZeroMemory(&rbBand, sizeof(REBARBANDINFO));

        rbBand.cbSize     = sizeof(REBARBANDINFO);
        rbBand.fMask      = RBBIM_HEADERSIZE | RBBIM_ID | RBBIM_STYLE | RBBIM_COLORS;
        rbBand.fStyle     = RBBS_FIXEDSIZE | RBBS_VARIABLEHEIGHT | RBBS_NOGRIPPER;
        rbBand.clrFore    = GetSysColor(COLOR_BTNTEXT);
        rbBand.clrBack    = GetSysColor(COLOR_BTNFACE);
        rbBand.cxHeader   = ((lpcs->style & CCS_VERT) ? 21 : 24);
        rbBand.wID        = (UINT)lpcs->hMenu;

        if (lpcs->style & CCS_VERT)
        {
            rbBand.fMask |= RBBIM_TEXT;
            rbBand.lpText = (char*)lpcs->lpszName;
        }

        SendMessage(lpbi->hwndRebar, RB_INSERTBAND, (int) -1, (LPARAM) &rbBand);

        ZeroMemory(&tbb, sizeof(TBBUTTON));

        tbb.iBitmap   = 0; 
        tbb.idCommand = IDM_BAND_CLOSE;
        tbb.fsState   = TBSTATE_ENABLED; 
        tbb.fsStyle   = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE;

        lpbi->hwndToolbar = CreateToolbarEx(lpbi->hwndRebar, WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER  | CCS_NOPARENTALIGN | CCS_NOMOVEY | CCS_NORESIZE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT,
            IDC_TOOLBAR, 1, PCPControls_GetHandle(), IDB_CHECKBOX, &tbb, 1, 13, 12, 11, 10, sizeof (TBBUTTON));

        SendMessage(lpbi->hwndToolbar, TB_SETBUTTONSIZE, 0, (LPARAM) MAKELONG(20, 18));
        SendMessage(lpbi->hwndToolbar, TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG(10, 9));
    }
    return (TRUE);
    case WM_SIZE:
    {
        RECT rcNew;

        GetClientRect(hwnd, &rcNew);

        if (wParam == SIZE_RESTORED && !EqualRect(&rcNew, &lpbi->rcSize))
        {
            NMHDR nmhdr;

            MoveWindow(lpbi->hwndRebar, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);

            nmhdr.code     = RBN_HEIGHTCHANGE;
            nmhdr.hwndFrom = hwnd;
            nmhdr.idFrom   = GetDlgCtrlID(hwnd);
            SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);

            if (lpbi->hwndToolbar)
            {
                RECT  rcBand;
                DWORD dwSize = (DWORD)SendMessage(lpbi->hwndToolbar, TB_GETBUTTONSIZE, 0, 0);

                SendMessage(lpbi->hwndRebar, RB_GETBANDBORDERS, 0, (LPARAM)&rcBand);

                if (lpbi->dwAlign == CCS_LEFT || lpbi->dwAlign == CCS_RIGHT)
                {
                    int x = (LOWORD(lParam) - 24);
                    int y = ((rcBand.top - HIWORD(dwSize)) / 2);
                    MoveWindow(lpbi->hwndToolbar, x, y, 20, 18, TRUE);
                }
                else
                {
                    MoveWindow(lpbi->hwndToolbar, 2, 2, 20, 18, TRUE);
                }
            }
        }

        GetClientRect(hwnd, &lpbi->rcSize);
    }
    break;
    case WM_NOTIFY:
    {
        LPNMHDR lphdr = (LPNMHDR)lParam;

        if (lphdr->code == NM_NCHITTEST && lphdr->idFrom == REBARID)
        {
            if (HIBYTE(GetAsyncKeyState(VK_RBUTTON)))
            {
                HMENU hMenu = LoadMenu(PCPControls_GetHandle(), MAKEINTRESOURCE(IDR_BANDMENU));
                HMENU hPopupMenu = GetSubMenu(hMenu, 0);
                POINT pt;

                if (lpbi->dwAllowableAligns & CCS_VERT)
                {
                    if (!(lpbi->dwAllowableAligns & CCS_LEFT))
                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_LEFT, FALSE);
                    if (!(lpbi->dwAllowableAligns & CCS_RIGHT))
                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_RIGHT, FALSE);

                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_TOP, FALSE);
                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_BOTTOM, FALSE);
                }
                else
                {
                    if (!(lpbi->dwAllowableAligns & CCS_TOP))
                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_TOP, FALSE);
                    if (!(lpbi->dwAllowableAligns & CCS_BOTTOM))
                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_BOTTOM, FALSE);

                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_LEFT, FALSE);
                        Menu_EnableMenuItem(hPopupMenu, IDM_BAND_RIGHT, FALSE);
                }

                GetCursorPos(&pt);

                Menu_TrackPopupMenu(hPopupMenu, pt.x, pt.y, hwnd);
            }
            return (HTCLIENT);
        }
        else if (lphdr->code == NM_CUSTOMDRAW && lphdr->idFrom == REBARID)
        {
            LPNMCUSTOMDRAW lpnmcd = (LPNMCUSTOMDRAW) lParam;

            if (lpnmcd->dwDrawStage == CDDS_PREPAINT)
                return (CDRF_NOTIFYPOSTPAINT);
            else if (lpnmcd->dwDrawStage == CDDS_POSTPAINT && (lpbi->dwAlign == CCS_TOP || lpbi->dwAlign == CCS_BOTTOM))
            {
                DrawEdge(lpnmcd->hdc, &lpnmcd->rc, EDGE_ETCHED, BF_RIGHT);
            }
        }
        else if (lphdr->idFrom == IDC_TOOLBAR)
        {
        }
    }
    return (SendMessage(GetParent(hwnd), uMessage, wParam, lParam));
    case WM_COMMAND:
    {
        DWORD dwAlign;

        switch (LOWORD(wParam))
        {
        case IDM_BAND_LEFT:
            dwAlign = CCS_LEFT;
        break;
        case IDM_BAND_RIGHT:
            dwAlign = CCS_RIGHT;
        break;
        case IDM_BAND_TOP:
            dwAlign = CCS_TOP;
        break;
        case IDM_BAND_BOTTOM:
            dwAlign = CCS_BOTTOM;
        break;
        case IDM_BAND_CLOSE:
        {
            NMHDR nmhdr;

            nmhdr.code     = BBN_CLOSE;
            nmhdr.hwndFrom = hwnd;
            nmhdr.idFrom   = GetDlgCtrlID(hwnd);

            SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
        }
        return (0);
        default:
        return (0);
        }

        SendMessage(hwnd, BCM_SETALIGNMENT, (WPARAM)dwAlign, 0L);
    }
    case WM_GETMINMAXINFO:
    {
        MINMAXINFO *lpmmi = (MINMAXINFO *)lParam;
        
        if (lpmmi != NULL)
        {
            int cx = GetSystemMetrics(SM_CXSCREEN);
            int cy = GetSystemMetrics(SM_CYSCREEN);
            
            if (lpbi->dwAlign == CCS_LEFT || lpbi->dwAlign == CCS_RIGHT)
                lpmmi->ptMaxTrackSize.x = cx / 2;
            else
                lpmmi->ptMaxTrackSize.y = cy / 2;
            
            if (lpbi->dwAlign == CCS_LEFT)
            {
                lpmmi->ptMinTrackSize.x = 50;
            }
            else if (lpbi->dwAlign == CCS_RIGHT)
            {
                lpmmi->ptMinTrackSize.x = 50;
            }
            else if (lpbi->dwAlign == CCS_TOP)
            {
                lpmmi->ptMinTrackSize.y = 50;
            }
            else if (lpbi->dwAlign == CCS_BOTTOM)
            {
                lpmmi->ptMinTrackSize.y = 50;
            }
            else
            {
                lpmmi->ptMinTrackSize.x = 56;
                lpmmi->ptMinTrackSize.y = 24;
            }
        }
    }
    return (FALSE);
    case WM_NCCREATE:
    {
        lpbi = Mem_Alloc(sizeof(BASEBARINFO));

        if (lpbi == NULL)
            return (FALSE);

        SetProp(hwnd, (LPCTSTR)MAKEWORD(s_hBaseBarAtom, 0), lpbi);
    }
    return (TRUE);
    case WM_NCDESTROY:
    {
        RemoveProp(hwnd, (LPCTSTR)MAKEWORD(s_hBaseBarAtom, 0));

        if (lpbi != NULL)
        {
            if (lpbi->pszTitle != NULL)
                Mem_Free(lpbi->pszTitle);

            Mem_Free(lpbi);
        }
    }
    return (TRUE);
    case WM_NCHITTEST:
    {
        POINT pt = {LOWORD(lParam), HIWORD(lParam)};
        RECT  re;

        GetWindowRect(hwnd, &re);

        if (!PtInRect(&re, pt))
            return (HTNOWHERE);

        if (lpbi->dwAlign == CCS_LEFT)
        {
            re.left = re.right - 4;

            if (PtInRect(&re, pt))
                return (HTRIGHT);
        }
        else if (lpbi->dwAlign == CCS_RIGHT)
        {
            re.right = re.left + 4;

            if (PtInRect(&re, pt))
                return (HTLEFT);
        }
        else if (lpbi->dwAlign == CCS_BOTTOM)
        {
            re.bottom = re.top + 4;

            if (PtInRect(&re, pt))
                return (HTTOP);
        }
        else if (lpbi->dwAlign == CCS_TOP)
        {
            re.top = re.bottom - 4;

            if (PtInRect(&re, pt))
                return (HTBOTTOM);
        }
    }
    return (HTCLIENT);
    case WM_NCCALCSIZE:
    {
        if (wParam == TRUE)
        {
            NCCALCSIZE_PARAMS *ncp = (NCCALCSIZE_PARAMS *) lParam;

            if (lpbi->dwAlign == CCS_LEFT)
            {
                ncp->rgrc[0].top    += 4;
                ncp->rgrc[0].right  -= 4;
            }
            else if (lpbi->dwAlign == CCS_RIGHT)
            {
                ncp->rgrc[0].top    += 4;
                ncp->rgrc[0].left   += 4;
            }
            else if (lpbi->dwAlign == CCS_BOTTOM)
            {
                ncp->rgrc[0].top    += 4;
            }
            else if (lpbi->dwAlign == CCS_TOP)
            {
                ncp->rgrc[0].bottom -= 4;
            }
            else
            {
                ncp->rgrc[0].top    += 4;
                ncp->rgrc[0].right  -= 4;
                ncp->rgrc[0].left   += 4;
                ncp->rgrc[0].bottom -= 4;
            }
        }
    }
    break;
    case WM_ERASEBKGND:
    return (TRUE);
    case WM_NCPAINT:
    {
        HDC  hdc = GetWindowDC(hwnd);
        RECT rcWindow, rcClient;

        if (hdc == NULL)
            break;

        GetClientRect(hwnd, &rcClient);
        GetWindowRect(hwnd, &rcWindow);

        MapWindowPoints(NULL, hwnd, (LPPOINT)&rcWindow, 2);
        OffsetRect(&rcClient, -rcWindow.left, -rcWindow.top);
        OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top);
        ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);

        FillRect(hdc, &rcWindow, (HBRUSH)GetSysColorBrush(COLOR_BTNFACE));
        ReleaseDC(hwnd, hdc);
    }
    return (TRUE);
    case BCM_SETCLIENTWND:
    {
        REBARBANDINFO rbBand;
        ZeroMemory(&rbBand, sizeof(REBARBANDINFO));

        rbBand.cbSize     = sizeof(REBARBANDINFO);
        rbBand.fMask      = RBBIM_CHILDSIZE | RBBIM_CHILD;
        rbBand.cyIntegral = 1;
        rbBand.cyMaxChild = -1;
        rbBand.hwndChild  = (HWND)lParam;

        return (SendMessage(lpbi->hwndRebar, RB_SETBANDINFO, 0, (LPARAM)&rbBand));
    }
    case BCM_GETCLIENTWND:
    {
        REBARBANDINFO rbBand;
        ZeroMemory(&rbBand, sizeof(REBARBANDINFO));

        rbBand.cbSize     = sizeof(REBARBANDINFO);
        rbBand.fMask      = RBBIM_CHILD;
        SendMessage(lpbi->hwndRebar, RB_GETBANDINFO, 0, (LPARAM)&rbBand);

        return (LRESULT)((IsWindow(rbBand.hwndChild) ? rbBand.hwndChild : NULL));
    }
    case BCM_SETIMAGELIST:
    {
        REBARINFO  rbi;
        HIMAGELIST hilOld = BandCtrl_GetImageList(hwnd);

        rbi.cbSize = sizeof(REBARINFO);
        rbi.fMask  = RBIM_IMAGELIST;
        rbi.himl   = (HIMAGELIST)lParam;

        if (!SendMessage(lpbi->hwndRebar, RB_SETBARINFO, 0, (LPARAM) &rbi))
            return ((LRESULT)NULL);

        return ((LRESULT)hilOld);
    }
    case BCM_GETIMAGELIST:
    {
        REBARINFO rbi;

        rbi.cbSize = sizeof(REBARINFO);
        rbi.fMask  = RBIM_IMAGELIST;
        rbi.himl   = 0;

        if (!SendMessage(lpbi->hwndRebar, RB_GETBARINFO, 0, (LPARAM) &rbi))
            return ((LRESULT)NULL);

        return ((LRESULT)rbi.himl);
    }
    case BCM_SETTITLEIMAGE:
    {
        REBARBANDINFO rbBand;

        ZeroMemory(&rbBand, sizeof(REBARBANDINFO));

        rbBand.cbSize = sizeof(REBARBANDINFO);
        rbBand.fMask  = RBBIM_IMAGE;
        rbBand.iImage = wParam;

        return (SendMessage(lpbi->hwndRebar, RB_SETBANDINFO, 0, (LPARAM)&rbBand));
    }
    case BCM_GETTITLEIMAGE:
    {
        REBARBANDINFO rbBand;

        ZeroMemory(&rbBand, sizeof(REBARBANDINFO));

        rbBand.cbSize = sizeof(REBARBANDINFO);
        rbBand.fMask  = RBBIM_IMAGE;
        rbBand.iImage = -1;
        SendMessage(lpbi->hwndRebar, RB_GETBANDINFO, 0, (LPARAM)&rbBand);

        return (rbBand.iImage);
    }
    case BCM_GETALIGNMENT:
    return ((LRESULT)lpbi->dwAlign);
    case BCM_SETALIGNMENT:
    {
        NMHDR nmhdr;
        DWORD dwStyle;

        if (lpbi->dwAlign == wParam)
            return (wParam);

        lpbi->dwAlign = wParam;

        dwStyle = GetWindowLong(lpbi->hwndRebar, GWL_STYLE);
        dwStyle &= ~(CCS_BOTTOM | CCS_TOP | CCS_LEFT | CCS_RIGHT);
        dwStyle |= lpbi->dwAlign;

        SetWindowLong(lpbi->hwndRebar, GWL_STYLE, dwStyle);

        SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);

        nmhdr.code     = RBN_HEIGHTCHANGE;
        nmhdr.hwndFrom = hwnd;
        nmhdr.idFrom   = GetDlgCtrlID(hwnd);
        SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);

        return (lpbi->dwAlign);
    }
    case BCM_SETDATA:
    {
        LPARAM lParamOld = lpbi->lParam;
        lpbi->lParam = lParam;
        return (lParamOld);
    }
    case BCM_GETDATA:
    return (lpbi->lParam);
    case BCM_SETALLOWABLEALIGNS:
    {
        DWORD dwOldAllowableAligns = lpbi->dwAllowableAligns;

        lpbi->dwAllowableAligns = lParam;

        return (dwOldAllowableAligns);
    }
    case BCM_GETALLOWABLEALIGNS:
    return (lpbi->dwAllowableAligns);
    }

    return (DefWindowProc(hwnd, uMessage, wParam, lParam));
}
Exemplo n.º 2
0
CME_CODE CEdit::RegisterLanguage( LPCTSTR pszName, CM_LANGUAGE *pLang )
{
   ASSERT( pszName );

   if ( !pLang )
   {
      // caller did not supply a language definition.  See if this
      // is a stock language for which we have a definition.
      static struct _StockLang {
         CM_LANGUAGE *pLang;
         LPCTSTR pszName;
      } Languages[] = { { &g_LangCPP, CMLANG_CPP },
                    { &g_LangPascal, CMLANG_PASCAL },
                    { &g_LangBasic, CMLANG_BASIC },
                    { &g_LangSQL, CMLANG_SQL },
                    { &g_LangJava, CMLANG_JAVA },
                    { &g_LangHTML, CMLANG_HTML },
                    { &g_LangXML, CMLANG_XML } };

      for ( int i = 0; i < ARRAY_SIZE( Languages ); i++ )
      {
         _StockLang *pLangCurr = Languages + i;
         if ( _tcsicmp( pLangCurr->pszName, pszName ) == 0 )
         {
            pLang = pLangCurr->pLang;
            break;
         }
      }
   }

   ASSERT( pLang );

   if ( !pLang )
   {
      return CME_BADARGUMENT;
   }

   // make sure the same language is not registered twice
   BOOL bDupe = FALSE;
   for ( int i = 0; i < g_nLanguageCount; i++ )
   {
      if ( _tcsicmp( g_pLanguages[ i ]->m_szName, pszName ) == 0 )
      {
         bDupe = TRUE;
         break;
      }
   }

   if ( bDupe )
   {
      delete g_pLanguages[ i ];
      g_pLanguages[ i ] = new CLanguage( pszName, pLang );

      // 'flash' the controls that have this language
      for ( int nWnd = 0; nWnd < g_nhWndCount; nWnd++ )
      {
         HWND hWnd = CEdit::g_phWnds[ nWnd ];
         ASSERT( IsWindow( hWnd ) );
         TCHAR szLang[ CM_MAX_LANGUAGE_NAME ];
         CM_GetLanguage( hWnd, szLang );
         if ( _tcsicmp( szLang, pszName ) == 0 )
         {
            // language in use -- re-establish the new language
            CM_SetLanguage( hWnd, NULL );
            CM_SetLanguage( hWnd, pszName );
         }
      }
   }
   else
   {
      g_pLanguages = g_pLanguages ? ( CLanguage ** ) realloc( g_pLanguages, ( g_nLanguageCount + 1 ) * sizeof( CLanguage * ) ) :
                                    ( CLanguage ** ) malloc( sizeof( CLanguage * ) );
      g_pLanguages[ g_nLanguageCount++ ] = new CLanguage( pszName, pLang );
   }

   return CME_SUCCESS;
}
Exemplo n.º 3
0
void lRunMainLoop(ENGD *engd, long xpos, long ypos, long xdim, long ydim,
                  BGRA **bptr, intptr_t *data, uint32_t flgs) {
    enum {EXT_ATTR = WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_LAYERED};
    BLENDFUNCTION bstr = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
    WNDCLASSEX wndc = {sizeof(wndc), CS_HREDRAW | CS_VREDRAW, WindowProc,
                       0, 0, 0, 0, LoadCursor(0, IDC_HAND), 0, 0, " ", 0};
    PIXELFORMATDESCRIPTOR ppfd = {sizeof(ppfd), 1, PFD_SUPPORT_OPENGL |
                                  PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER,
                                  PFD_TYPE_RGBA, 32};
    BITMAPINFO bmpi = {{sizeof(bmpi.bmiHeader), 0, 0,
                        1, 8 * sizeof(BGRA), BI_RGB}};
    struct { /// DWM_BLURBEHIND from DWM API (Vista and later)
        DWORD dwFlags;
        BOOL  fEnable;     /// dwFlags | 0x01 (DWM_BB_ENABLE)
        HRGN  hRgnBlur;    /// dwFlags | 0x02 (DWM_BB_BLURREGION)
        BOOL  fTransition; /// dwFlags | 0x04 (DWM_BB_TRANSITIONONMAXIMIZED)
    } blur = {0x03, TRUE, CreateRectRgn(0, 0, 1, 1), TRUE};
    SIZE dims = {xdim - xpos, ydim - ypos};
    POINT cpos, mpos, zpos = {};
    MSG pmsg = {};

    BLENDFUNCTION *bfun;
    BOOL APIENTRY (*ULW)(HWND, HDC, POINT*, SIZE*, HDC, POINT*,
                         COLORREF, BLENDFUNCTION*, DWORD) = 0;
    BOOL APIENTRY (*SLW)(HWND, COLORREF, BYTE, DWORD) = 0;
    HRESULT APIENTRY (*EBW)(HWND, typeof(blur)*) = 0;
    HRESULT APIENTRY (*ICE)(BOOL*) = 0;
    HINSTANCE husr, hdwm;
    UINT opts, attr;
    HDC devc, mwdc;
    HBITMAP hdib;
    HGLRC mwrc;
    HWND hwnd;
    BOOL comp;

    mwrc = 0;
    devc = CreateCompatibleDC(0);
    bmpi.bmiHeader.biWidth = dims.cx;
    bmpi.bmiHeader.biHeight = (~flgs & COM_RGPU)? -dims.cy : dims.cy;
    hdib = CreateDIBSection(devc, &bmpi, DIB_RGB_COLORS, (void*)bptr, 0, 0);
    SelectObject(devc, hdib);

    if ((hdwm = LoadLibrary("dwmapi")))
        EBW = (typeof(EBW))GetProcAddress(hdwm, "DwmEnableBlurBehindWindow");

    bfun = &bstr;
    opts = ULW_ALPHA;
    attr = EXT_ATTR;
    mpos = (POINT){xpos, ypos};

    husr = LoadLibrary("user32");
    if ((flgs & COM_OPAQ) || (flgs & WIN_IRGN)
    || !(ULW = (typeof(ULW))GetProcAddress(husr, "UpdateLayeredWindow"))) {
        bfun = (typeof(bfun))*bptr;
        zpos.y = bmpi.bmiHeader.biHeight;
        ULW = (typeof(ULW))ULWstub;
        attr &= ~WS_EX_LAYERED;
        if (flgs & COM_OPAQ)
            opts = ULW_OPAQUE;
    }
    RegisterClassEx(&wndc);
    hwnd = CreateWindowEx(attr, wndc.lpszClassName, 0, WS_POPUP | WS_VISIBLE,
                          0, 0, 0, 0, 0, 0, wndc.hInstance, engd);
    data[0] = (intptr_t)hwnd;
    mwdc = GetDC(hwnd);

    if (EBW) {
        comp = FALSE;
        ICE = (typeof(ICE))GetProcAddress(hdwm, "DwmIsCompositionEnabled");
        /// if there`s DWM, there absolutely have to be layered windows
        SLW = (typeof(SLW))GetProcAddress(husr, "SetLayeredWindowAttributes");
        ICE(&comp);
        attr = GetVersion();
        /// major 6 minor 1 is Win7; in newer versions ICE() is lying to us
        if (!comp && (MAKEWORD(HIBYTE(attr), LOBYTE(attr)) <= 0x0601))
            EBW = 0;
        else {
            /// does nothing visible to the window,
            /// but enables input transparency!
            SLW(hwnd, 0x000000, 0xFF, 2 /** 2 == LWA_ALPHA **/);
            EBW(hwnd, &blur);
        }
    }
    if (flgs & COM_RGPU) {
        ppfd.iLayerType = PFD_MAIN_PLANE;
        SetPixelFormat(mwdc, ChoosePixelFormat(mwdc, &ppfd), &ppfd);
        wglMakeCurrent(mwdc, mwrc = wglCreateContext(mwdc));
    }
    /// "+1" is a dirty hack to not let Windows consider us fullscreen if OGL
    /// is active: all sorts of weird things happen to fullscreen OGL windows
    /// when they are DWM + layered, at least on Intel HD 3000 + Vista / Win7
    SetWindowPos(hwnd, 0, mpos.x, mpos.y, dims.cx, dims.cy + ((EBW)? 1 : 0),
                 SWP_NOZORDER | SWP_NOACTIVATE);
    lShowMainWindow(engd, flgs & COM_SHOW);
    while (data[0]) {
        if (PeekMessage(&pmsg, 0, 0, 0, PM_REMOVE)) {
            TranslateMessage(&pmsg);
            DispatchMessage(&pmsg);
            continue;
        }
        GetCursorPos(&cpos);
        ScreenToClient(hwnd, &cpos);
        attr = ((GetActiveWindow() == hwnd)?    UFR_MOUS : 0)
             | ((GetAsyncKeyState(VK_LBUTTON))? UFR_LBTN : 0)
             | ((GetAsyncKeyState(VK_MBUTTON))? UFR_MBTN : 0)
             | ((GetAsyncKeyState(VK_RBUTTON))? UFR_RBTN : 0)
             | ((GetAsyncKeyState(VK_UP     ))? UFR_PL1W : 0)
             | ((GetAsyncKeyState(VK_DOWN   ))? UFR_PL1S : 0)
             | ((GetAsyncKeyState(VK_LEFT   ))? UFR_PL1A : 0)
             | ((GetAsyncKeyState(VK_RIGHT  ))? UFR_PL1D : 0)
             | ((GetAsyncKeyState('W'       ))? UFR_PL2W : 0)
             | ((GetAsyncKeyState('S'       ))? UFR_PL2S : 0)
             | ((GetAsyncKeyState('A'       ))? UFR_PL2A : 0)
             | ((GetAsyncKeyState('D'       ))? UFR_PL2D : 0);
        attr = cPrepareFrame(engd, cpos.x, cpos.y, attr);
        if (attr & PFR_SKIP)
            Sleep(1);
        if (!IsWindow(hwnd))
            break;
        if (attr & PFR_HALT)
            continue;
        if (~flgs & COM_RGPU)
            BitBlt(devc, 0, 0, dims.cx, dims.cy, mwdc, 0, 0, BLACKNESS);
        cOutputFrame(engd, !EBW);
        if (!EBW)
            ULW(hwnd, mwdc, &mpos, &dims, devc, &zpos, 0, bfun, opts);
        else {
            if (flgs & COM_RGPU)
                SwapBuffers(mwdc);
            else
                BitBlt(mwdc, 0, 0, dims.cx, dims.cy, devc, 0, 0, SRCCOPY);
            SetWindowLongPtr(hwnd, GWL_EXSTYLE, (attr & PFR_PICK)? EXT_ATTR :
                                               WS_EX_TRANSPARENT | EXT_ATTR);
        }
    }
    cDeallocFrame(engd, !EBW);
    if (flgs & COM_RGPU) {
        wglMakeCurrent(0, 0);
        wglDeleteContext(mwrc);
    }
    KillTimer(hwnd, 1);
    ReleaseDC(hwnd, mwdc);
    DestroyWindow(hwnd);
    DeleteDC(mwdc);
    DeleteDC(devc);
    DeleteObject(hdib);
    DeleteObject(blur.hRgnBlur);
    /// mandatory: we are a library, not an application
    UnregisterClass(wndc.lpszClassName, wndc.hInstance);
    /// finally, we need to purge the message queue, as it may be reused,
    /// and nobody wants garbage messages for windows that are long gone
    while (PeekMessage(&pmsg, 0, 0, 0, PM_REMOVE));
    FreeLibrary(husr);
    FreeLibrary(hdwm);
}
Exemplo n.º 4
0
void __declspec(dllexport) show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
{
  TCHAR fn[MAX_PATH];
  TCHAR temp[64];
  TCHAR *sleep=temp;

 
  EXDLL_INIT();

  popstring(sleep);
  popstring(fn);

  sleep_val=0;
  while (*sleep >= _T('0') && *sleep <= _T('9'))
  {
    sleep_val*=10;
    sleep_val+=*sleep++-_T('0');
  }

  if (fn[0] && sleep_val>0)
  {
    MSG msg;
    TCHAR classname[4]=_T("_sp");
    static WNDCLASS wc;
    wc.lpfnWndProc = WndProc;
    wc.hInstance = g_hInstance;
    wc.hCursor = LoadCursor(NULL,IDC_ARROW);
    wc.lpszClassName = classname;
    if (RegisterClass(&wc)) 
    {
      TCHAR fn2[MAX_PATH];
      lstrcpy(fn2,fn);
      lstrcat(fn,_T(".bmp"));
      lstrcat(fn2,_T(".wav"));
      g_hbm=LoadImage(NULL,fn,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
      if (g_hbm) 
      {
        HWND myWnd;

        PlaySound(fn2,NULL,SND_ASYNC|SND_FILENAME|SND_NODEFAULT);

        myWnd = CreateWindowEx(WS_EX_TOOLWINDOW,classname,classname,
          0,0,0,0,0,(HWND)hwndParent,NULL,g_hInstance,NULL);

        while (IsWindow(myWnd) && GetMessage(&msg,myWnd,0,0))
        {
          DispatchMessage(&msg);
        }

        // Stop currently playing wave, we want to exit
        PlaySound(0,0,0);

        DeleteObject(g_hbm);

        UnregisterClass(classname, g_hInstance);

      }
    }
  }
  wsprintf(temp,_T("%d"),g_rv);
  pushstring(temp);
}
Exemplo n.º 5
0
static void SendWordToServer()
{
    DWORD_PTR SendMsgAnswer;
    DWORD flags;
    LRESULT lr;

    if( !IsWindow( GlobalData->ServerWND ) )
        return;

    // Ask for needing to retrieve word - WPARAM = 1
    lr = SendMessageTimeout(GlobalData->ServerWND, WM_MY_SHOW_TRANSLATION, 1, 0, SMTO_ABORTIFHUNG, MOUSEOVER_INTERVAL, &SendMsgAnswer);
    if( lr == 0 || SendMsgAnswer == 0)	//No answer or no needing
        return;

    flags = SendMsgAnswer;

    if (hGetWordLib == 0 && ( flags & GD_FLAG_METHOD_STANDARD ) ) {
        hGetWordLib = LoadLibraryW(GlobalData->LibName);
        if (hGetWordLib) {
            GetWordProc = (GetWordProc_t)GetProcAddress(hGetWordLib, "__gdGetWord");
        }
        else {
            hGetWordLib = INVALID_HANDLE_VALUE;
        }
    }

    GlobalData->CurMod.MatchedWord[0] = 0;
    GlobalData->CurMod.WordLen = 0;
    GlobalData->CurMod.BeginPos = 0;

    if( ( flags & GD_FLAG_METHOD_GD_MESSAGE ) != 0 && uGdAskMessage != 0 ) {
        int n;
        gds.dwSize = sizeof(gds);
        gds.cwData = Buffer;
        gds.dwMaxLength = sizeof(Buffer) / sizeof(Buffer[0]);
        Buffer[0] = 0;
        gds.hWnd = GlobalData->LastWND;
        gds.Pt = GlobalData->LastPt;
        lr = SendMessageTimeout(gds.hWnd, uGdAskMessage, 0, (LPARAM)&gds, SMTO_ABORTIFHUNG, REQUEST_MESSAGE_INTERVAL, &SendMsgAnswer);
        if(lr != 0 && SendMsgAnswer != 0) {
            n = WideCharToMultiByte(CP_UTF8, 0, gds.cwData, lstrlenW(gds.cwData), GlobalData->CurMod.MatchedWord, sizeof(GlobalData->CurMod.MatchedWord) - 1, 0, 0);
            GlobalData->CurMod.MatchedWord[n] = 0;
            GlobalData->CurMod.WordLen = n;
            GlobalData->CurMod.BeginPos = 0;
            if(n > 0) {
                if( IsWindow( GlobalData->ServerWND ) ) {
#ifdef __WIN64
                    GlobalData32->LastWND = HandleToLong( GlobalData->LastWND );
                    GlobalData32->CurMod.WordLen = n;
                    GlobalData32->CurMod.BeginPos = 0;
                    lstrcpyn( GlobalData32->CurMod.MatchedWord, GlobalData->CurMod.MatchedWord, sizeof( GlobalData32->CurMod.MatchedWord ) );
#endif
                    SendMessageTimeout(GlobalData->ServerWND, WM_MY_SHOW_TRANSLATION, 0, 0, SMTO_ABORTIFHUNG, MOUSEOVER_INTERVAL, &SendMsgAnswer);
                }
            }
            return;
        }
    }

    if( ( flags & GD_FLAG_METHOD_STANDARD ) != 0 && GetWordProc != 0 ) {
        GlobalData->CurMod.WND = GlobalData->LastWND;
        GlobalData->CurMod.Pt = GlobalData->LastPt;

        GetWordProc(&(GlobalData->CurMod));

        if (GlobalData->CurMod.WordLen > 0) {
            if( IsWindow( GlobalData->ServerWND ) ) {
#ifdef __WIN64
                GlobalData32->LastWND = HandleToLong( GlobalData->LastWND );
                GlobalData32->CurMod.WordLen = GlobalData->CurMod.WordLen;
                GlobalData32->CurMod.BeginPos = GlobalData->CurMod.BeginPos;
                lstrcpyn( GlobalData32->CurMod.MatchedWord, GlobalData->CurMod.MatchedWord, sizeof( GlobalData32->CurMod.MatchedWord ) );
#endif
                SendMessageTimeout(GlobalData->ServerWND, WM_MY_SHOW_TRANSLATION, 0, 0, SMTO_ABORTIFHUNG, MOUSEOVER_INTERVAL, &SendMsgAnswer);
            }
            return;
        }
    }

    if( ( flags & GD_FLAG_METHOD_IACCESSIBLEEX ) != 0 ) {
        getWordByAccEx( GlobalData->LastPt );
        if (GlobalData->CurMod.WordLen > 0 ) {
            if( IsWindow( GlobalData->ServerWND ) ) {
#ifdef __WIN64
                GlobalData32->LastWND = HandleToLong( GlobalData->LastWND );
                GlobalData32->CurMod.WordLen = GlobalData->CurMod.WordLen;
                GlobalData32->CurMod.BeginPos = GlobalData->CurMod.BeginPos;
                lstrcpyn( GlobalData32->CurMod.MatchedWord, GlobalData->CurMod.MatchedWord, sizeof( GlobalData32->CurMod.MatchedWord ) );
#endif
                SendMessageTimeout(GlobalData->ServerWND, WM_MY_SHOW_TRANSLATION, 0, 0, SMTO_ABORTIFHUNG, MOUSEOVER_INTERVAL, &SendMsgAnswer);
            }
            return;
        }
    }

    if( ( flags & GD_FLAG_METHOD_UI_AUTOMATION ) != 0 && IsWindow( GlobalData->ServerWND ) ) {
#ifdef __WIN64
        GlobalData32->CurMod.MatchedWord[0] = 0;
        GlobalData32->CurMod.WordLen = 0;
        GlobalData32->CurMod.BeginPos = 0;
        GlobalData32->LastPt = GlobalData->LastPt;
#endif
        PostMessage( GlobalData->ServerWND, WM_MY_SHOW_TRANSLATION, 0, 0 );
    }
}
void CPageFileTypes::OnSize(UINT nType, int cx, int cy)
{
	if (IsWindow(tree)) tree.MoveWindow(0, 0, cx, cy);
}
Exemplo n.º 7
0
long CvReplicationPageCollisionViewRight::OnPropertiesChange(WPARAM wParam, LPARAM lParam)
{
	if (m_pDlg && IsWindow (m_pDlg->m_hWnd))
		PropertyChange(&(m_pDlg->m_cListCtrl), wParam, lParam);
	return 0;
}
Exemplo n.º 8
0
bool CAutoConnector::IsConnected()
{
    return ((_attached_hwnd != NULL) && IsWindow(_attached_hwnd));
}
Exemplo n.º 9
0
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	TRichUtil *ru;
	
	EnterCriticalSection(&csRich);
	ru = rlist_find(slist, hwnd);
	LeaveCriticalSection(&csRich);
	switch(msg) {
		case WM_THEMECHANGED:
		case WM_STYLECHANGED:
		{
			RichUtil_ClearUglyBorder(ru);
			break;
		}
		case WM_NCPAINT:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
			if (ru->hasUglyBorder&&MyIsThemeActive()) {
				HANDLE hTheme = MyOpenThemeData(ru->hwnd, L"EDIT");

				if (hTheme) {
					RECT rcBorder;
					RECT rcClient;
					int nState;
					HDC hdc = GetWindowDC(ru->hwnd);

					GetWindowRect(hwnd, &rcBorder);
					rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top;
					rcBorder.left = rcBorder.top = 0;
					CopyRect(&rcClient, &rcBorder);
					rcClient.left += ru->rect.left;
					rcClient.top += ru->rect.top;
					rcClient.right -= ru->rect.right;
					rcClient.bottom -= ru->rect.bottom;
					ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
					if(MyIsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
						MyDrawThemeParentBackground(hwnd, hdc, &rcBorder);
					if(!IsWindowEnabled(hwnd))
						nState = ETS_DISABLED;
					else if(SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY)
						nState = ETS_READONLY;
					else nState = ETS_NORMAL;
					MyDrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
					MyCloseThemeData(hTheme);
					ReleaseDC(hwnd, hdc);
					return 0;
				}
			}
			return ret;
		}
		case WM_NCCALCSIZE:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
			NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
			
			if (ru->hasUglyBorder&&MyIsThemeActive()) {
				HANDLE hTheme = MyOpenThemeData(hwnd, L"EDIT");

				if (hTheme) {
					RECT rcClient; 
					HDC hdc = GetDC(GetParent(hwnd));

					ZeroMemory(&rcClient, sizeof(RECT));
					if(MyGetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
						ru->rect.left = rcClient.left-ncsParam->rgrc[0].left;
						ru->rect.top = rcClient.top-ncsParam->rgrc[0].top;
						ru->rect.right = ncsParam->rgrc[0].right-rcClient.right;
						ru->rect.bottom = ncsParam->rgrc[0].bottom-rcClient.bottom;
						CopyRect(&ncsParam->rgrc[0], &rcClient);
						MyCloseThemeData(hTheme);
						ReleaseDC(GetParent(hwnd), hdc);
						return WVR_REDRAW;
					}
					ReleaseDC(GetParent(hwnd), hdc);
					MyCloseThemeData(hTheme);
				}
			}
			return ret;
		}
		case WM_ENABLE:
			RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
			break;
		case WM_DESTROY:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);

			if(IsWindow(hwnd)) {
				if((WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC) == &RichUtil_Proc)
					SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ru->origProc);
			}
			EnterCriticalSection(&csRich);
			slist = rlist_remove(slist, ru);
			LeaveCriticalSection(&csRich);
			if (ru) free(ru);
			return ret;
		}
	}
	return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
}
Exemplo n.º 10
0
int startwin_idle(void *v)
{
	if (!startupdlg || !IsWindow(startupdlg)) return 0;
	if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
	return 0;
}
Exemplo n.º 11
0
bool DisplayWGL::isValidNativeWindow(EGLNativeWindowType window) const
{
    return (IsWindow(window) == TRUE);
}
Exemplo n.º 12
0
//---------------------------------------------------------------------
// Function:    CreateRenderContext
// Description: Function to create a context in which to render to
// Parameters:  hWnd = windows handle for rendering context
//              name = name of the rendering context
//              left = left position inside window
//              top = top       "        "      "
//              width = width   "        "      "
//              height = height "        "      "
//              bpp = bits per pixel of rendering context
//              depth = Z-Buffer depth
//              stencil = Z-Stencil bits
//              fullscreen = whether window is full screen or not
//              parent = parents rendering context if available
// Returns:     TRUE, if successful
//---------------------------------------------------------------------
BOOL CDX8RenderCore::CreateRenderContext(HWND hWnd, LPCSTR name, DWORD left,
                              DWORD top, DWORD width, DWORD height, DWORD bpp, DWORD depth,
                              DWORD stencil, BOOL fullscreen, CRenderContext *parent)
{
    CDX8RenderContext *newCtx;

    // if parent is null then we have to have an hWnd
    if (parent == NULL)
    {
        // we have to have a valid window
        if (!IsWindow(hWnd))
        {
            m_LastError = ERROR_INVALID_WINDOW_HANDLE;
            gLogger->Print(_T("CreateRenderContext: Invalid Window handle specified"));
            return FALSE;
        }
    }
    else
    {
        // if we don't have a valid window, default to parents.
        if (!IsWindow(hWnd))
        {
            hWnd = parent->GetParentHwnd();
        }
    }

    // create a new DX8 Render context.
    newCtx = new CDX8RenderContext(m_pD3D, hWnd, name, left, top, width, height, bpp,
                                    depth, stencil, fullscreen, parent);

    if (newCtx == NULL)
    {
        m_LastError = ERROR_NOT_ENOUGH_MEMORY;
        gLogger->Print(_T("CreateRenderContext: Out of memory allocating CDX8RenderContext"));
        return FALSE;
    }

    if (newCtx->GetLastError() != D3D_OK)
    {
        gLogger->Print(_T("CreateRenderContext: Failed, see log file"));
        return FALSE;
    }

    // top level parents get saved here
    if (parent == NULL)
    {
        // what the hell?
        DWORD nContexts = m_RenderContexts.size();

        m_RenderContexts.insert(MAPHWNDRC::value_type(hWnd, newCtx));
        // and save into context list
//        m_RenderContexts[hWnd] = newCtx;
        if (nContexts != 0)
        {
            return FALSE;
        }
    }
    else
    {
        parent->AddChild(newCtx);
    }

    return TRUE;
}
Exemplo n.º 13
0
BOOL AeroAutoSubclass(HWND hWnd, DWORD dwFlags, DWORD dwReserved)
{
    if(!hWnd || !IsWindow(hWnd) || 0L!=dwReserved)  
    {
        SetLastError(ERROR_INVALID_PARAMETER);        
        return FALSE;
    }

    UINT uiRedrawMsg = RegisterWindowMessage(REDRAWSTRING);
    if(!uiRedrawMsg)
        return FALSE; // use the RegisterWindowMessage last error

    CDwmApiImpl *pDwm = NULL;
    CUxThemeAeroImpl *pUxTheme = NULL;
    PAERO_SUBCLASS_WND_DATA pWndData = NULL;
    DWORD dwLastError = ERROR_SUCCESS;
    MARGINS marGlassInset = {-1,-1,-1,-1};
    HRESULT hRes = S_OK;
    bool bBufferedPaintInitialized = false;
    ERROR_PARENT_AERO_SUBCLASS_WND_DATA errParentAeroData;
    ZeroMemory(&errParentAeroData, sizeof(errParentAeroData));
    errParentAeroData.m_dwFlags = dwFlags;
    errParentAeroData.m_hWndParent = hWnd;

    try
    {
        pDwm = new CDwmApiImpl;
    }
    catch (...)
    {
        dwLastError = ERROR_NOT_ENOUGH_MEMORY;
    }

    if(ERROR_SUCCESS!=dwLastError)
        goto CLEANUP;

    try
    {
        pUxTheme = new CUxThemeAeroImpl;
    }
    catch (...)
    {
        dwLastError = ERROR_NOT_ENOUGH_MEMORY;
    }

    if(ERROR_SUCCESS!=dwLastError)
        goto CLEANUP;

    pWndData = (PAERO_SUBCLASS_WND_DATA)LocalAlloc(LPTR, sizeof(AERO_SUBCLASS_WND_DATA));
    if(!pWndData)
    {
        dwLastError = GetLastError();
        goto CLEANUP;
    }

    if(!pDwm->Initialize())
    {
        dwLastError = GetLastError();
        goto CLEANUP;
    }

    if(!pUxTheme->Initialize())
    {
        dwLastError = GetLastError();
        goto CLEANUP;
    }

    if(pDwm->IsDwmCompositionEnabled() && !(dwFlags&ASC_NO_FRAME_EXTENSION))
    {
        /// 
        /// we do not evaluate the return value of pDwm->DwmExtendFrameIntoClientArea, because
        /// if composition is turned off in the tiny little race condition after the previous call
        /// to IsDwmCompositionEnabled and before the following call to DwmExtendFrameIntoClientArea,
        /// we would see DwmExtendFrameIntoClientArea fail. However, if composition is turned on again 
        /// aterwards, the UI can display composition again without problems:
        /// 
        pDwm->DwmExtendFrameIntoClientArea(hWnd, &marGlassInset);
    }

    hRes = pUxTheme->BufferedPaintInit();
    if(FAILED(hRes))
    {
        dwLastError = hRes;
        goto CLEANUP;
    }
    bBufferedPaintInitialized = true;

    if(!SetProp(hWnd, WINDOW_DATA_STRING, pWndData))
    {
        dwLastError = hRes;
        goto CLEANUP;
    }

    errParentAeroData.m_pdwError = &dwLastError;
    errParentAeroData.m_pWndParentAeroData = pWndData;
    pWndData->m_pDwmApiImpl = pDwm;
    pWndData->m_pUxTheme = pUxTheme;
    pWndData->m_uiRedrawMsg = uiRedrawMsg;

    if(dwFlags&ASC_NO_FRAME_EXTENSION)
        pWndData->m_dwFlags |= WD_NO_FRAME_EXTEND;

    if(!EnumChildWindows(hWnd, SubclassChildWindows, (LPARAM)&errParentAeroData))
    {
        if(ERROR_SUCCESS==dwLastError)
            dwLastError = GetLastError();
        goto CLEANUP;
    }
    
    
    if(ERROR_SUCCESS!=dwLastError)
        goto CLEANUP;


    pWndData->m_oldWndProc = (WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) WndProc);
    if(!pWndData->m_oldWndProc)
    {
        dwLastError = GetLastError();
        goto CLEANUP;
    }




CLEANUP:

    if(ERROR_SUCCESS!=dwLastError)
    {
        RemoveProp(hWnd, WINDOW_DATA_STRING); // don't care if this fails


        if(pDwm)
            delete pDwm;
        if(pUxTheme)
        {
            if(bBufferedPaintInitialized)
                pUxTheme->BufferedPaintUnInit();
                
            delete pUxTheme;
        }
        if(pWndData)
            VERIFY(!LocalFree(pWndData));

        SetLastError(dwLastError);
        return FALSE;
    }

    return TRUE;
}
Exemplo n.º 14
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    PAERO_SUBCLASS_WND_DATA pWndData = (PAERO_SUBCLASS_WND_DATA)GetProp(hWnd, WINDOW_DATA_STRING);
    ASSERT(pWndData);
    ASSERT(pWndData->m_pDwmApiImpl);
    WNDPROC pOldProc = pWndData->m_oldWndProc;
    ASSERT(pOldProc);
    BOOL bCompositionEnabled = pWndData->m_pDwmApiImpl->IsDwmCompositionEnabled();

    /// 
    /// if aero glass is turned off and if we are not in destruction code, 
    /// just call the original wnd proc we had prior to subclassing:
    /// 
    if(WM_COMMAND!=uMsg && WM_DWMCOMPOSITIONCHANGED!=uMsg && WM_DESTROY!=uMsg && WM_NCDESTROY!=uMsg && !bCompositionEnabled)
        return CallWindowProc(pOldProc, hWnd, uMsg, wParam, lParam);

    if (uMsg == pWndData->m_uiRedrawMsg)
    {
        HWND hControl = (HWND)lParam;
        ASSERT(hControl);
        ASSERT(::IsWindow(hControl));

        
        PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp(hControl, WINDOW_DATA_STRING);
        if(pCtrlData && pCtrlData->m_dwFlags & WD_IN_PAINT_CONTROL)
        {
            HDC hdc = GetDC(hControl);
            if(hdc)
            {
                RECT rc;
                VERIFY(GetWindowRect(hControl, &rc));

                VERIFY(MapWindowPoints(NULL, hControl, (LPPOINT) &rc, 2));

                PaintControl(hControl, hdc, &rc, (pCtrlData->m_dwFlags & WD_DRAW_BORDER)!=0);
                VERIFY(1==ReleaseDC(hControl, hdc));
            }
            pCtrlData->m_dwFlags &= ~WD_IN_PAINT_CONTROL;
            return 0;
        }
    }



    switch(uMsg)
    {
        case WM_CTLCOLORSTATIC:
            {
                HWND hControl = (HWND)lParam;
                ASSERT(hControl);
                ASSERT(IsWindow(hControl));
                PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp(hControl, WINDOW_DATA_STRING);
                if(pCtrlData)
                {
                    if(pCtrlData->m_dwFlags&WD_RETURN_BLACK_BRUSH)
                        return (LRESULT)GetStockObject(BLACK_BRUSH);

                    else if(pCtrlData->m_dwFlags&WD_RETURN_WHITE_BRUSH)
                        return (LRESULT)GetStockObject(WHITE_BRUSH);
                    else
                    {
                        pCtrlData->m_dwFlags|=WD_IN_PAINT_CONTROL;
                        PostMessage((HWND)lParam, pWndData->m_uiRedrawMsg, 0, NULL);
                    }
                }
            }

            break;
        case WM_CTLCOLOREDIT:
            {
                PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp((HWND)lParam, WINDOW_DATA_STRING);
                if(pCtrlData)
                    pCtrlData->m_dwFlags|=WD_IN_PAINT_CONTROL;
                PostMessage((HWND)lParam, pWndData->m_uiRedrawMsg, 0, NULL);
            }
            break;

        case WM_PAINT:
            {
                if(!IsIconic(hWnd) && !(pWndData->m_dwFlags&WD_NO_FRAME_EXTEND))
                {
                    PAINTSTRUCT ps;
                    HDC hdc = BeginPaint(hWnd, &ps);

                    /// 
                    /// we have to paint the *entire* client area in black, not only the
                    /// paint area inside ps, because otherwise we get ugly areas of white
                    /// if we partially move the window out of the desktop and back in again:
                    /// 
                    /// 
                    MARGINS marGlassInset = {-1, -1, -1, -1}; // -1 means the whole window
                    if(hdc && pWndData->m_pDwmApiImpl->IsDwmCompositionEnabled() 
                        && SUCCEEDED(pWndData->m_pDwmApiImpl->DwmExtendFrameIntoClientArea(hWnd, &marGlassInset)))
                    {
                        RECT rcClient;
                        VERIFY(GetClientRect(hWnd, &rcClient));
                        VERIFY(PatBlt(hdc, 0, 0, RECTWIDTH(rcClient), RECTHEIGHT(rcClient), BLACKNESS));
                    }

                    EndPaint(hWnd, &ps);
                    return 1;
                }
            }
            break;
        case WM_COMMAND:
            {
                if(bCompositionEnabled)
                {
                    if(LBN_SELCHANGE==HIWORD(wParam))
                    {
                        InvalidateRgn((HWND)lParam, NULL, TRUE);
                        VERIFY(UpdateWindow((HWND)lParam));
                    }
                }

                if(ACN_STOP==HIWORD(wParam))
                {
                    /// 
                    /// if it is an animation control that has just stopped playing,
                    /// reset the WD_PLAY flag so it repaints itself properly again if
                    /// e.g. Aero is turned off an on again:
                    /// 
                    PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp((HWND)lParam, WINDOW_DATA_STRING);                    
                    if(pCtrlData)
                    {
                        pCtrlData->m_dwFlags&=~WD_PLAY;
                    }
                }
                if(ACN_START==HIWORD(wParam))
                {
                    PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp((HWND)lParam, WINDOW_DATA_STRING);                    
                    if(pCtrlData)
                    {
                        pCtrlData->m_dwFlags|=WD_PLAY;
                    }
                }

            }

            break;
        case WM_NOTIFY:
            {
                
                LPNMHDR lpnmh = (LPNMHDR)lParam;

                if(lpnmh)
                {
                    ASSERT(lpnmh->hwndFrom);
                    ASSERT(IsWindow(lpnmh->hwndFrom));

                    switch(lpnmh->code)
                    {
                        case LVN_ITEMCHANGED:
                        {
                            /// 
                            /// if we select and deselect list view items,
                            /// its header control sometimes vanishes so
                            /// we have to force a redraw:
                            /// 
                            HWND hHeader = ListView_GetHeader(lpnmh->hwndFrom);
                            if(hHeader)
                            {
                                InvalidateRgn(hHeader, NULL, TRUE);
                                VERIFY(UpdateWindow(hHeader));
                            }
                         }
                            break;
                         default:
                            break;
                    }
                }
            }

            break;
        case WM_DESTROY:
            ASSERT(pWndData->m_pUxTheme);
            ASSERT(pWndData->m_pDwmApiImpl);
            VERIFY(SUCCEEDED(pWndData->m_pUxTheme->BufferedPaintUnInit()));
            delete pWndData->m_pUxTheme;
            delete pWndData->m_pDwmApiImpl;
            if(WndProc==(WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC))
            {
                VERIFY(WndProc==(WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pWndData->m_oldWndProc));
                VERIFY(pWndData==RemoveProp(hWnd, WINDOW_DATA_STRING)); 
                VERIFY(!LocalFree(pWndData));
            }
            break;
        case WM_NCDESTROY:
            if(WndProc==(WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC))
            {
                VERIFY(WndProc==(WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pWndData->m_oldWndProc));
                VERIFY(pWndData==RemoveProp(hWnd, WINDOW_DATA_STRING)); 
                VERIFY(!LocalFree(pWndData));
            }
            break;
                
    }
    
    return CallWindowProc(pOldProc, hWnd, uMsg, wParam, lParam);
}
Exemplo n.º 15
0
void
mswin_display_RIP_window(HWND hWnd)
{
    MSG msg;
    RECT rt;
    PNHRIPWindow data;
    HWND mapWnd;
    RECT riprt;
    RECT clientrect;
    RECT textrect;
    HFONT OldFont;
    MonitorInfo monitorInfo;

    win10_monitor_info(hWnd, &monitorInfo);

    data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);

    data->x = (int)(RIP_OFFSET_X * monitorInfo.scale);
    data->y = (int)(RIP_OFFSET_Y * monitorInfo.scale);
    data->width = (int)(RIP_WIDTH * monitorInfo.scale);
    data->height = (int)(RIP_HEIGHT * monitorInfo.scale);
    data->graveX = (int)(RIP_GRAVE_X * monitorInfo.scale);
    data->graveY = (int)(RIP_GRAVE_Y * monitorInfo.scale);
    data->graveWidth = (int)(RIP_GRAVE_WIDTH * monitorInfo.scale);
    data->graveHeight = (int)(RIP_GRAVE_HEIGHT * monitorInfo.scale);

    GetNHApp()->hPopupWnd = hWnd;
    mapWnd = mswin_hwnd_from_winid(WIN_MAP);
    if (!IsWindow(mapWnd))
        mapWnd = GetNHApp()->hMainWnd;
    GetWindowRect(mapWnd, &rt);
    GetWindowRect(hWnd, &riprt);
    GetClientRect(hWnd, &clientrect);
    textrect = clientrect;
    textrect.top += data->y;
    textrect.left += data->x;
    textrect.right -= data->x;
    if (data->window_text) {
        HDC hdc = GetDC(hWnd);
        OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE)->hFont);
        DrawText(hdc, data->window_text, strlen(data->window_text), &textrect,
                 DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
        SelectObject(hdc, OldFont);
        ReleaseDC(hWnd, hdc);
    }
    if (textrect.right - textrect.left > data->width)
        clientrect.right = textrect.right + data->y - clientrect.right;
    else
        clientrect.right =
            textrect.left + 2 * data->x + data->width - clientrect.right;
    clientrect.bottom =
        textrect.bottom + data->height + data->y - clientrect.bottom;
    GetWindowRect(GetDlgItem(hWnd, IDOK), &textrect);
    textrect.right -= textrect.left;
    textrect.bottom -= textrect.top;
    clientrect.bottom += textrect.bottom + data->y;
    riprt.right -= riprt.left;
    riprt.bottom -= riprt.top;
    riprt.right += clientrect.right;
    riprt.bottom += clientrect.bottom;
    rt.left += (rt.right - rt.left - riprt.right) / 2;
    rt.top += (rt.bottom - rt.top - riprt.bottom) / 2;

    MoveWindow(hWnd, rt.left, rt.top, riprt.right, riprt.bottom, TRUE);
    GetClientRect(hWnd, &clientrect);
    MoveWindow(GetDlgItem(hWnd, IDOK),
               (clientrect.right - clientrect.left - textrect.right) / 2,
               clientrect.bottom - textrect.bottom - data->y,
               textrect.right, textrect.bottom, TRUE);
    ShowWindow(hWnd, SW_SHOW);

    while (IsWindow(hWnd) && GetMessage(&msg, NULL, 0, 0) != 0) {
        if (!IsDialogMessage(hWnd, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    GetNHApp()->hPopupWnd = NULL;
}
Exemplo n.º 16
0
/**
 * name:	~CProgress
 * class:	CProgress
 * desc:	destroy the progress dialog and its data structure
 * params:	none
 * return:	nothing
 **/
CProgress::~CProgress()
{
	if(IsWindow(_hDlg)) DestroyWindow(_hDlg);
}
Exemplo n.º 17
0
/*--------------------------------------------------------
   window procedure of subclassed property sheet
---------------------------------------------------------*/
LRESULT CALLBACK SubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	LRESULT l;
  switch(message) {

	case WM_SHOWWINDOW: // adjust the window position
	  SetMyDialgPos(hwnd);
	  return FALSE; // Returning FALSE Allows it to Maintain Caret Focus
 }
	
	// default
	l = CallWindowProc(oldWndProc, hwnd, message, wParam, lParam);
	
	switch(message)
	{
		case WM_COMMAND:
		{
			WORD id;
			id = LOWORD(wParam);
			// close the window by "OK" or "Cancel"
			if(id == IDOK || id == IDCANCEL)
			{
				// MyHelp(hwnd, -1);
				startpage = (int)SendMessage(
					(HWND)SendMessage(hwnd, PSM_GETTABCONTROL, 0, 0), TCM_GETCURSEL, 0, 0);
				if(startpage < 0) startpage = 0;
				DestroyWindow(hwnd);
				g_hwndSheet = NULL;
			}
			// apply settings
			if(id == IDOK || id == 0x3021)
			{
				if(g_bApplyClock)
				{
					SendMessage(g_hwndClock, CLOCKM_REFRESHCLOCK, 0, 0);
					g_bApplyClock = FALSE;
				}
				if(g_bApplyClear)
				{
					SendMessage(g_hwndClock, CLOCKM_REFRESHCLEARTASKBAR, 0, 0);
					g_bApplyClear = FALSE;
				}
				if(g_bApplyTaskbar)
				{
					SendMessage(g_hwndClock, CLOCKM_REFRESHTASKBAR, 0, 0);
					g_bApplyTaskbar = FALSE;
				}
			}
			if(id == IDOK || id == IDCANCEL)
			{
						if(g_hDlgTimer && IsWindow(g_hDlgTimer))
							PostMessage(g_hDlgTimer, WM_CLOSE, 0, 0);
						if(g_hDlgCalender && IsWindow(g_hDlgCalender))
							PostMessage(g_hDlgCalender, WM_CLOSE, 0, 0);
			}
			EmptyWorkingSet(GetCurrentProcess());
			break;
		}
		// close by "x" button
		case WM_SYSCOMMAND:
		{
			if((wParam & 0xfff0) == SC_CLOSE)
				PostMessage(hwnd, WM_COMMAND, IDCANCEL, 0);
			break;
		}
	}
	return l;
}
Exemplo n.º 18
0
void CuEditableListCtrlCommentInsertValue::SetLimitEditText()
{
	CEdit* cEditTemp = EDIT_GetEditCtrl();
	if (cEditTemp && IsWindow(cEditTemp->m_hWnd))
		cEditTemp->LimitText(MAX_LENGTH_COMMENT);
}
Exemplo n.º 19
0
void CActionFeatureInfo::LButtonUpEvent(UINT nFlags, CPoint point)
{

	

	GEOMETRY::geom::Envelope envelop;
	DIS_RECT rect;
	rect.left =point.x -3;
	rect.right =point.x+3;
	rect.top =point.y -3;
	rect.bottom =point.y+3;

	m_pMap->GetDisplay()->GetDisplayTransformation().TransformToGeo(rect,&envelop);
	//构造一个用于查询的多边形

	Geodatabase::CSpatialQuery queryfilter;


	//构造一个空间查询条件
	GEOMETRY::geom::Geometry *pGeometry =GeometryFactory::getDefaultInstance()->toGeometry(&envelop);
	queryfilter.SetGeometry(pGeometry);
	queryfilter.SetSpatialRel(Geodatabase::SpatialRelIntersects);


	Carto::CLayerArray &layers =m_pMap->GetLayers();

	Carto::ILayerPtr pLayer;
	long FeatureLayernum=0;
	for(int i=0;i<layers.GetSize();i++)
	{
		pLayer =layers.GetAt(i);
		if(!pLayer->GetVisible())
		{
			continue;
		}
		if(pLayer->GetLayerType()!=Carto::FeatureLayer)
		{
			continue;
		}

		pLayer->Select(&queryfilter,Carto::SELECT_REPLACE);

		FeatureLayernum++;


	}

	if(FeatureLayernum==0)
	{
		return;
	}
	m_pMapCtrl->UpdateContent(otDrawGeoSelection);

    AFX_MANAGE_STATE(AfxGetStaticModuleState());

	if( NULL != m_dlg )
	{
		if( !IsWindow( m_dlg->m_hWnd ) )
		{
			m_dlg->Create( );			
		}
		m_dlg->SetMap(m_pMap);
		m_dlg->Refresh();
		m_dlg->ShowWindow(SW_SHOW);
	}
	else
	{
		m_dlg = new CDlgFeatureInfo;
		if( NULL == m_dlg )
			return;
		m_dlg->Create( );
		m_dlg->SetMap(m_pMap);
		m_dlg->Refresh();

	}
}
Exemplo n.º 20
0
/*************************************************
Function:       // ShowUserInfo
Description:    //
Calls:          //
Table Accessed: //
Table Updated:  //
Input:          //
                //
Output:         //
Return:         //
Others:         //
*************************************************/
void CIBATaskPane::ShowUserInfo(CActiveMember & ActiveMember)
{
	CString strContent;
	
	CString strUseTime = ActiveMember.GetCheckInTimeAsString();
	if (!strUseTime.IsEmpty())
	{
		strUseTime.AppendFormat(_T("(%s)"), ActiveMember.GetPayTypeAsString());
	}

		/*L"姓名:%s\r\n"
		L"账号:%s\r\n"
		L"用户级别:%s\r\n"
		L"证件号码:%s\r\n"
		L"\r\n"
		L"\r\n"
		L"电脑名称:%s\r\n"
		L"机器区域:%s\r\n"

		L"使用时间:%s\r\n"
		L"使用时长:%s\r\n"
		L"\r\n"
		L"\r\n"
		L"可用金额:%s\r\n"
		L"消费金额:%s\r\n",*/

	strContent.Format(LOAD_STRING(IDS_TASK_INFO),
		ActiveMember.GetUserName(),
		ActiveMember.GetNetId(),
		ActiveMember.GetUserClassName(),
		ActiveMember.GetPersonalID(),
		ActiveMember.GetTerminalID(),
		ActiveMember.GetPCClass(),
		strUseTime,
		ActiveMember.GetUseTimeAsString(),
		ActiveMember.GetAvailavleBalanceAsString(),
		ActiveMember.GetAmountAsString());

	m_ActiveMember = ActiveMember;

	ShowUserInfo(strContent);

	// GXX 2013-5-6 15:20:36 这段代码可能有用,不要删除
	/*if (CNetBarConfig::GetInstance()->GetEnableID2Reader())
	{
		if (m_dlgUserPhoto.m_hWnd == NULL)
		{
			CString strTmp = _T("证件照");
			int nPage1Gr4 = AddGroup(1, strTmp);
			m_dlgUserPhoto.Create(IDD_DLG_USER_PHOTO, this);
			AddWindow(nPage1Gr4, m_dlgUserPhoto, 150);
		}
		CString strPath = theApp.GetWorkPath();
		CString strImgPath = strPath + _T("\\IDImages\\");
		CString strPicPath = strImgPath;
		strPicPath.Append(ActiveMember.GetPersonalID());
		strPicPath.Append(_T(".jpg"));
		if (IsWindow(m_dlgUserPhoto.m_hWnd))
		{
			m_dlgUserPhoto.m_staticPhoto.ShowPic(strPicPath);
		}
	}*/
	if (1 == CNetBarConfig::GetInstance()->GetIsShowRzxPhoto())
	{
		if (m_dlgUserPhoto.m_hWnd == NULL)
		{
			CString strTmp = _T("证件照");
			int nPage1Gr4 = AddGroup(1, strTmp);
			m_dlgUserPhoto.Create(IDD_DLG_USER_PHOTO, this);
			AddWindow(nPage1Gr4, m_dlgUserPhoto, 150);
		}
		CString strPath = theApp.GetWorkPath();
		CString strImgPath = strPath + _T("\\UserImages\\");
		CString strPicPath = strImgPath;
		CString strID = CIBAHelpper::FormatNetId(ActiveMember.GetNetId());
		strPicPath.Append(strID);
		strPicPath.Append(_T(".jpg"));
		if (IsWindow(m_dlgUserPhoto.m_hWnd))
		{
			IBA_LOG(_T("实名照片路径:%s"), strPicPath);
			m_dlgUserPhoto.m_staticPhoto.ShowPic(strPicPath);
		}
	}
}
CExtentVisualWindow::~CExtentVisualWindow()
{
    if (IsWindow(_hwnd))
        DestroyWindow(_hwnd);
}
Exemplo n.º 22
0
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {

	static BOOL s_fConfirmActive = FALSE;
	static UINT s_uTaskbarCreated = 0;

	switch (uMsg) {

		case WM_HOTKEY: {

			switch (wParam) {

				case IDH_NEXTTASK:
				case IDH_PREVTASK:
				case IDH_WINNEXTTASK:
				case IDH_WINPREVTASK:
				case IDH_INSTNEXT:
				case IDH_INSTPREV:
				case IDH_STNEXTTASK:
				case IDH_STINEXTTASK:
					ShowTaskSwitchWnd((UINT)wParam);
					break;

				case IDH_MINIMIZETRAY:
					FlipToTray(GetForegroundWindow());
					break;

				case IDH_RESTORETRAY:
					if (g_cWti > 0)
						_UnflipFromTray(g_cWti - 1);
					break;

				case IDH_SHOWHIDE:
					ShowTrayIcon(!(g_dwFlags & TSF_SHOWTRAYICON));
					break;

				case IDH_CONFIG:
					ConfigTaskSwitchXP();
					break;
				case IDH_ALTAPPLIST:
					//MessageBox (0, L"This must display alternative task switching window\r\n"
					//	L"(or the same window but in alternative mode)", L"klvov says:", MB_OK);
					//ShowAltTSWindow();
					//OutputDebugString(L"IDH_ALTAPPLIST message received\n");
					ShowTaskSwitchWnd((UINT)wParam);
					break;

				case IDH_EXIT:
					if (!(g_dwFlags & TSF_NOCONFIRMEXIT)) {
						if (s_fConfirmActive) { // activate confirm dialog
#pragma FIX_LATER(multiple exit confirmations)
							break;
							/*HWND hwndMsg = FindWindowEx(NULL, NULL, L"#32770", L"TaskSwitchXP confirmation");
							if (hwndMsg) {
								SetForegroundWindow(hwndMsg);
								break;
							}*/
						}

						s_fConfirmActive = TRUE;
						if (ConfirmMessage(IDS_CONFIRM_EXIT))
							DestroyWindow(hwnd);
						s_fConfirmActive = FALSE;
					} else 
						DestroyWindow(hwnd);
					break;
			}
			break;
							}

		case WM_TIMER:
			if (wParam == TIMER_RIGHTUP) {
				KillTimer(hwnd, TIMER_RIGHTUP);
				mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTUP, 
					_ptRClick.x, _ptRClick.y, _dwRData, _dwRExtraInfo);
			} else if (wParam == TIMER_SETANIMATION) {
				KillTimer(hwnd, TIMER_SETANIMATION);
				ANIMATIONINFO ai;
				ai.cbSize = sizeof(ANIMATIONINFO);
				ai.iMinAnimate = TRUE;
				SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE);
			} else if (wParam == TIMER_CHECKTRAYWND) {
				for (UINT i = 0; i < g_cWti; i++) {
					if (!IsWindow(g_pWti[i].hwnd) || IsWindowVisible(g_pWti[i].hwnd))
						_UnflipFromTray(i, SC_MINIMIZE);
				}
			} else if (wParam == TIMER_RELOADICONS) {
				if (!(g_dwFlags & TSF_RELOADICONS))
					KillTimer(hwnd, TIMER_RELOADICONS);
				ReloadTsTrayIcons();
			} else if (wParam == TIMER_CHECKCOLORS) {
				KillTimer(hwnd, TIMER_CHECKCOLORS);
				if (CheckColorTheme())
					CheckDefaultColors();
			} else if (wParam == TIMER_CLOSEDESK) {
				if (WaitForSingleObject(g_hThreadTs, 0) == WAIT_OBJECT_0) {
					KillTimer(hwnd, TIMER_CLOSEDESK);
					//_RPT0(_CRT_WARN, "close desk\n");
					if (g_hThreadTs) {
						CloseHandle(g_hThreadTs);
						g_hThreadTs = NULL;
					}
					if (g_hDesk) {
						CloseDesktop(g_hDesk);
						g_hDesk = NULL;
					}
				}
			}
			break;

		case WM_REMOTECMD:
			SwitchToThisWindow(hwnd, TRUE);
			if (wParam & CCLF_ESCAPE) {
				if (g_hwndTs)
					PostMessage(g_hwndTs, WM_TASKSWITCH, IDH_ESCAPE, 0);
			} else if (wParam & CCLF_STINEXTTASK) {
				ShowTaskSwitchWnd(IDH_STINEXTTASK);
			} else if (wParam & CCLF_STNEXTTASK) {
				ShowTaskSwitchWnd(IDH_STNEXTTASK);
			}
			break;

		case WM_MYTRAYMSG:
			if (wParam == IDI_TASKSWITCHXP) {
				if ((UINT)lParam == g_uTrayMenu) {
					ShowTrayMenu();
				} else if ((UINT)lParam == g_uTrayConfig) {
					ConfigTaskSwitchXP();
				} else if ((UINT)lParam == g_uTrayNext) {
					ShowTaskSwitchWnd(IDH_STTRAYNEXT);
				} else if ((UINT)lParam == g_uTrayPrev) {
					ShowTaskSwitchWnd(IDH_STITRAYNEXT);
				}
			} else {
				if (lParam == WM_LBUTTONUP) {
                    UnflipFromTrayID((UINT)wParam);
				} else if (lParam == WM_RBUTTONUP) {
					ShowFlippedSystemMenu((UINT)wParam);
				} else if (lParam == WM_MBUTTONUP)
					UnflipFromTrayID((UINT)wParam, 0);
			}
			break;

		case WM_EXTMOUSE:
			if (wParam == HTMINBUTTON) {
				FlipToTray((HWND)lParam);
			} else if (wParam == HTMAXBUTTON) {
				HWND h = (HWND)lParam;
				DWORD dwExStyle = GetWindowLongPtr(h, GWL_EXSTYLE);
				SetWindowPos(h, ((dwExStyle & WS_EX_TOPMOST) 
					? HWND_NOTOPMOST : HWND_TOPMOST), 0, 0, 0, 0, 
					SWP_NOSIZE | SWP_NOMOVE);
			}
			break;

		case WM_FLIPTOTRAY:
			return(FlipToTray((HWND)wParam));
			//break;

		case WM_UNFLIPFROMTRAY:
			UnflipFromTray((HWND)wParam, (UINT)lParam);
			break;

		case WM_GETTRAYWINDOWS:
			if (wParam) {
				HWND *phWnd = (HWND*)wParam;
				int cWti = 0;
				while (cWti < MIN((int)lParam, (int)g_cWti)) {
					phWnd[cWti] = g_pWti[cWti].hwnd;
					cWti++;
				}
				return(cWti);
			} else 
				return(g_cWti);
			break;

		case WM_RELOADSETTINGS:
			if (!LoadSettings()) {
				ReportError(IDS_ERR_LOADSETTINGS);
				DestroyWindow(hwnd);
			}
			break;

		case WM_THEMECHANGED:
			if (CheckColorTheme())
				CheckDefaultColors();
			SetTimer(hwnd, TIMER_CHECKCOLORS, 1000, NULL);
			break;

		case WM_CREATE: {

			s_uTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated");
			g_hwndMain = hwnd;

			SendMessage(hwnd, WM_SETICON, ICON_BIG, 
				(LONG)(LONG_PTR)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TASKSWITCHXP), IMAGE_ICON, 
				GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR));
			SendMessage(hwnd, WM_SETICON, ICON_SMALL, 
				(LONG)(LONG_PTR)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TASKSWITCHXP), IMAGE_ICON, 
				GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR));

			if (!LoadSettings()) {
				ReportError(IDS_ERR_LOADSETTINGS);
				return(-1);
			}
			if (!InitPreviewThread())
				return(-1);

			// Weird huh? I cannot understand this...
			if (g_dwShowDelay && g_dwFlagsPv & TSFPV_DESKTOP && g_dwFlagsPv & TSFPV_TASKBAR) {

				RECT rcPvEx;
				rcPvEx.left = rcPvEx.top = 0;
				rcPvEx.right = 102;
				rcPvEx.bottom = 76;
				HDC hdcScreen = GetDC(NULL);
				HDC hdcMem = CreateCompatibleDC(hdcScreen);
				HBITMAP hbitmapMem = CreateCompatibleBitmap(hdcScreen, 
					rcPvEx.right - rcPvEx.left, rcPvEx.bottom - rcPvEx.top);
				ReleaseDC(NULL, hdcScreen);

				if (hbitmapMem) {
					HBITMAP hbitmapOld = (HBITMAP)SelectObject(hdcMem, hbitmapMem);

					SetForegroundWindow(g_hwndMain);
					MyPrintWindow(FindWindow(L"Shell_TrayWnd", L""), 
						hdcMem, &rcPvEx, &rcPvEx, MPW_NOCHECKPOS);

					SelectObject(hdcMem, hbitmapOld);
					DeleteObject(hbitmapMem);
				}
				DeleteDC(hdcMem);
			}
			SetTimer(hwnd, TIMER_CHECKTRAYWND, 1000, NULL);

			if (g_dwCmdLine & CCLF_STINEXTTASK) {
				ShowTaskSwitchWnd(IDH_STINEXTTASK);
			} else if (g_dwCmdLine & CCLF_STNEXTTASK) {
				ShowTaskSwitchWnd(IDH_STNEXTTASK);
			}
			break;
						}

		case WM_CLOSE:
			break;

		case WM_DESTROY:
			KillTimer(hwnd, TIMER_CHECKTRAYWND);
			DestroySettings();
			DestroyPreviewThread();
			for (int i = (int)g_cWti - 1; i >= 0; i--)
				_UnflipFromTray((UINT)i, 0);
			PostQuitMessage(0);
			break;

		default:
			if (uMsg == s_uTaskbarCreated) {
				ReloadTsTrayIcons();
			} else 
				return(DefWindowProc(hwnd, uMsg, wParam, lParam));
			break;
	}
	return(0);
}
Exemplo n.º 23
0
// 计算列表项大小
void CPopupList::SetItemPoint()
{
	int nItemCount =  m_vecItem.size();

	// 判断是否有Desc字段,如果都没有的话,则显示的列表一律用相同高度的
	BOOL bHaveDesc = FALSE;
	for (int i = 0; i < nItemCount; i++)
	{
		EditListItem &editListItem = m_vecItem.at(i);
		if(!editListItem.strDesc.IsEmpty())
		{
			bHaveDesc = TRUE;
			break;
		}
	}

	int nHeight = 4;
	nHeight += 24 * nItemCount;
	if(bHaveDesc)
	{
		if(0 == nItemCount) nHeight += 40;
		if(nItemCount >= 1) nHeight += 20;
		if(nItemCount >= 2) nHeight += 9;
		if(nItemCount >= 2) nHeight += 9;
	}

	int nStratTop = 2;
	for (int i = 0; i < nItemCount; i++)
	{
		EditListItem &editListItem = m_vecItem.at(i);
		editListItem.rcItem.left = 2;
		editListItem.rcItem.right = m_nWidth - 2;
		if((i - 1 == m_nHoverItem) && (m_nHoverItem != -1) || (i + 1 == m_nHoverItem))
		{
			editListItem.rcItem.top = nStratTop;
			editListItem.rcItem.bottom = nStratTop + (bHaveDesc ? 33 : 24);
			nStratTop += (bHaveDesc ? 33 : 24);
		}
		else if(i == m_nHoverItem)
		{
			editListItem.rcItem.top = nStratTop;
			editListItem.rcItem.bottom = nStratTop + (bHaveDesc ? 44 : 24);
			nStratTop += (bHaveDesc ? 44 : 24);

			int nLeft = editListItem.rcItem.right - m_sizeClose.cx - 7;
			int nTop = editListItem.rcItem.top + ((bHaveDesc ? 44 : 24) - m_sizeClose.cy) / 2 + 1;

			m_rcClose.SetRect(nLeft, nTop, nLeft + m_sizeClose.cx, nTop + m_sizeClose.cy);
		}
		else
		{
			editListItem.rcItem.top = nStratTop;
			editListItem.rcItem.bottom = nStratTop + 24;
			nStratTop += 24;
		}
	}
	
	if(IsWindow(GetSafeHwnd()))
	{
		SetWindowPos(NULL, 0, 0, m_nWidth, nHeight, SWP_NOMOVE);
	}
}
Exemplo n.º 24
0
BOOL FlipToTray(HWND hwnd) {

	if (g_cWti >= MAX_WNDTRAY)
		return(FALSE);
	if (!IsWindow(hwnd))
		return(FALSE);

	HWND hwndShell = GetShellWindow(), hwndTmp, hwndOwner;
	hwndTmp = hwndOwner = hwnd;
	do {
		hwndOwner = hwndTmp;
		hwndTmp = GetWindow(hwndTmp, GW_OWNER);
	} while (hwndTmp && hwndTmp != hwndShell);

	DWORD dw = GetWindowLongPtr(hwndOwner, GWL_STYLE);
	if (!(dw & WS_MINIMIZEBOX) || dw & WS_CHILD)
		return(FALSE);

	//SetForegroundWindow(g_hwndMain);
	//MySwitchToThisWindow(GetShellWindow());

	for (UINT i = 0; i < g_cWti; i++) {
		if (g_pWti[i].hwnd == hwndOwner) {
			if (IsWindowVisible(hwndOwner))
				_UnflipFromTray(i, 0);
			else return(FALSE);
		}
	}

	UINT uID = IDC_FIRSTTRAYICON;
	if (g_cWti > 0) {
		while (uID < IDC_FIRSTTRAYICON + MAX_WNDTRAY) {
			BOOL fIs1 = TRUE;
			for (UINT i = 0; i < g_cWti; i++) {
				if (g_pWti[i].uID == uID)
					fIs1 = FALSE;
			}
			if (fIs1) break;
			uID++;
		}
	}

	HICON hIcon, hIconSm;
	GetWindowIcons(hwndOwner, &hIcon, &hIconSm);

	WCHAR szCaption[MAX_CAPTION];
	InternalGetWindowText(hwndOwner, szCaption, MAX_CAPTION);
	if (szCaption[0] == L'\0' && hwnd != hwndOwner) {
		InternalGetWindowText(hwnd, szCaption, MAX_CAPTION);
	}

	if (MyIsHungAppWindow(hwndOwner))
		return(FALSE);

	RECT rcTray = { 0 };

	g_pWti[g_cWti].fAnimate = FALSE;

	if (!(dw & WS_MINIMIZE)) {

		GetWindowRect(hwnd, &g_pWti[g_cWti].rcWnd);
	
		ANIMATIONINFO ai;
		ai.cbSize = sizeof(ANIMATIONINFO);
		ai.iMinAnimate = FALSE;
		SystemParametersInfo(SPI_GETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE);

		if (ai.iMinAnimate) {
			HWND hwndTray = FindTrayToolbarWindow();
			if (hwndTray) {
				GetWindowRect(hwndTray, &rcTray);
				rcTray.bottom = rcTray.top;
				rcTray.right = rcTray.left;

				KillTimer(g_hwndMain, TIMER_SETANIMATION);
				g_pWti[g_cWti].fAnimate = TRUE;			
				ai.iMinAnimate = 0;
				SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE);
				SetTimer(g_hwndMain, TIMER_SETANIMATION, 500, NULL);

				DrawAnimatedRects(g_hwndMain, IDANI_CAPTION, 
					&g_pWti[g_cWti].rcWnd, &rcTray);
			}
		}

		//ShowWindow(hwndOwner, SW_MINIMIZE);
		if (!SendMessageTimeout(hwndOwner, WM_SYSCOMMAND, SC_MINIMIZE, 0, 
			SMTO_ABORTIFHUNG, 500, &dw)) return(FALSE);
	}

	//ShowWindow(hwndOwner, SW_HIDE);
	SetWindowPos(hwndOwner, NULL, 0, 0, 0, 0, 
		SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);

	//if (g_pWti[g_cWti].fAnimate) {
	//}

	g_pWti[g_cWti].hwnd = hwndOwner;
	g_pWti[g_cWti].uID = uID;
	g_pWti[g_cWti].hIconSm = hIconSm;
	g_cWti++;
	AddTrayIcon(g_hwndMain, uID, hIconSm, szCaption);
	return(TRUE);
}
Exemplo n.º 25
0
Arquivo: main.cpp Projeto: majek/avs
static unsigned int WINAPI RenderThread(LPVOID a)
{
  int framedata[FPS_NF]={0,};
	int framedata_pos=0;
  int s=0;
	char vis_data[2][2][576];
  FILETIME ft;
  GetSystemTimeAsFileTime(&ft);
  srand(ft.dwLowDateTime|ft.dwHighDateTime^GetCurrentThreadId());
	while (!g_ThreadQuit)
	{
		int w,h,*fb=NULL, *fb2=NULL,beat=0;

#ifdef REAPLAY_PLUGIN
    if(!IsWindowVisible(g_hwnd)) 
    {
      Sleep(1);
      continue;
    }

    char visdata[576*2*2];
    int ret = vuGetVisData(visdata, sizeof(visdata));
		if (!ret) 
    {
      memset(&vis_data[0][0][0],0,576*2*2);
      beat=0;
    }
    else
    {
      int x;
      unsigned char *v=(unsigned char *)visdata;
		  for (x = 0; x < 576*2; x ++)
			  vis_data[0][0][x]=g_logtab[*v++];
		  for (x = 0; x < 576*2; x ++)
        ((unsigned char *)vis_data[1][0])[x]=*v++;

      v=(unsigned char *)visdata+1152;
	    {
        int lt[2]={0,0};
        int ch;
        for (ch = 0; ch < 2; ch ++)
        {
          for (x = 0; x < 576; x ++)
          {
            int r=*v++^128;
            r-=128;
            if (r<0)r=-r;
            lt[ch]+=r;
          }
        }
        lt[0]=max(lt[0],lt[1]);

        beat_peak1=(beat_peak1*125+beat_peak2*3)/128;
        beat_cnt++;

        if (lt[0] >= (beat_peak1*34)/32 && lt[0] > (576*16)) 
        {
          if (beat_cnt>0)
          {
            beat_cnt=0;
            beat=1;
          }
          beat_peak1=(lt[0]+beat_peak1_peak)/2;
          beat_peak1_peak=lt[0];
        }
        else if (lt[0] > beat_peak2)
        {
          beat_peak2=lt[0];
        } 
        else beat_peak2=(beat_peak2*14)/16;

	    }
//     EnterCriticalSection(&g_title_cs);
	    beat=refineBeat(beat);
//      LeaveCriticalSection(&g_title_cs);
    }
#else
		EnterCriticalSection(&g_cs);
		memcpy(&vis_data[0][0][0],&g_visdata[0][0][0],576*2*2);
		g_visdata_pstat=1;
		beat=g_is_beat;
		g_is_beat=0;
		LeaveCriticalSection(&g_cs);
#endif

    if (!g_ThreadQuit)
    {
		  if (IsWindow(g_hwnd)&&!g_in_destroy) DDraw_Enter(&w,&h,&fb,&fb2);
      else break;
		  if (fb&&fb2)
		  {
        extern int g_dlg_w, g_dlg_h, g_dlg_fps;
#ifdef LASER
        g_laser_linelist->ClearLineList();
#endif

	      EnterCriticalSection(&g_render_cs);
				int t=g_render_transition->render(vis_data,beat,s?fb2:fb,s?fb:fb2,w,h);
	      LeaveCriticalSection(&g_render_cs);
        if (t&1) s^=1;

#ifdef LASER
        s=0;
        memset(fb,0,w*h*sizeof(int));
        LineDrawList(g_laser_linelist,fb,w,h);
#endif
			  if (IsWindow(g_hwnd)) DDraw_Exit(s);

        int lastt=framedata[framedata_pos];
        int thist=GetTickCount();
        framedata[framedata_pos]=thist;
        g_dlg_w=w;
        g_dlg_h=h;
        if (lastt)
        {
          g_dlg_fps=MulDiv(sizeof(framedata)/sizeof(framedata[0]),10000,thist-lastt);
        }
        framedata_pos++;
        if (framedata_pos >= sizeof(framedata)/sizeof(framedata[0])) framedata_pos=0;

		  }
      int fs=DDraw_IsFullScreen();
      int sv=(fs?(cfg_speed>>8):cfg_speed)&0xff;
	    Sleep(min(max(sv,1),100));
    }
	}
  _endthreadex(0);
	return 0;
}
Exemplo n.º 26
0
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) {
#else // _DEBUG
void APIENTRY _myWinMain() {
#endif // _DEBUG

    g_hinstExe = GetModuleHandle(NULL);

	int nExitCode = 1;
	//HANDLE hmtx = NULL;
    
	__try {

		ParseCommandLine();

		if (!CheckVersion() && !(g_dwCmdLine & CCLF_NOCHECKVER)) {
			MessageBoxA(NULL, "This program requires features present in Windows XP/2003.", 
				"Error", MB_OK | MB_ICONERROR | MB_TOPMOST | MB_SETFOREGROUND);
			__leave;
		}

		/*hmtx = CreateMutex(NULL, FALSE, g_szTaskSwitch);
		if (GetLastError() == ERROR_ALREADY_EXISTS) {
			ReportError(IDS_ERR_EXISTS);
			__leave;
		}*/

		InitThreadLang2();
		InitLanguage();

		HWND hwndTs = FindWindowEx(NULL/*HWND_MESSAGE*/, NULL, g_szMainWnd, g_szWindowName);
		if (IsWindow(hwndTs)) {
			if (g_dwCmdLine != 0) {
				SetForegroundWindow(hwndTs);
				PostMessage(hwndTs, WM_REMOTECMD, g_dwCmdLine, 0);
			} else {
				if (ConfirmMessage(IDS_CONFIRM_RUNNING, MB_ICONEXCLAMATION | MB_DEFBUTTON2))
					PostMessage(hwndTs, WM_DESTROY, 0, 0);
				//PostMessage(hwndTs, WM_RELOADSETTINGS, 0, 0);
			}
			__leave;
		}

		HINSTANCE hinstUser32 = LoadLibrary(L"user32.dll");
		g_pfnIsHungAppWindow = (ISHUNGAPPWINDOW)GetProcAddress(hinstUser32, "IsHungAppWindow");
		//g_pfnEndTask = (ENDTASK)GetProcAddress(hinstUser32, "EndTask");

		WNDCLASSEX wcex;
		wcex.cbSize			= sizeof(WNDCLASSEX);
		wcex.style			= 0;
		wcex.lpfnWndProc	= (WNDPROC)MainWndProc;
		wcex.cbClsExtra		= 0;
		wcex.cbWndExtra		= 0;
		wcex.hInstance		= g_hinstExe;
		wcex.hIcon			= NULL;
		wcex.hCursor		= NULL;
		wcex.hbrBackground	= NULL;
		wcex.lpszMenuName	= NULL;
		wcex.lpszClassName	= g_szMainWnd;
		wcex.hIconSm		= NULL;
		if (!RegisterClassEx(&wcex))
			__leave;

		if (!CreateWindowEx(WS_EX_TOOLWINDOW, g_szMainWnd, g_szWindowName, 
			0, 0, 0, 0, 0, NULL/*HWND_MESSAGE*/, NULL, g_hinstExe, NULL)) __leave;

		MSG msg;
		while (GetMessage(&msg, NULL, 0, 0)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		nExitCode = (int)msg.wParam;
	}
	__finally {
		DestroyThreadLang2();
		//if (hmtx) CloseHandle(hmtx);		
	}
#ifdef _DEBUG
	return(nExitCode);
#else // _DEBUG
	ExitProcess((UINT)nExitCode);
#endif
}
Exemplo n.º 27
0
void CaptureDDraw()
{
    //RUNEVERYRESET logOutput << CurrentTimeString() << "called CaptureDDraw()" << endl;

    if (bCapturing && WaitForSingleObject(hSignalEnd, 0) == WAIT_OBJECT_0)
    {
        //logOutput << CurrentTimeString() << "not capturing or received hSignalEnd" << endl;
        bStopRequested = true;
    }

    if (bCapturing && !IsWindow(hwndOBS))
    {
        //logOutput << CurrentTimeString() << "not capturing or OBS window not found" << endl;
        hwndOBS = NULL;
        bStopRequested = true;
    }

    if (bStopRequested)
    {
        CleanUpDDraw();
        bCapturing = false;
        bStopRequested = false;
    }

    if (!bCapturing && WaitForSingleObject(hSignalRestart, 0) == WAIT_OBJECT_0)
    {
        //logOutput << CurrentTimeString() << "capturing and received hSignalRestart" << endl;
        hwndOBS = FindWindow(OBS_WINDOW_CLASS, NULL);
        if (hwndOBS) {
            logOutput << CurrentTimeString() << "received restart event, capturing" << endl;
            bCapturing = true;
        }
        else {
            logOutput << CurrentTimeString() << "received restart event, but couldn't find window" << endl;
        }
    }

    LONGLONG timeVal = OSGetTimeMicroseconds();

    //check keep alive state, dumb but effective
    if (bCapturing)
    {
        if (!keepAliveTime)
            keepAliveTime = timeVal;

        if ((timeVal - keepAliveTime) > 5000000)
        {
            HANDLE hKeepAlive = OpenEvent(EVENT_ALL_ACCESS, FALSE, strKeepAlive.c_str());
            if (hKeepAlive) {
                CloseHandle(hKeepAlive);
            }
            else {
                logOutput << CurrentTimeString() << "Keepalive no longer found on ddraw, freeing capture data" << endl;
                CleanUpDDraw();
                bCapturing = false;
            }

            keepAliveTime = timeVal;
        }
    }

    if (bHasTextures)
    {
        LONGLONG frameTime;
        if (bCapturing)
        {
            if (copyData)
            {
                if (frameTime = copyData->frameTime)
                {
                    LONGLONG timeElapsed = timeVal - lastTime;

                    if (timeElapsed >= frameTime)
                    {
                        lastTime += frameTime;
                        if (timeElapsed > frameTime * 2)
                            lastTime = timeVal;


                        //logOutput << CurrentTimeString() << "CaptureDDraw: capturing screen from 0x" << g_frontSurface << endl;

                        HRESULT hr;
                        ddrawSurfaceBlt.Unhook();
                        hr = ddCaptures[curCapture]->Blt(NULL, g_frontSurface, NULL, DDBLT_ASYNC, NULL);
                        ddrawSurfaceBlt.Rehook();
                        if (SUCCEEDED(hr))
                        {
                            DWORD nextCapture = (curCapture == NUM_BUFFERS - 1) ? 0 : (curCapture + 1);
                            curCPUTexture = curCapture;
                            curCapture = nextCapture;

                            SetEvent(hCopyEvent);
                        }
                        else
                        {
                            printDDrawError(hr, "CaptureDDraw");
                        }
                        //logOutput << CurrentTimeString() << "CaptureDDraw: finished capturing" << endl;
                    }
                }
            }
        }
    }
}
Exemplo n.º 28
0
void mswin_display_RIP_window (HWND hWnd)
{
    MSG msg;
    RECT rt;
    PNHRIPWindow data;
    HWND mapWnd;
    RECT riprt;
    RECT clientrect;
    RECT textrect;
    HDC hdc;
    HFONT OldFont;

    data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA);

    GetNHApp()->hPopupWnd = hWnd;
    mapWnd = mswin_hwnd_from_winid(WIN_MAP);
    if( !IsWindow(mapWnd) ) mapWnd = GetNHApp()->hMainWnd;
    GetWindowRect(mapWnd, &rt);
    GetWindowRect(hWnd, &riprt);
    GetClientRect (hWnd, &clientrect);
    textrect = clientrect;
    textrect.top += RIP_OFFSET_Y;
    textrect.left += RIP_OFFSET_X;
    textrect.right -= RIP_OFFSET_X;
    if (data->window_text)
    {
        hdc = GetDC (hWnd);
        OldFont = SelectObject (hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
        DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
                  DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
        SelectObject (hdc, OldFont);
        ReleaseDC(hWnd, hdc);
    }
    if (textrect.right - textrect.left > RIP_WIDTH)
        clientrect.right = textrect.right + RIP_OFFSET_X - clientrect.right;
    else
        clientrect.right = textrect.left + 2 * RIP_OFFSET_X + RIP_WIDTH - clientrect.right;
    clientrect.bottom = textrect.bottom + RIP_HEIGHT + RIP_OFFSET_Y - clientrect.bottom;
    GetWindowRect (GetDlgItem(hWnd, IDOK), &textrect);
    textrect.right -= textrect.left;
    textrect.bottom -= textrect.top;
    clientrect.bottom += textrect.bottom + RIP_OFFSET_Y;
    riprt.right -= riprt.left;
    riprt.bottom -= riprt.top;
    riprt.right += clientrect.right;
    riprt.bottom += clientrect.bottom;
    rt.left += (rt.right - rt.left - riprt.right) / 2;
    rt.top += (rt.bottom - rt.top - riprt.bottom) / 2;

    MoveWindow(hWnd, rt.left, rt.top, riprt.right, riprt.bottom, TRUE);
    GetClientRect (hWnd, &clientrect);
    MoveWindow (GetDlgItem(hWnd, IDOK),
                (clientrect.right - clientrect.left - textrect.right) / 2,
                clientrect.bottom - textrect.bottom - RIP_OFFSET_Y, textrect.right, textrect.bottom, TRUE);
    ShowWindow(hWnd, SW_SHOW);

    while( IsWindow(hWnd) &&
            GetMessage(&msg, NULL, 0, 0)!=0 ) {
        if( !IsDialogMessage(hWnd, &msg) ) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    GetNHApp()->hPopupWnd = NULL;
}
Exemplo n.º 29
0
/****************************************************************************
 *                                                                          *
 *  FUNCTION   : DdeCallback()                                              *
 *                                                                          *
 *  PURPOSE    : This handles all callbacks from the DDEML.  This handles   *
 *               updating of the associated conversation and any special    *
 *               testing cases such as blocking callbacks etc.              *
 *                                                                          *
 *               For the most part, clients only handle advise data and     *
 *               asynchronous transaction completion here.                  *
 *                                                                          *
 *  RETURNS    : Results vary depending on transaction type.                *
 *                                                                          *
 ****************************************************************************/
HDDEDATA EXPENTRY DdeCallback(
WORD wType,
WORD wFmt,
HCONV hConv,
HSZ hsz1,
HSZ hsz2,
HDDEDATA hData,
DWORD lData1,
DWORD lData2)
{
    HWND hwnd;
    CONVINFO ci;
    XACT *pxact;

    if (hConv) {
        /*
         * update conversation status if it changed.
         */
        MYCONVINFO *pmci;
        
        ci.cb = sizeof(CONVINFO);
	if (!DdeQueryConvInfo(hConv,(DWORD) QID_SYNC, &ci) || (!IsWindow((HWND)ci.hUser))) {
            /*
             * This conversation does not yet have a corresponding MDI window
             * or is disconnected.
             */
            return 0;
        }
        if (pmci = (MYCONVINFO *)GetWindowWord((HWND)ci.hUser, 0)) {
            if (pmci->ci.wStatus != ci.wStatus ||
                    pmci->ci.wConvst != ci.wConvst ||
                    pmci->ci.wLastError != ci.wLastError) {
                /*
                 * Things have changed, updated the conversation window.
                 */
                InvalidateRect((HWND)ci.hUser, NULL, TRUE);
            }
            if (ci.wConvst & ST_INLIST) {
                /*
                 * update the associated list window (if any) as well.
                 */
                if (hwnd = FindListWindow(ci.hConvList))
                    InvalidateRect(hwnd, NULL, TRUE);
            }
        }
    }

    /*
     * handle special block on next callback option here.  This demonstrates
     * the CBR_BLOCK feature.
     */
    if (fBlockNextCB && !(wType & XTYPF_NOBLOCK)) {
        fBlockNextCB = FALSE;
        return(CBR_BLOCK);
    }

    /*
     * handle special termination here.  This demonstrates that at any time
     * a client can drop a conversation.
     */
    if (fTermNextCB && hConv && wType != XTYP_DISCONNECT) {
        fTermNextCB = FALSE;
        MyDisconnect(hConv);
        return(0);
    }

    /*
     * Now we begin sort out what to do.
     */
    switch (wType) {
    case XTYP_REGISTER:
    case XTYP_UNREGISTER:
        /*
         * This is where the client would insert code to keep track of
         * what servers are available.  This could cause the initiation
         * of some conversations.
         */
        break;

    case XTYP_DISCONNECT:
        if (fAutoReconnect) {
            /*
             * attempt a reconnection
             */
            if (hConv = DdeReconnect(hConv)) {
                AddConv(ci.hszServiceReq, ci.hszTopic, hConv, FALSE);
                return 0;
            }
        }
        
        /*
         * update conv window to show its new state.
         */
        SendMessage((HWND)ci.hUser, UM_DISCONNECTED, 0, 0);
        return 0;
        break;

    case XTYP_ADVDATA:
        /*
         * data from an active advise loop (from a server)
         */
        Delay(wDelay);
        hwnd = FindAdviseChild((HWND)ci.hUser, hsz2, wFmt);
        if (!IsWindow(hwnd)) {
            PSTR pszItem, pszFmt;
            /*
             * AdviseStart window is gone, make a new one.
             */
            pxact = (XACT *)MyAlloc(sizeof(XACT));
            pxact->wType = wType;
            pxact->hConv = hConv;
            pxact->wFmt = wFmt;
            pxact->hszItem = hsz2;
            DdeKeepStringHandle(idInst, hsz2);
            
            pszItem = GetHSZName(hsz2);
            pszFmt = GetFormatName(wFmt);
            
            hwnd = CreateInfoCtrl(NULL, 
                    (int)SendMessage((HWND)ci.hUser, UM_GETNEXTCHILDX, 0, 0L),
                    (int)SendMessage((HWND)ci.hUser, UM_GETNEXTCHILDY, 0, 0L),
                    200, 100,
                    (HWND)ci.hUser, hInst,
                    Type2String(wType, 0), (LPSTR)pszItem, NULL,
                    NULL, (LPSTR)pszFmt, NULL,
                    ICSTY_SHOWFOCUS, 0, (DWORD)(LPSTR)pxact);
                    
            MyFree(pszFmt);
            MyFree(pszItem);

            if (!IsWindow(hwnd))
                return(DDE_FNOTPROCESSED); 
        }
        if (!hData) {
            /*
             * XTYPF_NODATA case - request the info. (we do this synchronously
             * for simplicity)
             */
            hData = DdeClientTransaction(NULL, 0L, hConv, hsz2, wFmt,
                    XTYP_REQUEST, DefTimeout, NULL);
        }
        if (hData) {
            PSTR pData;
            /*
             * Show incomming data on corresponding transaction window.
             */
            pData = GetTextData(hData);
            SendMessage(hwnd, ICM_SETSTRING, ICSID_CENTER, (DWORD)(LPSTR)pData);
            MyFree(pData);
            DdeFreeDataHandle(hData);
        }
        SendMessage(hwnd, ICM_SETSTRING, ICSID_LL, (DWORD)(LPSTR)"Advised");
        return(DDE_FACK);
        break;
        
    case XTYP_XACT_COMPLETE:
        /*
         * An asynchronous transaction has completed.  Show the results.
         *
         * ...unless the XOPT_BLOCKRESULT is chosen.
         */
        
        ci.cb = sizeof(CONVINFO);
        if (DdeQueryConvInfo(hConv, lData1, &ci) &&
                IsWindow((HWND)ci.hUser) && 
                (pxact = (XACT *)GetWindowWord((HWND)ci.hUser, GWW_WUSER))) {
                
            if (pxact->fsOptions & XOPT_BLOCKRESULT) {
                pxact->fsOptions &= ~XOPT_BLOCKRESULT;
                return(CBR_BLOCK);
            }
            
            pxact->Result = lData2;
            pxact->ret = hData;
            CompleteTransaction((HWND)ci.hUser, pxact);
        }
        break;
    }
}
Exemplo n.º 30
0
/*************************************
*  
*  Engine for the CloseAllTVWindows()
*  function.   
*
*  Receives the each library's info.
*
*  Attempts to close window,
*  close library, and free associated
*  menu items for window.
*
**************************************/
BOOL __far __pascal CloseAllLibsWindows( FPTVLIBINFO fpTVLibInfo, LPARAM lParam )
{
  BOOL __far * bAllWndClosed;
  FPTVWNDINFO fpWndInfo;
  HTVWNDINFO hWndInfo;

  HWND hChildWnd;  
  HWND hChildsPopupWnd;  
  
  TVLIBCLOSEWINDOWPROC fpfnTVLibCloseWnd;


  /* Get LPARAM data. */
  bAllWndClosed = (BOOL __far *) lParam;
  
  /* Get library's handle to first window info. */
  hWndInfo = GetLibWndInfo( fpTVLibInfo );
  
  while( hWndInfo != 0 )
  {
    /* Lock it. */
    fpWndInfo = (FPTVWNDINFO) GlobalLock( hWndInfo ) ;
  
    /* Get the handle of the window we are closing. */
    hChildWnd = fpWndInfo->hWnd;

    /* Unlock it. */
    GlobalUnlock( hWndInfo ) ;

    /* 
    ** If we are already in the window's
    ** Wndproc() and awaiting it return,
    ** activate the last popup window.
    */
    if( GetTVEntryCount( hChildWnd ) != 0 )
    {
      /* Change focus to window. */
      MessageBeep( MB_ICONEXCLAMATION );
      hChildsPopupWnd = GetLastActivePopup( hChildWnd );
      SetActiveWindow( hChildsPopupWnd ); 

      /* Not all windows closed. */
      *bAllWndClosed = FALSE; 

      /* Stop enumerating. */
      return FALSE;
    }

    /* 
    **  Tell window to close by sending calling
    **  the TVLibWindowClose() function.
    */   
    /* Retrieve the address of the control's LibInfo() function. */
    (FARPROC) fpfnTVLibCloseWnd = GetProcAddress( fpTVLibInfo->hInstance, MAKEINTRESOURCE(TVLIB_CLOSEWINDOW_ORD) );
                                              
    /* Verify the GetProcAddress() function returned data. */
    if ( fpfnTVLibCloseWnd == NULL)
    {
      /* Not all windows closed. */
      *bAllWndClosed = FALSE; 

      /* Error message. */
      MessageBox(  NULL, (LPSTR)"GetProcAddress() failed!", (LPSTR)"Library Functions", MB_ICONHAND | MB_OK );

      /* Stop enumerating. */
      return FALSE;
    }
  
    /* 
    **  Restore the window's WndProc() to its original
    **  WndProc() so we aren't trapping for the
    **  WM_NCDESTROY message and won't therefore call
    **  PostCloseLibrary().
    */
//    RemoveChildWindowFilter( hChildWnd );

    /* Tell the library to close the window. */
    (*fpfnTVLibCloseWnd)(hChildWnd);

    /* 
    **  Window is still around. 
    */
    if( IsWindow( hChildWnd ) )
    {
      /* 
      **  Set the window's WndProc() to our special
      **  WndProc() so we can keep trapping for the
      **  WM_NCDESTROY message to call
      **  PostCloseLibrary().
      */
//      SetChildWindowFilter( hChildWnd );

      /* Not all windows closed. */
      *bAllWndClosed = FALSE; 
      
      /* Stop enumerating. */
      return FALSE;
    }
  
    /* 
    **  Window is not still around. 
    */

    /* Remove menu alias' associated with the window. */  
    DeleteMenuInfoForWnd( hChildWnd );
    
    /* Find and delete the window info. */
    DeleteWndInfo( &(fpTVLibInfo)->hTVWndInfo, hChildWnd );
  
    /* Close the library. */
    CloseLibrary( fpTVLibInfo );

    /* Get library's handle to first window info. */
    hWndInfo = GetLibWndInfo( fpTVLibInfo );
  }

  /* Keep enumerating - next library. */
  return TRUE;
}