void mxBitmapButton::redraw()
{
	HWND wnd = (HWND)getHandle();
	if ( !wnd )
		return;

	if ( !m_bmImage.valid )
		return;

	RECT rc;
	GetClientRect( wnd, &rc );
	
	HDC dc = GetDC( wnd );

	DrawBitmapToDC( dc, 0, 0, w(), h(), m_bmImage );

	ReleaseDC( wnd, dc );

	ValidateRect( wnd, &rc );
}
Ejemplo n.º 2
0
/*
** C256bmp message handlers
*/
void
C256bmp::OnPaint() 
{
    CPaintDC	dc(this); /* device context for painting */
    BITMAPINFO	*pb=GetBitmap();

    if (pb)
    {
	BITMAPINFOHEADER *pbh=( BITMAPINFOHEADER*)pb;
	HPALETTE hpal=CreateBIPalette (pbh);
	LPSTR pbits = (LPSTR)pbh + (WORD)pbh->biSize + PaletteSize(pbh);
	HPALETTE holdpal=::SelectPalette(dc.m_hDC,hpal,FALSE);
	if (!hSystemPalette) hSystemPalette=holdpal;
	::RealizePalette(dc.m_hDC);
	::SetDIBitsToDevice(dc.m_hDC,0,0,pbh->biWidth,pbh->biHeight,0,0,0,pbh->biHeight,pbits,pb,DIB_RGB_COLORS);
	::SelectPalette(dc.m_hDC,holdpal,FALSE);
	::DeleteObject(hpal);
    }
    ValidateRect(0);
}
Ejemplo n.º 3
0
//消息处理函数
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_PAINT:
		ValidateRect(hwnd, NULL);
		break;
	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE) 
		{
			DestroyWindow(hwnd);//销毁窗体并发送一个WM_DESTROY消息
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, message, wParam, lParam);
	}
}
Ejemplo n.º 4
0
	void drawGraph(HWND hwnd, HDC hdc) {
	
		HPEN oldPen = NULL;
		
		POINT pt;
		
		for(int i = 0; i < mChannels.size(); i++) {

			Channel* c = &mChannels[i];

			HPEN pen = CreatePen(PS_SOLID, 2, c->getColor());
			if(i == 0) {
				oldPen = (HPEN)SelectObject(hdc, pen);
			} else {
				SelectObject(hdc, pen);
			}

			for(int j = 1; j < c->getNumKeys(); j++) {
				Key* k1 = c->getKey(j-1);
				Key* k2 = c->getKey(j);
				int x1 = toScreenX(k1->x);
				int y1 = toScreenY(k1->y);
				int x2 = toScreenX(k2->x);
				int y2 = toScreenY(k2->y);
				MoveToEx(hdc, x1, y1, &pt);
				LineTo(hdc, x2, y2);
				Rectangle(hdc, x1-3, y1-3, x1+3, y1+3);
				Rectangle(hdc, x2-3, y2-3, x2+3, y2+3);
			}

			DeleteObject(pen);
	
		}

		SelectObject(hdc, oldPen);

		RECT r;
		GetClientRect(hwnd, &r);
		ValidateRect(hwnd, &r);

	}
Ejemplo n.º 5
0
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int res = 0;

	switch (message)
	{
		case WM_PAINT:
		{
			if (s_buffer)
			{
				StretchDIBits(s_hdc, 0, 0, s_width, s_height, 0, 0, s_width, s_height, s_buffer, 
							  &s_bitmapInfo, DIB_RGB_COLORS, SRCCOPY);

				ValidateRect(hWnd, NULL);
			}

			break;
		}

		case WM_KEYDOWN:
		{
			if ((wParam&0xFF) == 27) 
				s_close = 1;

			break;
		}

		case WM_CLOSE:
		{
			s_close = 1;
			break;
		}

		default:
		{
			res = DefWindowProc(hWnd, message, wParam, lParam);
		}
	}

	return res;
}
Ejemplo n.º 6
0
	virtual void repaint()
	{
		if ( retry_count && !restore_objects() ) return;

		lpdev->Clear( 0L, NULL, D3DCLEAR_TARGET, 0x000000ff, 1.0f, 0L );

		HRESULT rv = lpdev->BeginScene();

		if( SUCCEEDED( rv ) )
		{
			set_vertex( 0, 0, input_width, input_height, surface_width, surface_height, 0, 0, rcWindow.right, rcWindow.bottom );
			lpdev->SetTexture( 0, lptex );
			lpdev->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
			lpdev->EndScene();

			if ( lpdev->Present( NULL, NULL, NULL, NULL ) == D3DERR_DEVICELOST ) retry_count = 60;
		}
		else retry_count = 60;

		ValidateRect( hWnd, & rcWindow );
	}
