Beispiel #1
0
BOOL
CHyperLink:: ModifyLinkStyle( DWORD dwRemove, DWORD dwAdd,
                             BOOL bApply /* =TRUE */ )
{
   // Check if we are adding and removing the same style.
   if ( (dwRemove & dwAdd) != 0 )
      return( FALSE );

   // Remove old styles and set the new ones
   CLEARBITS( m_dwStyle, dwRemove );
   SETBITS( m_dwStyle, dwAdd );

   if ( bApply && mIs_hWnd( GetSafeHwnd( ) ) )
   {
      // If possible, APPLY the new styles on the fly.
      if ( BITSET( dwAdd, StyleUnderline ) ||
           BITSET( dwRemove, StyleUnderline ) )
      {
         SwitchUnderline( );
      }

      if ( BITSET( dwAdd, StyleAutoSize ) )
         AdjustWindow( );

      if ( BITSET( dwRemove, StyleUseHover ) )
         Invalidate( );
   }

   return( TRUE );
}
Beispiel #2
0
void TToolTipView::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
//		case B_SOME_APP_ACTIVATED:
//			msg->FindBool("active", &fTip.app_active);
//			break;

		case eToolTipStart:
			{
				const char	*str;

				// extract parameters
				msg->FindInt32("WorkSpaces", &fTip.WorkSpaces);
				msg->FindPoint("start", &fTip.start);
				msg->FindRect("bounds", &fTip.bounds);
				msg->FindString("string", &str);
				free(fString);
				fString = (char *)malloc(strlen(str) + 1);
				strcpy(fString, str);

				// force window to fit new parameters
				AdjustWindow();

				// flag thread to reset
				fTip.reset = true;
			}
			break;

		case eToolTipStop:
			// flag thread to stop
			fTip.stop = true;
			break;
	}
}
Beispiel #3
0
	void OGL4RenderWindow::Resize(int cx, int cy, bool fullscreen)
	{
		LONG_PTR value = GetWindowLongPtr(m_hWnd, GWL_STYLE);
		m_fullscreen = fullscreen;
		if(fullscreen == false)
		{
			value &= ~(WS_POPUP);
			value |= (WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU);

			SetWindowLongPtr(m_hWnd, GWL_STYLE, value);
			
			SetWindowPos( m_hWnd, 0, 0, 0, cx, cy, SWP_NOZORDER );
			AdjustWindow(cx, cy);
			CenterWindow();
			m_width			= cx;
			m_height		= cy;
		}
		else
		{
			int screen_w = GetSystemMetrics(SM_CXSCREEN);
			int screen_h = GetSystemMetrics(SM_CYSCREEN);
			
			value &= ~(WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU);
			value |= (WS_POPUP);

			SetWindowLongPtr(m_hWnd, GWL_STYLE, value);
			SetWindowPos( m_hWnd, 0, 0, 0, screen_w, screen_h, SWP_NOZORDER );

			m_width			= screen_w;
			m_height		= screen_h;
		}
	}
Beispiel #4
0
		//--------------------------------------------------------//
		//	created:	19:11:2009   18:29
		//	filename: 	d:\Develop\StarGame\GameSDK\GameUILib\Source\XUI_Wnd.cpp
		//	author:		Albert.xu
		//
		//	purpose:	查找能包容整个矩形的最深Wnd
		//--------------------------------------------------------//
		bool XUI_Wnd::FindRectIn( const iRect &rc, std::list< XUI_Wnd* >& l )
		{
			iRect rcAdjust(rc);
			AdjustWindow( rcAdjust, true);

			iRect rcWindow = GetWindowRect();
			if( rcWindow.PtInRect( rc.TopLeft() ) && rcWindow.PtInRect( rc.BottomRight() ) )
			{
				for( size_t i = 0; i < m_pChildren.size(); ++i )
				{
					XUI_Wnd* pElement = m_pChildren[i];
					iRect rcChildren = pElement->GetWindowRect();
					if( rc.PtInRect( rcChildren.TopLeft() ) && rc.PtInRect( rcChildren.BottomRight() ) )
					{
						l.push_back( pElement );
					}
					else if( pElement->FindRectIn( rcAdjust - m_WindowPosition, l ) )
					{
						return true;
					}
				}
				return true;
			}
			return false;
		}
