Ejemplo n.º 1
0
void CheckPrefs(HWND hwnd, int iDlg)
{
	/**************************************************************************************************/
	/**************** save the preferances based on the checkmarks/options ****************************/
	/**************************************************************************************************/
	switch(iDlg)
	{
	case IDD_EVENTS:
		{
			SetOption(hwnd, CHAN_HILIGHT,		CHAN_HILIGHT);
			SetOption(hwnd, CHAN_INVITE,		CHAN_INVITE);
			SetOption(hwnd, CHAN_TOPIC_CHANGE,	CHAN_TOPIC_CHANGE);
			SetOption(hwnd, CHAN_BANNED,		CHAN_BANNED);
			SetOption(hwnd, CHAN_KICKED,		CHAN_KICKED);
			SetOption(hwnd, CTCP_GENERIC,		CTCP_GENERIC);
			SetOption(hwnd, PMSG_RECEIVE,		PMSG_RECEIVE);
			SetOption(hwnd, SERV_KILLED,		SERV_KILLED);
			SetOption(hwnd, SERV_NOTICE,		SERV_NOTICE);
			SetOption(hwnd, SERV_DISCONNECT,	SERV_DISCONNECT);
			SetOption(hwnd, CHAN_MESSAGE,		CHAN_MESSAGE);
		}
		break;
	case IDD_ALERTS:
		{
			SetOption(hwnd, PREF_AMAE,	PREF_AMAE);
			SetOption(hwnd, PREF_OSBWM,	PREF_OSBWM);
			SetOption(hwnd, PREF_UWIOB,	PREF_UWIOB);
			SetOption(hwnd, PREF_KAOI,	PREF_KAOI);
			SetOption(hwnd, PREF_BLINK,	PREF_BLINK);

			/**************************************************************************/
			/**************************************************************************/
			/**************************************************************************/
			TCHAR tTime[512];

			GetWindowText(GetDlgItem(hwnd, IDC_ALERT_TIME), tTime, 511);
			
			g_iTime = _tstoi(tTime);
			
			/**************************************************************************/
			/**************** Get our Hotkey and save it                     **********/
			/**************** then remove the old hotkey and add the new one **********/
			/**************************************************************************/
			DWORD hHotkey;
			hHotkey = SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_GETHOTKEY, 0, 0);
			
			g_hHotKey.key = LOBYTE(hHotkey);
			g_hHotKey.mod = HotkeyfToMod(HIBYTE(hHotkey));
			
			if(IsDlgButtonChecked(hwnd, PREF_UWIOB) == BST_CHECKED)
			{
				UnregisterHotKey(g_hHotkeyWnd, 1);
				RegisterHotKey(g_hHotkeyWnd, 1, g_hHotKey.mod, g_hHotKey.key);
			}
			else
			{
				UnregisterHotKey(g_hHotkeyWnd, 1);
			}

			/*************************************************************************/
			/*********** Get and save the away msg and alert time ********************/
			/*************************************************************************/
		}
		break;
	case IDD_SETTINGS:
		{
			SetOption(hwnd, PREF_AOM, PREF_AOM);
			SetOption(hwnd, PREF_TOT, PREF_TOT);
			SetOption(hwnd, PREF_MIOC, PREF_MIOC);
			SetOption(hwnd, PREF_DNSIT, PREF_DNSIT);

			GetDlgItemText(hwnd, IDC_AWAY_MSG, g_szAway, 511);

			if(g_dwPrefs & (1<<PREF_DNSIT))
			{
				DWORD dwStyle;
				dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE);
				dwStyle |= (1<<WS_CHILD);
				SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle);
				SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, (LONG_PTR)g_hHotkeyWnd);
			}
			else
			{
				DWORD dwStyle;
				dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE);
				dwStyle &= ~(1<<WS_CHILD);
				SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle);
				SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, NULL);
			}
		}
		break;
	} 
}
Ejemplo n.º 2
0
BOOL player_impl::full_screen(BOOL fullscreen)
{
	HWND hparent = GetParent(m_hwnd);

	// 不支持非顶层窗口全屏操作.
	if (IsWindow(hparent))
	{
		::logger("do\'nt support full screen mode\n");
		return FALSE;
	}

	// Save the current windows placement/placement to
	// restore when fullscreen is over
	WINDOWPLACEMENT window_placement;
	window_placement.length = sizeof(WINDOWPLACEMENT);
	GetWindowPlacement(m_hwnd, &window_placement);

	if (fullscreen && !m_full_screen)
	{
		m_full_screen = true;
		m_wnd_style = GetWindowLong(m_hwnd, GWL_STYLE);
		printf("entering fullscreen mode.\n");
		SetWindowLong(m_hwnd, GWL_STYLE, WS_CLIPCHILDREN | WS_VISIBLE);

		if (IsWindow(hparent))
		{
			// Retrieve current window position so fullscreen will happen
			// on the right screen
			HMONITOR hmon = MonitorFromWindow(hparent, MONITOR_DEFAULTTONEAREST);
			MONITORINFO mi;
			mi.cbSize = sizeof(MONITORINFO);
			if (::GetMonitorInfo(hmon, &mi))
				::SetWindowPos(m_hwnd, 0,
				mi.rcMonitor.left,
				mi.rcMonitor.top,
				mi.rcMonitor.right - mi.rcMonitor.left,
				mi.rcMonitor.bottom - mi.rcMonitor.top,
				SWP_NOZORDER | SWP_FRAMECHANGED);
		}
		else
		{
			// Maximize non embedded window
			ShowWindow(m_hwnd, SW_SHOWMAXIMIZED);
		}

		if (IsWindow(hparent))
		{
			// Hide the previous window
			RECT rect;
			GetClientRect(m_hwnd, &rect);
			// SetParent(hwnd, hwnd);
			SetWindowPos(m_hwnd, 0, 0, 0,
				rect.right, rect.bottom,
				SWP_NOZORDER|SWP_FRAMECHANGED);
			HWND topLevelParent = GetAncestor(hparent, GA_ROOT);
			ShowWindow(topLevelParent, SW_HIDE);
		}
		SetForegroundWindow(m_hwnd);
		return TRUE;
	}

	if (!fullscreen && m_full_screen)
	{
		m_full_screen = FALSE;
		printf("leaving fullscreen mode.\n");
		// Change window style, no borders and no title bar
		SetWindowLong(m_hwnd, GWL_STYLE, m_wnd_style);

		if (hparent)
		{
			RECT rect;
			GetClientRect(hparent, &rect);
			// SetParent(hwnd, hparent);
			SetWindowPos(m_hwnd, 0, 0, 0,
				rect.right, rect.bottom,
				SWP_NOZORDER | SWP_FRAMECHANGED);

			HWND topLevelParent = GetAncestor(hparent, GA_ROOT);
			ShowWindow(topLevelParent, SW_SHOW);
			SetForegroundWindow(hparent);
			ShowWindow(m_hwnd, SW_HIDE);
		}
		else
		{
			// return to normal window for non embedded vout
			SetWindowPlacement(m_hwnd, &window_placement);
			ShowWindow(m_hwnd, SW_SHOWNORMAL);
		}
		return TRUE;
	}

	return FALSE;
}
Ejemplo n.º 3
0
BOOL CRegDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	CString str;
	sockaddr_in  sockAddr;
	memset(&sockAddr, 0, sizeof(sockAddr));
	int nSockAddrLen = sizeof(sockAddr);
	BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
	str.Format("\\\\%s - 注册表管理", bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
	SetWindowText(str);

	size[0]=120;size[1]=80;size[2]=310;
	m_list.InsertColumn(0,"名称",LVCFMT_LEFT,size[0],-1);
	m_list.InsertColumn(1,"类型",LVCFMT_LEFT,size[1],-1);
	m_list.InsertColumn(2,"数据",LVCFMT_LEFT,size[2],-1);
    m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	//////添加图标//////
	m_HeadIcon.Create(16,16,TRUE,2,2);
	m_HeadIcon.Add(AfxGetApp()->LoadIcon(IDI_STR_ICON));
	m_HeadIcon.Add(AfxGetApp()->LoadIcon(IDI_DWORD_ICON));	
	
	m_list.SetImageList(&m_HeadIcon,LVSIL_SMALL);	
	
	//树控件设置	
	HICON hIcon = NULL;
	m_ImageList_tree.Create(18, 18, ILC_COLOR16,10, 0);
	
	hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_FATHER_ICON), IMAGE_ICON, 18, 18, 0);
	m_ImageList_tree.Add(hIcon);
	hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_DIR_ICON), IMAGE_ICON, 32, 32, 0);
	m_ImageList_tree.Add(hIcon);	
	
	
	m_tree.SetImageList ( &m_ImageList_tree,TVSIL_NORMAL );
	
	DWORD	dwStyle = GetWindowLong(m_tree.m_hWnd,GWL_STYLE);
	
    dwStyle |=TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;	
    SetWindowLong(m_tree.m_hWnd,GWL_STYLE,dwStyle);

    m_hRoot = m_tree.InsertItem("注册表管理",0,0,0,0);   
	
	HKCU=m_tree.InsertItem("HKEY_CURRENT_USER",1,1,m_hRoot,0);
	HKLM=m_tree.InsertItem("HKEY_LOCAL_MACHINE",1,1,m_hRoot,0);
	HKUS=m_tree.InsertItem("HKEY_USERS",1,1,m_hRoot,0);
	HKCC=m_tree.InsertItem("HKEY_CURRENT_CONFIG",1,1,m_hRoot,0);
	HKCR=m_tree.InsertItem("HKEY_CLASSES_ROOT",1,1,m_hRoot,0);
	
	m_tree.Expand(m_hRoot,TVE_EXPAND);	
	
	CreatStatusBar();
	CRect rect;
	GetWindowRect(&rect);
	rect.bottom+=20;
	MoveWindow(&rect,true);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 4