Ejemplo n.º 7
0
LRESULT CALLBACK WinMainProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch (msg)
	{
	case WM_PAINT:	//客户区重绘
		Direct3DRender();//渲染图形
		ValidateRect(hWnd,NULL);//更新客户区显示
		break;
	case WM_DESTROY://窗口销毁消息
		Direct3DCleanup();//清理Direct3D
		PostQuitMessage(0);//退出
		break;
	case WM_KEYDOWN:
		if (wParam==VK_ESCAPE)//ESC键
		{
			DestroyWindow(hWnd);//销毁窗口,并发送一条WM_DESTROY消息
		}
		break;
	}
	return DefWindowProc(hWnd,msg,wParam,lParam);
}
Ejemplo n.º 8
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	switch (message)
	{
	case WM_CREATE:
		PlaySound(L"FirstBlood.wav", nullptr, SND_FILENAME | SND_ASYNC);
		break;

	case WM_PAINT:
		ValidateRect(hwnd, NULL);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
		
	default:
		return DefWindowProc(hwnd, message, wparam, lparam);
	}
	return 0;
}
Ejemplo n.º 9
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{

   switch(Message){
   case WM_CREATE:
     break;
   case WM_SIZE:  
     /* This is called with 0,0 when iconized. That is bad. So don't resize
	now.*/
     wWidth = LOWORD(lParam);  // width of client area 
     wHeight = HIWORD(lParam); // height of client area 
/*       printf("Resized: %d %d\n",wWidth,wHeight); */
     /*     AccisRenewBitmap(hwnd);*/
     break;
   case WM_PAINT:
/*       printf("Paint BitBlt\n"); */
     /*Trying for private DC*/
/*       hdcWindow = BeginPaint(hwnd, &ps); */
     BitBlt(hdcWindow, 0, 0, wWidth, wHeight, hdcMemory, 0, 0, SRCCOPY);
/*         EndPaint(hwnd, &ps); */
     GetClientRect(hwnd,&wRect);
     ValidateRect(hwnd,&wRect);/* Needed without endpaint. Not perfect.
				Resize leads to continuous BitBlt.
			       Needs new/current window size.*/
     break;
   case WM_CLOSE:
       /* It is not safe to do the following from the right-hand X.
	  Makes the program hang. The Default is also bad so act the same.*/
/*       DestroyWindow(hwnd); */
/*       break; */
   case WM_DESTROY:
   case WM_LBUTTONDOWN: /* Click in window to exit from this message loop. */
     DeleteDC(hdcMemory);
     PostQuitMessage(0);
     break;
   default:
     return DefWindowProc(hwnd, Message, wParam, lParam);
   }
   return 0;
}
Ejemplo n.º 10
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_CREATE:
	{
		if (FAILED(InitD3D(hWnd)))
		{
			MessageBox(hWnd, TEXT("Initialize DirectX failed"), TEXT("警告"), MB_OK | MB_ICONERROR);
			PostQuitMessage(0);
		}
		break;
	}
	case WM_PAINT:
		Render(hWnd);
		ValidateRect(hWnd, NULL);
		break;
	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
		{
			DestroyWindow(hWnd);
		}
		else
		{
			ChangeObject();
		}
		break;
	case WM_SIZE:
		OnSize((short)LOWORD(lParam), (short)HIWORD(lParam));
		break;
	case WM_DESTROY:
		Cleanup();
		PostQuitMessage(0);
		break;
	default:
		return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	return 0;
}
Ejemplo n.º 11
0
/*-----------------------------------------------------------------------------
    Name        : dbwWindowProc
    Description : Window Procedure for debug window
    Inputs      : see Windows docs
    Outputs     : "   "       "
    Return      : "   "       "
----------------------------------------------------------------------------*/
long FAR PASCAL dbwWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    RECT rect;
    switch (message)
    {
        case WM_SETFOCUS:
            SetFocus(ghMainWindow);
            break;
        case WM_MOVE:
            GetWindowRect(hWnd, &rect);
            dbwWindowX = rect.left;
            dbwWindowY = rect.top;
            return 0;
        case WM_PAINT:
            dbwAllPanesRepaint((HDC)wParam);
            ValidateRect(hDebugWindow, NULL);
            return 0;
        case WM_DESTROY:
            return 0;
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}
Ejemplo n.º 12
0
/***************************************************
OnPaint
	The framework calls this member function when Windows
	or an application makes a request to repaint a portion
	of an application’s window.
	The CUGHint uses this event to draw the tool tip
	window.
Params:
	<none>
Returns:
	<none>
*****************************************************/
void CUGHint::OnPaint() 
{
	if ( m_ctrl->m_GI->m_paintMode == FALSE )
		return;

	CDC* dc = GetDC();

	if(m_hFont != NULL)
		dc->SelectObject(m_hFont);
	
	CRect rect;
	GetClientRect(rect);

	dc->SetTextColor(m_textColor);
	dc->SetBkColor(m_backColor);

	dc->SetBkMode(OPAQUE);
	dc->DrawText(m_text,&rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);

	ReleaseDC(dc);
	ValidateRect(NULL);
}
Ejemplo n.º 13
0
LONG WINAPI PopupWndProc(HWND hWnd,UINT messg,UINT wParam,LONG lParam)
{
	int idPopup;
	HDC hdc;
	PAINTSTRUCT ps;
	static int xClientView,yClientView;
	static HWND hInst;
	static FARPROC fpfnAboutDiaProc;

	idPopup = GetWindowLong(hWnd, GWL_ID);
	switch (messg)
	{

          case WM_CREATE:
	    hdc =GetDC(hWnd);
	    GetTextMetrics(hdc, &tm);
	    ReleaseDC(hWnd,hdc);
	    wins[idPopup]->dwCharX = tm.tmAveCharWidth;
	    wins[idPopup]->dwCharY = tm.tmHeight;
	    return 0;

	  case WM_PAINT:
	    hdc=BeginPaint(hWnd,&ps);

	    ValidateRect(hWnd,0);
	    EndPaint(hWnd,&ps);
	    break;

	  case WM_DESTROY:
	    PostQuitMessage(0);
	    break;

	  case WM_VSCROLL:
	  case WM_HSCROLL:
	  default:
	    return(DefWindowProc(hWnd,messg,wParam,lParam));
	}
	return(0L);
}
Ejemplo n.º 14
0
//-----------------------------------------------------------------------------
// Purpose: Finish up
//-----------------------------------------------------------------------------
CDrawHelper::~CDrawHelper( void )
{
	SelectClipRgn( m_dcMemory, NULL );

	while ( m_ClipRects.Size() > 0 )
	{
		StopClipping();
	}

	BitBlt( m_dcReal, m_x, m_y, m_w, m_h, m_dcMemory, 0, 0, SRCCOPY );

	SetBkColor( m_dcMemory, m_clrOld );

	SelectObject( m_dcMemory, m_bmOld );
	DeleteObject( m_bmMemory );

	DeleteObject( m_dcMemory );

	ReleaseDC( m_hWnd, m_dcReal );

	ValidateRect( m_hWnd, &m_rcClient );
}
Ejemplo n.º 15
0
/**
 * Windows message process procedure
 */
