Example #1
0
BOOL
FASTCALL
GetCharOutline(
    IN     LONG            Unknown,
           PVOID,
    IN     PVOID           pThis,
    IN     ULONG           Height,
    IN     WCHAR           uChar,
    OUT    PULONG          pBitsPerRow,
    IN OUT PULONG          pDescent,
    IN OUT ALICE_MEMORY   *pMem
)
{
    HDC   hDC;
    HFONT hFont;
    ULONG FontIndex, OutlineSize, BytesPerRow, BitsOfLeftSpace;
    GLYPHMETRICS GlyphMetrics;
    BYTE  Buffer[0x5000];
    PBYTE pbOutline, pbBuffer;
    FONT_OUTLINE_INFO *pOutlineInfo;

    static FONT_OUTLINE_INFO *s_pOutlineInfo;
    static MAT2  mat = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 1 } };

    pOutlineInfo = s_pOutlineInfo;
    if (s_pOutlineInfo == NULL)
    {
        HANDLE hHeap = CMem::GetGlobalHeap();
        if (hHeap == NULL)
        {
            hHeap = CMem::CreateGlobalHeap();
            if (hHeap == NULL)
                goto DEFAULT_PROC;
        }

        pOutlineInfo = (FONT_OUTLINE_INFO *)HeapAlloc(hHeap, 0, sizeof(*pOutlineInfo));
        if (pOutlineInfo == NULL)
            goto DEFAULT_PROC;

        s_pOutlineInfo = pOutlineInfo;

        pOutlineInfo->hDC = NULL;
        pOutlineInfo->LastFontIndex = -1;
        ZeroMemory(pOutlineInfo->hFont, sizeof(pOutlineInfo->hFont));
        FillMemory(pOutlineInfo->Descent, sizeof(pOutlineInfo->Descent), -1);
    }

    if (Unknown < 0 || IsCharSpec(uChar))
        goto DEFAULT_PROC;

    FontIndex = Height / FONT_STEP;
    if (FontIndex > countof(pOutlineInfo->hFont))
        goto DEFAULT_PROC;

    hDC = pOutlineInfo->hDC;
    if (hDC == NULL)
    {
        hDC = CreateCompatibleDC(NULL);
        if (hDC == NULL)
            goto DEFAULT_PROC;

        pOutlineInfo->hDC = hDC;
    }

    hFont = pOutlineInfo->hFont[FontIndex];
    if (hFont == NULL)
    {
        LOGFONTW lf;

        ZeroMemory(&lf, sizeof(lf));
        lf.lfHeight = Height;
        lf.lfWeight = FW_NORMAL;
        lf.lfCharSet = GB2312_CHARSET;
        lf.lfQuality = CLEARTYPE_QUALITY;
        lf.lfPitchAndFamily = FIXED_PITCH;
        CopyStruct(lf.lfFaceName, g_szFaceName, sizeof(g_szFaceName));

        hFont = CreateFontIndirectW(&lf);
        if (hFont == NULL)
            goto DEFAULT_PROC;

        pOutlineInfo->hFont[FontIndex] = hFont;
    }

    if (FontIndex != pOutlineInfo->LastFontIndex)
    {
        if (SelectObject(hDC, hFont) == HGDI_ERROR)
            goto DEFAULT_PROC;

        pOutlineInfo->LastFontIndex = FontIndex;
    }

    if (pDescent != NULL)
    {
        TEXTMETRICW tm;

        tm.tmDescent = pOutlineInfo->Descent[FontIndex];
        if (tm.tmDescent == -1)
        {
            if (GetTextMetricsW(hDC, &tm))
                pOutlineInfo->Descent[FontIndex] = tm.tmDescent;
            else
                ++tm.tmDescent;
        }

        *pDescent = tm.tmDescent;
        if (pBitsPerRow == NULL)
            return TRUE;
    }

    uChar = MBCharToUnicode(uChar);
    OutlineSize = GetGlyphOutlineW(
                    hDC,
                    uChar,
                    GGO_BITMAP,
                    &GlyphMetrics,
                    sizeof(Buffer),
                    pThis == NULL ? NULL : Buffer,
                    &mat);
    if (OutlineSize == GDI_ERROR)
        goto DEFAULT_PROC;

#if 0
    ULONG DwordOfLeftSpace, BytesPerRowRaw, Mask;
    static BYTE Bits[FONT_COUNT] = 
    {
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x16,
        0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
        0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
        0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
        0x29, 0x2A, 0x2B, 0x2C
    };

    BitsOfLeftSpace = Bits[FontIndex];
    BitsOfLeftSpace = 4;
    DwordOfLeftSpace = BitsOfLeftSpace / 8 / 4;
    if (pBitsPerRow != NULL)
        *pBitsPerRow = GlyphMetrics.gmBlackBoxX + BitsOfLeftSpace % bitsof(DWORD) + DwordOfLeftSpace * 4 * 8;

    if (pDescent != NULL)
    {
        TEXTMETRICW tm;

        tm.tmDescent = s_Descent[FontIndex];
        if (tm.tmDescent == -1)
        {
            if (GetTextMetricsW(hDC, &tm))
                s_Descent[FontIndex] = tm.tmDescent;
            else
                ++tm.tmDescent;
        }

        *pDescent = tm.tmDescent;
    }

    if (pThis == NULL)
        return TRUE;

    BytesPerRow = GlyphMetrics.gmBlackBoxX + BitsOfLeftSpace;
    BytesPerRow = ROUND_UP(BytesPerRow, bitsof(DWORD)) / 8;
    BitsOfLeftSpace %= bitsof(DWORD);

    ChipSpriteEngAllocMemory(pMem, BytesPerRow * Height);
    if (pMem->pvBufferEnd == pMem->pvBuffer)
        goto DEFAULT_PROC;

    ZeroMemory(pMem->pvBuffer, BytesPerRow * Height);

    BytesPerRowRaw = ROUND_UP(GlyphMetrics.gmBlackBoxX, bitsof(DWORD)) / 8;

    pbBuffer   = Buffer;
    pbOutline  = (PBYTE)pMem->pvBuffer;
    pbOutline += (GlyphMetrics.gmBlackBoxY - 1) * BytesPerRow;
    pbOutline += ((Height - GlyphMetrics.gmBlackBoxY) / 2 - 1) * BytesPerRow;
    pbOutline += DwordOfLeftSpace * 4;
    Mask = _rotl(1, BitsOfLeftSpace) - 1;

    for (ULONG i = GlyphMetrics.gmBlackBoxY; i; --i)
    {
        PBYTE pbOutline2, pbBuffer2;
        DWORD BitsHigh, BitsLow;

        BitsHigh = 0;
        BitsLow = 0;
        pbBuffer2 = pbBuffer;
        pbOutline2 = pbOutline;
        for (ULONG Count = BytesPerRowRaw / 4; Count; --Count)
        {
            DWORD v = *(PDWORD)pbBuffer2;

            BitsHigh = _rotl(v, BitsOfLeftSpace) & Mask;
            v = (v << BitsOfLeftSpace) | BitsLow;
            BitsLow = BitsHigh;
            *(PDWORD)pbOutline2 = v;
            pbOutline2 += 4;
            pbBuffer2  += 4;
        }
//        *(PDWORD)pbOutline2 = BitsLow;

        pbOutline -= BytesPerRow;
        pbBuffer  += BytesPerRowRaw;
    }

    WCHAR buf[0x500];
    wsprintfW(
        buf - 1 + GetTextFaceW(hDC, countof(buf),
        buf),
        L" Char = %c Index = %02u Bits = %02X",
        uChar,
        FontIndex + 1,
        BitsOfLeftSpace);
    SetWindowTextW(GetActiveWindow(), buf);

#else
    ULONG BytesPerRowRaw;
    static BYTE Bits[FONT_COUNT] = 
    {
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x16,
        0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
        0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
        0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
        0x29, 0x2A, 0x2B, 0x2C
    };

    BitsOfLeftSpace = Bits[FontIndex];

    if (pBitsPerRow != NULL)
        *pBitsPerRow = GlyphMetrics.gmBlackBoxX + BitsOfLeftSpace;


    if (pThis == NULL)
        return TRUE;

    BytesPerRow = GlyphMetrics.gmBlackBoxX + BitsOfLeftSpace;
    BytesPerRow = ROUND_UP(BytesPerRow, bitsof(DWORD)) / 8;

    ChipSpriteEngAllocMemory(pMem, BytesPerRow * Height);
    if (pMem->pvBufferEnd == pMem->pvBuffer)
        goto DEFAULT_PROC;

    ZeroMemory(pMem->pvBuffer, BytesPerRow * Height);

    BytesPerRowRaw = ROUND_UP(GlyphMetrics.gmBlackBoxX, bitsof(DWORD)) / 8;

    pbBuffer   = Buffer;
    pbOutline  = (PBYTE)pMem->pvBuffer;
    pbOutline += (GlyphMetrics.gmBlackBoxY - 1) * BytesPerRow;
    pbOutline += ((Height - GlyphMetrics.gmBlackBoxY) / 2 - 1) * BytesPerRow;

    for (ULONG i = GlyphMetrics.gmBlackBoxY; i; --i)
    {
        __movsd(pbOutline, pbBuffer, BytesPerRowRaw / 4);
        pbOutline -= BytesPerRow;
        pbBuffer  += BytesPerRowRaw;
    }
#endif

    return TRUE;

DEFAULT_PROC:
    if (pThis == NULL)
        return FALSE;

    return OldGetCharOutline(Unknown, 0, pThis, Height, uChar, pBitsPerRow, pDescent, pMem);
}
Example #2
0
void SetEditText(HWND hWnd,DWORD type)
{
	DWORD  temp,t1,t2,i;
	char *info;
	wchar_t *winfo;
	if(type == CPUDUMP)
	{
//		__try
		{
			temp = Plugingetvalue(VAL_CPUDDUMP);
			t1=*(DWORD*)(temp+0x385);
			t2=*(DWORD*)(temp+0x389);
			temp=t2-t1;
			info = (char *)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, temp + 2);
			winfo = (wchar_t *)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, (temp + 2) * sizeof(wchar_t));
			Readmemory(info,(DWORD)t1,temp,MM_SILENT);
			for(i=0;i<temp;i++)
			{
				if(info[i]==0)
				{
					if(info[i+1]==0)
					{
					info[i]=0x0d;
					info[++i]=0x0a;
					}
					else
						info[i]=' ';
				}
			}
			MultiByteToWideChar(pagecode,0,info,-1,winfo,temp+2);
			SetWindowTextW(hWnd,winfo);
			HeapFree(hHeap, 0, info);
			HeapFree(hHeap, 0, winfo);
		}
//		__except(EXCEPTION_EXECUTE_HANDLER)
//		{
//			return;
//		}
	}
	else
	{
		temp = Plugingetvalue(VAL_CPUDSTACK	);
		t1 = *(DWORD*)(temp+0x385);
		char tempchar;
//		__try
		{
			Readmemory(&t2,t1,4,MM_SILENT);
/*			char s[128] = {0};
			sprintf(s,"0x%08x 0x%08x",t2,info);
			MessageBox(hWnd,s,s,0);*/
			t1 = t2;
			temp=0;
			do
			{
				Readmemory(&tempchar,t2++,1,MM_SILENT);
				++temp;
			}while( tempchar != 0 );
			if(temp==1)
				return;
			info = (char *)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, temp);
			Readmemory(info,t1,temp,MM_SILENT);
			winfo = (wchar_t *)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, temp * sizeof(wchar_t));
			MultiByteToWideChar(pagecode,0,info,-1,winfo,temp);
			SetWindowTextW(hWnd,winfo);
			HeapFree(hHeap, 0, info);
			HeapFree(hHeap, 0, winfo);
		}