0
cNinjaProgressBar *getNinjaProgressBar(HWND hwHost)
{
	cNinjaProgressBar *cNL = (cNinjaProgressBar*)GetWindowLong(hwHost,GWL_USERDATA);
	return cNL;
}
Ejemplo n.º 5
0
void makeWindow( )
{

	WNDCLASSEX	wndClass;

	wndClass.cbSize        = sizeof(wndClass);
	wndClass.style         = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc   = CGameGirlProc;
	wndClass.cbClsExtra    = 0;
	wndClass.cbWndExtra    = 0;
	wndClass.hInstance     = g_pWindows->m_hInstance;
	wndClass.hIcon         = LoadIcon( g_pWindows->m_hInstance , MAKEINTRESOURCE(IDI_APP));
	wndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
	wndClass.lpszMenuName  = NULL;//MAKEINTRESOURCE(CGameGirl::GetInstance()->MENU_BAR);
	wndClass.lpszClassName = TEXT( NAME_APRICLASS );
	wndClass.hIconSm       = LoadIcon (NULL, _T( "MAIN" ));

	RegisterClassEx(&wndClass);

	//画面の中央にセット
	RECT		desktop;
	GetWindowRect(GetDesktopWindow(), (LPRECT)&desktop);

	/*-- フレームなどのクライアント領域以外のサイズを考慮 --*/
	Sint32 w,h;
	RECT rect = { 0, 0, SWINDOW_W, SWINDOW_H };
	AdjustWindowRect( &rect, WS_OVERLAPPEDWINDOW|WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, FALSE );

	w = rect.right - rect.left;
	h = rect.bottom - rect.top;

	Sint32 ax,ay;

	ax = (desktop.right  - desktop.left)/2 - w/2;
	ay = (desktop.bottom - desktop.top)/2  - h/2;

	if( ax < 0) ax = 0;
	if( ay < 0) ay = 0;

	g_pWindows->m_hWindow = CreateWindow(
				TEXT( NAME_APRICLASS ),
				TEXT( NAME_APRICATION ),
	            WS_OVERLAPPEDWINDOW|WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE,
				ax,
				ay,
				w,
				h,
				NULL,
				NULL,
				g_pWindows->m_hInstance,
			    NULL);

	g_pWindows->m_WinDC = GetDC( g_pWindows->m_hWindow );

	g_pWindows->m_AppStyle = GetWindowLong( g_pWindows->m_hWindow , GWL_STYLE);
	GetWindowRect( g_pWindows->m_hWindow , &g_pWindows->m_WinRect );

	/*-- 念のためウインドウサイズ補正 --*/
	RECT client;
	GetClientRect( g_pWindows->m_hWindow, &client );
	int diffx = (client.right - client.left) - SWINDOW_W;
	int diffy = (client.bottom - client.top) - SWINDOW_H;
	if ( diffx != 0 || diffy != 0 ) {
		rect.right -= diffx;
		rect.bottom -= diffy;

		MoveWindow( g_pWindows->m_hWindow, g_pWindows->m_WinRect.left, g_pWindows->m_WinRect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE );
	}

	// ハードがマルチタッチをサポートしているかどうか
	int  value= ~GetSystemMetrics( SM_DIGITIZER );

	if( !(value & 0xc0) )
	{
		RegisterTouchWindow( g_pWindows->m_hWindow, 0 );
	}

	QueryPerformanceFrequency((LARGE_INTEGER*)&g_pWindows->Vsyncrate);		//秒間のカウント

}
Ejemplo n.º 6
0
static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
      WPARAM wparam, LPARAM lparam)
{
   int i, pos;
   const ui_window_t *window = ui_companion_driver_get_window_ptr();

   switch (message)
   {
      case WM_CREATE:
         break;

      case WM_CLOSE:
      case WM_DESTROY:
      case WM_QUIT:
         if (window)
            window->set_visible(&g_shader_dlg.window, false);
         return 0;

      case WM_COMMAND:
         i = LOWORD(wparam);

         if (i == SHADER_DLG_CHECKBOX_ONTOP_ID)
         {
            shader_dlg_update_on_top_state();
            break;
         }

         if (i >= GFX_MAX_PARAMETERS)
            break;

         if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_CHECKBOX)
            break;

         {
            video_shader_ctx_t shader_info;
            video_shader_driver_get_current_shader(&shader_info);

            if (SendMessage(g_shader_dlg.controls[i].elems.checkbox.hwnd,
                     BM_GETCHECK, 0, 0) == BST_CHECKED)
               shader_info.data->parameters[i].current =
                  shader_info.data->parameters[i].maximum;
            else
               shader_info.data->parameters[i].current =
                  shader_info.data->parameters[i].minimum;
         }
         break;

      case WM_HSCROLL:
         {
            video_shader_ctx_t shader_info;
            video_shader_driver_get_current_shader(&shader_info);
            i = GetWindowLong((HWND)lparam, GWL_ID);

            if (i >= GFX_MAX_PARAMETERS)
               break;

            if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_TRACKBAR)
               break;

            pos = (int)SendMessage(g_shader_dlg.controls[i].elems.trackbar.hwnd, TBM_GETPOS, 0, 0);

            {

               shader_info.data->parameters[i].current =
                  shader_info.data->parameters[i].minimum + pos * shader_info.data->parameters[i].step;
            }

            if (shader_info.data)
               shader_dlg_refresh_trackbar_label(i, &shader_info);
         }
         break;

   }

   return DefWindowProc(hwnd, message, wparam, lparam);
}
Ejemplo n.º 7
0
//
//  Page Layout Dialog Box
//
BOOL FAR PASCAL _export PAGE::PageDialog ( HWND hDlg, WORD message, WORD wParam, LONG lParam )
{

	PAGE *page;

	switch ( message )
	{
	case WM_INITDIALOG:
		page = (PAGE*)AObjGetRuntimeInfo((OBJECTID)lParam);
		SetWindowLong(hDlg, DWL_USER, (long)page);
		page->SetDialog(hDlg);
		page->hPen1 = CreatePen(PS_SOLID, 1, 0x00808080L);
		page->hPen2 = CreatePen(PS_SOLID, 2, 0x00808080L);

		page->InitDlgControl();
		AUtlSetTitleFont(OTYPE_PAGE, NULL, GetDlgItem(hDlg, IDD_OBJECT));
		AUtlCenterDialog(hDlg, 0);

		return TRUE;

	case WM_MOVE:
		page = (PAGE*)GetWindowLong(hDlg, DWL_USER);
		GetWindowRect(page->hLayout, &page->layoutRect);
		return 0;

	case WM_COMMAND:
		page = (PAGE*)GetWindowLong(hDlg, DWL_USER);
		switch ( wParam )
		{
		case PAGEOK:
			SetFocus(GetDlgItem(hDlg, PAGEOK));
			page->UpdateObject();
			page->DeleteListData();
			EndDialog(hDlg, 0);
			return TRUE;

		case PAGECANCEL:
			SetFocus(GetDlgItem(hDlg, PAGECANCEL));
			page->DeleteListData();
			EndDialog(hDlg, 0);
			return TRUE;

		case PAGEHELP:
//			WinHelp(hDlg, HELPFILE, HELP_CONTEXT, HELPID_OBJD_Page);
			return TRUE;

		case PAGEADD:
			page->Add();
			return TRUE;

		case PAGEGRID:
			page->snap = IsDlgButtonChecked(hDlg, PAGEGRID);
			return TRUE;

		case PAGEREMOVE:
			page->Remove();
			page->UpdateRemoveButton();
			page->UpdateEditButton();
			return TRUE;

		case PAGEEDIT:
			page->Edit();
			return TRUE;

		case PAGEAVAIL:
			if (HIWORD(lParam) == LBN_SELCHANGE)
				page->UpdateAddButton();

			if (HIWORD(lParam) == LBN_DBLCLK)
				page->Add();
			return TRUE;

		case PAGESELECT:
			if (HIWORD(lParam) == LBN_SELCHANGE)
			{
				page->MakeWindowTop();
				page->UpdateRemoveButton();
				page->UpdateEditButton();
			}

			if (HIWORD(lParam) == LBN_DBLCLK)
				page->Edit();
			return TRUE;
		}
		break;

	case WM_PAINT:
		page = (PAGE*)GetWindowLong(hDlg, DWL_USER);
		page->DrawObjectName();
   	return FALSE;
	}
	return FALSE;
}
Ejemplo n.º 8
0
inline CUWindow *GetThis (HWND hWnd) { return (CUWindow *)GetWindowLong(hWnd, GWL_USERDATA); }
Ejemplo n.º 9
0
static BOOL CALLBACK 
sSplashDlgProc (
		HWND	hDlg, 
		UINT	uMsg, 
		WPARAM	wParam, 
		LPARAM	lParam) 
{
	PSPLASHSTRUCT	pss;

	switch (uMsg) {

	case WM_INITDIALOG:
		{
			HWND hWndControl;

			SetWindowLong (hDlg, GWL_USERDATA, lParam);
			pss = (PSPLASHSTRUCT)lParam;

			g_hWndSplash = hDlg;
			SetWindowPos (hDlg, HWND_TOP, pss->uXpos, pss->uYpos, 
											pss->uXsize, pss->uYsize, 0);

			hWndControl = GetDlgItem (hDlg, IDOK);
			EnableWindow (hWndControl, FALSE);
			ShowWindow (hWndControl, SW_HIDE);
			hWndControl = GetDlgItem (hDlg, IDC_BUYNOW);
			EnableWindow (hWndControl, FALSE);
			ShowWindow (hWndControl, SW_HIDE);
			pss->uTimerTime = 0;
			SetTimer (hDlg, TIMER_ID, TIMER_PERIOD, NULL);
		}
		return TRUE;

	case WM_PAINT:
		{
			HDC			hDC, hMemDC;
			PAINTSTRUCT ps;
			HBITMAP		hBitmapOld;

			pss = (PSPLASHSTRUCT)GetWindowLong (hDlg, GWL_USERDATA);

			hDC = BeginPaint (hDlg, &ps);
			hMemDC = CreateCompatibleDC (hDC);
			if (pss->hPaletteSplash) {
				SelectPalette (hDC, pss->hPaletteSplash, FALSE);
				RealizePalette (hDC);
			}
			hBitmapOld = SelectObject (hMemDC, pss->hBitmapSplash);
			CLPaintUserInfo (MemMgr, hDlg, hMemDC, NULL);
			BitBlt (hDC, 0, 0, pss->uXsize, pss->uYsize, 
											hMemDC, 0, 0, SRCCOPY);
			SelectObject (hMemDC, hBitmapOld);
			DeleteDC (hMemDC);
			EndPaint (hDlg, &ps);
		}
		return FALSE;

	case WM_LBUTTONDOWN:
		if (hWndSplashParent) EndDialog (hDlg, 0);
		return TRUE;

	case WM_DESTROY:
		KillTimer (hDlg, TIMER_ID);
		return FALSE;

	case WM_TIMER:
		pss = (PSPLASHSTRUCT)GetWindowLong (hDlg, GWL_USERDATA);
		if (pss->uTimerTime < pss->uTimeOut) 
			pss->uTimerTime += TIMER_PERIOD;
		else 
			if (hWndSplashParent) EndDialog (hDlg, 0);
		return TRUE;

	case WM_CLOSE :
		EndDialog (hDlg, 0);
		break;

	case WM_COMMAND :
		switch(LOWORD (wParam)) {

		case IDOK: 
			if (hWndSplashParent) EndDialog (hDlg, 0);
			break;
		}
		return TRUE;

	default:
		return FALSE;

	}

	return FALSE;
}
Ejemplo n.º 10
0
LRESULT CALLBACK MetaTaskbar::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
	vnclog.Print(1, TEXT("%s: hwnd=0x%X, iMsg=0x%X, wParam=0x%X, lParam=0x%X\n"), __FUNCTION__, hwnd, iMsg, wParam, lParam);

    MetaTaskbar *_this = (MetaTaskbar *)GetWindowLong(hwnd, GWL_USERDATA);
    ULONG id = 0;
    if (_this)
        id = _this->getId(hwnd);
    
    //vnclog.Print(1, TEXT("%s: _this=0x%X, id=0x%X\n"), __FUNCTION__, _this, id);
    if (id == 0) {
        vnclog.Print(1, TEXT("%s: id=0\n"), __FUNCTION__);
        return DefWindowProc(hwnd, iMsg, wParam, lParam);
    }

    switch (iMsg) {
    case WM_SETFOCUS:
vnclog.Print(1, TEXT("%s: WM_SETFOCUS\n"), __FUNCTION__);
        _this->m_clientconn->SendWindowControl(id, rfbWindowControlSetFocus);
        SetForegroundWindow(_this->m_clientconn->m_hwnd1);
        break;

    case WM_KILLFOCUS:
vnclog.Print(1, TEXT("%s: WM_KILLFOCUS\n"), __FUNCTION__);
        break;

    case WM_ACTIVATE:
vnclog.Print(1, TEXT("%s: WM_ACTIVATE\n"), __FUNCTION__);
        break;

    case WM_ACTIVATEAPP:
vnclog.Print(1, TEXT("%s: WM_ACTIVATEAPP\n"), __FUNCTION__);
        break;

    case WM_SYSCOMMAND:
        vnclog.Print(1, TEXT("%s: WM_SYSCOMMAND: %s\n"), __FUNCTION__,
                     wParam == SC_SIZE ? TEXT("SC_SIZE") :
                     wParam == SC_MOVE ? TEXT("SC_MOVE") :
                     wParam == SC_MINIMIZE ? TEXT("SC_MINIMIZE") :
                     wParam == SC_MAXIMIZE ? TEXT("SC_MAXIMIZE") :
                     wParam == SC_NEXTWINDOW ? TEXT("SC_NEXTWINDOW") :
                     wParam == SC_PREVWINDOW ? TEXT("SC_PREVWINDOW") :
                     wParam == SC_CLOSE ? TEXT("SC_CLOSE") :
                     wParam == SC_VSCROLL ? TEXT("SC_VSCROLL") :
                     wParam == SC_HSCROLL ? TEXT("SC_HSCROLL") :
                     wParam == SC_MOUSEMENU ? TEXT("SC_MOUSEMENU") :
                     wParam == SC_KEYMENU ? TEXT("SC_KEYMENU") :
                     wParam == SC_ARRANGE ? TEXT("SC_ARRANGE") :
                     wParam == SC_RESTORE ? TEXT("SC_RESTORE") :
                     wParam == SC_TASKLIST ? TEXT("SC_TASKLIST") :
                     wParam == SC_SCREENSAVE ? TEXT("SC_SCREENSAVE") :
                     wParam == SC_HOTKEY ? TEXT("SC_HOTKEY") :
                     wParam == SC_DEFAULT ? TEXT("SC_DEFAULT") :
                     wParam == SC_MONITORPOWER ? TEXT("SC_MONITORPOWER") :
                     wParam == SC_CONTEXTHELP ? TEXT("SC_CONTEXTHELP") :
                     wParam == SC_SEPARATOR ? TEXT("SC_SEPARATOR") :
                     TEXT("unknown"));
        {
            ULONG state = _this->getTaskSwState(id);
            switch (wParam) {
            case SC_MINIMIZE:
                if (!(state & rfbWindowStateMinimized))
                    _this->m_clientconn->SendWindowControl(id, rfbWindowControlMinimize);
                else
                    vnclog.Print(0, TEXT("MetaTaskbar : ERROR : window 0x%X is already minimized\n"), id);
                break;
            case SC_MAXIMIZE:
                if (!(state & rfbWindowStateMaximized))
                    _this->m_clientconn->SendWindowControl(id, rfbWindowControlMaximize);
                else
                    vnclog.Print(0, TEXT("MetaTaskbar : ERROR : window 0x%X is already maximized\n"), id);
                break;
            case SC_RESTORE:
                if (state & (rfbWindowStateMinimized | rfbWindowStateMaximized))
                    _this->m_clientconn->SendWindowControl(id, rfbWindowControlRestore);
                else
                    _this->m_clientconn->SendWindowControl(id, rfbWindowControlMinimize);       // the task switch is clicked
                break;
            case SC_CLOSE:
                _this->m_clientconn->SendWindowControl(id, rfbWindowControlClose);
                break;
            }
        }
        break;

    default:
        break;
    }
	return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