LRESULT CALLBACK Application::winProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch( msg )
    {
        case WM_CLOSE:
            PostQuitMessage( 0 );
            return 0;
        
        case WM_ACTIVATE:
            isActive = HIWORD( wParam ) ? false : true;
            return 0;
            
        case WM_SYSCOMMAND:
            /* TODO (#1#): add here alt+tab or alt+enter */ 
            if (wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER)
                return 0;
            else
                break;

        case WM_PAINT:
            ValidateRect( hWnd, NULL );
            return 0;
            
        case WM_SIZE:
            Renderer::instance().resize( (int)LOWORD(lParam), (int)HIWORD(lParam) );
            return 0;
            
        case WM_KEYDOWN:
            keys[wParam] = true;
            return 0;
        
        case WM_KEYUP:
            keys[wParam] = false;
            return 0;
            
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}
Ejemplo n.º 16
0
LRESULT Win32DDFullScreen::wndProc( HWND hwnd,UINT msg,WPARAM wp,LPARAM lp,WNDPROC proc ){
	switch( msg ){
	case WM_PAINT:
		if( _excl!=this ){

		}else if( IsIconic(_hwnd.hwnd()) ){

		}else if( !primarySurface() ){

			//restore primary surface
			if( !_graphics->restore() ){
				//Argh! Don't work if an 'owned' window is active!!!!!
				break;
			}

			//create clipper
			if( _flags & BBScreen::SCREEN_GUICOMPATIBLE ){
				if( _clipper ){ _clipper->Release();_clipper=0; }
				if( win32DD.directDraw()->CreateClipper(0,&_clipper,0)<0 ){
					bbError( "Failed to create DD clipper" );
				}
				_clipper->SetHWnd( 0,_hwnd.hwnd() );
			}

			//fix gamma
//			updateGamma( false );

		}else if( _flags & BBScreen::SCREEN_GUICOMPATIBLE ){

			flip(false);
		}
		ValidateRect(hwnd,0);
		return 0;
	case WM_ERASEBKGND:
		return 1;
	}
	return Win32DDScreen::wndProc( hwnd,msg,wp,lp,proc );
}
Ejemplo n.º 17
0
static LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
	int result = 0, keycode = 0;
	switch (message)
	{
	case WM_PAINT:
		if (!buffer) break;
		StretchDIBits( window_hdc, 0, 0, SCRWIDTH, SCRHEIGHT, 0, 0, SCRWIDTH, SCRHEIGHT, buffer, bh, DIB_RGB_COLORS, SRCCOPY );
		ValidateRect( wnd, NULL );
		break;
	case WM_KEYDOWN:
		if ((wParam & 0xFF) != 27) break;
	case WM_CLOSE:
		ReleaseDC( wnd, window_hdc );
		DestroyWindow( wnd );
		SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, 1, 0, 0 );
		ExitProcess( 0 );
		break;
	default:
		result = DefWindowProc(hWnd,message,wParam,lParam);
	}
	return result;
}
Ejemplo n.º 18
0
long CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam){

	switch(uMessage){
	case WM_CREATE:
		{
			return 0;
		}
	case WM_PAINT:
		{
			ValidateRect(hWnd, NULL);//basically saying - yeah we took care of any paint msg without any overhead
			return 0;
		}
	case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		}
	default:
		{
			return DefWindowProc(hWnd, uMessage, wParam, lParam);
		}
	}
}
Ejemplo n.º 19
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_PAINT:					 // 客户区重绘消息
		Direct3D_Render(hwnd);          //调用Direct3D_Render函数,进行画面的绘制
		ValidateRect(hwnd, NULL);   // 更新客户区的显示
		break;									//跳出该switch语句

	case WM_KEYDOWN:                // 键盘按下消息
		if (wParam == VK_ESCAPE)    // ESC键
			DestroyWindow(hwnd);    // 销毁窗口, 并发送一条WM_DESTROY消息
		break;
	case WM_DESTROY:				//窗口销毁消息
		Direct3D_CleanUp();     //调用Direct3D_CleanUp函数,清理COM接口对象
		PostQuitMessage(0);		//向系统表明有个线程有终止请求。用来响应WM_DESTROY消息
		break;						//跳出该switch语句

	default:						//若上述case条件都不符合,则执行该default语句
		return DefWindowProc(hwnd, message, wParam, lParam);		//调用缺省的窗口过程来为应用程序没有处理的窗口消息提供缺省的处理。
	}
	return 0;
}
Ejemplo n.º 20
0
/* remove region from window update region*/
BOOL WINAPI
ValidateRgn(HWND hwnd, HRGN hrgn)
{
	if(hwnd) {
		if(!hrgn)
			/* remove client area from update region*/
			return ValidateRect(hwnd, NULL);

		/* passed region is in client coords, convert to screen*/
		GdOffsetRegion(((MWRGNOBJ *)hrgn)->rgn,
			hwnd->clirect.left, hwnd->clirect.top);
		GdSubtractRegion(hwnd->update, hwnd->update,
			((MWRGNOBJ *)hrgn)->rgn);
		GdOffsetRegion(((MWRGNOBJ *)hrgn)->rgn,
			-hwnd->clirect.left, -hwnd->clirect.top);

		/* if update region empty, mark window as painted*/
		if(hwnd->update->numRects == 0)
			if(hwnd->gotPaintMsg == PAINT_NEEDSPAINT)
				hwnd->gotPaintMsg = PAINT_PAINTED;
	}
	return TRUE;
}
Ejemplo n.º 21
0
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
static LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_KEYDOWN:
            if(wParam==VK_ESCAPE) 
			{
				g_bDone = true;
                Cleanup();
	            PostQuitMessage(0);
				return 0;
			}
            break;
        case WM_DESTROY:
			g_bDone = true;
            Cleanup();
            PostQuitMessage(0);
            return 0;
        case WM_PAINT:
            ValidateRect(hWnd, NULL);
            return 0;
    }
    return DefWindowProc(hWnd, msg, wParam, lParam);
}
Ejemplo n.º 22
0
static void sttDrawNonLayeredSkinedBar(HWND hwnd, HDC hdc)
{
	RECT rc = { 0 };
	GetClientRect(hwnd, &rc);
	rc.right++;
	rc.bottom++;
	HDC hdc2 = CreateCompatibleDC(hdc);
	HBITMAP hbmp = ske_CreateDIB32(rc.right, rc.bottom);
	HBITMAP hbmpo = (HBITMAP)SelectObject(hdc2, hbmp);
	if (GetParent(hwnd) != pcli->hwndContactList) {
		HBRUSH br = GetSysColorBrush(COLOR_3DFACE);
		FillRect(hdc2, &rc, br);
	}
	else ske_BltBackImage(hwnd, hdc2, &rc);

	SendMessage(hwnd, MTBM_LAYEREDPAINT, (WPARAM)hdc2, 0);
	BitBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdc2, rc.left, rc.top, SRCCOPY);
	SelectObject(hdc2, hbmpo);
	DeleteObject(hbmp);
	DeleteDC(hdc2);

	SelectObject(hdc, (HFONT)GetStockObject(DEFAULT_GUI_FONT));
	ValidateRect(hwnd, NULL);
}
Ejemplo n.º 23
0
void Ctrl::WndUpdate(const Rect& r)
{
	GuiLock __;
	Ctrl *top = GetTopCtrl();
	if(top->IsOpen()) {
		HWND hwnd = top->GetHWND();
		HDC hdc = GetDC(hwnd);
		HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
		if(GetUpdateRgn(hwnd, hrgn, FALSE) != NULLREGION) {
			SelectClipRgn(hdc, hrgn);
			SystemDraw draw(hdc);
			bool hcr = focusCtrl && focusCtrl->GetTopCtrl() == top &&
			           caretRect.Intersects(r + top->GetRect().TopLeft());
			if(hcr) ::HideCaret(hwnd);
			draw.Clip(r);
			top->UpdateArea(draw, r);
			ValidateRect(hwnd, r);
			SelectClipRgn(hdc, NULL);
			if(hcr) ::ShowCaret(hwnd);
		}
		ReleaseDC(hwnd, hdc);
		DeleteObject(hrgn);
	}
}
Ejemplo n.º 24
0
static BOOL 
TlbCustom_OnDrawItem 
(   
    	HWND                hwDlg, 
    	UINT                idCtl, 
    	LPDRAWITEMSTRUCT    lpdi 
) 
{
    	HWND                hwToolbar   = ( HWND )NULL;
    	HGLOBAL             hBtnText    = ( HGLOBAL )NULL;
    	LPSTR               pBtnText    = ( HWND )NULL;

    	int                 ErrorCode   = 0;

	if ( ! ( hwToolbar = GETTLBHANDLE ( hwDlg ) ) )
		ErrorCode = WTLB_ERR_GETWINPROP;
	else
	if ( ! ( hBtnText = GETBTNINFO ( hwDlg ) ) )
		ErrorCode = WTLB_ERR_GETWINPROP;
	else
	if ( ! ( pBtnText = GlobalLock ( hBtnText ) ) )
		ErrorCode = WTLB_ERR_GETWINPROP;
	else
    	if ( SendMessage ( GetDlgItem ( hwDlg, idCtl ), LB_GETCOUNT, 0, 0L ) > 0 )
    	{
    	    Toolbr_DrawDragLBxItem ( hwDlg, hwToolbar, lpdi, pBtnText );
#if 0
	    InvalidateRect ( lpdi->hwndItem, &lpdi->rcItem, TRUE );
	    ValidateRect ( lpdi->hwndItem, &lpdi->rcItem );
#endif
    	    GlobalUnlock ( hBtnText );
    	    return TRUE;
    	}

    	return FALSE;
}
Ejemplo n.º 25
0
void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_CLOSE:
		prepared = false;
		DestroyWindow(hWnd);
		PostQuitMessage(0);
		break;
	case WM_PAINT:
		ValidateRect(window, NULL);
		break;
	case WM_KEYDOWN:
		switch (wParam)
		{
		case 0x50:
			paused = !paused;
			break;
		case VK_ESCAPE:
			exit(0);
			break;
		}
		keyPressed((uint32_t)wParam);
		break;
	case WM_RBUTTONDOWN:
	case WM_LBUTTONDOWN:
	case WM_MBUTTONDOWN:
		mousePos.x = (float)LOWORD(lParam);
		mousePos.y = (float)HIWORD(lParam);
		break;
	case WM_MOUSEWHEEL:
	{
		short wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
		zoom += (float)wheelDelta * 0.005f * zoomSpeed;
		viewChanged();
		break;
	}
	case WM_MOUSEMOVE:
		if (wParam & MK_RBUTTON)
		{
			int32_t posx = LOWORD(lParam);
			int32_t posy = HIWORD(lParam);
			zoom += (mousePos.y - (float)posy) * .005f * zoomSpeed;
			mousePos = glm::vec2((float)posx, (float)posy);
			viewChanged();
		}
		if (wParam & MK_LBUTTON)
		{
			int32_t posx = LOWORD(lParam);
			int32_t posy = HIWORD(lParam);
			rotation.x += (mousePos.y - (float)posy) * 1.25f * rotationSpeed;
			rotation.y -= (mousePos.x - (float)posx) * 1.25f * rotationSpeed;
			mousePos = glm::vec2((float)posx, (float)posy);
			viewChanged();
		}
		if (wParam & MK_MBUTTON)
		{
			int32_t posx = LOWORD(lParam);
			int32_t posy = HIWORD(lParam);
			cameraPos.x -= (mousePos.x - (float)posx) * 0.01f;
			cameraPos.y -= (mousePos.y - (float)posy) * 0.01f;
			viewChanged();
			mousePos.x = (float)posx;
			mousePos.y = (float)posy;
		}
		break;
	case WM_SIZE:
		if ((prepared) && (wParam != SIZE_MINIMIZED))
		{
			destWidth = LOWORD(lParam);
			destHeight = HIWORD(lParam);
			if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED))
			{
				windowResize();
			}
		}
		break;
	case WM_EXITSIZEMOVE:
		if ((prepared) && ((destWidth != width) || (destHeight != height)))
		{
			windowResize();
		}
		break;
	}
}
Ejemplo n.º 26
0
/*****************************************************************************
 * DirectXEventProc: This is the window event processing function.
 *****************************************************************************
 * On Windows, when you create a window you have to attach an event processing
 * function to it. The aim of this function is to manage "Queued Messages" and
 * "Nonqueued Messages".
 * Queued Messages are those picked up and retransmitted by vout_Manage
 * (using the GetMessage and DispatchMessage functions).
 * Nonqueued Messages are those that Windows will send directly to this
 * procedure (like WM_DESTROY, WM_WINDOWPOSCHANGED...)
 *****************************************************************************/