Beispiel #5
0
void CEx_DrawView::OnSize(UINT nType, int cx, int cy) 
{
	CScrollView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
    BOOL bNeedAdjustWindow = FALSE;
    if (cx > VIEW_WIDTH)  { m_size.cx = cx + 20;   bNeedAdjustWindow = TRUE; }
    if (cy > VIEW_HEIGHT) { m_size.cy = cy + 20;   bNeedAdjustWindow = TRUE; }
    if (bNeedAdjustWindow) AdjustWindow();
}
Beispiel #6
0
void
pp::WindowManager::BorderManager::Enable (void)
{
  window.borderless = false;

  SetWindowLongW (window.hwnd, GWL_STYLE,   WS_OVERLAPPEDWINDOW);
  SetWindowLongW (window.hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);

  AdjustWindow ();
}
Beispiel #7
0
void CHyperLink::SetURL(CString strURL)
{
	m_strURL = strURL;

	if (::IsWindow(GetSafeHwnd())) {
		ShowWindow(SW_HIDE);
		AdjustWindow();
		m_ToolTip.UpdateTipText(strURL, this, TOOLTIP_ID);
		ShowWindow(SW_SHOW);
	}
}
Beispiel #8
0
void
CHyperLink::SetURL( CString csURL )
{
   m_csURL = csURL;

   if ( mIs_hWnd( GetSafeHwnd( ) ) )
   {
      ShowWindow( SW_HIDE );
      AdjustWindow( );
      m_ToolTip.UpdateTipText( csURL, this, TOOLTIP_ID );
      ShowWindow( SW_SHOW );
   }
}
void CInfoWindow::ShowInfo(HWND hparent,
	POINT pt,
	LPCTSTR pszText)
{
	assert(IsMainThread());
	this->KillTimer(_nTimerId);
	ShowWindow(SW_HIDE);
	SetText(pszText);

//	SetParent(hparent);
	AdjustWindow(hparent,pt);
	ShowWindow(SW_SHOWNORMAL);
	this->SetTimer(_nTimerId,1500);
}
Beispiel #10
0
void
CHyperLink::PreSubclassWindow( )
{
   // If the URL string is empty try to set it to the window text.
   if ( m_csURL.IsEmpty( ) )
      GetWindowText( m_csURL );

   // Check that the window text isn't empty.  If so, set it as URL string.
   CString csWndText;
   GetWindowText( csWndText );
   if ( csWndText.IsEmpty( ) )
   {
      // Set the URL string as the window text
      ASSERT( m_csURL.IsEmpty( ) == FALSE ); // window text and URL both empty!
      CStatic::SetWindowText( m_csURL );
   }

   // Get the current window font
   CFont *pFont = GetFont( );

   if ( pFont )
   {
      LOGFONT lf;
      pFont->GetLogFont( &lf );
      lf.lfUnderline = BITSET( m_dwStyle, StyleUnderline );
      if ( m_Font.CreateFontIndirect( &lf ) )
         CStatic::SetFont( &m_Font );

      // Adjust window size to fit URL if necessary.
      AdjustWindow( );
   }
   else
   {
      // If GetFont returns 0 then the static control is probably not of a
      // text type: it's better to set auto-resizing off.
      CLEARBITS( m_dwStyle, StyleAutoSize );
   }

   if ( !BITSET( m_dwStyle, StyleNoHandCursor ) )
      SetDefaultCursor( );      // try to load a "hand" cursor

    // Create the tooltip.
    CRect rect;
    GetClientRect( rect );
    m_ToolTip.Create( this );
    m_ToolTip.AddTool( this, m_csURL, rect, TOOLTIP_ID );

    CStatic::PreSubclassWindow( );
}
Beispiel #11
0
void CHyperLink::SetWindowText(LPCTSTR lpszText)
{
	ASSERT(lpszText != NULL);

	if (::IsWindow(GetSafeHwnd())) {
		// Set the window text and adjust its size while the window
		// is kept hidden in order to allow dynamic modification
		ShowWindow(SW_HIDE);                // Hide window
		// Call the base class SetWindowText()
		CStatic::SetWindowText(lpszText);
		// Resize the control if necessary
		AdjustWindow();
		ShowWindow(SW_SHOW);                // Show window
	}
}
Beispiel #12
0
void TToolTipView::SetSettings(tool_tip_settings *settings)
{
	bool	invalidate = fTip.settings.font != settings->font;

	// we should probably sanity-check user defined settings (but we won't)
	fTip.settings = *settings;

	// if the font changed, adjust window to fit
	if (invalidate) {
		Window()->Lock();
		SetFont(&fTip.settings.font);
		AdjustWindow();
		Window()->Unlock();
	}
}
Beispiel #13
0
void CEx_DrawView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

    m_pBar = &static_cast<CMainFrame*>(AfxGetMainWnd())->m_wndStatusBar;
    m_pToolbar = &static_cast<CMainFrame*>(AfxGetMainWnd())->m_wndToolBar;
    ASSERT(m_pBar && m_pToolbar);

    m_tabFont.CreateFont(20, 10, 0, 0, 12, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
        OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, TEXT("宋体"));

    GetDocument()->UpdateAllViews(NULL, 0x4000);
	SetScrollSizes( MM_TEXT, CSize( m_size.cx, m_size.cy ) );

    AdjustWindow();
}
Beispiel #14
0
void CHyperLink::PreSubclassWindow() 
{		    
  // Get the current window font	
  CFont* pFont = GetFont();	
  
  if (pFont != NULL) {
    LOGFONT lf;
    pFont->GetLogFont(&lf);
    lf.lfUnderline = TRUE;
    if (Font.CreateFontIndirect(&lf))
      CClickStatic::SetFont(&Font);    
    // Adjust window size to fit URL if necessary
    AdjustWindow();
  };
  
  CClickStatic::PreSubclassWindow();
}
Beispiel #15
0
void CHyperLink::SetFont(CFont* pFont)
{
	ASSERT(::IsWindow(GetSafeHwnd()));
	ASSERT(pFont != NULL);

	// Set the window font and adjust its size while the window
	// is kept hidden in order to allow dynamic modification
	ShowWindow(SW_HIDE);                // Hide window
	LOGFONT lf;
	// Create the new font
	pFont->GetLogFont(&lf);
	m_Font.DeleteObject();
	m_Font.CreateFontIndirect(&lf);
	// Call the base class SetFont()
	CStatic::SetFont(&m_Font);
	// Resize the control if necessary
	AdjustWindow();
	ShowWindow(SW_SHOW);                // Show window    
}
Beispiel #16
0
void
CHyperLink::SetWindowText( zCPCHAR cpcText )
{
   ASSERT( cpcText );

   if ( mIs_hWnd( GetSafeHwnd( ) ) )
   {
      // Set the window text and adjust its size while the window
      // is kept hidden in order to allow dynamic modification.
      ShowWindow( SW_HIDE );          // hide window

      // Call the base class SetWindowText( ).
      CStatic::SetWindowText( cpcText );

      // Resize the control if necessary.
      AdjustWindow( );
      ShowWindow( SW_SHOW );          // show window
   }
}
Beispiel #17
0
/*
==================
Channel::
==================
*/
void Channel::HandleMessage(const ubyte *data, uint32 len) {
	if (winSizeIn < 5000) {
		AdjustWindow(15000);
	}

	if (!len || !data) {
		Warning("Channel::HandleMessage(): NULL-data given!");
		return;
	}

	if (!IsPacketForMe(data, len)) {
		return;
	}

	winSizeIn -= len;

	Packet p(data, len);
	
	switch (p.type) {
		case SSH_MSG_CHANNEL_OPEN_CONFIRMATION:
			OnChanOpenConfirmation(data, len);
			break;
		case SSH_MSG_CHANNEL_SUCCESS:
			OnChanSuccess(data, len);
			break;
		case SSH_MSG_CHANNEL_FAILURE:
			OnChanFailure(data, len);
			break;
		case SSH_MSG_CHANNEL_WINDOW_ADJUST:
			OnWindowAdjust(data, len);
			break;
		case SSH_MSG_CHANNEL_DATA:
		case SSH_MSG_CHANNEL_EXTENDED_DATA:
			OnChanData(data, len);
			break;
		default:
			printf("[Chann] Unkown packet:  ");
			Session::GetSingleton()->DeterminePacket(data,len);
			break;
	}
}
Beispiel #18
0
void
pp::WindowManager::BorderManager::Disable (void)
{
  //dll_log.Log (L"BorderManager::Disable");

  window.borderless = true;

  //BringWindowToTop (window.hwnd);
  //SetActiveWindow  (window.hwnd);

  DWORD dwNewLong = window.style;

#if 0
  dwNewLong &= ~( WS_BORDER           | WS_CAPTION  | WS_THICKFRAME |
                  WS_OVERLAPPEDWINDOW | WS_MINIMIZE | WS_MAXIMIZE   |
                  WS_SYSMENU          | WS_GROUP );
#endif

  dwNewLong = WS_POPUP | WS_MINIMIZEBOX;

  SetWindowLongW (window.hwnd, GWL_STYLE,   dwNewLong);

  dwNewLong = window.style_ex;

#if 0
  dwNewLong &= ~( WS_EX_DLGMODALFRAME    | WS_EX_CLIENTEDGE    |
                  WS_EX_STATICEDGE       | WS_EX_WINDOWEDGE    |
                  WS_EX_OVERLAPPEDWINDOW | WS_EX_PALETTEWINDOW |
                  WS_EX_MDICHILD );
#endif

  dwNewLong = WS_EX_APPWINDOW;

  SetWindowLongW (window.hwnd, GWL_EXSTYLE, dwNewLong);

  AdjustWindow ();
}
Beispiel #19
0
/******************************************************************************
  MakeMeWindow - Create and setup the window we will need
******************************************************************************/
void MakeMeWindow(void)
{
  XSizeHints hints;
  XGCValues gcval;
  unsigned long gcmask;
  unsigned int dummy1, dummy2;
  int x, y, ret, count;
  Window dummyroot, dummychild;
  int i;

  
  if ((count = ItemCountD(&windows))==0 && Transient) ShutMeDown(0);
  AdjustWindow();

  hints.width=win_width;
  hints.height=win_height;
  hints.win_gravity=NorthWestGravity;
  hints.flags=PSize|PWinGravity|PResizeInc;
  hints.width_inc=0;
  hints.height_inc=0;

  if (geometry!= NULL)
  {
    ret=XParseGeometry(geometry,&x,&y,&dummy1,&dummy2);

    if (ret&XValue && ret &YValue)
    {
      hints.x=x;
      if (ret&XNegative)
        hints.x+=XDisplayWidth(dpy,screen)-win_width;

      hints.y=y;
      if (ret&YNegative)
        hints.y+=XDisplayHeight(dpy,screen)-win_height;

      hints.flags|=USPosition;
    }

    if (ret&XNegative)
    {
      if (ret&YNegative) hints.win_gravity=SouthEastGravity;
      else  hints.win_gravity=NorthEastGravity;
    }
    else
    {
      if (ret&YNegative) hints.win_gravity=SouthWestGravity;
      else  hints.win_gravity=NorthWestGravity;
    }

  }

  if (Transient)
  {
    XQueryPointer(dpy,Root,&dummyroot,&dummychild,&hints.x,&hints.y,&x,&y,&dummy1);
    hints.win_gravity=NorthWestGravity;
    hints.flags |= USPosition;
  }
  win_grav=hints.win_gravity;
  win_x=hints.x;
  win_y=hints.y;


  for (i = 0; i != MAX_COLOUR_SETS; i++)
  if(d_depth < 2)
  {
    back[i] = GetColor("white");
    fore[i] = GetColor("black");
  }
  else
  {
    back[i] = GetColor(BackColor[i] == NULL ? BackColor[0] : BackColor[i]);
    fore[i] = GetColor(ForeColor[i] == NULL ? ForeColor[0] : ForeColor[i]);
  }

  win=XCreateSimpleWindow(dpy,Root,hints.x,hints.y,hints.width,hints.height,1,
    fore[0],back[0]);

  wm_del_win=XInternAtom(dpy,"WM_DELETE_WINDOW",False);
  XSetWMProtocols(dpy,win,&wm_del_win,1);
  
  XSetWMNormalHints(dpy,win,&hints);

  if (!Transient)
  {
    XGrabButton(dpy,1,AnyModifier,win,True,GRAB_EVENTS,GrabModeAsync,
      GrabModeAsync,None,None);
    XGrabButton(dpy,2,AnyModifier,win,True,GRAB_EVENTS,GrabModeAsync,
      GrabModeAsync,None,None);
    XGrabButton(dpy,3,AnyModifier,win,True,GRAB_EVENTS,GrabModeAsync,
      GrabModeAsync,None,None);
    SetMwmHints(MWM_DECOR_ALL|MWM_DECOR_RESIZEH|MWM_DECOR_MAXIMIZE|MWM_DECOR_MINIMIZE,
      MWM_FUNC_ALL|MWM_FUNC_RESIZE|MWM_FUNC_MAXIMIZE|MWM_FUNC_MINIMIZE,
      MWM_INPUT_MODELESS);
  }
  else
  {
    SetMwmHints(0,MWM_FUNC_ALL,MWM_INPUT_MODELESS);
  }

  for (i = 0; i != MAX_COLOUR_SETS; i++)
  {
    gcval.foreground=fore[i];
    gcval.background=back[i];
    gcval.font=ButtonFont->fid;
    gcmask=GCForeground|GCBackground|GCFont;
    graph[i]=XCreateGC(dpy,Root,gcmask,&gcval);

    if(d_depth < 2) 
      gcval.foreground=GetShadow(fore[i]);
    else 
      gcval.foreground=GetShadow(back[i]);
    gcval.background=back[i];
    gcmask=GCForeground|GCBackground;
    shadow[i]=XCreateGC(dpy,Root,gcmask,&gcval);

    gcval.foreground=GetHilite(back[i]);
    gcval.background=back[i];
    gcmask=GCForeground|GCBackground;
    hilite[i]=XCreateGC(dpy,Root,gcmask,&gcval);

    gcval.foreground=back[i];
    gcmask=GCForeground;
    background[i]=XCreateGC(dpy,Root,gcmask,&gcval);
  }
  
  XSelectInput(dpy,win,(ExposureMask | KeyPressMask));

  ChangeWindowName(&Module[1]);

  if (ItemCountD(&windows) > 0)
  {
    XMapRaised(dpy,win);
    WaitForExpose();
    WindowIsUp=1;
  } else WindowIsUp=2;

  if (Transient)
  {
    if ( XGrabPointer(dpy,win,True,GRAB_EVENTS,GrabModeAsync,GrabModeAsync,
      None,None,CurrentTime)!=GrabSuccess) ShutMeDown(1);
    XQueryPointer(dpy,Root,&dummyroot,&dummychild,&hints.x,&hints.y,&x,&y,&dummy1);
    if (!SomeButtonDown(dummy1)) ShutMeDown(0);
  }

}
Beispiel #20
0
/******************************************************************************
  ProcessMessage - Process the message coming from Fvwm
    Skeleton based on processmessage() from FvwmIdent:
      Copyright 1994, Robert Nation and Nobutaka Suzuki.
******************************************************************************/
void ProcessMessage(unsigned long type,unsigned long *body)
{
  int redraw=0,i;
  long flags;
  char *name,*string;
  static current_focus=-1;

  Picture p;

  switch(type)
  {
    case M_ADD_WINDOW:
    case M_CONFIGURE_WINDOW:
      if (body[0] == win)
      {
        win_x=(int)body[3];
        win_y=(int)body[4];

        win_title=(int)body[9];
        win_border=(int)body[10];
      }
      if ((i = FindItem(&windows,body[0]))!=-1) 
      { 
/*	printf("does it go here on MOVE %ld, %ld ?\n", i, CurrentDesk);
*/
	if(UpdateItemDesk(&windows, i, body[7]) > 0)
        {
/*         printf("why doesnt it go here on MOVE ?\n");
*/
          AdjustWindow();
          RedrawWindow(1);
        }
	break;
      }

      if (!(body[8]&WINDOWLISTSKIP) || !UseSkipList)
        AddItem(&windows,body[0],body[8], body[7] /* desk */);
      break;
    case M_DESTROY_WINDOW:
      if ((i=DeleteItem(&windows,body[0]))==-1) break;
      RemoveButton(&buttons,i);
      if (WindowIsUp)
        AdjustWindow();

      redraw=1;
      break;

  case M_MINI_ICON:
    if ((i=FindItem(&windows,body[0]))==-1) break;

    if (UpdateButton(&buttons,i,NULL,-1)!=-1)
    {
      p.picture = body[1];
      p.mask = body[2];
      p.width = body[3];
      p.height = body[4];
      p.depth = body[5];
      UpdateButtonPicture(&buttons, i, &p);
      redraw = 0;
    }
    break;

    case M_WINDOW_NAME:
    case M_ICON_NAME:
      if ((type==M_ICON_NAME && !UseIconNames) || 
          (type==M_WINDOW_NAME && UseIconNames)) break;
      if ((i=UpdateItemName(&windows,body[0],(char *)&body[3]))==-1) break;
      string=(char *)&body[3];
      name=makename(string,ItemFlags(&windows,body[0]));
      if (UpdateButton(&buttons,i,name,-1)==-1)
      {
	AddButton(&buttons, name, NULL, 1);
	UpdateButtonSet(&buttons,i,ItemFlags(&windows,body[0])&ICONIFIED?1:0);
        UpdateButtonDesk(&buttons,i,ItemDesk(&windows, body[0]));
      }
      free(name);
      if (WindowIsUp) AdjustWindow();
      redraw=1;
      break;
    case M_DEICONIFY:
    case M_ICONIFY:
      if ((i=FindItem(&windows,body[0]))==-1) break;
      flags=ItemFlags(&windows,body[0]);
      if (type==M_DEICONIFY && !(flags&ICONIFIED)) break;
      if (type==M_ICONIFY && flags&ICONIFIED) break;
      flags^=ICONIFIED;
      UpdateItemFlags(&windows,body[0],flags);
      string=ItemName(&windows,i);
      name=makename(string,flags);
      if (UpdateButton(&buttons,i,name,-1)!=-1) redraw=1;
      if (i!=current_focus||(flags&ICONIFIED))
        if (UpdateButtonSet(&buttons,i,(flags&ICONIFIED) ? 1 : 0)!=-1) redraw=1;
      free(name);
      break;
    case M_FOCUS_CHANGE:

/* old coded, before Task bar code spliced in

      i=FindItem(&windows,body[0]);
      if (i==current_focus) break;
      if (current_focus!=-1)
	if ((ItemFlags(&windows,ItemID(&windows,current_focus))&ICONIFIED)==0)
	  if (UpdateButtonSet(&buttons,current_focus,0)!=-1) redraw=1;
      current_focus=-1;
      if (i!=-1&&(ItemFlags(&windows,body[0])&ICONIFIED)) break;
      current_focus=i;
      if (current_focus!=-1)
	if (UpdateButtonSet(&buttons,current_focus,2)!=-1) redraw=1;
* end of old code */

/* Code copied Straight from TaskBar */

    if ((i=FindItem(&windows,body[0]))!=-1)
    {
	    flags=ItemFlags(&windows,body[0]);
 	    UpdateItemFlags(&windows,body[0],flags);
    }
    RadioButton(&buttons,i);
    redraw = 1;
    break;

      break;
    case M_END_WINDOWLIST:
      if (!WindowIsUp) MakeMeWindow();
      redraw=1;
      break;
    case M_NEW_DESK:
	CurrentDesk = body[0];
	if(ShowCurrentDesk)
	{
	  RESIZE_BUG_HACK = 1;
	  AdjustWindow();
	  RESIZE_BUG_HACK = 0;
	  RedrawWindow(1);
        }
      break;
    case M_NEW_PAGE:
      break;
  }

  if (redraw && WindowIsUp==1) RedrawWindow(0);
}
Beispiel #21
0
bool WinApp::Initialize(HINSTANCE hInst, const std::wstring& title, int w, int h)
{
	m_hInst = hInst;
	m_wndTitle = title;
	m_wndClass = L"WinAppClass";

	m_width = w;
	m_height = h;

	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= m_hInst;
	wcex.hIcon			= NULL;
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	wcex.lpszMenuName	= NULL;
	wcex.lpszClassName	= m_wndClass.c_str();
	wcex.hIconSm		= NULL;

		
	if(FALSE == RegisterClassEx(&wcex))
	{
		return false;
	}


	m_hWnd = CreateWindow(m_wndClass.c_str(), 
							m_wndTitle.c_str(), 
							(WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU), 
							CW_USEDEFAULT, 
							0, 
							m_width, 
							m_height, 
							NULL, 
							NULL, 
							m_hInst, 
							NULL);

   if (!m_hWnd)
   {
      return false;
   }

   AdjustWindow(m_width, m_height);

   engine::EngineParameters param;

   param.input.inputMod = L"./input.dll";
   param.input.hWnd = m_hWnd;

   param.graphics.width = m_width;
   param.graphics.height = m_height;
   param.graphics.wnd = m_hWnd;
   param.graphics.graphicsMod = L"./graphics_d3d11.dll";

   m_pEngine = engine::EngineCreate(param);

   if(m_pEngine == NULL)
   {
	   return false;
   }

   ShowWindow(m_hWnd, SW_SHOW);
   UpdateWindow(m_hWnd);

   return true;
}
Beispiel #22
0
bool WinApp::Initialize(HINSTANCE hInst, const std::wstring& title, int w, int h)
{
	m_hInst = hInst;
	m_wndTitle = title;
	m_wndClass = title + L"_WndClass";

	m_width = w;
	m_height = h;

	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= m_hInst;
	wcex.hIcon			= NULL;
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	wcex.lpszMenuName	= NULL;
	wcex.lpszClassName	= m_wndClass.c_str();
	wcex.hIconSm		= NULL;


	if(FALSE == RegisterClassEx(&wcex))
	{
		return false;
	}


	m_hWnd = CreateWindow(m_wndClass.c_str(), 
		m_wndTitle.c_str(), 
		(WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU), 
		CW_USEDEFAULT, 
		0, 
		m_width, 
		m_height, 
		NULL, 
		NULL, 
		m_hInst, 
		NULL);

	if (!m_hWnd)
	{
		return false;
	}

	AdjustWindow(m_width, m_height);

	ShowWindow(m_hWnd, SW_SHOW);
	UpdateWindow(m_hWnd);

	if(OnInit() == false)
	{
		return false;
	}
	
	return true;
}
Beispiel #23
0
// WINMAIN ////////////////////////////////////////////////
int WINAPI WinMain(	HINSTANCE hinstance,
					HINSTANCE hprevinstance,
					LPSTR lpcmdline,
					int ncmdshow)
{

	WNDCLASSEX winclass; // this will hold the class we create
	HWND	   hwnd;	 // generic window handle
	MSG		   msg;		 // generic message

	// first fill in the window class stucture
	winclass.cbSize         = sizeof(WNDCLASSEX);
	winclass.style			= CS_DBLCLKS | CS_OWNDC | 
							  CS_HREDRAW | CS_VREDRAW;


	winclass.lpfnWndProc	= WindowProc;
	winclass.cbClsExtra		= 0;
	winclass.cbWndExtra		= 0;
	winclass.hInstance		= hinstance;
	winclass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	winclass.hCursor		= LoadCursor(NULL, IDC_ARROW);
	winclass.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	winclass.lpszMenuName	= NULL;
	winclass.lpszClassName	= WINDOW_CLASS_NAME;
	winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);

	// register the window class
	if (!RegisterClassEx(&winclass))
		return(0);

	// create the window
	if (!(hwnd = CreateWindowEx(NULL,                  // extended style
								WINDOW_CLASS_NAME,     // class
								"Your Basic Window++", // title
								(WS_OVERLAPPEDWINDOW | WS_VISIBLE) & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME,
								(GetSystemMetrics(SM_CXSCREEN) - GAME_WIDTH)/2,
								(GetSystemMetrics(SM_CYSCREEN) - GAME_HEIGHT)/2, 
								GAME_WIDTH,GAME_HEIGHT,  // initial width, height
								NULL,	    // handle to parent 
								NULL,	    // handle to menu
								hinstance,// instance of this application
								NULL)))	// extra creation parms
	return(0);

	AdjustWindow(hwnd);

	if (gameWorld.Init(hwnd)!=0)
	{
		MessageBox(hwnd,"Game_Init error","",MB_OK);
		return 0;
	}

	while (GetMessage(&msg, NULL, 0, 0)) 
	{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
	}

	gameWorld.Shutdown();	

	// return to Windows like this
	return(msg.wParam);

} // end WinMain
Beispiel #24
0
	bool OGL4RenderWindow::Create(void* wnd, int w, int h, G_FORMAT color_format, G_FORMAT depth_format)
	{
		if(wnd == nullptr)
		{
			return false;
		}

		m_hWnd = (HWND)wnd;

		AdjustWindow(w, h);
		CenterWindow();

		m_hDC = ::GetDC(m_hWnd);

		PIXELFORMATDESCRIPTOR pfd;
		memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
		pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
		pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
		pfd.iPixelType = PFD_TYPE_RGBA;
		pfd.cColorBits = 32;
		pfd.cDepthBits = 32;
		pfd.iLayerType = PFD_MAIN_PLANE;

		int nPixelFormat = ChoosePixelFormat(m_hDC, &pfd);
		if (nPixelFormat == 0)
			return false;  

		bool bResult = (SetPixelFormat(m_hDC, nPixelFormat, &pfd) != FALSE);
		if (!bResult)
			return false;

		HGLRC tempOpenGLContext = wglCreateContext(m_hDC);
		wglMakeCurrent(m_hDC, tempOpenGLContext);


		int attributes[] = 
		{  
			WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
			WGL_CONTEXT_MINOR_VERSION_ARB, 3,
			WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB |
			WGL_CONTEXT_DEBUG_BIT_ARB,        
			WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
			0
		};
		PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
		if(wglCreateContextAttribsARB == nullptr)
		{
			m_hRC = tempOpenGLContext;
			return true;
		}

		m_hRC = wglCreateContextAttribsARB(m_hDC, NULL, attributes);

		if(m_hRC == nullptr)
		{
			m_hRC = tempOpenGLContext;
			return true;
		}
		MakeCurrent();

		wglDeleteContext(tempOpenGLContext);

		m_width = w;
		m_height = h;
		return true;
	}