//		__except(EXCEPTION_EXECUTE_HANDLER)
//		{
//			return;
//		}
	}
}
Example #3
0
void DoOpenFile(LPCWSTR szFileName, ENCODING enc)
{
    static const WCHAR dotlog[] = { '.','L','O','G',0 };
    HANDLE hFile;
    LPSTR pTemp;
    DWORD size;
    DWORD dwNumRead;
    int lenW;
    WCHAR* textW;
    int i;
    WCHAR log[5];

    /* Close any files and prompt to save changes */
    if (!DoCloseFile())
	return;

    hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if(hFile == INVALID_HANDLE_VALUE)
    {
	AlertFileNotFound(szFileName);
	return;
    }

    size = GetFileSize(hFile, NULL);
    if (size == INVALID_FILE_SIZE)
    {
	CloseHandle(hFile);
	ShowLastError();
	return;
    }

    /* Extra memory for (WCHAR)'\0'-termination. */
    pTemp = HeapAlloc(GetProcessHeap(), 0, size+2);
    if (!pTemp)
    {
	CloseHandle(hFile);
	ShowLastError();
	return;
    }

    if (!ReadFile(hFile, pTemp, size, &dwNumRead, NULL))
    {
	CloseHandle(hFile);
	HeapFree(GetProcessHeap(), 0, pTemp);
	ShowLastError();
	return;
    }

    CloseHandle(hFile);

    size = dwNumRead;

    if (enc == ENCODING_AUTO)
        enc = detect_encoding_of_buffer(pTemp, size);
    else if (size >= 2 && (enc==ENCODING_UTF16LE || enc==ENCODING_UTF16BE))
    {
        /* If UTF-16 (BE or LE) is selected, and there is a UTF-16 BOM,
         * override the selection (like native Notepad).
         */
        if ((BYTE)pTemp[0] == 0xff && (BYTE)pTemp[1] == 0xfe)
            enc = ENCODING_UTF16LE;
        else if ((BYTE)pTemp[0] == 0xfe && (BYTE)pTemp[1] == 0xff)
            enc = ENCODING_UTF16BE;
    }

    switch (enc)
    {
    case ENCODING_UTF16BE:
        byteswap_wide_string((WCHAR*) pTemp, size/sizeof(WCHAR));
        /* Forget whether the file is BE or LE, like native Notepad. */
        enc = ENCODING_UTF16LE;

        /* fall through */

    case ENCODING_UTF16LE:
        textW = (LPWSTR)pTemp;
        lenW  = size/sizeof(WCHAR);
        break;

    default:
        {
            int cp = (enc==ENCODING_UTF8) ? CP_UTF8 : CP_ACP;
            lenW = MultiByteToWideChar(cp, 0, pTemp, size, NULL, 0);
            textW = HeapAlloc(GetProcessHeap(), 0, (lenW+1) * sizeof(WCHAR));
            if (!textW)
            {
                ShowLastError();
                HeapFree(GetProcessHeap(), 0, pTemp);
                return;
            }
            MultiByteToWideChar(cp, 0, pTemp, size, textW, lenW);
            HeapFree(GetProcessHeap(), 0, pTemp);
            break;
        }
    }

    /* Replace '\0's with spaces. Other than creating a custom control that
     * can deal with '\0' characters, it's the best that can be done.
     */
    for (i = 0; i < lenW; i++)
        if (textW[i] == '\0')
            textW[i] = ' ';
    textW[lenW] = '\0';

    if (lenW >= 1 && textW[0] == 0xfeff)
        SetWindowTextW(Globals.hEdit, textW+1);
    else
        SetWindowTextW(Globals.hEdit, textW);

    HeapFree(GetProcessHeap(), 0, textW);

    SendMessageW(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
    SendMessageW(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
    SetFocus(Globals.hEdit);
    
    /*  If the file starts with .LOG, add a time/date at the end and set cursor after */
    if (GetWindowTextW(Globals.hEdit, log, ARRAY_SIZE(log)) && !lstrcmpW(log, dotlog))
    {
	static const WCHAR lfW[] = { '\r','\n',0 };
        SendMessageW(Globals.hEdit, EM_SETSEL, GetWindowTextLengthW(Globals.hEdit), -1);
        SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW);
	DIALOG_EditTimeDate();
        SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW);
    }

    SetFileNameAndEncoding(szFileName, enc);
    UpdateWindowCaption();
}
Example #4
0
LRESULT CWebWindow::_windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
    case WM_CREATE:
        {
            DragAcceptFiles(hwnd, TRUE);
            //SetTimer(hwnd, 100, 20, NULL);
        }
        return 0;

    case WM_CLOSE:
        if (m_windowClosingCallback)
        {
            if (!m_windowClosingCallback(this, m_windowClosingCallbackParam))
                return 0;
        }

        ShowWindow(hwnd, SW_HIDE);
        DestroyWindow(hwnd);
        return 0;

    case WM_DESTROY:
        {
            //KillTimer(hwnd, 100);
            RemovePropW(hwnd, L"wkeWebWindow");
            m_hwnd = NULL;

            if (m_windowDestroyCallback)
                m_windowDestroyCallback(this, m_windowDestroyCallbackParam);

            wkeDestroyWebView(this);
        }
        return 0;

    //case WM_TIMER:
    //    {
    //        wkeRepaintIfNeeded(this);
    //    }
    //    return 0;

    case WM_PAINT:
        {
            PAINTSTRUCT ps = { 0 };
            HDC hdc = BeginPaint(hwnd, &ps);
            _paintDC(hdc, (HDC)wkeGetViewDC(this));
            EndPaint(hwnd, &ps);
        }
        return 0;

    case WM_ERASEBKGND:
        return TRUE;

    case WM_SIZE:
        {
            RECT rc = { 0 };
            GetClientRect(hwnd, &rc);
            int width = rc.right - rc.left;
            int height = rc.bottom - rc.top;

            CWebView::resize(width, height);
            wkeRepaintIfNeeded(this);
        }
        return 0;

    case WM_DROPFILES:
        {
            wchar_t szFile[MAX_PATH + 8] = {0};
            wcscpy(szFile, L"file:///");

            HDROP hDrop = reinterpret_cast<HDROP>(wParam);

            UINT uFilesCount = DragQueryFileW(hDrop, 0xFFFFFFFF, szFile, MAX_PATH);
            if (uFilesCount != 0)
            {
                UINT uRet = DragQueryFileW(hDrop, 0, (wchar_t*)szFile + 8, MAX_PATH);
                if ( uRet != 0)
                {
                    wkeLoadURLW(this, szFile);
                    SetWindowTextW(hwnd, szFile);
                }
            }
            DragFinish(hDrop);
        }
        return 0;


    //case WM_NCHITTEST:
    //    if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION))
    //    {
    //        IWebkitObserverPtr observer = m_observer.lock();
    //        if (!observer)
    //            break;

    //        QPoint cursor(LOWORD(lParam), HIWORD(lParam));
    //        ScreenToClient(m_hwnd, &cursor);

    //        QRect clientRect;
    //        QSize clientSize;
    //        GetClientRect(hwnd, &clientRect);
    //        clientSize.cx = clientRect.width();
    //        clientSize.cy = clientRect.height();

    //        EWebkitHitTest hit = observer->onHitTest(QWebkitView(thisView), clientSize, cursor);
    //        switch (hit)
    //        {
    //        case eWebkitHitLeftTop:     return HTTOPLEFT;
    //        case eWebkitHitLeft:        return HTLEFT;
    //        case eWebkitHitLeftBottom:  return HTBOTTOMLEFT;
    //        case eWebkitHitRightTop:    return HTTOPRIGHT;
    //        case eWebkitHitRight:       return HTRIGHT;
    //        case eWebkitHitRightBottom: return HTBOTTOMRIGHT;
    //        case eWebkitHitTop:         return HTTOP;
    //        case eWebkitHitBottom:      return HTBOTTOM;
    //        case eWebkitHitCaption:     return HTCAPTION;
    //        case eWebkitHitClient:      return HTCLIENT;
    //        case eWebkitHitNone:        return HTCLIENT;
    //        }
    //    }
    //    break;

    //case WM_SETCURSOR:
    //    if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION))
    //    {
    //        WORD hit = LOWORD(lParam);
    //        switch (hit)
    //        {
    //        case HTCAPTION:
    //        case HTSYSMENU:
    //        case HTMENU:
    //        case HTCLIENT:
    //            SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
    //            return TRUE;

    //        case HTTOP:
    //        case HTBOTTOM:
    //            SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS)));
    //            return TRUE;

    //        case HTLEFT:
    //        case HTRIGHT:
    //            SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE)));
    //            return TRUE;

    //        case HTTOPLEFT:
    //        case HTBOTTOMRIGHT:
    //            SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENWSE)));
    //            return TRUE;

    //        case HTTOPRIGHT:
    //        case HTBOTTOMLEFT:
    //            SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENESW)));
    //            return TRUE;

    //        default:
    //            SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
    //            return TRUE;
    //        }
    //    }
    //    break;

    //case WM_NCLBUTTONDOWN:
    //    if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION))
    //    {
    //        int hit = wParam;
    //        switch (hit)
    //        {
    //        case HTTOP:         SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_TOP, lParam); return 0;
    //        case HTBOTTOM:      SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOM, lParam); return 0;
    //        case HTLEFT:        SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_LEFT, lParam); return 0;
    //        case HTRIGHT:       SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_RIGHT, lParam); return 0;
    //        case HTTOPLEFT:     SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_TOPLEFT, lParam); return 0;
    //        case HTTOPRIGHT:    SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_TOPRIGHT, lParam); return 0;
    //        case HTBOTTOMLEFT:  SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOMLEFT, lParam); return 0;
    //        case HTBOTTOMRIGHT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOMRIGHT, lParam); return 0;
    //        case HTCAPTION:     SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_MOVE|4, lParam); return 0;
    //        }
    //    }
    //    break;

    //case WM_NCLBUTTONDBLCLK:
    //    if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION))
    //    {
    //        int hit = wParam;
    //        if (hit == HTCAPTION)
    //        {
    //            if (IsZoomed(m_hwnd))
    //                SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam);
    //            else
    //                SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, lParam);
    //            return 0;
    //        }
    //    }
    //    break;

    case WM_KEYDOWN:
        {
            unsigned int virtualKeyCode = wParam;
            unsigned int flags = 0;
            if (HIWORD(lParam) & KF_REPEAT)
                flags |= WKE_REPEAT;
            if (HIWORD(lParam) & KF_EXTENDED)
                flags |= WKE_EXTENDED;

            if (wkeFireKeyDownEvent(this, virtualKeyCode, flags, false))
                return 0;
        }
        break;

    case WM_KEYUP:
        {
            unsigned int virtualKeyCode = wParam;
            unsigned int flags = 0;
            if (HIWORD(lParam) & KF_REPEAT)
                flags |= WKE_REPEAT;
            if (HIWORD(lParam) & KF_EXTENDED)
                flags |= WKE_EXTENDED;

            if (wkeFireKeyUpEvent(this, virtualKeyCode, flags, false))
                return 0;
        }
        break;

    case WM_CHAR:
        {
            unsigned int charCode = wParam;
            unsigned int flags = 0;
            if (HIWORD(lParam) & KF_REPEAT)
                flags |= WKE_REPEAT;
            if (HIWORD(lParam) & KF_EXTENDED)
                flags |= WKE_EXTENDED;

            if (wkeFireKeyPressEvent(this, charCode, flags, false))
                return 0;
        }
        break;

    case WM_LBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_LBUTTONDBLCLK:
    case WM_MBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_LBUTTONUP:
    case WM_MBUTTONUP:
    case WM_RBUTTONUP:
    case WM_MOUSEMOVE:
        {
            if (message == WM_LBUTTONDOWN || message == WM_MBUTTONDOWN || message == WM_RBUTTONDOWN)
            {
                SetFocus(hwnd);
                SetCapture(hwnd);
            }
            else if (message == WM_LBUTTONUP || message == WM_MBUTTONUP || message == WM_RBUTTONUP)
            {
                ReleaseCapture();
            }

            int x = LOWORD(lParam);
            int y = HIWORD(lParam);

            unsigned int flags = 0;

            if (wParam & MK_CONTROL)
                flags |= WKE_CONTROL;
            if (wParam & MK_SHIFT)
                flags |= WKE_SHIFT;

            if (wParam & MK_LBUTTON)
                flags |= WKE_LBUTTON;
            if (wParam & MK_MBUTTON)
                flags |= WKE_MBUTTON;
            if (wParam & MK_RBUTTON)
                flags |= WKE_RBUTTON;

            if (wkeFireMouseEvent(this, message, x, y, flags))
                return 0;
        }
        break;

    case WM_CONTEXTMENU:
        {
            POINT pt;
            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);

            if (pt.x != -1 && pt.y != -1)
                ScreenToClient(hwnd, &pt);

            unsigned int flags = 0;

            if (wParam & MK_CONTROL)
                flags |= WKE_CONTROL;
            if (wParam & MK_SHIFT)
                flags |= WKE_SHIFT;

            if (wParam & MK_LBUTTON)
                flags |= WKE_LBUTTON;
            if (wParam & MK_MBUTTON)
                flags |= WKE_MBUTTON;
            if (wParam & MK_RBUTTON)
                flags |= WKE_RBUTTON;

            if (wkeFireContextMenuEvent(this, pt.x, pt.y, flags))
                return 0;
        }
        break;

    case WM_MOUSEWHEEL:
        {
            POINT pt;
            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            ScreenToClient(hwnd, &pt);

            int delta = GET_WHEEL_DELTA_WPARAM(wParam);

            unsigned int flags = 0;

            if (wParam & MK_CONTROL)
                flags |= WKE_CONTROL;
            if (wParam & MK_SHIFT)
                flags |= WKE_SHIFT;

            if (wParam & MK_LBUTTON)
                flags |= WKE_LBUTTON;
            if (wParam & MK_MBUTTON)
                flags |= WKE_MBUTTON;
            if (wParam & MK_RBUTTON)
                flags |= WKE_RBUTTON;

            if (wkeFireMouseWheelEvent(this, pt.x, pt.y, delta, flags))
                return 0;
        }
        break;

    case WM_SETFOCUS:
        wkeSetFocus(this);
        return 0;

    case WM_KILLFOCUS:
        wkeKillFocus(this);
        return 0;

    case WM_IME_STARTCOMPOSITION:
        {
            wkeRect caret = wkeGetCaretRect(this);

            CANDIDATEFORM form;
            form.dwIndex = 0;
            form.dwStyle = CFS_EXCLUDE;
            form.ptCurrentPos.x = caret.x;
            form.ptCurrentPos.y = caret.y + caret.h;
            form.rcArea.top = caret.y;
            form.rcArea.bottom = caret.y + caret.h;
            form.rcArea.left = caret.x;
            form.rcArea.right = caret.x + caret.w;

            COMPOSITIONFORM compForm;
            compForm.ptCurrentPos = form.ptCurrentPos;
            compForm.rcArea = form.rcArea;
            compForm.dwStyle = CFS_POINT;

            HIMC hIMC = ImmGetContext(hwnd);
            ImmSetCandidateWindow(hIMC, &form);
            ImmSetCompositionWindow(hIMC, &compForm);
            ImmReleaseContext(hwnd, hIMC);
        }
        return 0;
    }

    return DefWindowProcW(hwnd, message, wParam, lParam);
}
Example #5
0
INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwnd;
	char *str;
	int sel, i;

	switch(msg)
	{
		case WM_INITDIALOG:
		{	
			// Font necessary for all controls created with CreateWindowsEx
			//HFONT hfDefault = GetStockObject(DEFAULT_GUI_FONT);
			//HWND combo = GetDlgItem(hwndDlg,IDC_DEFAULT);
			int nb_contacts, default_contact_number, offline_contact_number;
			LVCOLUMN LvCol;

			TranslateDialogDefault( hwndDlg );

			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(I_EDIT));

			// Disable the 'Apply' button.
			EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),FALSE);

			// (from http://www.codeproject.com/listctrl/listview.asp)
			// initialize list
			hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
			SendMessage(hwnd,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT); // Set style

			// Create list columns
			ZeroMemory(&LvCol, sizeof(LvCol));
			LvCol.mask=LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;    // Type of mask

			// Inserting Couloms as much as we want
			LvCol.pszText=Translate("Contact");              // First Header Text
			LvCol.cx=100;                                   // width of column
			SendMessage(hwnd,LVM_INSERTCOLUMN,0,(LPARAM)&LvCol); // Insert/Show the coloum

			LvCol.pszText=Translate("Id");                            // Next coloum
			LvCol.cx=130;                                   // width of column
			SendMessage(hwnd,LVM_INSERTCOLUMN,1,(LPARAM)&LvCol); // ...
			LvCol.pszText=Translate("Protocol");                            //
			LvCol.cx=100;                                   // width of column
			SendMessage(hwnd,LVM_INSERTCOLUMN,2,(LPARAM)&LvCol); //
			LvCol.pszText=Translate("Default");                            //
			LvCol.cx=60;                                   // width of column
			SendMessage(hwnd,LVM_INSERTCOLUMN,3,(LPARAM)&LvCol); //
			LvCol.pszText=Translate("Send Offline");                            //
			LvCol.cx=85;                                   // width of column
			SendMessage(hwnd,LVM_INSERTCOLUMN,4,(LPARAM)&LvCol); //
	
			// disable buttons until a selection is made in the list
			hwnd = GetDlgItem(hwndDlg, IDC_BTN_REM);
			EnableWindow(hwnd, FALSE);
			hwnd = GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT);
			EnableWindow(hwnd, FALSE);
			hwnd = GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE);
			EnableWindow(hwnd, FALSE);
			hwnd = GetDlgItem(hwndDlg, IDC_BTN_UP);
			EnableWindow(hwnd, FALSE);
			hwnd = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
			EnableWindow(hwnd, FALSE);

			nb_contacts = DBGetContactSettingDword((HANDLE)lParam, META_PROTO, "NumContacts", 0);
			default_contact_number = DBGetContactSettingDword((HANDLE)lParam, META_PROTO, "Default", (DWORD)-1);
			offline_contact_number = DBGetContactSettingDword((HANDLE)lParam, META_PROTO, "OfflineSend", (DWORD)-1);

			changes.hMeta = (HANDLE)lParam;
			changes.num_contacts = nb_contacts;
			changes.num_deleted = 0;
			changes.hDefaultContact = Meta_GetContactHandle((HANDLE)lParam, default_contact_number);
			changes.hOfflineContact = Meta_GetContactHandle((HANDLE)lParam, offline_contact_number);
			for(i = 0; i < nb_contacts; i++)
				changes.hContact[i] = Meta_GetContactHandle((HANDLE)lParam, i);
			changes.force_default = MetaAPI_GetForceState((WPARAM)lParam, 0);

			SendMessage(hwndDlg, WMU_SETTITLE, 0, lParam);

			CheckDlgButton(hwndDlg, IDC_CHK_FORCEDEFAULT, changes.force_default);

			FillContactList(hwndDlg, &changes);
			return TRUE;
		}
		case WMU_SETTITLE:
			{

				char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)lParam, 0);
				if(os_unicode_enabled) {
					wchar_t *swzCDN = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)lParam, GCDNF_UNICODE),
						*swzContactDisplayName;

					// detect if the clist provided unicode display name by comparing with non-unicode
					if(szCDN && swzCDN && strncmp(szCDN, (char *)swzCDN, strlen(szCDN)) != 0 && wcslen(swzCDN) >= strlen(szCDN)) { 
						swzContactDisplayName = swzCDN;
					} else {
						// no? convert to unicode
						if(szCDN) {
							swzContactDisplayName = (wchar_t *) _malloca(sizeof(wchar_t) * (strlen(szCDN) + 1));
							MultiByteToWideChar(CP_ACP, 0, (char *) szCDN, -1, swzContactDisplayName, (int)strlen((char *)szCDN) + 1);
						} else {
							swzContactDisplayName = TranslateW(L"(Unknown Contact)");
						}
					}				

					SetWindowTextW(GetDlgItem(hwndDlg,IDC_ED_NAME), swzContactDisplayName);
				} else {
					SetWindowText(GetDlgItem(hwndDlg,IDC_ED_NAME), szCDN);
				}
			}
			return TRUE;
		case WM_NOTIFY: // the message that is being sent always
			switch(LOWORD(wParam)) // hit control
			{
				case IDC_LST_CONTACTS:      // did we hit our ListView contorl?
					if(((LPNMHDR)lParam)->code == NM_CLICK) {
						hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
						sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected
						// enable buttons
						hwnd = GetDlgItem(hwndDlg, IDC_BTN_REM);
						EnableWindow(hwnd, sel!=-1);
						hwnd = GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT);
						EnableWindow(hwnd, sel!=-1 && changes.hContact[sel] != changes.hDefaultContact);
						hwnd = GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE);
						EnableWindow(hwnd, sel!=-1 && changes.hContact[sel] != changes.hOfflineContact);
						hwnd = GetDlgItem(hwndDlg, IDC_BTN_UP);
						EnableWindow(hwnd, (sel > 0));
						hwnd = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
						EnableWindow(hwnd, (sel != -1) && (sel < changes.num_contacts - 1));