static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
                                         WPARAM wParam, LPARAM lParam )
{
    event_thread_t *p_event;

    if( message == WM_CREATE )
    {
        /* Store vd for future use */
        p_event = (event_thread_t *)((CREATESTRUCT *)lParam)->lpCreateParams;
        SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_event );
        return TRUE;
    }
    else
    {
        LONG_PTR p_user_data = GetWindowLongPtr( hwnd, GWLP_USERDATA );
        p_event = (event_thread_t *)p_user_data;
        if( !p_event )
        {
            /* Hmmm mozilla does manage somehow to save the pointer to our
             * windowproc and still calls it after the vout has been closed. */
            return DefWindowProc(hwnd, message, wParam, lParam);
        }
    }
    vout_display_t *vd = p_event->vd;

#ifndef UNDER_CE
    /* Catch the screensaver and the monitor turn-off */
    if( message == WM_SYSCOMMAND &&
        ( (wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER ) )
    {
        //if( vd ) msg_Dbg( vd, "WinProc WM_SYSCOMMAND screensaver" );
        return 0; /* this stops them from happening */
    }
#endif
#if 0
    if( message == WM_SETCURSOR )
    {
        msg_Err(vd, "WM_SETCURSOR: %d (t2)", p_event->is_cursor_hidden);
        SetCursor( p_event->is_cursor_hidden ? p_event->cursor_empty : p_event->cursor_arrow );
        return 1;
    }
#endif
    if( message == WM_CAPTURECHANGED )
    {
        for( int button = 0; p_event->button_pressed; button++ )
        {
            unsigned m = 1 << button;
            if( p_event->button_pressed & m )
                vout_display_SendEventMouseReleased( p_event->vd, button );
            p_event->button_pressed &= ~m;
        }
        p_event->button_pressed = 0;
        return 0;
    }

    if( hwnd == p_event->hvideownd )
    {
#ifdef MODULE_NAME_IS_directx
        vlc_mutex_lock( &p_event->lock );
        const bool use_overlay = p_event->use_overlay;
        vlc_mutex_unlock( &p_event->lock );
#endif

        switch( message )
        {
#ifdef MODULE_NAME_IS_directx
        case WM_ERASEBKGND:
        /* For overlay, we need to erase background */
            return !use_overlay ? 1 : DefWindowProc(hwnd, message, wParam, lParam);
        case WM_PAINT:
        /*
        ** For overlay, DefWindowProc() will erase dirty regions
        ** with colorkey.
        ** For non-overlay, vout will paint the whole window at
        ** regular interval, therefore dirty regions can be ignored
        ** to minimize repaint.
        */
            if( !use_overlay )
            {
                ValidateRect(hwnd, NULL);
            }
            // fall through to default
#else
        /*
        ** For OpenGL and Direct3D, vout will update the whole
        ** window at regular interval, therefore dirty region
        ** can be ignored to minimize repaint.
        */
        case WM_ERASEBKGND:
            /* nothing to erase */
            return 1;
        case WM_PAINT:
            /* nothing to repaint */
            ValidateRect(hwnd, NULL);
            // fall through
#endif
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
        }
    }

    switch( message )
    {

    case WM_WINDOWPOSCHANGED:
        vlc_mutex_lock( &p_event->lock );
        p_event->has_moved = true;
        vlc_mutex_unlock( &p_event->lock );
        return 0;

    /* the user wants to close the window */
    case WM_CLOSE:
        vout_display_SendEventClose(vd);
        return 0;

    /* the window has been closed so shut down everything now */
    case WM_DESTROY:
        msg_Dbg( vd, "WinProc WM_DESTROY" );
        /* just destroy the window */
        PostQuitMessage( 0 );
        return 0;

    case WM_SYSCOMMAND:
        switch (wParam)
        {
        case IDM_TOGGLE_ON_TOP:            /* toggle the "on top" status */
        {
            msg_Dbg(vd, "WinProc WM_SYSCOMMAND: IDM_TOGGLE_ON_TOP");
            HMENU hMenu = GetSystemMenu(vd->sys->hwnd, FALSE);
            vout_display_SendWindowState(vd, (GetMenuState(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND) & MF_CHECKED) ?
                    VOUT_WINDOW_STATE_NORMAL : VOUT_WINDOW_STATE_ABOVE);
            return 0;
        }
        default:
            break;
        }
        break;

    case WM_PAINT:
    case WM_NCPAINT:
    case WM_ERASEBKGND:
        return DefWindowProc(hwnd, message, wParam, lParam);

    case WM_KILLFOCUS:
#ifdef MODULE_NAME_IS_wingapi
        GXSuspend();
#endif
#ifdef UNDER_CE
        if( hwnd == p_event->hfswnd )
        {
            HWND htbar = FindWindow( _T("HHTaskbar"), NULL );
            ShowWindow( htbar, SW_SHOW );
        }

        if( !p_event->hparent ||
            hwnd == p_event->hfswnd )
        {
            SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
        }
#endif
        return 0;

    case WM_SETFOCUS:
#ifdef MODULE_NAME_IS_wingapi
        GXResume();
#endif
#ifdef UNDER_CE
        /* FIXME vd->cfg is not lock[ed/able] */
#warning "FIXME: race condition"
        if( p_event->hparent &&
            hwnd != p_event->hfswnd && vd->cfg->is_fullscreen )
            vout_display_SendEventFullscreen(vd, false);

        if( hwnd == p_event->hfswnd )
        {
            HWND htbar = FindWindow( _T("HHTaskbar"), NULL );
            ShowWindow( htbar, SW_HIDE );
        }

        if( !p_event->hparent ||
            hwnd == p_event->hfswnd )
        {
            SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
        }
#endif
        return 0;

    default:
        //msg_Dbg( vd, "WinProc WM Default %i", message );
        break;
    }

    /* Let windows handle the message */
    return DefWindowProc(hwnd, message, wParam, lParam);
}
Ejemplo n.º 27
0
		void iRenderer::Initialize3D()
		{
			// DirectX オブジェクトの生成
			m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
			assert(m_pD3D);

			// プレゼンテーションパラメータの設定
			{
				D3DDISPLAYMODE disp_mode;
				m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &disp_mode);

				ZeroMemory(&m_D3DPresentParam, sizeof(D3DPRESENT_PARAMETERS));

				m_D3DPresentParam.BackBufferFormat			= disp_mode.Format;
				//m_D3DPresentParam.BackBufferWidth			= 512;
				//m_D3DPresentParam.BackBufferHeight			= static_cast<int>(512.f / GetAspect());
				m_D3DPresentParam.BackBufferCount			= 1;
				m_D3DPresentParam.SwapEffect				= D3DSWAPEFFECT_DISCARD;
				m_D3DPresentParam.EnableAutoDepthStencil	= TRUE;
				m_D3DPresentParam.AutoDepthStencilFormat	= D3DFMT_D16;
				m_D3DPresentParam.Windowed					= m_IsFullScreen ? FALSE : TRUE;
			}

			// デバイスオブジェクトの生成
			{
				HRESULT result;

				// 高度なハードウェアデバイス
				result = m_pD3D->CreateDevice(
					D3DADAPTER_DEFAULT,
					D3DDEVTYPE_HAL,
					m_hwnd,
					D3DCREATE_HARDWARE_VERTEXPROCESSING,
					&m_D3DPresentParam,
					&GetGlobalInstance()->GetDeviceInformation()->pDevice
					);

				// 失敗したら
				if ( FAILED(result) )
				{
					// ソフトウェアデバイス
					result = m_pD3D->CreateDevice(
						D3DADAPTER_DEFAULT,
						D3DDEVTYPE_HAL,
						m_hwnd,
						D3DCREATE_SOFTWARE_VERTEXPROCESSING,
						&m_D3DPresentParam,
						&GetGlobalInstance()->GetDeviceInformation()->pDevice
						);

					// 失敗したら
					if ( FAILED(result) )
					{
						// ソフトウェアデバイス
						result = m_pD3D->CreateDevice(
							D3DADAPTER_DEFAULT,
							D3DDEVTYPE_REF,
							m_hwnd,
							D3DCREATE_SOFTWARE_VERTEXPROCESSING,
							&m_D3DPresentParam,
							&GetGlobalInstance()->GetDeviceInformation()->pDevice
							);

						// 失敗
						assert ( ! result );
					}
				}
			}

			// WM_PAINTを呼ばないようにする
			ValidateRect(m_hwnd, NULL);
		}