Beispiel #25
0
/******************************************************************************
  ProcessMessage - Process the message coming from Fvwm
    Skeleton based on processmessage() from FvwmIdent:
      Copyright 1994, Robert Nation and Nobutaka Suzuki.
******************************************************************************/
void ProcessMessage(unsigned long type,unsigned long *body)
{
    int redraw=0,i;
    long flags;
    char *name,*string;
    static int current_focus=-1;

    FvwmPicture p;

    switch(type)
    {
    case M_ADD_WINDOW:
    case M_CONFIGURE_WINDOW:
        if ((i = FindItem(&windows,body[0]))!=-1)
        {
            if(UpdateItemDesk(&windows, i, body[7]) > 0)
            {
                AdjustWindow();
                RedrawWindow(1);
            }
            break;
        }

        if (!(body[8]&WINDOWLISTSKIP) || !UseSkipList)
            AddItem(&windows,body[0],body[8], body[7] /* desk */);
        break;
    case M_DESTROY_WINDOW:
        if ((i=DeleteItem(&windows,body[0]))==-1) break;
        RemoveButton(&buttons,i);
        if (WindowIsUp)
            AdjustWindow();

        redraw=1;
        break;

#ifdef MINI_ICONS
    case M_MINI_ICON:
        if ((i=FindItem(&windows,body[0]))==-1) break;

        if (UpdateButton(&buttons,i,NULL,-1)!=-1)
        {
            p.width = body[3];
            p.height = body[4];
            p.depth = body[5];
            p.picture = body[6];
            p.mask = body[7];

            UpdateButtonPicture(&buttons, i, &p);
            redraw = 0;
        }
        break;
#endif

    case M_WINDOW_NAME:
    case M_ICON_NAME:
        if ((type==M_ICON_NAME && !UseIconNames) ||
                (type==M_WINDOW_NAME && UseIconNames)) break;
        if ((i=UpdateItemName(&windows,body[0],(char *)&body[3]))==-1) break;
        string=(char *)&body[3];
        name=makename(string,ItemFlags(&windows,body[0]));
        if (UpdateButton(&buttons,i,name,-1)==-1)
        {
            AddButton(&buttons, name, NULL, 1);
            UpdateButtonSet(&buttons,i,ItemFlags(&windows,body[0])&ICONIFIED?1:0);
            UpdateButtonDesk(&buttons,i,ItemDesk(&windows, body[0]));
        }
        free(name);
        if (WindowIsUp) AdjustWindow();
        redraw=1;
        break;
    case M_DEICONIFY:
    case M_ICONIFY:
        if ((i=FindItem(&windows,body[0]))==-1) break;
        flags=ItemFlags(&windows,body[0]);
        if (type==M_DEICONIFY && !(flags&ICONIFIED)) break;
        if (type==M_ICONIFY && flags&ICONIFIED) break;
        flags^=ICONIFIED;
        UpdateItemFlags(&windows,body[0],flags);
        string=ItemName(&windows,i);
        name=makename(string,flags);
        if (UpdateButton(&buttons,i,name,-1)!=-1) redraw=1;
        if (i!=current_focus||(flags&ICONIFIED))
            if (UpdateButtonSet(&buttons,i,(flags&ICONIFIED) ? 1 : 0)!=-1) redraw=1;
        free(name);
        break;
    case M_FOCUS_CHANGE:
        if ((i=FindItem(&windows,body[0]))!=-1)
        {
            flags=ItemFlags(&windows,body[0]);
            UpdateItemFlags(&windows,body[0],flags);
            RadioButton(&buttons,i);
        }
        else
            RadioButton(&buttons,-1);
        redraw = 1;
        break;
    case M_END_WINDOWLIST:
        if (!WindowIsUp) MakeMeWindow();
        redraw = 1;
        break;
    case M_NEW_DESK:
        CurrentDesk = body[0];
        if(ShowCurrentDesk)
        {
            AdjustWindow();
            RedrawWindow(1);
        }
        break;
    case M_NEW_PAGE:
        break;
    }

    if (redraw && WindowIsUp==1) RedrawWindow(0);
}