Ejemplo n.º 11
0
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
{
    if (message == WM_NCCREATE)
        return true;

    MSG msg;
    msg.hwnd = hwnd;
    msg.message = message;
    msg.wParam = wp;
    msg.lParam = lp;
    QCoreApplication *app = QCoreApplication::instance();
    long result;
    if (!app) {
        if (message == WM_TIMER)
            KillTimer(hwnd, wp);
        return 0;
    } else if (app->filterEvent(&msg, &result)) {
        return result;
    }

#ifdef GWLP_USERDATA
    QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
#else
    QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA);
#endif
    QEventDispatcherWin32Private *d = 0;
    if (q != 0)
        d = q->d_func();

    if (message == WM_QT_SOCKETNOTIFIER) {
        // socket notifier message
        int type = -1;
        switch (WSAGETSELECTEVENT(lp)) {
        case FD_READ:
        case FD_CLOSE:
        case FD_ACCEPT:
            type = 0;
            break;
        case FD_WRITE:
        case FD_CONNECT:
            type = 1;
            break;
        case FD_OOB:
            type = 2;
            break;
        }
        if (type >= 0) {
            Q_ASSERT(d != 0);
            QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except };
            QSNDict *dict = sn_vec[type];

            QSockNot *sn = dict ? dict->value(wp) : 0;
            if (sn) {
                QEvent event(QEvent::SockAct);
                QCoreApplication::sendEvent(sn->obj, &event);
            }
        }
        return 0;
    } else if (message == WM_TIMER) {    
        Q_ASSERT(d != 0);
        d->sendTimerEvent(wp);
        return 0;
    } else if (message == WM_QT_SENDPOSTEDEVENTS) {
        int localSerialNumber = d->serialNumber;
        if (localSerialNumber != d->lastSerialNumber) {
            d->lastSerialNumber = localSerialNumber;
#ifndef Q_OS_WINCE
            d->lastMessageTime = GetMessageTime();
#endif
            QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
        }
        return 0;
    }

    return DefWindowProc(hwnd, message, wp, lp);
}
Ejemplo n.º 12
0
/* 
 * Download a file from an URL
 * Mostly taken from http://support.microsoft.com/kb/234913
 * If hProgressDialog is not NULL, this function will send INIT and EXIT messages
 * to the dialog in question, with WPARAM being set to nonzero for EXIT on success
 * and also attempt to indicate progress using an IDC_PROGRESS control
 */
BOOL DownloadFile(const char* url, const char* file, HWND hProgressDialog)
{
	HWND hProgressBar = NULL;
	BOOL r = FALSE;
	DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize, dwStatus;
	FILE* fd = NULL; 
	LONG progress_style;
	unsigned char buf[DOWNLOAD_BUFFER_SIZE];
	char agent[64], hostname[64], urlpath[128];
	HINTERNET hSession = NULL, hConnection = NULL, hRequest = NULL;
	URL_COMPONENTSA UrlParts = {sizeof(URL_COMPONENTSA), NULL, 1, (INTERNET_SCHEME)0,
		hostname, sizeof(hostname), 0, NULL, 1, urlpath, sizeof(urlpath), NULL, 1};
	int i;

	if (hProgressDialog != NULL) {
		// Use the progress control provided, if any
		hProgressBar = GetDlgItem(hProgressDialog, IDC_PROGRESS);
		if (hProgressBar != NULL) {
			progress_style = GetWindowLong(hProgressBar, GWL_STYLE);
			SetWindowLong(hProgressBar, GWL_STYLE, progress_style & (~PBS_MARQUEE));
			SendMessage(hProgressBar, PBM_SETPOS, 0, 0);
		}
		SendMessage(hProgressDialog, UM_ISO_INIT, 0, 0);
	}

	PrintStatus(0, FALSE, lmprintf(MSG_240, file));
	uprintf("Downloading %s from %s\n", file, url);

	if (!InternetCrackUrlA(url, (DWORD)safe_strlen(url), 0, &UrlParts)) {
		uprintf("Unable to decode URL: %s\n", WindowsErrorString());
		goto out;
	}
	hostname[sizeof(hostname)-1] = 0;

	// Open an Internet session
	for (i=5; (i>0) && (!InternetGetConnectedState(&dwFlags, 0)); i--) {
		Sleep(1000);
	}
	if (i <= 0) {
		// http://msdn.microsoft.com/en-us/library/windows/desktop/aa384702.aspx is wrong...
		SetLastError(ERROR_INTERNET_NOT_INITIALIZED);
		uprintf("Network is unavailable: %s\n", WinInetErrorString());
		goto out;
	}
	_snprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d.%d", rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]);
	hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if (hSession == NULL) {
		uprintf("Could not open internet session: %s\n", WinInetErrorString());
		goto out;
	}

	hConnection = InternetConnectA(hSession, UrlParts.lpszHostName, UrlParts.nPort, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)NULL);
	if (hConnection == NULL) {
		uprintf("Could not connect to server %s:%d: %s\n", UrlParts.lpszHostName, UrlParts.nPort, WinInetErrorString());
		goto out;
	}

	hRequest = HttpOpenRequestA(hConnection, "GET", UrlParts.lpszUrlPath, NULL, NULL, (const char**)"*/*\0",
		INTERNET_FLAG_HYPERLINK|INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP|INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS|INTERNET_FLAG_NO_COOKIES|
		INTERNET_FLAG_NO_UI|INTERNET_FLAG_NO_CACHE_WRITE, (DWORD_PTR)NULL);
	if (hRequest == NULL) {
		uprintf("Could not open url %s: %s\n", url, WindowsErrorString());
		goto out;
	}

	if (!HttpSendRequestA(hRequest, NULL, 0, NULL, 0)) {
		uprintf("Unable to send request: %s\n", WinInetErrorString());
		goto out;
	}

	// Get the file size
	dwSize = sizeof(dwStatus);
	dwStatus = 404;
	HttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwStatus, &dwSize, NULL);
	if (dwStatus != 200) {
		error_code = ERROR_INTERNET_ITEM_NOT_FOUND;
		uprintf("Unable to access file: Server status %d\n", dwStatus);
		goto out;
	}
	dwSize = sizeof(dwTotalSize);
	if (!HttpQueryInfoA(hRequest, HTTP_QUERY_CONTENT_LENGTH|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwTotalSize, &dwSize, NULL)) {
		uprintf("Unable to retrieve file length: %s\n", WinInetErrorString());
		goto out;
	}
	uprintf("File length: %d bytes\n", dwTotalSize);

	fd = fopenU(file, "wb");
	if (fd == NULL) {
		uprintf("Unable to create file '%s': %s\n", file, WinInetErrorString());
		goto out;
	}

	// Keep checking for data until there is nothing left.
	dwSize = 0;
	while (1) {
		if (IS_ERROR(FormatStatus))
			goto out;

		if (!InternetReadFile(hRequest, buf, sizeof(buf), &dwDownloaded) || (dwDownloaded == 0))
			break;
		dwSize += dwDownloaded;
		SendMessage(hProgressBar, PBM_SETPOS, (WPARAM)(MAX_PROGRESS*((1.0f*dwSize)/(1.0f*dwTotalSize))), 0);
		PrintStatus(0, FALSE, lmprintf(MSG_241, (100.0f*dwSize)/(1.0f*dwTotalSize)));
		if (fwrite(buf, 1, dwDownloaded, fd) != dwDownloaded) {
			uprintf("Error writing file '%s': %s\n", file, WinInetErrorString());
			goto out;
		}
	}

	if (dwSize != dwTotalSize) {
		uprintf("Could not download complete file - read: %d bytes, expected: %d bytes\n", dwSize, dwTotalSize);
		FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
		goto out;
	} else {
		r = TRUE;
		uprintf("Successfully downloaded '%s'\n", file);
	}