Ejemplo n.º 28
0
// Window procedure, handles all messages for this program
LRESULT CALLBACK WndProc(	HWND 	hWnd,
							UINT	message,
							WPARAM	wParam,
							LPARAM	lParam)
	{
	static HGLRC hRC;		// Permenant Rendering context
	static HDC hDC;			// Private GDI Device context

	switch (message)
	   	{
		// Window creation, setup for OpenGL
		case WM_CREATE:
			// Store the device context
			hDC = GetDC(hWnd);		

			// Select the pixel format
			SetDCPixelFormat(hDC);		

			// Create the rendering context and make it current
			hRC = wglCreateContext(hDC);
			wglMakeCurrent(hDC, hRC);

			// Create a timer that fires 30 times a second
			SetTimer(hWnd,33,1,NULL);
			break;

		// Window is being destroyed, cleanup
		case WM_DESTROY:
			// Kill the timer that we created
			KillTimer(hWnd,101);

			// Deselect the current rendering context and delete it
			wglMakeCurrent(hDC,NULL);
			wglDeleteContext(hRC);

			// Tell the application to terminate after the window
			// is gone.
			PostQuitMessage(0);
			break;
        
		// Window is resized.
		case WM_SIZE:
			// Call our function which modifies the clipping
			// volume and viewport
			ChangeSize(LOWORD(lParam), HIWORD(lParam));
			break;

		// Timer, moves and bounces the rectangle, simply calls
		// our previous OnIdle function, then invalidates the 
		// window so it will be redrawn.
		case WM_TIMER:
			{
			IdleFunction();
		
			InvalidateRect(hWnd,NULL,FALSE);
			}
			break;

		// The painting function.  This message sent by Windows 
		// whenever the screen needs updating.
		case WM_PAINT:
			{
			// Call OpenGL drawing code
			RenderScene();

			// Call function to swap the buffers
			SwapBuffers(hDC);

			// Validate the newly painted client area
			ValidateRect(hWnd,NULL);
			}
			break;



        default:   // Passes it on if unproccessed
            return (DefWindowProc(hWnd, message, wParam, lParam));

        }

    return (0L);
	}