/*
					// custom draw stuff - change colour of listview things - doesn't affect selection :(
					} else if(((LPNMHDR)lParam)->code == NM_CUSTOMDRAW) {
						SetWindowLong(hwndDlg, DWL_MSGRESULT, (LONG)ProcessCustomDraw(lParam));
						return TRUE;					
*/
					}					
					break;
			}
			break;
		case WM_COMMAND:
			switch(HIWORD(wParam))
			{
				case BN_CLICKED:	// A button ('Remove', 'Ok', 'Cancel' or 'Apply', normally) has been clicked
					switch(LOWORD(wParam))
					{
						case IDC_VALIDATE:			// Apply changes, if there is still one contact attached to the metacontact.
							if(changes.num_contacts == 0)	// Otherwise, delete the metacontact.
							{
								if(MessageBox(hwndDlg,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"),
									Translate("Delete MetaContact?"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)!=IDYES)
									return TRUE;
								else
								{
									Meta_Delete((WPARAM)changes.hMeta,(LPARAM)NULL);
									DestroyWindow(hwndDlg);
									return TRUE;
								}
							}
							ApplyChanges(&changes);

							// Disable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),FALSE);
							break;
						case IDOK:
							if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_VALIDATE)))
							{							// If there are changes that could be made,
								if(changes.num_contacts == 0)	// do the work that would have be done if
								{						// the button 'Apply' has been clicked.
									if(MessageBox(hwndDlg,Translate("You are going to remove all the contacts associated with this MetaContact.\nThis will delete the MetaContact.\n\nProceed Anyway?"),
										Translate("Delete MetaContact?"),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)!=IDYES)
									{
										return TRUE;
									} else {
										Meta_Delete((WPARAM)changes.hMeta,(LPARAM)NULL);
										DestroyWindow(hwndDlg);
										return TRUE;
									}
								}
								ApplyChanges(&changes);
							}
							EndDialog(hwndDlg, IDOK);
							return TRUE;
						case IDCANCEL:	// Simply close the dialog
							EndDialog(hwndDlg, IDCANCEL);
							return TRUE;
						case IDC_BTN_SETDEFAULT:
							hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
							sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected
							InvalidateRect(hwnd, 0, TRUE);
							changes.hDefaultContact = changes.hContact[sel];
							SendMessage(hwndDlg, WMU_SETTITLE, 0, (LPARAM)changes.hContact[sel]);

							FillContactList(hwndDlg, &changes);
							SetListSelection(hwnd, sel);
							// Disable set default button
							EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_SETDEFAULT),FALSE);
							// Enable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE);

							// repaint list
							return TRUE;
						case IDC_BTN_SETOFFLINE:
							hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
							sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected
							InvalidateRect(hwnd, 0, TRUE);
							changes.hOfflineContact = changes.hContact[sel];

							FillContactList(hwndDlg, &changes);
							SetListSelection(hwnd, sel);
							// Disable set offline button
							EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_SETOFFLINE),FALSE);
							// Enable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE);

							// repaint list
							return TRUE;
						case IDC_BTN_REM:
							hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
							sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected
							changes.num_contacts--;
							changes.hDeletedContacts[changes.num_deleted++] = changes.hContact[sel];
							if(changes.hDefaultContact == changes.hContact[sel]) {
								if(changes.num_contacts > 0) {
									changes.hDefaultContact = changes.hContact[0];
									str = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)changes.hDefaultContact, 0);
									SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT),str);
								} else {
									changes.hDefaultContact = 0;
									SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT),"None");
								}

							}

							for(i = sel; i < changes.num_contacts; i++)
								changes.hContact[i] = changes.hContact[i + 1];
							FillContactList(hwndDlg, &changes);
							// disable buttons
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_REM);
							EnableWindow(hwnd, FALSE);
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT);
							EnableWindow(hwnd, FALSE);
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE);
							EnableWindow(hwnd, FALSE);
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_UP);
							EnableWindow(hwnd, FALSE);
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
							EnableWindow(hwnd, FALSE);
							// Enable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE);
							return TRUE;
						case IDC_BTN_UP:
							hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
							sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected

							{
								HANDLE temp = changes.hContact[sel];
								changes.hContact[sel] = changes.hContact[sel - 1];
								changes.hContact[sel - 1] = temp;
							}
							FillContactList(hwndDlg, &changes);
							sel--;
							SetListSelection(hwnd, sel);

							hwnd = GetDlgItem(hwndDlg, IDC_BTN_UP);
							EnableWindow(hwnd, (sel > 0));
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
							EnableWindow(hwnd, (sel < changes.num_contacts - 1));
							// Enable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE);
							return TRUE;
						case IDC_BTN_DOWN:
							hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
							sel=SendMessage(hwnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED); // return item selected

							{
								HANDLE temp = changes.hContact[sel];
								changes.hContact[sel] = changes.hContact[sel + 1];
								changes.hContact[sel + 1] = temp;
							}
							FillContactList(hwndDlg, &changes);
							sel++;
							SetListSelection(hwnd, sel);

							hwnd = GetDlgItem(hwndDlg, IDC_BTN_UP);
							EnableWindow(hwnd, (sel > 0));
							hwnd = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
							EnableWindow(hwnd, (sel < changes.num_contacts - 1));
							// Enable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE);
							return TRUE;
						case IDC_CHK_FORCEDEFAULT:
							changes.force_default = IsDlgButtonChecked(hwndDlg, IDC_CHK_FORCEDEFAULT);
							// Enable the 'Apply' button.
							EnableWindow(GetDlgItem(hwndDlg,IDC_VALIDATE),TRUE);
							return TRUE;
					}
			}
			break;
		case WM_CLOSE:
			DestroyWindow(hwndDlg);
			return TRUE;

		case WM_DESTROY:
			ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
			EndDialog(hwndDlg, IDCANCEL);
			break;
	}

	return FALSE;
}
Example #6
0
//--------------------------------------------------------------------------------------
// Render a frame
//--------------------------------------------------------------------------------------
void Render()
{
	// Update our time
	static float t = 0.0f;
	if (!paused)
	{
		if (g_driverType == D3D_DRIVER_TYPE_REFERENCE)
		{
			t += (float)XM_PI * 0.0125f;
		}
		else
		{
			static DWORD dwTimeStart = 0;
			DWORD dwTimeCur = GetTickCount();
			if (dwTimeStart == 0)
				dwTimeStart = dwTimeCur;
			if (restarted)
			{
				restarted = false;
				t = dwLastT;
				dwTimeStart = dwTimeCur - t * 1000.0f;
			}
			else
			{
				t = (dwTimeCur - dwTimeStart) / 1000.0f;
			}
		}
		dwLastT = t;
	}

	// 1st Cube: Rotate around the origin
	// JPE : Se verifica si debe rotar
	if (rotate)
	{
		//JPE: Para mesh del mono
		if (modelo == ModeloMono)
		{
			g_World1 = XMMatrixRotationX(-1.570796f) * XMMatrixRotationY(t);
		}
		else // Para cubo
		{
			g_World1 = XMMatrixRotationY(t);
		}
	}
	else
	{
		//JPE: Para mesh del mono
		if (modelo == ModeloMono)
		{
			g_World1 = XMMatrixRotationX(-1.570796f);
			g_World1 *= XMMatrixRotationY(2 * -1.570796f);
		}
		else // Para cubo
		{
			g_World1 = XMMatrixIdentity();
		}
	}
	XMVECTOR Det;
	g_Normal1 = XMMatrixTranspose(XMMatrixInverse(&Det, g_World1));

	// 2nd Cube:  Rotate around origin
	XMMATRIX mSpin = XMMatrixRotationZ(-t);
	XMMATRIX mOrbit = XMMatrixRotationY(-t * 2.0f);
	XMMATRIX mTranslate = XMMatrixTranslation(-4.0f, 0.0f, 0.0f);
	XMMATRIX mScale = XMMatrixScaling(0.3f, 0.3f, 0.3f);

	g_World2 = mScale * mSpin * mTranslate * mOrbit;

	//
	// Clear the back buffer
	//
	float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red, green, blue, alpha
	g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor);

	//
	// Clear the depth buffer to 1.0 (max depth)
	//
	g_pImmediateContext->ClearDepthStencilView(g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);


	// JPE:	
	// CARGA LOS CONSTANT BUFFERS
	if (!constBuffer)
	{
		g_pImmediateContext->PSSetConstantBuffers(1, 1, &g_pConstantBufferPS);
		g_pImmediateContext->VSSetConstantBuffers(0, 1, &g_pConstantBuffer);
		g_pImmediateContext->VSSetConstantBuffers(1, 1, &g_pConstantBufferPS);
		// Set shader texture resource in the pixel shader.
		g_pImmediateContext->PSSetShaderResources(0, 1, &m_texture);
		g_pImmediateContext->PSSetShaderResources(1, 1, &m_normalmap);
		g_pImmediateContext->PSSetShaderResources(2, 1, &m_specularmap);
		// Set the sampler state in the pixel shader.
		g_pImmediateContext->PSSetSamplers(0, 1, &m_sampleState);

		constBuffer = true;
	}

	//
	// Update variables for the first cube
	//
	ConstantBuffer cb1;
	cb1.mWorld = XMMatrixTranspose(g_World1);
	cb1.mView = XMMatrixTranspose(g_View);
	cb1.mProjection = XMMatrixTranspose(g_Projection);
	cb1.mNormal = XMMatrixTranspose(g_Normal1);
	//
	// Update variables for the second cube
	//
	ConstantBuffer cb2;
	cb2.mWorld = XMMatrixTranspose(g_World2);
	cb2.mView = XMMatrixTranspose(g_View);
	cb2.mProjection = XMMatrixTranspose(g_Projection);

	// JPE: variables for PS
	ConstantBufferPS psCb1;
	psCb1.time = t;
	psCb1.vecEye = XMFLOAT3(x, y, z);
	psCb1.bump = bump;
	psCb1.useTexture = useTexture;

	// FIRST PASS
	g_pImmediateContext->RSSetState(m_rasterState);
	g_pImmediateContext->VSSetShader(g_pVertexShader, NULL, 0);
	g_pImmediateContext->PSSetShader(g_pPixelShader, NULL, 0);

	// Render the first cube
	g_pImmediateContext->UpdateSubresource(g_pConstantBuffer, 0, NULL, &cb1, 0, 0);
	g_pImmediateContext->UpdateSubresource(g_pConstantBufferPS, 0, NULL, &psCb1, 0, 0);
	g_pImmediateContext->DrawIndexed( cantIndices, 0, 0 );
	// Render the second cube
	g_pImmediateContext->UpdateSubresource( g_pConstantBuffer, 0, NULL, &cb2, 0, 0 );
	g_pImmediateContext->DrawIndexed(cantIndices, 0, 0);
	
    // SECOND PASS
	if (wireframe)
	{
		g_pImmediateContext->RSSetState(m_rasterStateWF);
		g_pImmediateContext->VSSetShader(g_pVertexShaderWF, NULL, 0);
		g_pImmediateContext->PSSetShader(g_pPixelShaderWF, NULL, 0);

		// Render the first cube
		g_pImmediateContext->UpdateSubresource(g_pConstantBuffer, 0, NULL, &cb1, 0, 0);
		g_pImmediateContext->UpdateSubresource(g_pConstantBufferPS, 0, NULL, &psCb1, 0, 0);
		g_pImmediateContext->DrawIndexed(cantIndices, 0, 0);
		// Render the second cube
		g_pImmediateContext->UpdateSubresource(g_pConstantBuffer, 0, NULL, &cb2, 0, 0);
		g_pImmediateContext->DrawIndexed(cantIndices, 0, 0);
	}

    //
    // Present our back buffer to our front buffer
    //
	// JPE: primer parametro = 1 para Vertical Sync, 0 para Inmediato
	UINT SyncInterval = vsync ? 1: 0;
    g_pSwapChain->Present(SyncInterval, 0 );

	frameCount++;
	
	if (frameCount % frameDelay == 0)
	{
		DWORD tAct = timeGetTime();

		DWORD elapsed = tAct - tAnt;
		long frames = frameCount - frameCountLast;
		float fps = frames / (elapsed / 1000.0f);


		frameDelay = fps / 5;

		if (frameDelay < 10) frameDelay = 10;

		wchar_t text[256];

		swprintf(text, 256, L"FPS = %.1f", fps);

		SetWindowTextW(g_hWnd, text);

		frameCountLast = frameCount;
		tAnt = tAct;
	}
}
Example #7
0
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
{
    ULONGLONG  CommitChargeTotal;
    ULONGLONG  CommitChargeLimit;
    ULONGLONG  CommitChargePeak;

    ULONG  CpuUsage;
    ULONG  CpuKernelUsage;

    ULONGLONG  KernelMemoryTotal;
    ULONGLONG  KernelMemoryPaged;
    ULONGLONG  KernelMemoryNonPaged;

    ULONGLONG  PhysicalMemoryTotal;
    ULONGLONG  PhysicalMemoryAvailable;
    ULONGLONG  PhysicalMemorySystemCache;

    ULONG  TotalHandles;
    ULONG  TotalThreads;
    ULONG  TotalProcesses;

    WCHAR  Text[260];
    WCHAR  szMemUsage[256];

    MSG    msg;

    LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, 256);

    while (1)
    {
        int nBarsUsed1;
        int nBarsUsed2;

        WCHAR szChargeTotalFormat[256];
        WCHAR szChargeLimitFormat[256];

        /*  Wait for an the event or application close */
        if (GetMessage(&msg, NULL, 0, 0) <= 0)
            return 0;

        if (msg.message == WM_TIMER)
        {
            /*
             *  Update the commit charge info
             */
            CommitChargeTotal = PerfDataGetCommitChargeTotalK();
            CommitChargeLimit = PerfDataGetCommitChargeLimitK();
            CommitChargePeak  = PerfDataGetCommitChargePeakK();
            _ultow(CommitChargeTotal, Text, 10);
            SetWindowTextW(hPerformancePageCommitChargeTotalEdit, Text);
            _ultow(CommitChargeLimit, Text, 10);
            SetWindowTextW(hPerformancePageCommitChargeLimitEdit, Text);
            _ultow(CommitChargePeak, Text, 10);
            SetWindowTextW(hPerformancePageCommitChargePeakEdit, Text);

            StrFormatByteSizeW(CommitChargeTotal * 1024,
                               szChargeTotalFormat,
                               sizeof(szChargeTotalFormat));

            StrFormatByteSizeW(CommitChargeLimit * 1024,
                               szChargeLimitFormat,
                               sizeof(szChargeLimitFormat));

            wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
                      (CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));

            SendMessageW(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);

            /*
             *  Update the kernel memory info
             */
            KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
            KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
            KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
            _ultow(KernelMemoryTotal, Text, 10);
            SetWindowTextW(hPerformancePageKernelMemoryTotalEdit, Text);
            _ultow(KernelMemoryPaged, Text, 10);
            SetWindowTextW(hPerformancePageKernelMemoryPagedEdit, Text);
            _ultow(KernelMemoryNonPaged, Text, 10);
            SetWindowTextW(hPerformancePageKernelMemoryNonPagedEdit, Text);

            /*
             *  Update the physical memory info
             */
            PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
            PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
            PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
            _ultow(PhysicalMemoryTotal, Text, 10);
            SetWindowTextW(hPerformancePagePhysicalMemoryTotalEdit, Text);
            _ultow(PhysicalMemoryAvailable, Text, 10);
            SetWindowTextW(hPerformancePagePhysicalMemoryAvailableEdit, Text);
            _ultow(PhysicalMemorySystemCache, Text, 10);
            SetWindowTextW(hPerformancePagePhysicalMemorySystemCacheEdit, Text);

            /*
             *  Update the totals info
             */
            TotalHandles = PerfDataGetSystemHandleCount();
            TotalThreads = PerfDataGetTotalThreadCount();
            TotalProcesses = PerfDataGetProcessCount();
            _ultow(TotalHandles, Text, 10);
            SetWindowTextW(hPerformancePageTotalsHandleCountEdit, Text);
            _ultow(TotalThreads, Text, 10);
            SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text);
            _ultow(TotalProcesses, Text, 10);
            SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text);

            /*
             *  Redraw the graphs
             */
            InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
            InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);

            /*
             *  Get the CPU usage
             */
            CpuUsage = PerfDataGetProcessorUsage();
            if (CpuUsage <= 0 )       CpuUsage = 0;
            if (CpuUsage > 100)       CpuUsage = 100;

            if (TaskManagerSettings.ShowKernelTimes)
            {
                CpuKernelUsage = PerfDataGetProcessorSystemUsage();
                if (CpuKernelUsage <= 0)   CpuKernelUsage = 0;
                if (CpuKernelUsage > 100) CpuKernelUsage = 100;
            }
            else
            {
                CpuKernelUsage = 0;
            }
            /*
             *  Get the memory usage
             */
            CommitChargeTotal = PerfDataGetCommitChargeTotalK();
            CommitChargeLimit = PerfDataGetCommitChargeLimitK();
            nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;

            PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
            PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
            nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;

            GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
            GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
            /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
            InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
            InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
        }
    }
    return 0;
}
Example #8
0
BOOL UpdateProgressBarProc (__int64 byteOffset)
{
	wchar_t text[100];
	wchar_t speed[100];
	HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
	int time = GetTickCount ();
	int elapsed = (time - startTime) / 1000;

	uint64 bytesDone = (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset);
	uint64 bytesPerSec = (bProgressBarReverse ? (resumedPointBytesDone - byteOffset) : (bytesDone - resumedPointBytesDone)) / (elapsed + 1);

	if (bPercentMode)
	{
		double perc = (double) (100.0 * (bProgressBarReverse ? ((double) (TotalSize - byteOffset)) : ((double) byteOffset)) / (TotalSize == 0 ? 0.0001 : ((double) TotalSize)));

		if (perc > 99.999999999)
			wcscpy (text, GetString ("PROCESSED_PORTION_100_PERCENT"));
		else
			_snwprintf (text, sizeof text/2, GetString ("PROCESSED_PORTION_X_PERCENT"), perc);

		wcscat (speed, L" ");
	}
	else
	{
		GetSizeString (bytesDone, text);
		if (bytesDone < (unsigned __int64) BYTES_PER_MB * 1000000)
			swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB"));
		else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 1000000)
			swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB"));
		else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 1000000)
			swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB"));
		else
			swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB"));
	}

	SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text);

	if (!bShowStatus)
	{
		GetSpeedString (bRWThroughput ? bytesPerSec*2 : bytesPerSec, speed);
		wcscat (speed, L" ");
		SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), speed);
	}

	if (byteOffset < TotalSize)
	{
		int64 sec = (int64) ((bProgressBarReverse ? byteOffset : (TotalSize - byteOffset)) / (bytesPerSec == 0 ? 0.001 : bytesPerSec));

		if (bytesPerSec == 0 || sec > 60 * 60 * 24 * 999)
			swprintf (text, L"%s ", GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE"));
		else if (sec >= 60 * 60 * 24 * 2)
			swprintf (text, L"%I64d %s ", sec / (60 * 24 * 60), days);
		else if (sec >= 120 * 60)
			swprintf (text, L"%I64d %s ", sec / (60 * 60), hours);
		else if (sec >= 120)
			swprintf (text, L"%I64d %s ", sec / 60, minutes);
		else
			swprintf (text, L"%I64d %s ", sec, seconds);

		SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text);
	}

	prevTime = time;

	SendMessage (hProgressBar, PBM_SETPOS, 
		(int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)),
		0);

	return bVolTransformThreadCancel;
}
Example #9
0
void onTitleChanged(const wkeClientHandler* clientHandler, const wkeString title)
{
    HWND hWnd = 0;
    Ogre::Root::getSingleton().getAutoCreatedWindow()->getCustomAttribute("WINDOW", &hWnd);
    SetWindowTextW(hWnd, wkeToStringW(title));
}
Example #10
0
/*************************************************************************
 *             BrsFolderDlgProc32  (not an exported API function)
 */