out:
	if (hProgressDialog != NULL)
		SendMessage(hProgressDialog, UM_ISO_EXIT, (WPARAM)r, 0);
	if (fd != NULL) fclose(fd);
	if (!r) {
		_unlink(file);
		PrintStatus(0, FALSE, lmprintf(MSG_242));
		SetLastError(error_code);
		MessageBoxU(hMainDialog, IS_ERROR(FormatStatus)?StrError(FormatStatus):WinInetErrorString(),
		lmprintf(MSG_044), MB_OK|MB_ICONERROR);
	}
	if (hRequest) InternetCloseHandle(hRequest);
	if (hConnection) InternetCloseHandle(hConnection);
	if (hSession) InternetCloseHandle(hSession);

	return r;
}
Ejemplo n.º 13
0
//***********************************************************************
void CJungleScene::HandlePuzzle1Buttons( HWND hWnd, ITEMID id )
//***********************************************************************
{
	int iSndID = GetWindowWord( GetDlgItem(hWnd, id), GWW_ICONID );
	if ( !iSndID )
		iSndID = id;

	// Get the current shot info from the video
	LPVIDEO lpVideo = (LPVIDEO)GetWindowLong( GetDlgItem(hWnd, IDC_VIDEO_GAME), GWL_DATAPTR );
	if ( !lpVideo)
		return;
	LPSHOT lpShot =  &lpVideo->lpAllShots [lpVideo->lCurrentShot - 1];
	if (!lpShot)
		return;

	// Extract the shot number
	int iShotNum = (int)(lpShot->lFlags & A_VALUE_BITS);
	// How many items in the list?
	int nItems = sizeof(m_PuzzleInfo) / sizeof(VRECOINFO);
	// Get the index of the item matching the shot
	for ( int idx = 0; idx < nItems; idx++ )
	{
		if ( iShotNum == m_PuzzleInfo[idx].iShotNum )
			break;
	}

	if ( idx == nItems )
		return; // Couldn't find the shot in the list

	int iNxtSyllable = m_PuzzleInfo[idx].iSyllables[nMatches];
	int iNumSyllables = m_PuzzleInfo[idx].sNumSyllables;

	// Does the button match the next syllable?
	if (iSndID == iNxtSyllable)
	{
//		int iState = GetWindowWord( GetDlgItem(hWnd, id), GWW_STATE );
//		SendMessage( GetDlgItem(hWnd, id), SM_SETSTATE, !iState, 0L);
		SendMessage( GetDlgItem(hWnd, id), SM_SETSTATE, 1, 0L);

		// Give them instinct points
		ChangeInstinctMeter (hWnd, GOOD_RESPONSE);
		// Set progress meter
		nMatches++;
		long lProgress = (METER_MAX * nMatches) / (long)iNumSyllables;
		SendMessage( GetDlgItem(hWnd, IDC_PUZ_PROGRESS), SM_SETPOSITION, 0, lProgress );
		// Is this the last syllable?
		if (nMatches >= iNumSyllables)
		{
			// Delay so the progress meter is shown
			Delay( 1500 );
			// Simulate an EVENT_DOWN (good response) to the video control
			FORWARD_WM_KEYDOWN (GetDlgItem(hWnd, IDC_VIDEO_GAME), VK_DOWN,
				0/*cRepeat*/, 0/*flags*/, SendMessage);
		}
		return;
	}

	// It is not a match

	// Take instinct points away
	ChangeInstinctMeter (hWnd, BAD_RESPONSE);

//	// Simulate a wrong button pressed
//	FORWARD_WM_KEYDOWN (GetDlgItem(hWnd, IDC_VIDEO_GAME), VK_UP,
//		0/*cRepeat*/, 0/*flags*/, SendMessage);
}
Ejemplo n.º 14
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Сохранить дескриптор экземпляра в глобальной переменной

   hWnd = CreateWindow(szWindowClass, L"Пятнашки", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,100, 100, 640, 490, NULL, NULL, hInstance, NULL);

   CreateWindow(L"button", L"Перемішати", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,450, 40, 150, 30, hWnd, (HMENU)10000, hInstance, NULL);

   CreateWindow(L"button", L"Зберегти", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,	450, 80, 150, 30, hWnd, (HMENU)9000, hInstance, NULL);

   CreateWindow(L"button", L"Відкрити останнє", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 450, 120, 150, 30, hWnd, (HMENU)8000, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   InvalidateRect(hWnd, NULL,true);
   UpdateWindow(hWnd);

   return TRUE;
}
Ejemplo n.º 15
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	PTOON pToon = NULL;
	PDIB pdibSrc, pdibDst;
	LPOFFSCREEN lpOffScreen = NULL;

	if (IsRectEmpty(lpRect))
		return;
	PSTORY pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	// Draw the Bitmap
	rSrcArea = *lpRect;
	rDstArea = *lpRect;

	LPSCENE lpScene = CScene::GetScene(GetParent(hWindow));
	if (lpScene)
		lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
	 	if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
	}
	else
	{
		// see if there is a toon control
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		pdibSrc = pToon->GetStageDib();
		MapWindowPoints( hWindow, GetParent(hToon), (LPPOINT)&rDstArea, 2 );
 	}

	// create a dib to draw into
	pdibDst = new CDib();
	if (!pdibDst)
		return;
	if (!pdibDst->Create(pdibSrc->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pdibDst;
		return;
	}
	pdibDst->CopyColorTable(pdibSrc);
	
	// copy our color table into the dest dib
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	// draw in background
	pdibSrc->DibBlt( pdibDst,
					0, 0,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	rDstArea.left, rDstArea.top,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	NO /*bTransparent*/ );

	// now draw in foreground
	RGBTRIPLE rgb;
	LPRGBTRIPLE lpRGB = NULL;
	if (dwStyle & BS_MASK)
	{
		STRING szColor;
		GetWindowText(hWindow, szColor, sizeof(szColor));
		AsciiRGB( szColor, &rgb );
		if (fHighlight)
		{
			// this relies on the fact that AsciiRGB replaces commas
			// with NULL terminators
			LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
			lp += lstrlen(lp) + 1; // passed green
			lp += lstrlen(lp) + 1; // passed blue to higlight color
			AsciiRGB(lp, &rgb);
			rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
		}
		else
			rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
		lpRGB = &rgb;
	}
	pStory->m_pDib->DibBlt( pdibDst,
				0, 0,
				rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				YES /*bTransparent*/, lpRGB, App.m_lpLut );

	pdibDst->DCBlt( hDC,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
			 	0, 0,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top);

	delete pdibDst;
}
Ejemplo n.º 16
0
/*
  \internal
  Platform-specific part of QWidget::show().
*/
void QWidgetPrivate::show_sys() {
    Q_Q(QWidget);
#if defined(QT_NON_COMMERCIAL)
    QT_NC_SHOW_WINDOW
#endif
    if (q->testAttribute(Qt::WA_OutsideWSRange))
        return;

    q->setAttribute(Qt::WA_Mapped);

    Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));

    if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
        invalidateBuffer(q->rect());
        return;
    }


    int sm = SW_SHOW;
    bool fakedMaximize = false;
    if (q->isWindow()) {
#ifndef Q_WS_WINCE_WM
        if (q->isMinimized()) {
            sm = SW_SHOWMINIMIZED;
        } else if (q->isMaximized()) {
            sm = SW_SHOWMAXIMIZED;
            // Windows will not behave correctly when we try to maximize a window which does not
            // have minimize nor maximize buttons in the window frame. Windows would then ignore
            // non-available geometry, and rather maximize the widget to the full screen, minus the
            // window frame (caption). So, we do a trick here, by adding a maximize button before
            // maximizing the widget, and then remove the maximize button afterwards.
            Qt::WindowFlags &flags = data.window_flags;
            if (flags & Qt::WindowTitleHint &&
                !(flags & (Qt::WindowMinMaxButtonsHint | Qt::FramelessWindowHint))) {
                fakedMaximize = TRUE;
                int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
                SetWindowLong(q->internalWinId(), GWL_STYLE, style | WS_MAXIMIZEBOX);
            }
        } else
#else
        // Imitate minimizing on Windows mobile by hiding the widget.
        if (q->isMinimized())
            sm = SW_HIDE;
#endif
        if (q->isHidden()) {
            sm = SW_HIDE;
        }
    }
    if (q->testAttribute(Qt::WA_ShowWithoutActivating)
        || (q->windowType() == Qt::Popup)
        || (q->windowType() == Qt::ToolTip)
        || (q->windowType() == Qt::Tool)) {
        sm = SW_SHOWNOACTIVATE;
    }

    ShowWindow(q->internalWinId(), sm);

    if (q->isMaximized() && q->isWindow())
        qt_wince_maximize(q);

#ifndef Q_WS_WINCE_WM
    if (!qt_wince_is_mobile() && q->isFullScreen()) {
        HWND handle = FindWindow(L"HHTaskBar", L"");
        if (handle) {
            ShowWindow(handle, SW_HIDE);
            EnableWindow(handle, false);
        }
    }

    if (fakedMaximize) {
        int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
        SetWindowLong(q->internalWinId(), GWL_STYLE, style & ~WS_MAXIMIZEBOX);
        SetWindowPos(q->internalWinId(), 0, 0, 0, 0, 0,
                     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER
                     | SWP_FRAMECHANGED);
    }
