//----------------------------------------------------------------------------- // Window management //----------------------------------------------------------------------------- bool CInputTestApp::CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h ) { WNDCLASSEX wc; memset( &wc, 0, sizeof( wc ) ); wc.cbSize = sizeof( wc ); wc.style = CS_OWNDC | CS_DBLCLKS; wc.lpfnWndProc = DefWindowProc; wc.hInstance = (HINSTANCE)GetAppInstance(); wc.lpszClassName = "Valve001"; wc.hIcon = NULL; //LoadIcon( s_HInstance, MAKEINTRESOURCE( IDI_LAUNCHER ) ); wc.hIconSm = wc.hIcon; RegisterClassEx( &wc ); // Note, it's hidden DWORD style = WS_POPUP | WS_CLIPSIBLINGS; if ( bWindowed ) { // Give it a frame style |= WS_OVERLAPPEDWINDOW; style &= ~WS_THICKFRAME; } // Never a max box style &= ~WS_MAXIMIZEBOX; RECT windowRect; windowRect.top = 0; windowRect.left = 0; windowRect.right = w; windowRect.bottom = h; // Compute rect needed for that size client area based on window style AdjustWindowRectEx(&windowRect, style, FALSE, 0); // Create the window m_HWnd = CreateWindow( wc.lpszClassName, pTitle, style, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL, (HINSTANCE)GetAppInstance(), NULL ); if (!m_HWnd) return false; int CenterX, CenterY; CenterX = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; CenterY = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; CenterX = (CenterX < 0) ? 0: CenterX; CenterY = (CenterY < 0) ? 0: CenterY; // In VCR modes, keep it in the upper left so mouse coordinates are always relative to the window. SetWindowPos (m_HWnd, NULL, CenterX, CenterY, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME); return true; }
/*! サイズボックスの表示/非表示切り替え */ void CFuncKeyWnd::SizeBox_ONOFF( bool bSizeBox ) { RECT rc; ::GetWindowRect( GetHwnd(), &rc ); if( m_bSizeBox == bSizeBox ){ return; } if( m_bSizeBox ){ ::DestroyWindow( m_hwndSizeBox ); m_hwndSizeBox = NULL; m_bSizeBox = false; OnSize( NULL, 0, 0, 0 ); }else{ m_hwndSizeBox = ::CreateWindowEx( 0L, /* no extended styles */ _T("SCROLLBAR"), /* scroll bar control class */ NULL, /* text for window title bar */ WS_VISIBLE | WS_CHILD | SBS_SIZEBOX | SBS_SIZEGRIP, /* scroll bar styles */ 0, /* horizontal position */ 0, /* vertical position */ 200, /* width of the scroll bar */ CW_USEDEFAULT, /* default height */ GetHwnd(), /* handle of main window */ (HMENU) NULL, /* no menu for a scroll bar */ GetAppInstance(), /* instance owning this window */ (LPVOID) NULL /* pointer not needed */ ); ::ShowWindow( m_hwndSizeBox, SW_SHOW ); m_bSizeBox = true; OnSize( NULL, 0, 0, 0 ); } return; }
//----------------------------------------------------------------------------- // Create the application window //----------------------------------------------------------------------------- bool CIHVTestApp::CreateAppWindow( const char* pAppName, int width, int height ) { // Register the window class WNDCLASSEX wc; memset( &wc, 0, sizeof( wc ) ); wc.cbSize = sizeof( wc ); wc.style = CS_CLASSDC; wc.lpfnWndProc = WinAppWindowProc; wc.hInstance = (HINSTANCE)GetAppInstance(); wc.lpszClassName = pAppName; wc.hIcon = NULL; wc.hIconSm = wc.hIcon; RegisterClassEx( &wc ); // Create the application's window m_hWnd = CreateWindow( pAppName, pAppName, WS_OVERLAPPEDWINDOW, 0, 0, width, height, GetDesktopWindow(), NULL, wc.hInstance, NULL ); ShowWindow (m_hWnd, SW_SHOWDEFAULT); return (m_hWnd != 0); }
void Main_OnDisplay( HWND hWnd ) { TCHAR strAppName[MAX_PATH]={0}; TCHAR strBlock[10]={0}; TCHAR* pEnd=nullptr; TABLEDLG_DATA tblDlgData={0}; // Get the appname, the selected block ID & the selected // language. Create the string block. If the block creation is successful, // bring up the table dialog box. CWindow wnd(hWnd); if (!wnd.GetDlgItemText(IDC_EDIT_APPNAME, strAppName, MAX_PATH)) { DisplayMsg(hWnd, IDS_INVALIDAPPNAME); return; } CComboBox combo(wnd.GetDlgItem(IDC_COMBO_LANGUAGES)); int nSel = combo.GetCurSel(); if( CB_ERR == nSel ) { DisplayMsg(hWnd, IDS_INVALIDLANGUAGE); return; } if (!wnd.GetDlgItemText(IDC_EDIT_BLOCKID, strBlock, _countof(strBlock))) { DisplayMsg(hWnd, IDS_INVALIDBLOCKID); return; } UINT nBlockID = _tcstoul(strBlock, &pEnd, 10); if( *pEnd != 0 ) { DisplayMsg(hWnd, IDS_INVALIDBLOCKID); return; } HSTRBLOCK hStrBlock = GetStringBlock(strAppName, nBlockID, s_langInfo[nSel].wLangID); if( nullptr == hStrBlock ) { DisplayStatus(hWnd, GetStringBlockError()); return; } // Show up the table dialog-box that displays the string block. tblDlgData.strAppName = strAppName; tblDlgData.nBlockID = nBlockID; tblDlgData.wStrID = static_cast<WORD>(s_langInfo[nSel].nStrID); tblDlgData.hStrBlock = hStrBlock; DialogBoxParam(GetAppInstance(), MAKEINTRESOURCE(IDD_DIALOG_TABLE), hWnd, Table_DlgProc, reinterpret_cast<LPARAM>(&tblDlgData)); // Delete the string block. DeleteStringBlock(hStrBlock); }
//----------------------------------------------------------------------------- // Purpose: // Output : const char //----------------------------------------------------------------------------- const char *GetBaseDirectory( void ) { static char path[MAX_PATH] = {0}; if ( path[0] == 0 ) { GetModuleFileName( (HMODULE)GetAppInstance(), path, sizeof( path ) ); Q_StripLastDir( path, sizeof( path ) ); // Get rid of the filename. Q_StripTrailingSlash( path ); } return path; }
void Engine::Start() { auto iter = Component::components.begin(); for (; iter != Component::components.end(); iter++) { (*iter)->Start(); } gDInput = new DirectInput(GetAppInstance(), GetMainWindow(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); gTimer = new GameTimer(); gTimer->Reset(); }
/* ウィンドウ オープン */ HWND CFuncKeyWnd::Open( HINSTANCE hInstance, HWND hwndParent, CEditDoc* pCEditDoc, bool bSizeBox ) { LPCTSTR pszClassName = _T("CFuncKeyWnd"); m_pcEditDoc = pCEditDoc; m_bSizeBox = bSizeBox; m_hwndSizeBox = NULL; m_nCurrentKeyState = -1; // 2002.11.04 Moca 変更できるように m_nButtonGroupNum = m_pShareData->m_Common.m_sWindow.m_nFUNCKEYWND_GroupNum; if( 1 > m_nButtonGroupNum || 12 < m_nButtonGroupNum ){ m_nButtonGroupNum = 4; } /* ウィンドウクラス作成 */ RegisterWC( hInstance, NULL,// Handle to the class icon. NULL, //Handle to a small icon ::LoadCursor( NULL, IDC_ARROW ),// Handle to the class cursor. (HBRUSH)(COLOR_3DFACE + 1),// Handle to the class background brush. NULL/*MAKEINTRESOURCE( MYDOCUMENT )*/,// Pointer to a null-terminated character string that specifies the resource name of the class menu, as the name appears in the resource file. pszClassName// Pointer to a null-terminated string or is an atom. ); /* 基底クラスメンバ呼び出し */ CWnd::Create( hwndParent, 0, // extended window style pszClassName, // Pointer to a null-terminated string or is an atom. pszClassName, // pointer to window name WS_CHILD/* | WS_VISIBLE*/ | WS_CLIPCHILDREN, // window style // 2006.06.17 ryoji WS_CLIPCHILDREN 追加 // 2007.03.08 ryoji WS_VISIBLE 除去 CW_USEDEFAULT, // horizontal position of window 0, // vertical position of window 0, // window width // 2007.02.05 ryoji 100->0(半端なサイズで一瞬表示されるより見えないほうがいい) ::GetSystemMetrics( SM_CYMENU ), // window height NULL // handle to menu, or child-window identifier ); m_hwndSizeBox = NULL; if( m_bSizeBox ){ m_hwndSizeBox = ::CreateWindowEx( 0L, /* no extended styles */ _T("SCROLLBAR"), /* scroll bar control class */ NULL, /* text for window title bar */ WS_VISIBLE | WS_CHILD | SBS_SIZEBOX | SBS_SIZEGRIP, /* scroll bar styles */ 0, /* horizontal position */ 0, /* vertical position */ 200, /* width of the scroll bar */ CW_USEDEFAULT, /* default height */ GetHwnd(), /* handle of main window */ (HMENU) NULL, /* no menu for a scroll bar */ GetAppInstance(), /* instance owning this window */ (LPVOID) NULL /* pointer not needed */ ); } /* ボタンの生成 */ CreateButtons(); Timer_ONOFF( true ); // 20060126 aroka OnTimer( GetHwnd(), WM_TIMER, IDT_FUNCWND, ::GetTickCount() ); // 初回更新 // 2006.12.20 ryoji return GetHwnd(); }
/* create main window */ int PrefsWindow::Create(HWND parent) { RECT rect; int mx,my; const int PREFS_WINDOW_WIDTH=190; const int PREFS_WINDOW_HEIGHT=150; /* Get Overview Window Location for Prefs window alignment*/ GetWindowRect(overviewWindow.GetHandle(),&rect); /* create prefs window */ if (!CreateWin(0, "Parbat3D Prefs Window", "Preferences", WS_POPUP+WS_SYSMENU+WS_CAPTION, rect.left+50, rect.bottom-150, PREFS_WINDOW_WIDTH, PREFS_WINDOW_HEIGHT, parent, NULL)) return false; HBRUSH backBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE)); SetBackgroundBrush(backBrush); cacheLabel =CreateWindowEx( 0, szStaticControl, "Cache size (MB):", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_OWNERDRAW, 6, 6, 120, 20, GetHandle(), NULL, GetAppInstance(), NULL); SetFont(cacheLabel, FONT_NORMAL); cacheEntry =CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", (settingsFile->getSetting("preferences", "cachesize")).c_str(), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_LEFT | SS_OWNERDRAW, 138, 6, 40, 20, GetHandle(), NULL, GetAppInstance(), NULL); SetFont(cacheEntry, FONT_NORMAL); texSizeLabel =CreateWindowEx( 0, szStaticControl, "Texture dimension (pixels):", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_OWNERDRAW, 6, 29, 130, 20, GetHandle(), NULL, GetAppInstance(), NULL); SetFont(texSizeLabel, FONT_NORMAL); texSizeEntry =CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", (settingsFile->getSetting("preferences", "texsize")).c_str(), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_LEFT | SS_OWNERDRAW, 138, 29, 40, 20, GetHandle(), NULL, GetAppInstance(), NULL); SetFont(texSizeEntry, FONT_NORMAL); displayCloseConfirmLabel =CreateWindowEx( 0, szStaticControl, "Display \'open file\' warning", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_OWNERDRAW, 6, 52, 130, 20, GetHandle(), NULL, GetAppInstance(), NULL); SetFont(displayCloseConfirmLabel, FONT_NORMAL); displayCloseConfirmCheckbox = CreateWindowEx( 0, "BUTTON", NULL, BS_AUTOCHECKBOX | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 138, 52, 40, 20, GetHandle(), NULL, GetAppInstance(), NULL); if (settingsFile->getSettingi("preferences", "displayconfirmwindow", 1) == 1) { LRESULT theResult = SendMessage(displayCloseConfirmCheckbox, BM_SETCHECK, BST_CHECKED, 0); } else { LRESULT theResult = SendMessage(displayCloseConfirmCheckbox, BM_SETCHECK, BST_UNCHECKED, 0); } okButton = CreateWindowEx(0, "BUTTON", "OK", WS_CHILD | WS_VISIBLE, 60, 85, 55, 25, GetHandle(), (HMENU) 1, Window::GetAppInstance(), NULL); SetFont(okButton, FONT_BOLD); cancelButton = CreateWindowEx(0, "BUTTON", "Cancel", WS_CHILD | WS_VISIBLE, 120, 85, 55, 25, GetHandle(), (HMENU) 2, Window::GetAppInstance(), NULL); SetFont(cancelButton, FONT_BOLD); prevProc=SetWindowProcedure(&WindowProcedure); //stickyWindowManager.AddStickyWindow(this); // make the window stick to others return true; }
bool GameApplication::InitWindow(int showFlag) { const TCHAR *CLASSNAME = TEXT ( "EIAPPCLASS" ); WNDCLASS wc; ZeroMemory( &wc, sizeof(wc) ); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetAppInstance (); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = GetBackgroundBrush(); wc.lpszClassName = CLASSNAME; ATOM rc = RegisterClass ( &wc ); assert(rc); long WinStyle, WinStyleEx; WinStyleEx = 0; WinStyle = WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_CAPTION; RECT rect; rect.left = rect.top = 0; long w, h; GetWindowDims( w, h ); rect.right = w; rect.bottom = h; AdjustWindowRectEx ( &rect, WinStyle, false, WinStyleEx ); long width = rect.right - rect.left; long height = rect.bottom - rect.top; appWindow = CreateWindowEx ( WinStyleEx, CLASSNAME, GetTitle(), WinStyle, 0, 0, width, height, NULL, 0, GetAppInstance (), NULL ); if ( !appWindow ) return false; long left = ( GetSystemMetrics ( SM_CXSCREEN ) - width ) / 2; long top = ( GetSystemMetrics ( SM_CYSCREEN ) - height ) / 2; MoveWindow ( appWindow, left, top, width, height, TRUE ); ShowWindow ( appWindow, showFlag ); UpdateWindow ( appWindow ); return true; }