static INT_PTR CALLBACK BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
				          LPARAM lParam )
{
    browse_info *info;

    TRACE("hwnd=%p msg=%04x 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam );

    if (msg == WM_INITDIALOG)
        return BrsFolder_OnCreate( hWnd, (browse_info*) lParam );

    info = GetPropW( hWnd, szBrowseFolderInfo );

    switch (msg)
    {
    case WM_NOTIFY:
        return BrsFolder_OnNotify( info, (UINT)wParam, (LPNMHDR)lParam);

    case WM_COMMAND:
        return BrsFolder_OnCommand( info, wParam );

    case WM_WINDOWPOSCHANGING:
        return BrsFolder_OnWindowPosChanging( info, (WINDOWPOS *)lParam);

    case WM_SIZE:
        if (info->layout)  /* new style dialogs */
            LayoutUpdate(hWnd, info->layout, g_layout_info, LAYOUT_INFO_COUNT);
        return 0;

    case BFFM_SETSTATUSTEXTA:
        TRACE("Set status %s\n", debugstr_a((LPSTR)lParam));
        SetWindowTextA(GetDlgItem(hWnd, IDD_STATUS), (LPSTR)lParam);
        break;

    case BFFM_SETSTATUSTEXTW:
        TRACE("Set status %s\n", debugstr_w((LPWSTR)lParam));
        SetWindowTextW(GetDlgItem(hWnd, IDD_STATUS), (LPWSTR)lParam);
        break;

    case BFFM_ENABLEOK:
        TRACE("Enable %ld\n", lParam);
        EnableWindow(GetDlgItem(hWnd, 1), lParam != 0);
        break;

    case BFFM_SETOKTEXT: /* unicode only */
        TRACE("Set OK text %s\n", debugstr_w((LPWSTR)lParam));
        SetWindowTextW(GetDlgItem(hWnd, 1), (LPWSTR)lParam);
        break;

    case BFFM_SETSELECTIONA:
        return BrsFolder_OnSetSelectionA(info, (LPVOID)lParam, (BOOL)wParam);

    case BFFM_SETSELECTIONW:
        return BrsFolder_OnSetSelectionW(info, (LPVOID)lParam, (BOOL)wParam);

    case BFFM_SETEXPANDED: /* unicode only */
        return BrsFolder_OnSetExpanded(info, (LPVOID)lParam, (BOOL)wParam, NULL);

    case WM_DESTROY:
        return BrsFolder_OnDestroy(info);
    }
    return FALSE;
}
Example #11
0
void setWindowText(HWND hwnd, WCHAR *wtext)
{
	if (SetWindowTextW(hwnd, wtext) == 0)
		logLastError(L"error setting window text");
}
Example #12
0
static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info )
{
    LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;

    info->hWnd = hWnd;
    SetPropW( hWnd, szBrowseFolderInfo, info );

    if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
        FIXME("flags BIF_NEWDIALOGSTYLE partially implemented\n");
    if (lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS)
	FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS);

    if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
    {
        RECT rcWnd;

        info->layout = LayoutInit(hWnd, g_layout_info, LAYOUT_INFO_COUNT);

        /* TODO: Windows allows shrinking the windows a bit */
        GetWindowRect(hWnd, &rcWnd);
        info->szMin.cx = rcWnd.right - rcWnd.left;
        info->szMin.cy = rcWnd.bottom - rcWnd.top;
    }
    else
    {
        info->layout = NULL;
    }

    if (lpBrowseInfo->lpszTitle)
	SetWindowTextW( GetDlgItem(hWnd, IDD_TITLE), lpBrowseInfo->lpszTitle );
    else
	ShowWindow( GetDlgItem(hWnd, IDD_TITLE), SW_HIDE );

    if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT)
        || (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
	ShowWindow( GetDlgItem(hWnd, IDD_STATUS), SW_HIDE );

    /* Hide "Make New Folder" Button? */
    if ((lpBrowseInfo->ulFlags & BIF_NONEWFOLDERBUTTON)
        || !(lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
        ShowWindow( GetDlgItem(hWnd, IDD_MAKENEWFOLDER), SW_HIDE );

    /* Hide the editbox? */
    if (!(lpBrowseInfo->ulFlags & BIF_EDITBOX))
    {
        ShowWindow( GetDlgItem(hWnd, IDD_FOLDER), SW_HIDE );
        ShowWindow( GetDlgItem(hWnd, IDD_FOLDERTEXT), SW_HIDE );
    }

    info->hwndTreeView = GetDlgItem( hWnd, IDD_TREEVIEW );
    if (info->hwndTreeView)
    {
        InitializeTreeView( info );

        /* Resize the treeview if there's not editbox */
        if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
            && !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
        {
            RECT rc;
            GetClientRect(info->hwndTreeView, &rc);
            SetWindowPos(info->hwndTreeView, HWND_TOP, 0, 0,
                         rc.right, rc.bottom + 40, SWP_NOMOVE);
        }
    }
    else
        ERR("treeview control missing!\n");

    browsefolder_callback( info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0 );

    return TRUE;
}
Example #13
0
bool DisplayMessageBox(const char* pTitle, const char* pText)
{
    #define ID_EDIT 100

    struct Dialog
    {
        static size_t LineCount(const char* pText)
        {
            size_t count = 0;
            while(*pText)
            {
                if(*pText++ == '\n')
                    count++;
            }
            return count;
        }

        static WORD* WordUp(WORD* pIn){ return (WORD*)((((uintptr_t)pIn + 3) >> 2) << 2); }

        static BOOL CALLBACK Proc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
        {
            switch (iMsg)
            {
                case WM_INITDIALOG:
                {
                    HWND hWndEdit = GetDlgItem(hDlg, ID_EDIT);

                    const wchar_t* pText = (const wchar_t*)lParam;
                    SetWindowTextW(hWndEdit, pText);

                    HFONT hFont = CreateFontW(-11, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Courier New");
                    if(hFont)
                        SendMessage(hWndEdit, WM_SETFONT, WPARAM(hFont), TRUE);

                    SendMessage(hWndEdit, EM_SETSEL, (WPARAM)0, (LPARAM)0);

                    return TRUE;
                }

                case WM_COMMAND:
                    switch (LOWORD(wParam))
                    {
                        case ID_EDIT:
                        {
                            // Handle messages from the edit control here.
                            HWND hWndEdit = GetDlgItem(hDlg, ID_EDIT);
                            SendMessage(hWndEdit, EM_SETSEL, (WPARAM)0, (LPARAM)0);
                            return TRUE;
                        }

                        case IDOK:
                            EndDialog(hDlg, 0);
                            return TRUE;
                        case IDABORT:
                            _exit(0); // We don't call abort() because the visual studio runtime
                                      // will capture the signal and throw up another dialog
                    }
                    break;
                case WM_CLOSE:

                    EndDialog(hDlg, 0);
                    return TRUE;
            }

            return FALSE;
        }
    };
Example #14
0
	void UGameWindow::SetWindowName(const eastl::string& inWindowName)
	{
		auto wWindowName = utf8util::UTF16FromUTF8(inWindowName);
		SetWindowTextW(m_hWnd, wWindowName.c_str());
	}
Example #15
0
void winopen()
{
	WNDCLASS wc;
	HMENU menu;
	RECT r;
	ATOM a;

	/* Create and register window frame class */
	memset(&wc, 0, sizeof(wc));
	wc.style = 0;
	wc.lpfnWndProc = frameproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = GetModuleHandle(NULL);
	wc.hIcon = LoadIconA(wc.hInstance, "IDI_ICONAPP");
	wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = L"FrameWindow";
	a = RegisterClassW(&wc);
	if (!a)
		winerror(&gapp, "cannot register frame window class");

	/* Create and register window view class */
	memset(&wc, 0, sizeof(wc));
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = viewproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = GetModuleHandle(NULL);
	wc.hIcon = NULL;
	wc.hCursor = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = L"ViewWindow";
	a = RegisterClassW(&wc);
	if (!a)
		winerror(&gapp, "cannot register view window class");

	/* Get screen size */
	SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
	gapp.scrw = r.right - r.left;
	gapp.scrh = r.bottom - r.top;

	/* Create cursors */
	arrowcurs = LoadCursor(NULL, IDC_ARROW);
	handcurs = LoadCursor(NULL, IDC_HAND);
	waitcurs = LoadCursor(NULL, IDC_WAIT);
	caretcurs = LoadCursor(NULL, IDC_IBEAM);

	/* And a background color */
	bgbrush = CreateSolidBrush(RGB(0x70,0x70,0x70));
	shbrush = CreateSolidBrush(RGB(0x40,0x40,0x40));

	/* Init DIB info for buffer */
	dibinf = malloc(sizeof(BITMAPINFO) + 12);
	assert(dibinf);
	dibinf->bmiHeader.biSize = sizeof(dibinf->bmiHeader);
	dibinf->bmiHeader.biPlanes = 1;
	dibinf->bmiHeader.biBitCount = 32;
	dibinf->bmiHeader.biCompression = BI_RGB;
	dibinf->bmiHeader.biXPelsPerMeter = 2834;
	dibinf->bmiHeader.biYPelsPerMeter = 2834;
	dibinf->bmiHeader.biClrUsed = 0;
	dibinf->bmiHeader.biClrImportant = 0;
	dibinf->bmiHeader.biClrUsed = 0;

	/* Create window */
	hwndframe = CreateWindowW(L"FrameWindow", // window class name
	NULL, // window caption
	WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
	CW_USEDEFAULT, CW_USEDEFAULT, // initial position
	300, // initial x size
	300, // initial y size
	0, // parent window handle
	0, // window menu handle
	0, // program instance handle
	0); // creation parameters
	if (!hwndframe)
		winerror(&gapp, "cannot create frame");

	hwndview = CreateWindowW(L"ViewWindow", // window class name
	NULL,
	WS_VISIBLE | WS_CHILD,
	CW_USEDEFAULT, CW_USEDEFAULT,
	CW_USEDEFAULT, CW_USEDEFAULT,
	hwndframe, 0, 0, 0);
	if (!hwndview)
		winerror(&gapp, "cannot create view");

	hdc = NULL;

	SetWindowTextW(hwndframe, L"MuPDF");

	menu = GetSystemMenu(hwndframe, 0);
	AppendMenuW(menu, MF_SEPARATOR, 0, NULL);
	AppendMenuW(menu, MF_STRING, ID_ABOUT, L"About MuPDF...");
	AppendMenuW(menu, MF_STRING, ID_DOCINFO, L"Document Properties...");

	SetCursor(arrowcurs);
}
Example #16
0
INT_PTR CALLBACK
ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    RECT    rc;
    int     nXDifference;
    int     nYDifference;
    int     cx, cy;

    switch (message) {
    case WM_INITDIALOG:
        /*
         * Save the width and height
         */
        GetClientRect(hDlg, &rc);
        nProcessPageWidth = rc.right;
        nProcessPageHeight = rc.bottom;

        /* Update window position */
        SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);

        /*
         * Get handles to the controls
         */
        hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
        hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
        hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
        hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);

        /*
         * Set the title, and extended window styles for the list control
         */
        SetWindowTextW(hProcessPageListCtrl, L"Processes");
        (void)ListView_SetExtendedListViewStyle(hProcessPageListCtrl, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);

        AddColumns();

        /*
         * Subclass the process list control so we can intercept WM_ERASEBKGND
         */
        OldProcessListWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc);

#ifdef RUN_PROC_PAGE
        /* Start our refresh thread */
        hProcessThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, &dwProcessThread);
#endif
        return TRUE;

    case WM_DESTROY:
        /* Close the event handle, this will make the */
        /* refresh thread exit when the wait fails */
#ifdef RUN_PROC_PAGE
        EndLocalThread(&hProcessThread, dwProcessThread);
#endif
        SaveColumnSettings();
        break;

    case WM_COMMAND:
        /* Handle the button clicks */
        switch (LOWORD(wParam))
        {
                case IDC_ENDPROCESS:
                        ProcessPage_OnEndProcess();
        }
        break;

    case WM_SIZE:
        if (wParam == SIZE_MINIMIZED)
            return 0;

        cx = LOWORD(lParam);
        cy = HIWORD(lParam);
        nXDifference = cx - nProcessPageWidth;
        nYDifference = cy - nProcessPageHeight;
        nProcessPageWidth = cx;
        nProcessPageHeight = cy;

        /* Reposition the application page's controls */
        GetWindowRect(hProcessPageListCtrl, &rc);
        cx = (rc.right - rc.left) + nXDifference;
        cy = (rc.bottom - rc.top) + nYDifference;
        SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
        InvalidateRect(hProcessPageListCtrl, NULL, TRUE);

        GetClientRect(hProcessPageEndProcessButton, &rc);
        MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(PRECT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
           cx = rc.left + nXDifference;
        cy = rc.top + nYDifference;
        SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
        InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE);

        GetClientRect(hProcessPageShowAllProcessesButton, &rc);
        MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(PRECT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
           cx = rc.left;
        cy = rc.top + nYDifference;
        SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
        InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
        break;

    case WM_NOTIFY:
        ProcessPageOnNotify(wParam, lParam);
        break;

    case WM_KEYDOWN:
        if (wParam == VK_DELETE)
            ProcessPage_OnEndProcess();
        break;
    }

    return 0;
}
Example #17
0
void MusPlayer_WinAPI::initUI(HWND hWnd)
{
    HGDIOBJ hFont   = GetStockObject(DEFAULT_GUI_FONT);
    HFONT hFontBold = CreateFontW(-11, 0, 0, 0, FW_BOLD, FALSE, FALSE,
                                0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
                               CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                               DEFAULT_PITCH | FF_SWISS, L"Tahoma");
    int left = 5;
    int top = 10;

    HWND hText = CreateWindowExW(0, L"STATIC", L"Press \"Open\" or drag&&drop music file into this window",
                                WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 25;

    m_labelTitle = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;
    m_labelArtist = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;
    m_labelAlboom = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;
    m_labelCopyright = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;


    m_buttonOpen = CreateWindowExW(0, L"BUTTON", L"Open", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                left, top, 60, 21, hWnd,
                                (HMENU)CMD_Open, // Here is the ID of your button ( You may use your own ID )
                                m_hInstance, NULL);
    left += 60;

    m_buttonPlay = CreateWindowExW(0, L"BUTTON", L"Play/Pause", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                left, top, 60, 21, hWnd,
                                (HMENU)CMD_Play, // Here is the ID of your button ( You may use your own ID )
                                m_hInstance, NULL);
    left += 60;

    m_buttonStop = CreateWindowExW(0, L"BUTTON", L"Stop", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                left, top, 60, 21, hWnd,
                                (HMENU)CMD_Stop, // Here is the ID of your button ( You may use your own ID )
                                m_hInstance, NULL);

    left += 60;
    m_volume    = CreateWindowExW(0, TRACKBAR_CLASS, L"Volume", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                  left, top-2, 80, 25, hWnd,
                                  (HMENU)CMD_Volume, // Here is the ID of your button ( You may use your own ID )
                                  m_hInstance, NULL);
    SendMessageW(m_volume, TBM_SETRANGE,
                (WPARAM)TRUE,               //redraw flag
                (LPARAM)MAKELONG(0, 128));  //min. & max. positions
    SendMessageW(m_volume, TBM_SETPOS,
                (WPARAM)TRUE,               //redraw flag
                (LPARAM)128);
    SendMessageW(m_volume, WM_SETFONT, (WPARAM)hFont, 0);
    left += 80;

    m_formatInfo = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                   left, top, 200, 15,
                                   hWnd, NULL, m_hInstance, NULL);
    SendMessageW(m_formatInfo, WM_SETFONT, (WPARAM)hFont, 0);

    left = 5;
    top += 21;

    m_recordWave = CreateWindowExW(0, L"BUTTON", L"Record wave", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                                             left, top, 200, 15,
                                                             hWnd, (HMENU)CMD_RecordWave, m_hInstance, NULL);
    SendMessageW(m_recordWave, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_RecordWave, BST_UNCHECKED);

    top += 18;

    WNDPROC OldBtnProc;

    m_groupGME = CreateWindowExW(0, L"BUTTON", L"Game Music Emulators setup", WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
                                left, top, 330, 50, hWnd, (HMENU)GRP_GME, m_hInstance, NULL);
    SendMessageW(m_groupGME, WM_SETFONT, (WPARAM)hFont, 0);
    OldBtnProc = reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>(
                 SetWindowLongPtr(m_groupGME, GWLP_WNDPROC,
                 reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) );
    SetWindowLongPtr(m_groupGME, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc));

    m_gme.m_labelTrack = CreateWindowExW(0, L"STATIC", L"Track number:", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                10, 20, 70, 15,
                                 m_groupGME, NULL, m_hInstance, NULL);
    SendMessageW(m_gme.m_labelTrack, WM_SETFONT, (WPARAM)hFont, 0);

    m_gme.m_trackNum = CreateWindowExW(0, L"EDIT", L"ED_RED",
                                    WS_TABSTOP|WS_CHILD|WS_VISIBLE|ES_LEFT|WS_BORDER,
                                    80, 20, 240, 20,
                                    m_groupGME, (HMENU)(CMD_TrackID),
                                    m_hInstance, NULL);

    SendMessageW(m_gme.m_trackNum, WM_SETFONT, (WPARAM)hFont, 0);
    // with a spin control to its right side
    m_gme.m_trackNumUpDown = CreateWindowExW(0, UPDOWN_CLASS, L"SP_RED",
                                            WS_TABSTOP|WS_CHILD | WS_VISIBLE
                                            | UDS_ARROWKEYS | UDS_ALIGNRIGHT
                                            | UDS_SETBUDDYINT | WS_BORDER,
                                            80, 20, 240, 20,
                                            m_groupGME, (HMENU)(CMD_TrackIDspin), m_hInstance, NULL);
    SendMessageW(m_gme.m_trackNumUpDown, WM_SETFONT, (WPARAM)hFont, 0);

    // Set the buddy control.
    SendMessage(m_gme.m_trackNumUpDown, UDM_SETBUDDY, (LONG)m_gme.m_trackNum, 0L);
    // Set the range.
    SendMessage(m_gme.m_trackNumUpDown, UDM_SETRANGE, 0L, MAKELONG(32000, 0) );
    // Set the initial value
    SendMessage(m_gme.m_trackNumUpDown, UDM_SETPOS, 0L, MAKELONG((int)(0), 0));

    //SendMessage(m_gme.m_trackNumUpDown, UDS_WRAP, 0L, FALSE);




    m_groupMIDI = CreateWindowExW(0, L"BUTTON", L"MIDI Setup", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|WS_GROUP,
                                left, top, 330, 50,
                                hWnd, (HMENU)GRP_MIDI, m_hInstance, NULL);
    SendMessageW(m_groupMIDI, WM_SETFONT, (WPARAM)hFont, 0);

    OldBtnProc = reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>(
                 SetWindowLongPtr(m_groupMIDI, GWLP_WNDPROC,
                 reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) );
    SetWindowLongPtr(m_groupMIDI, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc));

    top += 50;

    m_midi.m_labelDevice = CreateWindowExW(0, L"STATIC", L"MIDI Device:", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                10, 20, 70, 15,
                                m_groupMIDI, NULL, m_hInstance, NULL);
    SendMessageW(m_midi.m_labelDevice, WM_SETFONT, (WPARAM)hFont, 0);

    const wchar_t* midiDevices[] = {
        L"ADL Midi (OPL Synth emulation)",
        L"Timidity (GUS-like wavetable MIDI Synth)",
        L"Native midi (Built-in MIDI of your OS)"
    };
    m_midi.m_midiDevice = CreateWindowExW(0, L"COMBOBOX", L"MidiDevice", WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_TABSTOP,
                                              80, 17, 240, 210, m_groupMIDI, (HMENU)CMD_MidiDevice, m_hInstance, NULL);
    SendMessageW(m_midi.m_midiDevice, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[0]);
    SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[1]);
    SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[2]);
    SendMessageW(m_midi.m_midiDevice, CB_SETCURSEL, 0, 0);

    m_groupADLMIDI = CreateWindowExW(0, L"BUTTON", L"ADLMIDI Extra Setup", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|WS_GROUP,
                                left, top, 330, 125,
                                hWnd, (HMENU)GRP_ADLMIDI, m_hInstance, NULL);
    SendMessageW(m_groupADLMIDI, WM_SETFONT, (WPARAM)hFont, 0);
    //top += 50;

    OldBtnProc=reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>(
                 SetWindowLongPtr(m_groupADLMIDI, GWLP_WNDPROC,
                 reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) );
    SetWindowLongPtr(m_groupADLMIDI, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc));


    m_adlmidi.m_labelBank = CreateWindowExW(0, L"STATIC", L"ADL Midi bank ID:", WS_CHILD|WS_VISIBLE | SS_LEFT,
                                10, 20, 70, 15,
                                m_groupADLMIDI, NULL, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_labelBank, WM_SETFONT, (WPARAM)hFont, 0);

    m_adlmidi.m_bankID = CreateWindowExW(0, L"COMBOBOX", L"BankId", WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL|WS_VSCROLL|CBS_NOINTEGRALHEIGHT|WS_TABSTOP,
                                              80, 17, 240, 210, m_groupADLMIDI, (HMENU)CMD_Bank, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_bankID, WM_SETFONT, (WPARAM)hFont, 0);
    int insCount            = MIX_ADLMIDI_getTotalBanks();
    const char*const* names = MIX_ADLMIDI_getBankNames();
    for(int i=0; i<insCount; i++)
    {
        SendMessageA(m_adlmidi.m_bankID, CB_ADDSTRING, 0, (LPARAM)names[i]);
    }
    SendMessageW(m_adlmidi.m_bankID, CB_SETCURSEL, 58, 0);


    m_adlmidi.m_tremolo = CreateWindowExW(0, L"BUTTON", L"Deep tremolo", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 40, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_Tremolo, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_tremolo, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_Tremolo, BST_CHECKED);

    m_adlmidi.m_vibrato = CreateWindowExW(0, L"BUTTON", L"Deep vibrato", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 60, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_Vibrato, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_vibrato, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_Vibrato, BST_CHECKED);

    m_adlmidi.m_scalableMod = CreateWindowExW(0, L"BUTTON", L"Scalable modulation", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 80, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_ScalableMod, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_scalableMod, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_ScalableMod, BST_UNCHECKED);

    m_adlmidi.m_adlibDrums = CreateWindowExW(0, L"BUTTON", L"AdLib drums mode", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 100, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_AdLibDrums, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_adlibDrums, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_AdLibDrums, BST_UNCHECKED);


    ShowWindow(m_groupGME, SW_HIDE);
    ShowWindow(m_groupMIDI, SW_HIDE);
    ShowWindow(m_groupADLMIDI, SW_HIDE);


    SendMessageW(hWnd, WM_SETFONT, (WPARAM)hFont, 0);

    SendMessageW(m_buttonOpen, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_buttonPlay, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_buttonStop, WM_SETFONT, (WPARAM)hFont, 0);

    SendMessageW(hText, WM_SETFONT, (WPARAM)hFontBold, 0);

    SendMessageW(m_labelTitle, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_labelArtist, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_labelAlboom, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_labelCopyright, WM_SETFONT, (WPARAM)hFont, 0);

    SetWindowTextW(hWnd, L"Simple SDL2 Mixer X Music player [WinAPI-based]");

    HMENU hSubMenu;
    m_contextMenu = CreatePopupMenu();
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Open, L"Open");
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Play, L"Play/Pause");
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Stop, L"Stop");
    AppendMenuW(m_contextMenu, MF_SEPARATOR, 0, 0);
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Reverb, L"Reverb");
    AppendMenuW(m_contextMenu, MF_STRING, CMD_AssocFiles, L"Associate files");
    EnableMenuItem(m_contextMenu, CMD_AssocFiles, MF_GRAYED);
    AppendMenuW(m_contextMenu, MF_SEPARATOR, 0, 0);

    hSubMenu = CreatePopupMenu();
    AppendMenuA(hSubMenu, MF_STRING, CMD_Version, "SDL Mixer X Music Player [WinAPI], v." _FILE_VERSION);
    EnableMenuItem(hSubMenu, CMD_Version, MF_GRAYED);
    AppendMenuW(hSubMenu, MF_STRING, CMD_ShowLicense, L"Licensed under GNU GPLv3 license");
    AppendMenuW(hSubMenu, MF_SEPARATOR, 0, 0);
    AppendMenuW(hSubMenu, MF_STRING, CMD_ShowSource, L"Get source code");

    AppendMenuW(m_contextMenu,  MF_STRING | MF_POPUP, (UINT)hSubMenu, L"About");

}
Example #18
0
void cWindow::setCaptionText(const eiString& str) {
	SetWindowTextW(handle,str.strConst());
}
Example #19
0
void WIN32Window::setTitle(const std::string& title)
{
    SetWindowTextW(m_window, stdext::latin1_to_utf16(title).c_str());
}
Example #20
0
/**
 *  Erstellt das Fenster mit entsprechenden Werten.
 *
 *  @param[in] width      Breite des Fensters
 *  @param[in] height     Höhe des Fensters
 *  @param[in] fullscreen Vollbildmodus ja oder nein
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @bug Hardwarecursor ist bei Fenstermodus sichtbar,
 *       Cursor deaktivieren ist fehlerhaft
 *
 *  @author FloSoft
 */