#else
    Q_UNUSED(fakedMaximize);
#endif

    if (q->isWindow() && sm == SW_SHOW)
        SetForegroundWindow(q->internalWinId());

    invalidateBuffer(q->rect());
}
Ejemplo n.º 17
0
PSTORY GetStory(HWND hWindow)
/***********************************************************************/
{
	return((PSTORY)GetWindowLong(hWindow, GWL_STORY));
}
Ejemplo n.º 18
0
void QWidget::setWindowState(Qt::WindowStates newstate)
{
    Q_D(QWidget);
    Qt::WindowStates oldstate = windowState();
    if (oldstate == newstate)
        return;

    int max = SW_SHOWNORMAL;
    int normal = SW_SHOWNOACTIVATE;

    if ((oldstate & Qt::WindowMinimized) && !(newstate & Qt::WindowMinimized))
        newstate |= Qt::WindowActive;
    if (newstate & Qt::WindowActive)
        normal = SW_SHOWNORMAL;
    if (isWindow()) {
        createWinId();
        Q_ASSERT(testAttribute(Qt::WA_WState_Created));
        // Ensure the initial size is valid, since we store it as normalGeometry below.
        if ((!testAttribute(Qt::WA_Resized) && !isVisible()))
            adjustSize();
        if (!d->topData()->normalGeometry.isValid()) {
            if (newstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen))
                d->topData()->normalGeometry = geometry();
            if (newstate & Qt::WindowMinimized && !(oldstate & Qt::WindowFullScreen))
                d->topData()->normalGeometry = geometry();
        }
        if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {
            if (!(newstate & Qt::WindowMaximized)) {
                int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION;
                SetWindowLong(internalWinId(), GWL_STYLE, style);
                SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG);
            }
            if (isVisible() && newstate & Qt::WindowMaximized)
                qt_wince_maximize(this);
            if (isVisible() && !(newstate & Qt::WindowMinimized)) {
                ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal);
                if (!(newstate & Qt::WindowFullScreen)) {
                    QRect r = d->topData()->normalGeometry;
                    if (!(newstate & Qt::WindowMaximized) && r.width() >= 0) {
                        if (pos() != r.topLeft() || size() !=r.size()) {
                            d->topData()->normalGeometry = QRect(0,0,-1,-1);
                            setGeometry(r);
                        }
                    }
                } else {
                    d->updateFrameStrut();
                }
            }
        }
        if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
            if (newstate & Qt::WindowFullScreen) {
                if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
                    d->topData()->normalGeometry = geometry();
                d->topData()->savedFlags = (Qt::WindowFlags)GetWindowLong(internalWinId(), GWL_STYLE);
                UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
                if (isVisible())
                    style |= WS_VISIBLE;
                SetWindowLong(internalWinId(), GWL_STYLE, style);
                QRect r = qApp->desktop()->screenGeometry(this);
                UINT swpf = SWP_FRAMECHANGED;
                if (newstate & Qt::WindowActive)
                    swpf |= SWP_NOACTIVATE;
                qt_wince_full_screen(internalWinId(), true, swpf);
                d->updateFrameStrut();
            } else {
                UINT style = d->topData()->savedFlags;
                if (isVisible())
                    style |= WS_VISIBLE;
                SetWindowLong(internalWinId(), GWL_STYLE, style);
                UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
                if (newstate & Qt::WindowActive)
                    swpf |= SWP_NOACTIVATE;
                qt_wince_full_screen(internalWinId(), false, swpf);
                d->updateFrameStrut();

                // preserve maximized state
                if (isVisible()) {
                    ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal);
                    if (newstate & Qt::WindowMaximized)
                        qt_wince_maximize(this);
                }
                if (!(newstate & Qt::WindowMaximized)) {
                    QRect r = d->topData()->normalGeometry;
                    d->topData()->normalGeometry = QRect(0,0,-1,-1);
                    if (r.isValid())
                        setGeometry(r);
                }
            }
        }
        if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
            if (newstate & Qt::WindowMinimized)
                qt_wince_minimize(internalWinId());
            else if (newstate & Qt::WindowMaximized) {
                ShowWindow(internalWinId(), max);
                qt_wince_maximize(this);
            } else {
                ShowWindow(internalWinId(), normal);
            }
        }
    }
    data->window_state = newstate;
    QWindowStateChangeEvent e(oldstate);
    QApplication::sendEvent(this, &e);
}
Ejemplo n.º 19
0
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	TRichUtil *ru = 0, tru;
	int idx;

	EnterCriticalSection(&csRich);
	tru.hwnd = hwnd;
	if (li.List_GetIndex(&sListInt, &tru, &idx))
		ru = (TRichUtil*)sListInt.items[idx];
	LeaveCriticalSection(&csRich);
	switch(msg) {
		case WM_THEMECHANGED:
		case WM_STYLECHANGED:
		{
			RichUtil_ClearUglyBorder(ru);
			break;
		}
		case WM_NCPAINT:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
			if (ru->hasUglyBorder&&MyIsThemeActive()) {
				HANDLE hTheme = MyOpenThemeData(ru->hwnd, L"EDIT");

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

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

			if (ru->hasUglyBorder&&MyIsThemeActive()) {
				HANDLE hTheme = MyOpenThemeData(hwnd, L"EDIT");

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

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

			if(IsWindow(hwnd)) {
				if((WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC) == &RichUtil_Proc)
					SetWindowLong(hwnd, GWL_WNDPROC, (LONG)ru->origProc);
			}
			EnterCriticalSection(&csRich);
			li.List_Remove(&sListInt, idx);
			LeaveCriticalSection(&csRich);
			if (ru) mir_free(ru);
			return ret;
		}
	}
	return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
}
Ejemplo n.º 20
0
//
//	Initialize the cool scrollbars for a window by subclassing it
//	and using the coolsb window procedure instead
//
BOOL WINAPI InitializeCoolSB(HWND hwnd)
{
	SCROLLWND *sw;
	SCROLLINFO *si;
	INITCOMMONCONTROLSEX ice;
	TOOLINFO ti;
	RECT rect;
	DWORD dwCurStyle;
	//BOOL fDisabled;

	if(pEnableScrollBar == 0)
		pEnableScrollBar = EnableScrollBar;

	GetClientRect(hwnd, &rect);

	//if we have already initialized Cool Scrollbars for this window,
	//then stop the user from doing it again
	if(GetScrollWndFromHwnd(hwnd) != 0)
	{
		return FALSE;
	}

	//allocate a private scrollbar structure which we 
	//will use to keep track of the scrollbar data
	sw = (SCROLLWND *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SCROLLWND));

	si = &sw->sbarHorz.scrollInfo;
	si->cbSize = sizeof(SCROLLINFO);
	si->fMask  = SIF_ALL;
	GetScrollInfo(hwnd, SB_HORZ, si);

	si = &sw->sbarVert.scrollInfo;
	si->cbSize = sizeof(SCROLLINFO);
	si->fMask  = SIF_ALL;
	GetScrollInfo(hwnd, SB_VERT, si);

	//check to see if the window has left-aligned scrollbars
	if(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LEFTSCROLLBAR)
		sw->fLeftScrollbar = TRUE;
	else
		sw->fLeftScrollbar = FALSE;

	dwCurStyle = GetWindowLong(hwnd, GWL_STYLE);

	SetProp(hwnd, szPropStr, (HANDLE)sw);

	//try to enable the scrollbar arrows - if the return value is
	//non-zero, then the scrollbars were previously disabled
	//fDisabled = pEnableScrollBar(hwnd, SB_HORZ, ESB_ENABLE_BOTH);

	//scrollbars will automatically get enabled, even if
	//they aren't to start with....sorry, but there isn't an
	//easy alternative.
	if(dwCurStyle & WS_HSCROLL)
		sw->sbarHorz.fScrollFlags = CSBS_VISIBLE;

	if(dwCurStyle & WS_VSCROLL)
		sw->sbarVert.fScrollFlags = CSBS_VISIBLE;

	//need to be able to distinguish between horizontal and vertical
	//scrollbars in some instances
	sw->sbarHorz.nBarType	     = SB_HORZ;
	sw->sbarVert.nBarType	     = SB_VERT;

	sw->sbarHorz.fFlatScrollbar  = CSBS_NORMAL;
	sw->sbarVert.fFlatScrollbar  = CSBS_NORMAL;

	//set the default arrow sizes for the scrollbars
	sw->sbarHorz.nArrowLength	 = SYSTEM_METRIC;
	sw->sbarHorz.nArrowWidth	 = SYSTEM_METRIC;
	sw->sbarVert.nArrowLength	 = SYSTEM_METRIC;
	sw->sbarVert.nArrowWidth	 = SYSTEM_METRIC;

	sw->bPreventStyleChange		 = FALSE;
	
	sw->oldproc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)CoolSBWndProc);

	CoolSB_SetMinThumbSize(hwnd, SB_BOTH, CoolSB_GetDefaultMinThumbSize());