Ejemplo n.º 29
0
//*------------------------------------------------------------------------
//| WctFleditWndProc
//|
//| PURPOSE:    Window procedure for the Fledit window.
//|
//| ENTRY/EXIT: Per Windows convention
//*------------------------------------------------------------------------
LONG  APIENTRY WctFleditWndProc(HWND hWnd, UINT wMsgID,
                                 WPARAM wParam, LPARAM lParam )
{
        HANDLE  hBuffer;
        LPSTR   lpBuffer, lpFNameTemp;
        RECT    rect;
        HDC     hdc;
        static  HWND  hWndEdit;
        static  TEXTMETRIC tm;
        static  CHAR szFileName[80];
        HFONT   hFont;

        switch( wMsgID ) {
            case WM_CREATE:
                GetClientRect (hWnd, &rect);

                hdc = GetDC(hWnd);
                GetTextMetrics(hdc, (LPTEXTMETRIC)&tm);

                hWndEdit = CreateWindow("EDIT", "",
                   WS_CHILD | WS_VSCROLL | WS_HSCROLL | ES_AUTOVSCROLL |
                   ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE | ES_MULTILINE,
                   0, tm.tmHeight,rect.right, rect.bottom - tm.tmHeight,
                   hWnd, NULL, hgInstWct, 0L);

                ReleaseDC(hWnd, hdc);

                lpFNameTemp = (LPSTR)(((LPCREATESTRUCT)lParam)->lpszName);

                // Use lParam as LPSTR to file to load.
                //--------------------------------------------------------
                if ( lpFNameTemp != NULL)
                        if ((hBuffer = WctReadFile(lpFNameTemp, sp)) != NULL)
                            {
                                lpBuffer = (LPSTR)GlobalLock(hBuffer);
                                if (lpBuffer != NULL)
                                {
                                    SetWindowText(hWndEdit, lpBuffer);
                                    GlobalUnlock(hBuffer);
                                }
                                GlobalFree(hBuffer);
                           }

                // After reading in file NULL terminate text if too Long.
                //--------------------------------------------------------
                if ( lstrlen(lpFNameTemp) > 72)
                        *(lpFNameTemp+72) = '\0';

                wsprintf(szFileName, "FILE: %s", (LPSTR)lpFNameTemp);

                hdc = GetDC(hWnd);
                GetTextMetrics(hdc, (LPTEXTMETRIC)&tm);
                hFont = GetStockObject(ANSI_VAR_FONT);
                SelectObject(hdc, hFont);
                DeleteObject(SelectObject(hdc, GetStockObject(BLACK_PEN)));
                TextOut(hdc, 0, 0, (LPSTR)szFileName,
                        lstrlen((LPSTR)szFileName));
                DeleteObject(SelectObject(hdc, hFont));
                ReleaseDC(hWnd, hdc);

                SetWindowText(hWnd, "Compare Results");
                break;

           case WM_SIZE:
                GetClientRect (hWnd, (LPRECT)&rect);
                SetWindowPos (hWndEdit, NULL, 0, 0, rect.right,
                            rect.bottom - tm.tmHeight, SWP_NOMOVE);
                break;

           case WM_SETFOCUS:
                SetFocus(hWndEdit);
                break;

           case WM_PAINT:
                ValidateRect (hWnd, (LPRECT)NULL);
                hdc = GetDC(hWnd);
                DeleteObject(SelectObject(hdc, GetStockObject(BLACK_PEN)));
                hFont = GetStockObject(ANSI_VAR_FONT);
                SelectObject(hdc, hFont);
                TextOut(hdc, 0, 0, (LPSTR)szFileName,
                        lstrlen((LPSTR)szFileName));
                DeleteObject(SelectObject(hdc, hFont));
                ReleaseDC(hWnd, hdc);
                break;

           case WM_CHAR:
                if (wParam == VK_ESCAPE)
                    {
                        DestroyWindow (hWndEdit);
                        DestroyWindow (hWnd);
                    }
                break;

           default:
                return ( DefWindowProc(hWnd, wMsgID, wParam, lParam));
           }

        return (0L);
}
Ejemplo n.º 30
0
//This function processes any Windows messages we get. Keyboard, OnClose, etc
LRESULT CALLBACK ProcessMessages(HWND__ *hWnd,unsigned int Msg,
                                 WPARAM wParam, LPARAM lParam)
{
    uint16_t MouseOver;
    switch (Msg)
    {
    case WM_DEADCHAR:
    case WM_CHAR:
        lastchar = (int)wParam;
        switch (lastchar){
            case VK_RETURN: //Reroute ENTER key for compatilbity purposes
                lastchar=10;
                break;
            case VK_BACK: //Reroute BACKSPACE key for compatilbity purposes
                lastchar=127;
                break;
        }
        return 0;

    case WM_KEYDOWN:                //Here we handle non-character input
        switch (wParam){
            case VK_LEFT:
                lastchar = KEY_LEFT;
                break;
            case VK_RIGHT:
                lastchar = KEY_RIGHT;
                break;
            case VK_UP:
                lastchar = KEY_UP;
                break;
            case VK_DOWN:
                lastchar = KEY_DOWN;
                break;
            case VK_NEXT:
                lastchar = KEY_NPAGE;
                break;
            case VK_PRIOR:
                lastchar = KEY_PPAGE;
                break;
            case VK_F1:
                lastchar = KEY_F(1);
                break;
            case VK_F2:
                lastchar = KEY_F(2);
                break;
            case VK_F3:
                lastchar = KEY_F(3);
                break;
            case VK_F4:
                lastchar = KEY_F(4);
                break;
            case VK_F5:
                lastchar = KEY_F(5);
                break;
            case VK_F6:
                lastchar = KEY_F(6);
                break;
            case VK_F7:
                lastchar = KEY_F(7);
                break;
            case VK_F8:
                lastchar = KEY_F(8);
                break;
            case VK_F9:
                lastchar = KEY_F(9);
                break;
            case VK_F10:
                lastchar = KEY_F(10);
                break;
            case VK_F11:
                lastchar = KEY_F(11);
                break;
            case VK_F12:
                lastchar = KEY_F(12);
                break;
            default:
                break;
        };
        return 0;

    case WM_KEYUP:
        if (!GetAsyncKeyState(VK_LMENU) && alt_down){ // LeftAlt hack
            if (int code = end_alt_code())
                lastchar = code;
        }
        return 0;

    case WM_SYSCHAR:
        add_alt_code((char)wParam);
        return 0;

    case WM_SYSKEYDOWN:
        if (GetAsyncKeyState(VK_LMENU) && !alt_down){ // LeftAlt hack
            begin_alt_code();
        }
        break;

    case WM_SETCURSOR:
        MouseOver = LOWORD(lParam);
        if (OPTIONS["HIDE_CURSOR"] == "hide")
        {
            if (MouseOver==HTCLIENT && CursorVisible)
            {
                CursorVisible = false;
                ShowCursor(false);
            }
            else if (MouseOver!=HTCLIENT && !CursorVisible)
            {
                CursorVisible = true;
                ShowCursor(true);
            }
        }
        else if (!CursorVisible)
        {
            CursorVisible = true;
            ShowCursor(true);
        }
        break;

    case WM_ERASEBKGND:
        return 1; // Don't erase background

    case WM_PAINT:
        BitBlt(WindowDC, 0, 0, WindowWidth, WindowHeight, backbuffer, 0, 0,SRCCOPY);
        ValidateRect(WindowHandle,NULL);
        return 0;

    case WM_DESTROY:
        exit(0); // A messy exit, but easy way to escape game loop
    };

    return DefWindowProcW(hWnd, Msg, wParam, lParam);
}