bool VideoWinAPI::CreateScreen(unsigned short width, unsigned short height, const bool fullscreen)
{
    if(!initialized)
        return false;

    std::wstring wTitle = AnsiToUtf8(GetWindowTitle());

    WNDCLASSW  wc;
    wc.style            = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    wc.lpfnWndProc      = WindowProc;
    wc.cbClsExtra       = 0;
    wc.cbWndExtra       = 0;
    wc.hInstance        = GetModuleHandle(NULL);
    wc.hIcon            = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SYMBOL));
    wc.hCursor          = NULL;
    wc.hbrBackground    = NULL;
    wc.lpszMenuName     = NULL;
    wc.lpszClassName    = wTitle.c_str();

    // Fensterklasse registrieren
    if (!RegisterClassW(&wc))
        return false;

    DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
    DWORD dwStyle   = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX;

    if(fullscreen)
    {
        dwExStyle   = WS_EX_APPWINDOW;
        dwStyle     = WS_POPUP;

        EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm_prev);
    }
    else
    {
        // Bei Fensteranwendung die Breiten und Hoehen der Fensterrahmen, Titelleiste draufaddieren
        width += 2 * GetSystemMetrics(SM_CXFIXEDFRAME);
        height += 2 * GetSystemMetrics(SM_CXFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION);
    }

    // Fenster erstellen
    screen = CreateWindowExW(dwExStyle, wTitle.c_str(), wTitle.c_str(), dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);

    if(screen == NULL)
        return false;

    SetClipboardViewer(screen);

    std::stringstream title;
    title << GetWindowTitle() << " - v" << GetWindowVersion() << "-" << GetWindowRevisionShort();

    wTitle = AnsiToUtf8(title.str().c_str());

    SetWindowTextW(screen, wTitle.c_str());
    SetWindowTextW(GetConsoleWindow(), wTitle.c_str());

    // Pixelformat zuweisen
    GLuint PixelFormat;
    static PIXELFORMATDESCRIPTOR pfd =
    {
        sizeof(PIXELFORMATDESCRIPTOR),
        1,
        PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
        PFD_TYPE_RGBA,
        8, // 8 Bit
        8, // red
        0,
        8, // green
        0,
        8, // blue
        0,
        8, // alpha
        0,
        0,
        0,
        0,
        0,
        0,
        32, // 32 Bit
        0,
        0,
        PFD_MAIN_PLANE,
        0,
        0,
        0,
        0
    };

    screen_dc = GetDC(screen);
    if(screen_dc == NULL)
        return false;

    // Pixelformat auswaehlen
    PixelFormat = ChoosePixelFormat(screen_dc, &pfd);
    if(PixelFormat == 0)
        return false;

    // Pixelformat zuweisen
    if(!SetPixelFormat(screen_dc, PixelFormat, &pfd))
        return false;

    // Renderingkontext erstellen
    screen_rc = wglCreateContext(screen_dc);
    if(screen_rc == NULL)
        return false;

    // Renderingkontext aktivieren
    if(!wglMakeCurrent(screen_dc, screen_rc))
        return false;

    // Mauscursor ausblenden
    ShowCursor(FALSE);

    // Bei Fullscreen Aufloesung umstellen
    if(fullscreen)
    {
        // Aktuelle Framerate holen und die spaeter dann benutzen
        DEVMODE prev;
        EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &prev);

        DEVMODE dm;
        memset(&dm, 0, sizeof(dm));
        dm.dmSize = sizeof(dm);
        dm.dmFields = DM_DISPLAYFREQUENCY | DM_PELSWIDTH | DM_PELSHEIGHT;
        dm.dmDisplayFrequency = prev.dmDisplayFrequency;
        dm.dmPelsWidth = width;
        dm.dmPelsHeight = height;

        ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
    }

    this->screenWidth  = width;
    this->screenHeight = height;
    this->isFullscreen_ = fullscreen;

    // Das Fenster anzeigen
    ShowWindow(screen, SW_SHOW);
    // Das Fenster in den Vordergrund rcken
    SetForegroundWindow(screen);
    // Dem Fenster den Eingabefokus geben
    SetFocus(screen);

    return true;
}
Example #21
0
int vo_w32_control(struct vo *vo, int *events, int request, void *arg)
{
    struct vo_w32_state *w32 = vo->w32;
    switch (request) {
    case VOCTRL_CHECK_EVENTS:
        *events |= vo_w32_check_events(vo);
        return VO_TRUE;
    case VOCTRL_FULLSCREEN:
        vo_w32_fullscreen(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    case VOCTRL_ONTOP:
        vo_w32_ontop(vo);
        return VO_TRUE;
    case VOCTRL_BORDER:
        vo_w32_border(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    case VOCTRL_UPDATE_SCREENINFO:
        w32_update_xinerama_info(vo);
        return VO_TRUE;
    case VOCTRL_GET_WINDOW_SIZE: {
        int *s = arg;
        if (!w32->window_bounds_initialized)
            return VO_FALSE;
        s[0] = w32->current_fs ? w32->prev_width : vo->dwidth;
        s[1] = w32->current_fs ? w32->prev_height : vo->dheight;
        return VO_TRUE;
    }
    case VOCTRL_SET_WINDOW_SIZE: {
        int *s = arg;
        if (!w32->window_bounds_initialized)
            return VO_FALSE;
        if (w32->current_fs) {
            w32->prev_width = s[0];
            w32->prev_height = s[1];
        } else {
            vo->dwidth = s[0];
            vo->dheight = s[1];
        }
        reinit_window_state(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    }
    case VOCTRL_SET_CURSOR_VISIBILITY:
        w32->cursor_visible = *(bool *)arg;

        if (vo_w32_is_cursor_in_client(vo)) {
            if (w32->cursor_visible)
                SetCursor(LoadCursor(NULL, IDC_ARROW));
            else
                SetCursor(NULL);
        }
        return VO_TRUE;
    case VOCTRL_KILL_SCREENSAVER:
        w32->disable_screensaver = true;
        SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
        return VO_TRUE;
    case VOCTRL_RESTORE_SCREENSAVER:
        w32->disable_screensaver = false;
        SetThreadExecutionState(ES_CONTINUOUS);
        return VO_TRUE;
    case VOCTRL_UPDATE_WINDOW_TITLE: {
        wchar_t *title = mp_from_utf8(NULL, (char *)arg);
        SetWindowTextW(w32->window, title);
        talloc_free(title);
        return VO_TRUE;
    }
    }
    return VO_NOTIMPL;
}
Example #22
0
LRESULT ProgressDialog::dialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    const auto updateDialogTimerID = 1U;
    const auto progressDialogShowDetailedOutputSetting = String("ProgressDialogShowDetailedOutput");

    switch (message)
    {
    case WM_INITDIALOG:
    {
        detailedOutput_.clear();
        isTaskComplete_ = false;
        currentTaskString_.clear();

        // Set the exporter version label
        SetWindowTextA(GetDlgItem(hDlg, IDC_VERSION), ("Version " + BuildInfo::getVersion()).cStr());

        // Hide the Close button
        ShowWindow(GetDlgItem(hDlg, IDC_CLOSE), SW_HIDE);

        // Start a timer to update the progress bar at 25Hz
        SetTimer(hDlg, updateDialogTimerID, 40, nullptr);

        // Set range of progress bar to 0-1000
        SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE32, 0, 1000);

        // Move the Close button on top of the Cancel button, only one is available at any given time
        auto cancelRect = RECT();
        GetWindowRect(GetDlgItem(hDlg, IDC_CANCEL), &cancelRect);
        auto p = POINT{cancelRect.left, cancelRect.top};
        ScreenToClient(hDlg, &p);
        SetWindowPos(GetDlgItem(hDlg, IDC_CLOSE), nullptr, p.x, p.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

        // Initialize the show detailed output checkbox and state
        if (settings().getBoolean(progressDialogShowDetailedOutputSetting))
            CheckDlgButton(hDlg, IDC_SHOW_DETAILED_OUTPUT, BST_CHECKED);
        else
        {
            CheckDlgButton(hDlg, IDC_SHOW_DETAILED_OUTPUT, BST_UNCHECKED);
            dialogProc(hDlg, WM_COMMAND, MAKEWPARAM(IDC_SHOW_DETAILED_OUTPUT, 0), 0);
        }

        // Create events used for inter-thread communication
        hUpdateOutputEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);
        hWorkerCompleteEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);
        hWorkerSucceededEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);

        // Start worker thread
        workerThread_ = HANDLE(_beginthreadex(nullptr, 0, staticWorkerThreadMain, this, 0, nullptr));
        if (workerThread_)
            SetThreadPriority(workerThread_, THREAD_PRIORITY_BELOW_NORMAL);

        return TRUE;
    }

    case WM_DESTROY:
    {
        // The worker thread should be finished by now assuming everything worked correctly. However, it is
        // important to check it is finished, as odd behavior or crashes could result from lurking worker threads.
        auto workerThreadExitCode = DWORD();
        GetExitCodeThread(workerThread_, &workerThreadExitCode);
        if (workerThreadExitCode == STILL_ACTIVE)
        {
            // Give the worker thread more time to close
            Sleep(10000);

            // Check the thread state again
            GetExitCodeThread(workerThread_, &workerThreadExitCode);
            if (workerThreadExitCode == STILL_ACTIVE)
            {
                LOG_WARNING << "Worker thread is still active after progress dialog closed";

                MessageBoxA(GetParent(hDlg), "Warning: Worker thread still active after progress dialog closed",
                            Globals::getClientName().cStr(), MB_ICONERROR);
            }
        }

        // Cleanup
        CloseHandle(workerThread_);
        CloseHandle(hUpdateOutputEvent_);
        CloseHandle(hWorkerCompleteEvent_);
        CloseHandle(hWorkerSucceededEvent_);

        break;
    }

    case WM_TIMER:
    {
        if (wParam == updateDialogTimerID)
        {
            events().dispatchEvent(UpdateEvent());

            // Update log output display if required
            if (WaitForSingleObject(hUpdateOutputEvent_, 0) == WAIT_OBJECT_0)
            {
                auto lock = ScopedMutexLock(detailedOutputMutex_);

                // Update text in the output editbox from the 'output' variable
                SetWindowTextW(GetDlgItem(hDlg, IDC_OUTPUT), detailedOutput_.toUTF16().as<wchar_t>());
            }

            if (WaitForSingleObject(hWorkerCompleteEvent_, 0) == WAIT_OBJECT_0)
            {
                isTaskComplete_ = true;

                // Hide the Cancel button and show the Close button
                ShowWindow(GetDlgItem(hDlg, IDC_CANCEL), SW_HIDE);
                ShowWindow(GetDlgItem(hDlg, IDC_CLOSE), SW_SHOW);
                SetFocus(GetDlgItem(hDlg, IDC_CLOSE));

                // Check if job completed successfully
                if (WaitForSingleObject(hWorkerSucceededEvent_, 0) == WAIT_OBJECT_0)
                {
                    // Set task label to 'Done' and progress bar to full
                    SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), "Done");
                    PostMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETPOS, 1000, 0);
                }
                else
                {
                    // The job did not complete successfully

                    if (runnable_->isCancelled())
                    {
                        // Close the dialog following cancellation
                        EndDialog(hDlg, IDC_CLOSE);
                    }
                    else
                        SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), "Failed");
                }
            }

            if (!isTaskComplete_)
            {
                // Update current task display
                if (runnable_->isTaskStringDirty())
                {
                    auto newTaskString = String();
                    if (IsDlgButtonChecked(hDlg, IDC_SHOW_DETAILED_OUTPUT))
                        newTaskString = runnable_->getTaskString();
                    else
                        newTaskString = runnable_->getSimpleTaskString();

                    newTaskString += " ...";

                    // Check the new task string is different
                    if (currentTaskString_ != newTaskString)
                    {
                        SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), newTaskString.cStr());
                        currentTaskString_ = newTaskString;
                    }
                }

                // Update progress bar position
                if (runnable_->isPercentageDirty())
                {
                    auto position = runnable_->getPercentage() * 10.0f;
                    PostMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETPOS, int(position), 0);
                }
            }
        }

        return TRUE;
    }

    case WM_CLOSE:
    {
        // Close the dialog if the task is complete, otherwise cancel it
        if (isTaskComplete_)
            EndDialog(hDlg, IDC_CLOSE);
        else
            dialogProc(hDlg, WM_COMMAND, MAKEWPARAM(IDC_CANCEL, 0), 0);

        return TRUE;
    }

    case WM_COMMAND:
    {
        if (LOWORD(wParam) == IDC_CANCEL)
        {
            runnable_->cancel();
            EnableWindow(GetDlgItem(hDlg, IDC_CANCEL), FALSE);
            SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), "Cancelling ...");
        }
        else if (LOWORD(wParam) == IDC_CLOSE)
        {
            // Close the dialog
            EndDialog(hDlg, IDC_CLOSE);
        }
        else if (LOWORD(wParam) == IDC_SHOW_DETAILED_OUTPUT)
        {
            // Show/hide the detailed output
            auto showDetailedOutput = (IsDlgButtonChecked(hDlg, IDC_SHOW_DETAILED_OUTPUT) == BST_CHECKED);

            // Update output window visibility
            ShowWindow(GetDlgItem(hDlg, IDC_OUTPUT), showDetailedOutput);

            // Get sizes of the dialog items needed to do resize the dialog window correctly
            auto cancelRect = RECT();
            auto outputRect = RECT();
            auto dialogRect = RECT();
            GetWindowRect(GetDlgItem(hDlg, IDC_CANCEL), &cancelRect);
            GetWindowRect(GetDlgItem(hDlg, IDC_OUTPUT), &outputRect);
            GetWindowRect(hDlg, &dialogRect);

            auto heightDelta = (outputRect.bottom - cancelRect.bottom);
            if (!showDetailedOutput)
                heightDelta = -heightDelta;

            // Update dialog size
            SetWindowPos(hDlg, nullptr, 0, 0, dialogRect.right - dialogRect.left,
                         dialogRect.bottom - dialogRect.top + heightDelta, SWP_NOZORDER | SWP_NOMOVE);

            // Force the task string to update
            runnable_->setTaskStringDirty();

            // Update the persistent show detailed output setting
            settings().set(progressDialogShowDetailedOutputSetting, showDetailedOutput);
        }

        break;
    }
    }

    return FALSE;
}
Example #23
0
void CWebWindow::setTitle(const wchar_t* text)
{
    SetWindowTextW(m_hwnd, text);
}
Example #24
0
static INT_PTR CALLBACK ps_dlg_proc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
{
    /* native uses prop name "Structure", but we're not compatible
       with that so we'll prepend "Wine_". */
    static const WCHAR prop_name[] = {'W','i','n','e','_','S','t','r','u','c','t','u','r','e',0};
    ps_struct_t *ps_struct;

    TRACE("(%p, %04x, %08lx, %08lx)\n", hdlg, msg, wp, lp);

    ps_struct = GetPropW(hdlg, prop_name);

    if(msg != WM_INITDIALOG)
    {
        if(!ps_struct)
            return 0;

        if(ps_struct->ps->lpfnHook)
        {
            INT_PTR ret = ps_struct->ps->lpfnHook(hdlg, msg, wp, lp);
            if(ret) return ret;
        }
    }

    switch(msg)
    {
    case WM_INITDIALOG:
    {
        ps_struct = HeapAlloc(GetProcessHeap(), 0, sizeof(*ps_struct));
        ps_struct->ps = (OLEUIPASTESPECIALW*)lp;
        ps_struct->type_name = NULL;
        ps_struct->source_name = NULL;
        ps_struct->link_type_name = NULL;
        ps_struct->link_source_name = NULL;
        ps_struct->app_name = NULL;
        ps_struct->flags = ps_struct->ps->dwFlags;

        SetPropW(hdlg, prop_name, ps_struct);

        if(!(ps_struct->ps->dwFlags & PSF_SHOWHELP))
        {
            ShowWindow(GetDlgItem(hdlg, IDC_OLEUIHELP), SW_HIDE);
            EnableWindow(GetDlgItem(hdlg, IDC_OLEUIHELP), 0);
        }

        if(ps_struct->ps->lpszCaption)
            SetWindowTextW(hdlg, ps_struct->ps->lpszCaption);

        get_descriptors(hdlg, ps_struct);

        init_lists(hdlg, ps_struct);

        update_src_text(hdlg, ps_struct);

        selection_change(hdlg, ps_struct);

        SetFocus(GetDlgItem(hdlg, IDC_PS_DISPLAYLIST));

        if(ps_struct->ps->lpfnHook)
            ps_struct->ps->lpfnHook(hdlg, msg, 0, 0);
        return FALSE; /* use new focus */
    }
    case WM_COMMAND:
        switch(LOWORD(wp))
        {
        case IDC_PS_DISPLAYLIST:
            switch(HIWORD(wp))
            {
            case LBN_SELCHANGE:
                selection_change(hdlg, ps_struct);
                return FALSE;
            default:
                return FALSE;
            }
        case IDC_PS_PASTE:
        case IDC_PS_PASTELINK:
            switch(HIWORD(wp))
            {
            case BN_CLICKED:
                mode_change(hdlg, ps_struct, LOWORD(wp));
                return FALSE;

            default:
                return FALSE;
            }
        case IDC_OLEUIHELP:
            switch(HIWORD(wp))
            {
            case BN_CLICKED:
                post_help_msg(hdlg, ps_struct);
                return FALSE;
            default:
                return FALSE;
            }
        case IDOK:
        case IDCANCEL:
            switch(HIWORD(wp))
            {
            case BN_CLICKED:
                send_end_dialog_msg(hdlg, ps_struct, LOWORD(wp));
                return FALSE;
            default:
                return FALSE;
            }
        }
        return FALSE;
    default:
        if(msg == oleui_msg_enddialog)
        {
            if(wp == IDOK)
                update_structure(hdlg, ps_struct);
            EndDialog(hdlg, wp);
            /* native does its cleanup in WM_DESTROY */
            RemovePropW(hdlg, prop_name);
            free_structure(ps_struct);
            return TRUE;
        }
        return FALSE;
    }

}
Example #25
0
//! sets the caption of the window
void CIrrDeviceWinCE::setWindowCaption(const wchar_t* text)
{
    SetWindowTextW(HWnd, text);
}
Example #26
0
	void BaseManager::setWindowCaption(const std::wstring& _text)
	{
		SetWindowTextW(hWnd, _text.c_str());
	}