#ifdef COOLSB_TOOLTIPS
	ice.dwSize = sizeof(ice);
	ice.dwICC  = ICC_BAR_CLASSES;
	InitCommonControlsEx(&ice);

	sw->hwndToolTip = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, TOOLTIPS_CLASS, _T(""),
                            WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            hwnd, NULL, GetModuleHandle(0),
                            NULL);

	ti.cbSize = sizeof(TOOLINFO);
	ti.uFlags = TTF_IDISHWND;
	ti.hwnd   = hwnd;
	ti.uId    = (UINT)hwnd;
	ti.lpszText = LPSTR_TEXTCALLBACK;
	ti.hinst   = GetModuleHandle(0);

	SendMessage(sw->hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
	
#else

	UNREFERENCED_PARAMETER(ice);
	UNREFERENCED_PARAMETER(ti);
	sw->hwndToolTip = 0;

#endif
	
	//send the window a frame changed message to update the scrollbars
	RedrawNonClient(hwnd, TRUE);

	return TRUE;
}
Ejemplo n.º 21
0
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
            LPSTR lpCmdLine, int nCmdShow)
{
    HWND hWnd;
    WNDCLASSEX wcex;
    MSG nMsg;
    HFONT hfHelp;

    long lStyle;
    const char* lpWndClass = "CClock";
    const char* lpTitle = "";

    lWinWidth = 450;
    lWinHeight = 135;
    lDeskWidth = GetDeviceCaps(GetDC(GetDesktopWindow()), HORZRES);
    lDeskHeight = GetDeviceCaps(GetDC(GetDesktopWindow()), VERTRES);
    crWndColor = RGB(0, 0, 0);
    srand((unsigned)time(NULL));

    // The WNDCLASSEX details
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_DROPSHADOW;
    wcex.lpfnWndProc = WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP));
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = CreateSolidBrush(crWndColor);
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = lpWndClass;
    wcex.hIconSm = NULL;

    RegisterClassEx(&wcex);

    hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, lpWndClass, lpTitle,
                          WS_POPUP, (lDeskWidth - lWinWidth)/2,
                          (lDeskHeight - lWinHeight)/2, lWinWidth, lWinHeight,
                          NULL, NULL, hInstance, NULL);

    hLblHelp = CreateWindowEx(WS_EX_TOOLWINDOW, "STATIC", "?",
                              WS_CHILD | SS_NOTIFY, 440, -2, 25, 20,
                              hWnd, NULL, hInstance, NULL);

    hfHelp = CreateFont(0, 6, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
                        ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                        DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma");

    SendMessage(hLblHelp, WM_SETFONT, (WPARAM)hfHelp, (LPARAM)TRUE);

    lOpacity = 255;
    lStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
    SetWindowLong(hWnd, GWL_EXSTYLE, lStyle | WS_EX_LAYERED);
    SetLayeredWindowAttributes(hWnd, crWndColor, lOpacity, LWA_ALPHA);

    ShowWindow(hWnd, SW_SHOWNORMAL);
    ShowWindow(hLblHelp, SW_SHOWNORMAL);

    UpdateWindow(hWnd);

    SetTimer(hWnd, nIDTmr, 1000, TmrProc);
    fnParseTime(hWnd);

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

    DeleteObject(hfHelp);
    return nMsg.wParam;
}
Ejemplo n.º 22
0
void * s_video_gdi_create_window (void *arg)
{
	MSG msg;
	RECT rect;
	HDC mainwindow;
	WNDCLASSEX wndclass;
	char *szMainWndClass = "XynthWindowingSystem";
	s_video_gdi_data_t *priv = (s_video_gdi_data_t *) xynth_server->driver->driver_data;

	memset(&wndclass, 0, sizeof(WNDCLASSEX));
	wndclass.lpszClassName = szMainWndClass;
	wndclass.cbSize = sizeof(WNDCLASSEX);
	wndclass.style = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc = MainWndProc;
	wndclass.hInstance = priv->hinst;
	wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
	RegisterClassEx(&wndclass);
	
	priv->hwndMain = CreateWindow(szMainWndClass,
	                              "Xynth Windowing system",
                                      WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX | WS_CAPTION,
	                              CW_USEDEFAULT,
	                              CW_USEDEFAULT,
	                              CW_USEDEFAULT,
	                              CW_USEDEFAULT,
	                              NULL,
	                              NULL,
	                              priv->hinst,
	                              NULL);

	rect.left = 0;
	rect.right = xynth_server->window->surface->width;
	rect.top = 0;
	rect.bottom = xynth_server->window->surface->height;
        AdjustWindowRect(&rect, GetWindowLong(priv->hwndMain, GWL_STYLE), FALSE);
        SetWindowPos(priv->hwndMain, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE);

	ShowWindow(priv->hwndMain, TRUE);
	UpdateWindow(priv->hwndMain);
	
	mainwindow = GetDC(priv->hwndMain);
	if (mainwindow == NULL) {
                debugf(DSER | DFAT, "What the fuck is this?");
		return NULL;
	}
	priv->bpp_windows = GetDeviceCaps(mainwindow, BITSPIXEL);
	if (priv->bpp_windows == 24) {
                debugf(DSER | DFAT, "24 bitsperpixel modes are not supported by Xynth Windowing System. "
                                    "Try changing display mode from "
                                    "Display Properties -> Settings -> Color quality.");
        }

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

	return (void *) msg.wParam;
}
Ejemplo n.º 23
0
void ChangeScreenMode( gxBool bFullScreen )
{
	//フルスクリーン / ウインドウモード切り替え

	RECT rc;
	DEVMODE devmode;

	EnumDisplaySettings( NULL, 0, &devmode );

	if( bFullScreen )
	{
		//フルスクリーンモード
		if( g_pWindows->m_bFullScreen ) return;

		Sint32 w,h;
		w = 640;
		h = 480;
		g_pWindows->m_AppStyle = GetWindowLong( g_pWindows->m_hWindow , GWL_STYLE);
		GetWindowRect( g_pWindows->m_hWindow , &g_pWindows->m_WinRect );

		devmode.dmSize       = sizeof(DEVMODE);
		devmode.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT;
		devmode.dmPelsWidth  = w;//SWINDOW_W;
		devmode.dmPelsHeight = h;//SWINDOW_H;

		Sint32 bw,bh;
		bw =  GetSystemMetrics(SM_CXSIZEFRAME)*2;
		bh =  GetSystemMetrics(SM_CYSIZEFRAME)*2;
		SetMenu           ( g_pWindows->m_hWindow , NULL );
		SetWindowLong     ( g_pWindows->m_hWindow , GWL_STYLE, WS_POPUP|WS_VISIBLE|WS_EX_TOPMOST );
		MoveWindow        (	g_pWindows->m_hWindow , -bw/2,-bh/2, w+bw , h+bh , true	);

		Sint32 err = ChangeDisplaySettings( &devmode, CDS_FULLSCREEN );
		if( DISP_CHANGE_SUCCESSFUL )
		{
		}

		//マルチディスプレイ時のカーソルの移動制限を行う
		g_pWindows->m_uScreenWidth  = w;
		g_pWindows->m_uScreenHeight = h;

		SetRect(&rc, 0, 0, g_pWindows->m_uScreenWidth, g_pWindows->m_uScreenHeight );
		ClipCursor( &rc );

		UpdateWindow( g_pWindows->m_hWindow );

//		::Resume();

		g_pWindows->m_bFullScreen = gxTrue;

		while( ShowCursor(FALSE)>0 );
	}
	else
	{
		//Windowモード

		if( !g_pWindows->m_bFullScreen ) return;
/*
		devmode.dmSize       = sizeof(DEVMODE);
		devmode.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT;
		devmode.dmPelsWidth  = SWINDOW_W;
		devmode.dmPelsHeight = SWINDOW_H;
*/
		Sint32 bw,bh;
#ifdef NDEBUG
		bw =  GetSystemMetrics(SM_CXSIZEFRAME)*2;
		bh =  GetSystemMetrics(SM_CYSIZEFRAME)*2+GetSystemMetrics(SM_CYCAPTION);
//		SetMenu( ggx.m_Windows.g_hWnd , NULL );
#else
		bw =  GetSystemMetrics(SM_CXFIXEDFRAME)*2;
		bh =  GetSystemMetrics(SM_CYFIXEDFRAME)*2;
		bh += GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYMENU);
//		SetMenu( ggx.m_Windows.g_hWnd , LoadMenu( ggx.m_Windows.hInst ,	MAKEINTRESOURCE(CGameGirl::GetInstance()->MENU_BAR) ) );
#endif

		//Windowの大きさを元に戻す
		SetWindowLong( g_pWindows->m_hWindow , GWL_STYLE  , g_pWindows->m_AppStyle );
		SetWindowPos ( g_pWindows->m_hWindow,
		               HWND_NOTOPMOST,
		               g_pWindows->m_WinRect.left , g_pWindows->m_WinRect.top,
					   g_pWindows->m_WinRect.right-g_pWindows->m_WinRect.left, g_pWindows->m_WinRect.bottom-g_pWindows->m_WinRect.top,
					   SWP_SHOWWINDOW );

		ChangeDisplaySettings(NULL, 0);

		//マルチディスプレイ時のカーソルの移動制限を解除
		ClipCursor( NULL );

//		g_pWindows->m_uScreenWidth  = SWINDOW_W;
//		g_pWindows->m_uScreenHeight = SWINDOW_H;

		UpdateWindow( g_pWindows->m_hWindow );

//		::Resume();

		g_pWindows->m_bFullScreen = gxFalse;

		ShowCursor(TRUE);
	}

}
Ejemplo n.º 24
0
BOOL CALLBACK MsdDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	int port;
	static wchar_t buff[4096] = { 0 };

	switch (uMsg) {
	case WM_INITDIALOG:
	{
		memset(buff, 0, sizeof(buff));
		port = (int)lParam;
		SetWindowLong(hW, GWL_USERDATA, (LONG)lParam);
		CONFIGVARIANT var(N_CONFIG_PATH, CONFIG_TYPE_WCHAR);
		if (LoadSetting(port, APINAME, var))
			wcsncpy_s(buff, var.wstrValue.c_str(), ARRAYSIZE(buff));
		SetWindowTextW(GetDlgItem(hW, IDC_EDIT1), buff);
		return TRUE;
	}
	case WM_CREATE:
		SetWindowLong(hW, GWL_USERDATA, (LONG)lParam);
		break;
	case WM_COMMAND:

		if (HIWORD(wParam) == BN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDC_BUTTON1:
				ZeroMemory(&ofn, sizeof(ofn));
				ofn.lStructSize = sizeof(ofn);
				ofn.hwndOwner = hW;
				ofn.lpstrTitle = L"USB image file";
				ofn.lpstrFile = buff;
				ofn.nMaxFile = ARRAYSIZE(buff);
				ofn.lpstrFilter = L"All\0*.*\0";
				ofn.nFilterIndex = 1;
				ofn.lpstrFileTitle = NULL;
				ofn.nMaxFileTitle = 0;
				ofn.lpstrInitialDir = NULL;
				ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;

				if (GetOpenFileName(&ofn) == TRUE) {
					SetWindowText(GetDlgItem(hW, IDC_EDIT1), ofn.lpstrFile);
				}
				break;
			case IDOK:
			{
				INT_PTR res = RESULT_OK;
				GetWindowTextW(GetDlgItem(hW, IDC_EDIT1), buff, ARRAYSIZE(buff));
				port = (int)GetWindowLong(hW, GWL_USERDATA);
				CONFIGVARIANT var(N_CONFIG_PATH, CONFIG_TYPE_WCHAR);
				var.wstrValue = buff;
				if (!SaveSetting(port, APINAME, var))
					res = RESULT_FAILED;
				//strcpy_s(conf.usb_img, ofn.lpstrFile);
				EndDialog(hW, res);
				return TRUE;
			}
			case IDCANCEL:
				EndDialog(hW, FALSE);
				return TRUE;
			}
		}
	}
	return FALSE;
}
Ejemplo n.º 25
0
void RunAppl( HWND hWnd )
{
   zVIEW vSubtask = NULL;
   zSHORT nRC;
   char cNet = '\0', cError = '\0' ;
   char cApplication[ 32 ], cTE_Name[ 256 ], cLogFile[ 256 ] ;
   char *pc;

   HANDLE hInstance = (HANDLE) GetWindowLong( hWnd, GWL_HINSTANCE );
   LPSTR  lpCmdLine = (LPSTR) GetWindowLong( hWnd, GWL_USERDATA );

   // Analyze the Command Line

   // The command line is
   // "-p Application" "-t TE-Name" "[-n]" ["Log-File"]
   // "Application" and "TE-Name" are  required

   cApplication[ 0 ] = cLogFile[ 0 ] = '\0';
   pc = lpCmdLine + strspn( lpCmdLine, " "); // Blank-Eli

   do
   {

      if ( *pc != '-' )
      {
         cError = 'E';
         break;
      }
      ++pc;
      pc = pc + strspn( pc, " "); // Blank-Eli

      switch ( *pc )
      {
         case 'p':
            // Application name
            ++pc;
            pc = extract_name( pc, cApplication, sizeof( cApplication ) );
            break;

         case 't':
            // DBMS source name
            ++pc;
            pc = extract_name( pc, cTE_Name, sizeof( cTE_Name ) );
            break;

         case 'l':
            // Log file
            ++pc;
            pc = extract_name( pc, cLogFile, sizeof( cLogFile ) );
            break;

         case 'n':
            // Network switch
            cNet = 'X';
            ++pc;
            pc = pc + strspn( pc, " "); // Blank-Eli
            break;

         default:
            cError = 'E';
            break;
      }
   } while ( *pc != '\0' && cError == '\0' );

   if ( cApplication[ 0 ] == '\0' || cTE_Name[ 0 ] == '\0'|| cError != '\0' )
   {
      MessageBox( hWnd,
                  "Invalid Command Line - Application and TE-Name required",
                  "Error Running xodgen",
                  MB_OK | MB_ICONSTOP | MB_APPLMODAL );
      return;
   }

// nRC = RegisterZeidonApplication( &vSubtask, (zLONG) hInstance, (zLONG) hWnd,
//                                  WM_USER + 1, "~~Zeidon_Tools~", 0, 0 );
   nRC = RegisterZeidonApplication( &vSubtask, 0L, 0L,
                                    WM_USER + 1, "~~Zeidon_Tools~", 0, 0 );


   nRC= InitializeLPLR( vSubtask, cApplication );

   ProcessXods( hWnd, vSubtask, cTE_Name, cLogFile, cNet );

   UnregisterZeidonApplication( );
}
Ejemplo n.º 26
0
static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  if (uMsgCreate && message == uMsgCreate)
  {
    static HWND hwndPrevFocus;
    static BOOL fCancelDisabled;

    if (wParam)
    {
      childwnd = FindWindowEx((HWND) lParam, NULL, "#32770", NULL);
      hwndL = GetDlgItem(childwnd, 1016);
      hwndB = GetDlgItem(childwnd, 1027);
      HWND hwndP = GetDlgItem(childwnd, 1004);
      HWND hwndS = GetDlgItem(childwnd, 1006);
      if (childwnd && hwndP && hwndS)
      {
        // Where to restore focus to before we disable the cancel button
        hwndPrevFocus = GetFocus();
        if (!hwndPrevFocus)
          hwndPrevFocus = hwndP;

        if (IsWindowVisible(hwndL))
          ShowWindow(hwndL, SW_HIDE);
        else
          hwndL = NULL;
        if (IsWindowVisible(hwndB))
          ShowWindow(hwndB, SW_HIDE);
        else
          hwndB = NULL;

        RECT wndRect, ctlRect;

        GetClientRect(childwnd, &wndRect);

        GetWindowRect(hwndS, &ctlRect);

        HWND s = g_hwndStatic = CreateWindow(
          "STATIC",
          "",
          WS_CHILD | WS_CLIPSIBLINGS | SS_CENTER,
          0,
          wndRect.bottom / 2 - (ctlRect.bottom - ctlRect.top) / 2,
          wndRect.right,
          ctlRect.bottom - ctlRect.top,
          childwnd,
          NULL,
          hModule,
          NULL
        );

        DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS;
        dwStyle |= GetWindowLong(hwndP, GWL_STYLE) & PBS_SMOOTH;

        GetWindowRect(hwndP, &ctlRect);

        HWND pb = g_hwndProgressBar = CreateWindow(
          "msctls_progress32",
          "",
          dwStyle,
          0,
          wndRect.bottom / 2 + (ctlRect.bottom - ctlRect.top) / 2,
          wndRect.right,
          ctlRect.bottom - ctlRect.top,
          childwnd,
          NULL,
          hModule,
          NULL
        );

        long c;

        c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
        SendMessage(hwndP, PBM_SETBARCOLOR, 0, c);
        SendMessage(pb, PBM_SETBARCOLOR, 0, c);

        c = SendMessage(hwndP, PBM_SETBKCOLOR, 0, 0);
        SendMessage(hwndP, PBM_SETBKCOLOR, 0, c);
        SendMessage(pb, PBM_SETBKCOLOR, 0, c);

        // set font
        long hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0);
        SendMessage(pb, WM_SETFONT, hFont, 0);
        SendMessage(s, WM_SETFONT, hFont, 0);

        ShowWindow(pb, SW_SHOWNA);
        ShowWindow(s, SW_SHOWNA);

        fCancelDisabled = EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE);
        SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwnd, IDCANCEL), TRUE);
      }
      else
        childwnd = NULL;
    }
    else if (childwnd)
    {
      if (hwndB)
      {
        ShowWindow(hwndB, SW_SHOWNA);
        hwndB = NULL;
      }
      if (hwndL)
      {
        ShowWindow(hwndL, SW_SHOWNA);
        hwndL = NULL;
      }

      // Prevent wierd stuff happening if the cancel button happens to be
      // pressed at the moment we are finishing and restore the previous focus
      // and cancel button states
      SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwndPrevFocus, TRUE);
      SendMessage(GetDlgItem(hwnd, IDCANCEL), BM_SETSTATE, FALSE, 0);
      if (fCancelDisabled)
        EnableWindow(GetDlgItem(hwnd, IDCANCEL), FALSE);

      if (g_hwndStatic)
      {
        DestroyWindow(g_hwndStatic);
        g_hwndStatic = NULL;
      }
      if (g_hwndProgressBar)
      {
        DestroyWindow(g_hwndProgressBar);
        g_hwndProgressBar = NULL;
      }
      childwnd = NULL;
    }
  }
  else if (message == WM_COMMAND && LOWORD(wParam) == IDCANCEL)
  {
    g_cancelled = 1;
  }
  else
  {
    return CallWindowProc(
      (WNDPROC) lpWndProcOld,
      hwnd,
      message,
      wParam,
      lParam
    );
  }
  return 0;
}
Ejemplo n.º 27
0
//--------------------------------------------------------------------------
bool WindowsVideoDevice::SetupWindowData(VeWindow::Data* pkWindow,
	HWND hWnd, VE_BOOL bCreated) noexcept
{
	VE_ASSERT(pkWindow);
	VeWindowData* pkData = VE_NEW VeWindowData;
	VE_ASSERT(pkData);
	pkData->m_pkWindow = pkWindow;
	pkData->m_hWnd = hWnd;
	pkData->m_hDc = GetDC(hWnd);
	pkData->m_bCreated = bCreated;
	pkData->m_u32MouseButtonFlags = 0;
	pkWindow->m_spDriverdata = pkData;

	if (!SetProp(hWnd, TEXT("VeWindowData"), pkData))
	{
		ReleaseDC(hWnd, pkData->m_hDc);
		pkWindow->m_spDriverdata = nullptr;
		pkData = nullptr;
		return false;
	}

	pkData->m_pfuncWndProc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC);
	if (pkData->m_pfuncWndProc == WindowProc)
	{
		pkData->m_pfuncWndProc = nullptr;
	}
	else
	{
		SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)WindowProc);
	}

	{
		RECT rect;
		if (GetClientRect(hWnd, &rect))
		{
			VeInt32 w = rect.right;
			VeInt32 h = rect.bottom;
			if ((pkWindow->w && pkWindow->w != w) || (pkWindow->h && pkWindow->h != h))
			{
				SetWindowPositionInternal(pkWindow,
					SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
			}
			else
			{
				pkWindow->w = w;
				pkWindow->h = h;
			}
		}
	}

	{
		POINT point;
		point.x = 0;
		point.y = 0;
		if (ClientToScreen(hWnd, &point))
		{
			pkWindow->x = point.x;
			pkWindow->y = point.y;
		}
	}

	{
		DWORD style = GetWindowLong(hWnd, GWL_STYLE);
		if (style & WS_VISIBLE)
		{
			pkWindow->m_u32Flags |= VE_WINDOW_SHOWN;
		}
		else
		{
			pkWindow->m_u32Flags &= ~VE_WINDOW_SHOWN;
		}
		if (style & (WS_BORDER | WS_THICKFRAME))
		{
			pkWindow->m_u32Flags &= ~VE_WINDOW_BORDERLESS;
		}
		else
		{
			pkWindow->m_u32Flags |= VE_WINDOW_BORDERLESS;
		}
		if (style & WS_THICKFRAME)
		{
			pkWindow->m_u32Flags |= VE_WINDOW_RESIZABLE;
		}
		else
		{
			pkWindow->m_u32Flags &= ~VE_WINDOW_RESIZABLE;
		}
#		ifdef WS_MAXIMIZE
		if (style & WS_MAXIMIZE)
		{
			pkWindow->m_u32Flags |= VE_WINDOW_MAXIMIZED;
		}
		else
#		endif
		{
			pkWindow->m_u32Flags &= ~VE_WINDOW_MAXIMIZED;
		}
#		ifdef WS_MINIMIZE
		if (style & WS_MINIMIZE)
		{
			pkWindow->m_u32Flags |= VE_WINDOW_MINIMIZED;
		}
		else
#		endif
		{
			pkWindow->m_u32Flags &= ~VE_WINDOW_MINIMIZED;
		}
	}

	if (GetFocus() == hWnd)
	{
		pkWindow->m_u32Flags |= VE_WINDOW_INPUT_FOCUS;
		//SDL_SetKeyboardFocus(data->window);

		if (pkWindow->m_u32Flags & VE_WINDOW_INPUT_GRABBED)
		{
			RECT rect;
			GetClientRect(hWnd, &rect);
			ClientToScreen(hWnd, (LPPOINT)& rect);
			ClientToScreen(hWnd, (LPPOINT)& rect + 1);
			ClipCursor(&rect);
		}
	}

	/*if (videodata->RegisterTouchWindow)
	{
		videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH | TWF_WANTPALM));
	}*/

	DragAcceptFiles(hWnd, TRUE);

	return true;
}
Ejemplo n.º 28
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	POINT ptDst;
	PDIB pdibSrc, pdibDst, pDib;
	LPOFFSCREEN lpOffScreen;
	PTOON pToon;
	LPSCENE lpScene;
	PSTORY pStory;
	RGBQUAD rgbQuad[256];
	BITMAPINFOHEADER bmi;
	LPTR lp;
	HDC hWinGDC;
	HPALETTE hWinGPal = NULL, hDisplayPal = NULL, hOldPal;

	if (IsRectEmpty(lpRect))
		return;
	pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	lpScene = CScene::GetScene(GetParent(hWindow));
	if (!lpScene)
		return;

	rSrcArea = *lpRect;
	rDstArea = *lpRect;
	bSelected = GetWindowWord(hWindow, GWW_STATE );
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
 		if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		if ( !(pdibDst = lpOffScreen->GetWritableDIB()) )
			return;
		hWinGDC = lpOffScreen->GetDC();
		hWinGPal = hDisplayPal = GetApp()->m_hPal;
	}
	else
	{
		// fix
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		MapWindowPoints( hWindow, pToon->GetWindow(), (LPPOINT)&rDstArea, 2 );
		pdibSrc = pToon->GetStageDib();
		lp = ToonGetDIBPointer(pToon->GetToonHandle(), &bmi);
		ToonGetColors(pToon->GetToonHandle(), 0, 256, rgbQuad);
		bmi.biClrUsed = 256;
		pdibDst = new CDib(&bmi, rgbQuad, lp);
		if (!pdibDst)
			return;
		hWinGDC = ToonDC(pToon->GetToonHandle());
		// to make sure we don't change the system palette
		hDisplayPal = CopySystemPalette();
		// to match WinG dib
		hWinGPal = CreateCustomPalette(rgbQuad, 256);
	}

	if (!pStory->m_fMappedToPalette && ((dwStyle & BS_MASK) == 0))
	{
		pStory->m_pDib->MapToPalette(hWinGPal);
		pStory->m_fMappedToPalette = TRUE;
	}


	// Copy source dib so we can twiddle its bits
	pDib = new CDib();
	if (!pDib)
	{
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	if (!pDib->Create(pStory->m_pDib->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pDib;
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	pDib->CopyColorTable(pStory->m_pDib);
	// draw in source bitmap
	pStory->m_pDib->DibBlt( pDib,
					0, 0,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	rSrcArea.left, rSrcArea.top,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	NO /*bTransparent*/ );
	
	if ( pdibSrc->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8)
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
	}
	else
	{
		pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	NO /*bTransparent*/ );
	}

	if ( pDib->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8 )
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pDib->DCBlt( hWinGDC,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					rSrcArea.left, rSrcArea.top,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top );
	}
	else
	{
		RGBTRIPLE rgb;
		LPRGBTRIPLE lpRGB = NULL;
		if (dwStyle & BS_MASK)
		{
			STRING szColor;
			GetWindowText(hWindow, szColor, sizeof(szColor));
			AsciiRGB( szColor, &rgb );
			if (fHighlight)
			{
				// this relies on the fact that AsciiRGB replaces commas
				// with NULL terminators
				LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
				lp += lstrlen(lp) + 1; // passed green
				lp += lstrlen(lp) + 1; // passed blue to higlight color
				AsciiRGB(lp, &rgb);
				rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
			}
			else
				rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
			lpRGB = &rgb;
		}
		else
		{
			BYTE bTrans = *pStory->m_pDib->GetXY(0, 0);
			LPTR lpColor = pStory->m_pDib->GetXY(1, 0);
			LPTR lpHighlight = pStory->m_pDib->GetXY(2, 0); 
			BYTE bColor = *lpColor;
			BYTE bHighlight = *lpHighlight;
			// if highlight color is the transparent color then
			// we are hiding and showing highlighted area
			// if not, then we are changing the color of highlighted area
			if (bHighlight == bTrans)
			{
				// we need to strip off highlight info if we are not
				// highlighted
				if (!fHighlight && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp != bColor)
							*hp = bTrans;
						++hp;
						--dwSize;
					}
				}
			}
			else
			{
				// we need to change the color if we are highlighted
				if (fHighlight && (bColor != bHighlight) && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp == bColor)
							*hp = bHighlight;
						++hp;
						--dwSize;
					}
				}
			}
		}
		pDib->DibBlt( pdibDst,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					0, 0,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
					YES/*bTransparent*/, lpRGB, NULL, hWinGPal );
	}
	delete pDib;

	ptDst.x = rSrcArea.left;
	ptDst.y = rSrcArea.top;
	if (lpOffScreen)
	{
		lpOffScreen->DrawRect( hDC, &rDstArea, &ptDst );
	}
	else
	{
		//if (hDisplayPal)
		//{
		//	hOldPal = SelectPalette(hDC, hDisplayPal, FALSE);
		//	RealizePalette(hDC);
		//}
		//pdibDst->DCBlt( hDC,
		//	ptDst.x, ptDst.y,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
		//	rDstArea.left, rDstArea.top,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		WinGStretchBlt( hDC,
			ptDst.x, ptDst.y,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
			hWinGDC,
			rDstArea.left, rDstArea.top,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		//if (hDisplayPal)
	    //{
		//	SelectPalette(hDC, hOldPal, TRUE);
	   	//	DeleteObject(hDisplayPal);
		//}
		if (hWinGPal)
			DeleteObject(hWinGPal);
	}
}
Ejemplo n.º 29
0
void drawsplash(HWND hDlg, char* str){
	m_Blend.BlendOp = AC_SRC_OVER; //theonlyBlendOpdefinedinWindows2000
	m_Blend.BlendFlags = 0; //nothingelseisspecial...
	m_Blend.AlphaFormat = AC_SRC_ALPHA; //...
	m_Blend.SourceConstantAlpha = 255;//AC_SRC_ALPHA 
	static Image *m_pImageBack;
	if(!m_pImageBack) ImageFromIDResource(IDB_PNG1, L"PNG", m_pImageBack);
	//----绘制
	PAINTSTRUCT ps;
	HDC hdcTemp = BeginPaint(hDlg, &ps);
	HDC hMemDC = CreateCompatibleDC(hdcTemp);
	RECT rct;
	GetWindowRect(hDlg, &rct);
	HBITMAP hBitMap = CreateCompatibleBitmap(hdcTemp, rct.right - rct.left, rct.bottom - rct.top);
	HBITMAP hBmpOld = (HBITMAP)SelectObject(hMemDC, hBitMap);
	HDC hdcScreen = GetDC(hDlg);

	POINT ptWinPos = { rct.left, rct.top };

	Graphics imageGraphics(hMemDC);
	Point points[] = { Point(0, 0),
		Point(400, 0),
		Point(0, 255) };
	Point points2[] = { Point(50, 50),
		Point(450, 50),
		Point(50, 305) };

	// 设置层次窗口
	DWORD dwExStyle = GetWindowLong(hDlg, GWL_EXSTYLE);

	if ((dwExStyle & 0x80000) != 0x80000){
		SetWindowLong(hDlg, GWL_EXSTYLE, dwExStyle ^ 0x80000);
	}

	POINT    ptSrc = { 0, 0 };
	SIZE    sizeWindow = { rct.right - rct.left, rct.bottom - rct.top };

	// 完成透明不规则窗口的绘制
	imageGraphics.DrawImage(m_pImageBack, points, 3);

	WCHAR* drawString = (WCHAR*)calloc(256, sizeof(WCHAR));
	MultiByteToWideChar(CP_ACP, 0, str, (int)strlen(str), drawString, 255);

	// Create font and brush.
	Font* drawFont = new Font(L"Tahoma", 8);
	SolidBrush* drawBrush = new SolidBrush(Color::White);

	// Create point for upper-left corner of drawing.
	PointF drawPoint = PointF(210.0F, 240.0F);

	// Draw string to screen.
	imageGraphics.DrawString(drawString, -1, drawFont, drawPoint, drawBrush);

	delete drawFont;
	delete drawBrush;

	UpdateLayeredWindow(hDlg, hdcScreen, &ptWinPos, &sizeWindow, hMemDC, &ptSrc, 255, &m_Blend, ULW_ALPHA);

	// 释放空间
	EndPaint(hDlg, &ps);
}
Ejemplo n.º 30
0
BOOL CALLBACK SearchRssItemDlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
	{
		//设置窗口的透明属性。
		DWORD dwExStyle = GetWindowLong(hwnd, GWL_USERDATA);
		dwExStyle |= WS_EX_LAYERED;
		SetWindowLong(hwnd, GWL_USERDATA, dwExStyle);
		SetLayeredWindowAttributes(hwnd, NULL, 200, LWA_ALPHA);
		//根据传过来的位置参数设置窗口的位置。
		//要得到的是按钮的左上角坐标,作为窗口的右上角坐标。
		RECT rssSearchBtnRect = *(RECT*)lParam;
		RECT searchRssItemDlgRect;
		GetClientRect(hwnd, &searchRssItemDlgRect);
		iWinWidth = searchRssItemDlgRect.right - searchRssItemDlgRect.left;
		iWinHeight = searchRssItemDlgRect.bottom - searchRssItemDlgRect.top;
		//设置窗口的位置。
		SetWindowPos(hwnd, NULL, rssSearchBtnRect.left - iWinWidth, rssSearchBtnRect.top,
			iWinWidth, iWinHeight, SWP_NOSIZE | SWP_NOZORDER);
		//初始化搜索编辑框。
		SetDlgItemText(hwnd, IDC_SearchRssItemMsgEdit, TEXT(""));
	}
		return TRUE;
	case WM_COMMAND:
	{
		switch (LOWORD(wParam))
		{
		case IDC_StartSearchRssItemBtn:
		{
			//获得文本框内输入的数据。
			TCHAR szSearchRssItemMsg[256] = { NULL };
			GetDlgItemText(hwnd, IDC_SearchRssItemMsgEdit, szSearchRssItemMsg, sizeof(szSearchRssItemMsg));
			//返回消息给RssTab窗口。
			HWND hParentWnd = (HWND)GetWindowLong(hwnd, GWL_USERDATA);
			SendMessage(hParentWnd, WM_SEARCHITEMMSG, (WPARAM)szSearchRssItemMsg, (LPARAM)IDC_SearchRssItemBtn);
			DestroyWindow(hwnd);
		}
			return TRUE;
		default:
			return FALSE;
		}
	}
		return TRUE;
	case WM_MAINDLGMOVE_RssDlg:
	{
		//接收到按钮的左上角坐标。
		int iXRightPixel = (int)wParam;
		int iYTopPixel = (int)lParam;
		//设置窗口的位置。
		SetWindowPos(hwnd, NULL, iXRightPixel - iWinWidth, iYTopPixel, iWinWidth,
			iWinHeight, SWP_NOSIZE | SWP_NOZORDER);
	}
		return TRUE;
	case WM_DRAWITEM:
	{
		LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT)lParam;
		switch (lpDrawItemStruct->CtlType)
		{
		case ODT_BUTTON:
		{
			DrawBkgndToButton(hwnd, wParam, lpDrawItemStruct);
		}
			return TRUE;
		default:
			return FALSE;
		}
	}
		return FALSE;
	default:
		return FALSE;
	}
	return FALSE;
}