Example #27
0
/*****************************************************************************
 * EventThread: Create video window & handle its messages
 *****************************************************************************
 * This function creates a video window and then enters an infinite loop
 * that handles the messages sent to that window.
 * The main goal of this thread is to isolate the Win32 PeekMessage function
 * because this one can block for a long time.
 *****************************************************************************/
static void *EventThread( void *p_this )
{
    event_thread_t *p_event = (event_thread_t *)p_this;
    vout_display_t *vd = p_event->vd;
    MSG msg;
    POINT old_mouse_pos = {0,0}, mouse_pos;
    int canc = vlc_savecancel ();

    bool b_mouse_support = var_InheritBool( p_event->vd, "mouse-events" );
    bool b_key_support = var_InheritBool( p_event->vd, "keyboard-events" );

    vlc_mutex_lock( &p_event->lock );
    /* Create a window for the video */
    /* Creating a window under Windows also initializes the thread's event
     * message queue */
    if( Win32VoutCreateWindow( p_event ) )
        p_event->b_error = true;

    p_event->b_ready = true;
    vlc_cond_signal( &p_event->wait );

    const bool b_error = p_event->b_error;
    vlc_mutex_unlock( &p_event->lock );

    if( b_error )
    {
        vlc_restorecancel( canc );
        return NULL;
    }

    /* Prevent monitor from powering off */
    if (var_GetBool(vd, "disable-screensaver"))
        SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS );

    /* Main loop */
    /* GetMessage will sleep if there's no message in the queue */
    for( ;; )
    {
        vout_display_place_t place;
        video_format_t       source;

        if( !GetMessage( &msg, 0, 0, 0 ) )
        {
            vlc_mutex_lock( &p_event->lock );
            p_event->b_done = true;
            vlc_mutex_unlock( &p_event->lock );
            break;
        }

        /* Check if we are asked to exit */
        vlc_mutex_lock( &p_event->lock );
        const bool b_done = p_event->b_done;
        vlc_mutex_unlock( &p_event->lock );
        if( b_done )
            break;

        if( !b_mouse_support && isMouseEvent( msg.message ) )
            continue;

        if( !b_key_support && isKeyEvent( msg.message ) )
            continue;

        /* Handle mouse state */
        if( msg.message == WM_MOUSEMOVE ||
            msg.message == WM_NCMOUSEMOVE )
        {
            GetCursorPos( &mouse_pos );
            /* FIXME, why this >2 limits ? */
            if( (abs(mouse_pos.x - old_mouse_pos.x) > 2 ||
                (abs(mouse_pos.y - old_mouse_pos.y)) > 2 ) )
            {
                old_mouse_pos = mouse_pos;
                UpdateCursor( p_event, true );
            }
        }
        else if( isMouseEvent( msg.message ) )
        {
            UpdateCursor( p_event, true );
        }
        else if( msg.message == WM_VLC_HIDE_MOUSE )
        {
            UpdateCursor( p_event, false );
        }

        /* */
        switch( msg.message )
        {
        case WM_MOUSEMOVE:
            vlc_mutex_lock( &p_event->lock );
            place  = p_event->place;
            source = p_event->source;
            vlc_mutex_unlock( &p_event->lock );

            if( place.width > 0 && place.height > 0 )
            {
                if( msg.hwnd == p_event->hvideownd )
                {
                    /* Child window */
                    place.x = 0;
                    place.y = 0;
                }
                const int x = source.i_x_offset +
                    (int64_t)(GET_X_LPARAM(msg.lParam) - place.x) * source.i_width  / place.width;
                const int y = source.i_y_offset +
                    (int64_t)(GET_Y_LPARAM(msg.lParam) - place.y) * source.i_height / place.height;
                vout_display_SendEventMouseMoved(vd, x, y);
            }
            break;
        case WM_NCMOUSEMOVE:
            break;

        case WM_VLC_HIDE_MOUSE:
            break;

        case WM_LBUTTONDOWN:
            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_LEFT );
            break;
        case WM_LBUTTONUP:
            MouseReleased( p_event, MOUSE_BUTTON_LEFT );
            break;
        case WM_LBUTTONDBLCLK:
            vout_display_SendEventMouseDoubleClick(vd);
            break;

        case WM_MBUTTONDOWN:
            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_CENTER );
            break;
        case WM_MBUTTONUP:
            MouseReleased( p_event, MOUSE_BUTTON_CENTER );
            break;

        case WM_RBUTTONDOWN:
            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_RIGHT );
            break;
        case WM_RBUTTONUP:
            MouseReleased( p_event, MOUSE_BUTTON_RIGHT );
            break;

        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        {
            /* The key events are first processed here and not translated
             * into WM_CHAR events because we need to know the status of the
             * modifier keys. */
            int i_key = Win32VoutConvertKey( msg.wParam );
            if( !i_key )
            {
                /* This appears to be a "normal" (ascii) key */
                i_key = tolower( (unsigned char)MapVirtualKey( msg.wParam, 2 ) );
            }

            if( i_key )
            {
                if( GetKeyState(VK_CONTROL) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_CTRL;
                }
                if( GetKeyState(VK_SHIFT) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_SHIFT;
                }
                if( GetKeyState(VK_MENU) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_ALT;
                }

                vout_display_SendEventKey(vd, i_key);
            }
            break;
        }

        case WM_MOUSEWHEEL:
        {
            int i_key;
            if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 )
            {
                i_key = KEY_MOUSEWHEELUP;
            }
            else
            {
                i_key = KEY_MOUSEWHEELDOWN;
            }
            if( i_key )
            {
                if( GetKeyState(VK_CONTROL) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_CTRL;
                }
                if( GetKeyState(VK_SHIFT) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_SHIFT;
                }
                if( GetKeyState(VK_MENU) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_ALT;
                }
                vout_display_SendEventKey(vd, i_key);
            }
            break;
        }

        case WM_VLC_CHANGE_TEXT:
        {
            vlc_mutex_lock( &p_event->lock );
            wchar_t *pwz_title = NULL;
            if( p_event->psz_title )
            {
                const size_t i_length = strlen(p_event->psz_title);
                pwz_title = malloc( 2 * (i_length + 1) );
                if( pwz_title )
                {
                    mbstowcs( pwz_title, p_event->psz_title, 2 * i_length );
                    pwz_title[i_length] = 0;
                }
            }
            vlc_mutex_unlock( &p_event->lock );

            if( pwz_title )
            {
                SetWindowTextW( p_event->hwnd, pwz_title );
                if( p_event->hfswnd )
                    SetWindowTextW( p_event->hfswnd, pwz_title );
                free( pwz_title );
            }
            break;
        }

        default:
            /* Messages we don't handle directly are dispatched to the
             * window procedure */
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            break;

        } /* End Switch */

    } /* End Main loop */

    /* Check for WM_QUIT if we created the window */
    if( !p_event->hparent && msg.message == WM_QUIT )
    {
        msg_Warn( vd, "WM_QUIT... should not happen!!" );
        p_event->hwnd = NULL; /* Window already destroyed */
    }

    msg_Dbg( vd, "Win32 Vout EventThread terminating" );

    Win32VoutCloseWindow( p_event );
    vlc_restorecancel(canc);
    return NULL;
}
Example #28
0
BOOL UT_SetWindowText(HWND hWnd, const wchar_t * lpString)
{
	return SetWindowTextW(hWnd, lpString);
}
Example #29
0
HRESULT    CProxyDirect3D9::CreateDevice                ( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface )
{
// Do not change the code at the start of this function.
// Some graphic card drivers seem sensitive to the content of the CreateDevice function.
    HRESULT hResult;

    WriteDebugEvent ( "CProxyDirect3D9::CreateDevice" );

    WriteDebugEvent ( SString ( "    Adapter:%d  DeviceType:%d  BehaviorFlags:0x%x"
                                ,Adapter
                                ,DeviceType
                                ,BehaviorFlags
                            ) );

    // Make sure DirectX Get calls will work
    BehaviorFlags &= ~D3DCREATE_PUREDEVICE;

    WriteDebugEvent ( SString ( "    BackBufferWidth:%d  Height:%d  Format:%d  Count:%d"
                                ,pPresentationParameters->BackBufferWidth
                                ,pPresentationParameters->BackBufferHeight
                                ,pPresentationParameters->BackBufferFormat
                                ,pPresentationParameters->BackBufferCount
                           ) );

    WriteDebugEvent ( SString ( "    MultiSampleType:%d  Quality:%d"
                                ,pPresentationParameters->MultiSampleType
                                ,pPresentationParameters->MultiSampleQuality
                           ) );

    WriteDebugEvent ( SString ( "    SwapEffect:%d  Windowed:%d  EnableAutoDepthStencil:%d  AutoDepthStencilFormat:%d  Flags:0x%x"
                                ,pPresentationParameters->SwapEffect
                                ,pPresentationParameters->Windowed
                                ,pPresentationParameters->EnableAutoDepthStencil
                                ,pPresentationParameters->AutoDepthStencilFormat
                                ,pPresentationParameters->Flags
                           ) );

    WriteDebugEvent ( SString ( "    FullScreen_RefreshRateInHz:%d  PresentationInterval:0x%08x"
                                ,pPresentationParameters->FullScreen_RefreshRateInHz
                                ,pPresentationParameters->PresentationInterval
                           ) );


    // Change the window title to MTA: San Andreas
    #ifdef MTA_DEBUG
        SetWindowTextW ( hFocusWindow, MbUTF8ToUTF16("MTA: San Andreas [DEBUG]").c_str() );
    #else
        SetWindowTextW ( hFocusWindow, MbUTF8ToUTF16("MTA: San Andreas").c_str() );
    #endif

    // Detect if second call to CreateDevice
    if ( CreateDeviceSecondCallCheck( hResult, m_pDevice, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface ) )
    {
        return hResult;
    }

    // Enable the auto depth stencil parameter
    pPresentationParameters->EnableAutoDepthStencil = true;
    
    GetVideoModeManager ()->PreCreateDevice ( pPresentationParameters );

    // Create our object.
    hResult = m_pDevice->CreateDevice ( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface );

    // Store the rendering window in the direct 3d data
    CDirect3DData::GetSingleton ().StoreDeviceWindow ( pPresentationParameters->hDeviceWindow );

    // Make sure the object was created successfully.
    if ( hResult == D3D_OK )
    {
        // Apply input hook
        CMessageLoopHook::GetSingleton ( ).ApplyHook ( hFocusWindow );

        GetVideoModeManager ()->PostCreateDevice ( *ppReturnedDeviceInterface, pPresentationParameters );

        // We must first store the presentation values.
        CDirect3DData::GetSingleton ( ).StoreViewport ( 0, 0,
                                                        pPresentationParameters->BackBufferWidth,
                                                        pPresentationParameters->BackBufferHeight );
        
        // Calc and store readable depth format for shader use
        ERenderFormat ReadableDepthFormat = CDirect3DEvents9::DiscoverReadableDepthFormat ( *ppReturnedDeviceInterface, pPresentationParameters->MultiSampleType, pPresentationParameters->Windowed != 0 );
        CGraphics::GetSingleton ().GetRenderItemManager ()->SetDepthBufferFormat ( ReadableDepthFormat );

        // Now create the proxy device.
        *ppReturnedDeviceInterface = new CProxyDirect3DDevice9 ( *ppReturnedDeviceInterface );

        // Debug output
        D3DDEVICE_CREATION_PARAMETERS parameters;
        (*ppReturnedDeviceInterface)->GetCreationParameters ( &parameters );

        WriteDebugEvent ( SString ( "    Adapter:%d  DeviceType:%d  BehaviorFlags:0x%x  ReadableDepth:%s"
                                    ,parameters.AdapterOrdinal
                                    ,parameters.DeviceType
                                    ,parameters.BehaviorFlags
                                    ,ReadableDepthFormat ? std::string ( (char*)&ReadableDepthFormat, 4 ).c_str () : "None"
                                ) );
    }

    hResult = HandleCreateDeviceResult( hResult, m_pDevice, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface );

    return hResult;
}
Example #30
0
/***********************************************************************
 *         WININET_InvalidCertificateDialog
 */
static INT_PTR WINAPI WININET_InvalidCertificateDialog(
    HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    struct WININET_ErrorDlgParams *params;
    HWND hitem;
    WCHAR buf[1024];

    if( uMsg == WM_INITDIALOG )
    {
        TRACE("WM_INITDIALOG (%08lx)\n", lParam);

        /* save the parameter list */
        params = (struct WININET_ErrorDlgParams*) lParam;
        SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );

        switch( params->dwError )
        {
        case ERROR_INTERNET_INVALID_CA:
            LoadStringW( WININET_hModule, IDS_CERT_CA_INVALID, buf, 1024 );
            break;
        case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
            LoadStringW( WININET_hModule, IDS_CERT_DATE_INVALID, buf, 1024 );
            break;
        case ERROR_INTERNET_SEC_CERT_CN_INVALID:
            LoadStringW( WININET_hModule, IDS_CERT_CN_INVALID, buf, 1024 );
            break;
        case ERROR_INTERNET_SEC_CERT_ERRORS:
            /* FIXME: We should fetch information about the
             * certificate here and show all the relevant errors.
             */
            LoadStringW( WININET_hModule, IDS_CERT_ERRORS, buf, 1024 );
            break;
        default:
            FIXME( "No message for error %d\n", params->dwError );
            buf[0] = '\0';
        }

        hitem = GetDlgItem( hdlg, IDC_CERT_ERROR );
        SetWindowTextW( hitem, buf );

        return TRUE;
    }

    params = (struct WININET_ErrorDlgParams*)
                 GetWindowLongPtrW( hdlg, GWLP_USERDATA );

    switch( uMsg )
    {
    case WM_COMMAND:
        if( wParam == IDOK )
        {
            BOOL res = TRUE;

            if( params->dwFlags & FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS )
            {
                http_request_t *req = params->req;
                DWORD flags, size = sizeof(flags);

                InternetQueryOptionW( req->hdr.hInternet, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size );
                switch( params->dwError )
                {
                case ERROR_INTERNET_INVALID_CA:
                    flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
                    break;
                case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
                    flags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
                    break;
                case ERROR_INTERNET_SEC_CERT_CN_INVALID:
                    flags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
                    break;
                case ERROR_INTERNET_SEC_CERT_REV_FAILED:
                    flags |= SECURITY_FLAG_IGNORE_REVOCATION;
                    break;
                case ERROR_INTERNET_SEC_CERT_ERRORS:
                    if(flags & _SECURITY_FLAG_CERT_REV_FAILED)
                        flags |= SECURITY_FLAG_IGNORE_REVOCATION;
                    if(flags & _SECURITY_FLAG_CERT_INVALID_CA)
                        flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
                    if(flags & _SECURITY_FLAG_CERT_INVALID_CN)
                        flags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
                    if(flags & _SECURITY_FLAG_CERT_INVALID_DATE)
                        flags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
                    break;
                }
                /* FIXME: Use helper function */
                flags |= SECURITY_FLAG_SECURE;
                req->security_flags |= flags;
                if(req->netconn)
                    req->netconn->security_flags |= flags;
            }

            EndDialog( hdlg, res ? ERROR_SUCCESS : ERROR_NOT_SUPPORTED );
            return TRUE;
        }
        if( wParam == IDCANCEL )
        {
            TRACE("Pressed cancel.\n");

            EndDialog( hdlg, ERROR_CANCELLED );
            return TRUE;
        }
        break;
    }

    return FALSE;
}