本文整理汇总了C++中SetFocus函数的典型用法代码示例。如果您正苦于以下问题:C++ SetFocus函数的具体用法?C++ SetFocus怎么用?C++ SetFocus使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetFocus函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxDialog
//.........这里部分代码省略.........
wxGridSizer* const szr_debug = new wxGridSizer(2, 5, 5);
szr_debug->Add(CreateCheckBox(page_advanced, _("Enable Wireframe"),
wxGetTranslation(wireframe_desc), vconfig.bWireFrame));
szr_debug->Add(CreateCheckBox(page_advanced, _("Show Statistics"),
wxGetTranslation(show_stats_desc), vconfig.bOverlayStats));
szr_debug->Add(CreateCheckBox(page_advanced, _("Texture Format Overlay"),
wxGetTranslation(texfmt_desc), vconfig.bTexFmtOverlayEnable));
wxStaticBoxSizer* const group_debug =
new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Debugging"));
szr_advanced->Add(group_debug, 0, wxEXPAND | wxALL, 5);
group_debug->Add(szr_debug, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
}
// - utility
{
wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5);
szr_utility->Add(CreateCheckBox(page_advanced, _("Dump Textures"),
wxGetTranslation(dump_textures_desc), vconfig.bDumpTextures));
szr_utility->Add(CreateCheckBox(page_advanced, _("Load Custom Textures"),
wxGetTranslation(load_hires_textures_desc),
vconfig.bHiresTextures));
cache_hires_textures =
CreateCheckBox(page_advanced, _("Prefetch Custom Textures"),
wxGetTranslation(cache_hires_textures_desc), vconfig.bCacheHiresTextures);
szr_utility->Add(cache_hires_textures);
szr_utility->Add(CreateCheckBox(page_advanced, _("Dump EFB Target"),
wxGetTranslation(dump_efb_desc), vconfig.bDumpEFBTarget));
szr_utility->Add(CreateCheckBox(page_advanced, _("Free Look"),
wxGetTranslation(free_look_desc), vconfig.bFreeLook));
#if defined(HAVE_LIBAV) || defined(_WIN32)
szr_utility->Add(CreateCheckBox(page_advanced, _("Frame Dumps use FFV1"),
wxGetTranslation(use_ffv1_desc), vconfig.bUseFFV1));
#endif
wxStaticBoxSizer* const group_utility =
new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Utility"));
szr_advanced->Add(group_utility, 0, wxEXPAND | wxALL, 5);
group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
}
// - misc
{
wxGridSizer* const szr_misc = new wxGridSizer(2, 5, 5);
szr_misc->Add(
CreateCheckBox(page_advanced, _("Crop"), wxGetTranslation(crop_desc), vconfig.bCrop));
// Progressive Scan
{
progressive_scan_checkbox =
new wxCheckBox(page_advanced, wxID_ANY, _("Enable Progressive Scan"));
RegisterControl(progressive_scan_checkbox, wxGetTranslation(prog_scan_desc));
progressive_scan_checkbox->Bind(wxEVT_CHECKBOX, &VideoConfigDiag::Event_ProgressiveScan,
this);
progressive_scan_checkbox->SetValue(SConfig::GetInstance().bProgressive);
// A bit strange behavior, but this needs to stay in sync with the main progressive boolean;
// TODO: Is this still necessary?
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", SConfig::GetInstance().bProgressive);
szr_misc->Add(progressive_scan_checkbox);
}
#if defined WIN32
// Borderless Fullscreen
borderless_fullscreen = CreateCheckBox(page_advanced, _("Borderless Fullscreen"),
wxGetTranslation(borderless_fullscreen_desc),
vconfig.bBorderlessFullscreen);
szr_misc->Add(borderless_fullscreen);
#endif
wxStaticBoxSizer* const group_misc =
new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Misc"));
szr_advanced->Add(group_misc, 0, wxEXPAND | wxALL, 5);
group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
}
szr_advanced->AddStretchSpacer();
CreateDescriptionArea(page_advanced, szr_advanced);
page_advanced->SetSizerAndFit(szr_advanced);
}
wxButton* const btn_close = new wxButton(this, wxID_OK, _("Close"));
btn_close->Bind(wxEVT_BUTTON, &VideoConfigDiag::Event_ClickClose, this);
Bind(wxEVT_CLOSE_WINDOW, &VideoConfigDiag::Event_Close, this);
wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5);
szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
SetSizerAndFit(szr_main);
Center();
SetFocus();
UpdateWindowUI();
}
示例2: GetModuleHandle
void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
{
WNDCLASSEX wc;
DEVMODE dmScreenSettings;
int posX, posY;
// Get an external pointer to this object.
ApplicationHandle = this;
// Get the instance of this application.
m_hinstance = GetModuleHandle(NULL);
// Give the application a name.
m_applicationName = L"Engine";
// Setup the windows class with default settings.
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = m_hinstance;
wc.hIcon = LoadIcon(0, IDI_WINLOGO);
wc.hIconSm = wc.hIcon;
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = m_applicationName;
wc.cbSize = sizeof(WNDCLASSEX);
// Register the window class.
RegisterClassEx(&wc);
// Determine the resolution of the clients desktop screen.
screenWidth = GetSystemMetrics(SM_CXSCREEN);
screenHeight = GetSystemMetrics(SM_CYSCREEN);
// Setup the screen settings depending on whether it is running in full screen or in windowed mode.
if(FULL_SCREEN)
{
// If full screen set the screen to maximum size of the users desktop and 32bit.
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = (unsigned long)screenWidth;
dmScreenSettings.dmPelsHeight = (unsigned long)screenHeight;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
// Change the display settings to full screen.
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
// Set the position of the window to the top left corner.
posX = posY = 0;
}
else
{
// If windowed then set it to 800x600 resolution.
//screenWidth = 1680;
//screenHeight = 1050;
// Place the window in the middle of the screen.
posX = (GetSystemMetrics(SM_CXSCREEN) - screenWidth) / 2;
posY = (GetSystemMetrics(SM_CYSCREEN) - screenHeight) / 2;
}
HMENU hmenu;
hmenu = LoadMenu(m_hinstance, MAKEINTRESOURCE(IDR_MENU1));
// Create the window with the screen settings and get the handle to it.
m_hwnd = CreateWindowEx(
WS_EX_APPWINDOW, // Extended Window Style - Forces top-level window on the taskbar when it's visible
m_applicationName, // lpClassName
m_applicationName, // lpWindowName
WS_OVERLAPPEDWINDOW, // dwStyle - Overlapped Window
posX, posY, // Position
screenWidth, screenHeight, // Height and width
NULL, // Window Parent
hmenu, // Handle to a menu
m_hinstance, // hInstance - handle to the module associated with the window
NULL); // lpParam - handle to the value passed to the window through CREATESTRUCT
// Bring the window up on the screen and set it as main focus.
ShowWindow(m_hwnd, SW_MAXIMIZE);
SetForegroundWindow(m_hwnd);
SetFocus(m_hwnd);
// Hide the mouse cursor.
ShowCursor(true);
return;
}// InitializeWindows
示例3: ASSERT
void CXTPPropertyGridInplaceList::Create(CXTPPropertyGridItem* pItem, CRect rect)
{
ASSERT(pItem && pItem->GetGrid());
if (!pItem)
return;
CRect rcValue(rect);
rcValue.left = pItem->GetGrid()->GetDividerPos() + 1;
CWnd* pParent = (CWnd*)pItem->GetGrid();
m_pItem = pItem;
DestroyWindow();
if (!m_hWnd)
{
CListBox::CreateEx(WS_EX_TOOLWINDOW | (pParent->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""),
LBS_NOTIFY | WS_CHILD | WS_VSCROLL | WS_BORDER | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS, CRect(0, 0, 0, 0), pParent, 0);
SetOwner(pParent);
if (m_bShowShadow && XTPSystemVersion()->IsWinXPOrGreater())
SetClassLongPtr(m_hWnd, GCL_STYLE, GetClassLongPtr(m_hWnd, GCL_STYLE) | 0x00020000);
}
SetFont(pParent->GetFont());
ResetContent();
CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints();
int dx = rect.right - rcValue.left;
CWindowDC dc(pParent);
CXTPFontDC font(&dc, pParent->GetFont());
int nHeight = dc.GetTextExtent(_T(" "), 1).cy + 3;
for (int i = 0; i < pList->GetCount(); i++)
{
CXTPPropertyGridItemConstraint* pConstraint = pList->GetConstraintAt(i);
CString str = pConstraint->m_strConstraint;
int nIndex = AddString(str);
SetItemDataPtr(nIndex, pConstraint);
CSize sz = pItem->OnMergeItemConstraint(&dc, pConstraint);
dx = max(dx, sz.cx);
nHeight = max(nHeight, sz.cy);
if (pItem->GetValue() == str)
SetCurSel(nIndex);
}
SetItemHeight(0, nHeight);
rect.top = rect.bottom;
rect.bottom += nHeight * __min(pItem->GetDropDownItemCount(), GetCount()) + 2;
rect.left = rect.right - __min(dx, rect.Width() - XTP_PGI_EXPAND_BORDER);
pParent->ClientToScreen(&rect);
CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
{
rect.OffsetRect(0, - rect.Height() - rcValue.Height() - 1);
}
if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0);
if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0);
SetFocus();
SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0);
ModifyStyle(WS_CHILD, WS_POPUP);
SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pParent->m_hWnd);
SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
CXTPMouseMonitor::SetupHook(this);
}
示例4: SessDlgProc
//.........这里部分代码省略.........
fLoadIt = false;
_this->m_pDSMPlugin->SetPluginParams(hwnd, szParams);
}
else
{
// Unload the previous plugin
_this->m_pDSMPlugin->UnloadPlugin();
fLoadIt = true;
}
}
if (!fLoadIt) return TRUE;
if (_this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening))
{
// We don't know the password yet... no matter the plugin requires
// it or not, we will provide it later (at plugin "real" startup)
// Knowing the environnement ("viewer") right now can be usefull or
// even mandatory for the plugin (specific params saving and so on...)
// The plugin receives environnement info but isn't inited at this point
_this->m_pDSMPlugin->SetPluginParams(hwnd, szParams);
}
else
{
MessageBox(hwnd,
sz_F1,
sz_F3, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
}
}
return TRUE;
}
case IDC_LOADPROFILE_B:
{
TCHAR szFileName[MAX_PATH];
memset(szFileName, '\0', MAX_PATH);
if (_this->m_pCC->LoadConnection(szFileName, true) != -1)
{
TCHAR szHost[250];
if (_this->m_pCC->m_port == 5900)
_tcscpy(szHost, _this->m_pCC->m_host);
else if (_this->m_pCC->m_port > 5900 && _this->m_pCC->m_port <= 5999)
_stprintf(szHost, TEXT("%s:%d"), _this->m_pCC->m_host, _this->m_pCC->m_port - 5900);
else
_stprintf(szHost, TEXT("%s::%d"), _this->m_pCC->m_host, _this->m_pCC->m_port);
SetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, szHost);
//AaronP
HWND hPlugins = GetDlgItem(hwnd, IDC_PLUGINS_COMBO);
if( strcmp( _this->m_pOpt->m_szDSMPluginFilename, "" ) != 0 && _this->m_pOpt->m_fUseDSMPlugin ) {
int pos = SendMessage(hPlugins, CB_FINDSTRINGEXACT, -1,
(LPARAM)&(_this->m_pOpt->m_szDSMPluginFilename[0]));
if( pos != CB_ERR ) {
SendMessage(hPlugins, CB_SETCURSEL, pos, 0);
HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
}
}
//EndAaronP
}
SetFocus(GetDlgItem(hwnd, IDC_HOSTNAME_EDIT));
_this->SetQuickOption(_this, hwnd);
HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
SendMessage(hViewOnly, BM_SETCHECK, _this->m_pOpt->m_ViewOnly, 0);
HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
SendMessage(hAutoScaling, BM_SETCHECK, _this->m_pOpt->m_fAutoScaling, 0);
HWND hExitCheck = GetDlgItem(hwnd, IDC_EXIT_CHECK); //PGM @ Advantig
SendMessage(hExitCheck, BM_SETCHECK, _this->m_pOpt->m_fExitCheck, 0); //PGM @ Advantig
_this->m_fFromOptions = true;
_this->m_fFromFile = true;
return TRUE;
}
// [v1.0.2-jp1 fix]
case IDC_HOSTNAME_DEL:
HWND hcombo = GetDlgItem( hwnd, IDC_HOSTNAME_EDIT);
int sel = SendMessage(hcombo, CB_GETCURSEL, 0, 0);
if(sel != CB_ERR){
SendMessage(hcombo, CB_DELETESTRING, sel, 0);
_this->m_pMRU->RemoveItem(sel);
}
return TRUE;
}
break;
case WM_CLOSE:
EndDialog(hwnd, FALSE);
return FALSE;
case WM_DESTROY:
EndDialog(hwnd, FALSE);
return TRUE;
}
return 0;
}
示例5: GetScreen
void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
int localrealbutt = 0, localbutt = 0;
BASE_SCREEN* screen = GetScreen();
if( !screen )
return;
/* Adjust value to filter mouse displacement before consider the drag
* mouse is really a drag command, not just a movement while click
*/
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
if( event.Leaving() )
m_canStartBlock = -1;
if( !IsMouseCaptured() ) // No mouse capture in progress.
m_requestAutoPan = false;
if( GetParent()->IsActive() )
SetFocus();
else
return;
if( !event.IsButton() && !event.Moving() && !event.Dragging() )
return;
if( event.RightDown() )
{
OnRightClick( event );
return;
}
if( m_ignoreMouseEvents )
return;
if( event.LeftIsDown() )
localrealbutt |= GR_M_LEFT_DOWN;
if( event.MiddleIsDown() )
localrealbutt |= GR_M_MIDDLE_DOWN;
if( event.LeftDown() )
localbutt = GR_M_LEFT_DOWN;
if( event.ButtonDClick( 1 ) )
localbutt = GR_M_LEFT_DOWN | GR_M_DCLICK;
if( event.MiddleDown() )
localbutt = GR_M_MIDDLE_DOWN;
localrealbutt |= localbutt; // compensation default wxGTK
INSTALL_UNBUFFERED_DC( DC, this );
DC.SetBackground( *wxBLACK_BRUSH );
// Compute the cursor position in drawing (logical) units.
GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );
int kbstat = 0;
if( event.ShiftDown() )
kbstat |= GR_KB_SHIFT;
if( event.ControlDown() )
kbstat |= GR_KB_CTRL;
if( event.AltDown() )
kbstat |= GR_KB_ALT;
// Calling Double Click and Click functions :
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{
GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) );
// inhibit a response to the mouse left button release,
// because we have a double click, and we do not want a new
// OnLeftClick command at end of this Double Click
m_ignoreNextLeftButtonRelease = true;
}
else if( event.LeftUp() )
{
// A block command is in progress: a left up is the end of block
// or this is the end of a double click, already seen
// Note also m_ignoreNextLeftButtonRelease can be set by
// the call to OnLeftClick(), so do not change it after calling OnLeftClick
bool ignoreEvt = m_ignoreNextLeftButtonRelease;
m_ignoreNextLeftButtonRelease = false;
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
GetParent()->OnLeftClick( &DC, GetParent()->RefPos( true ) );
}
else if( !event.LeftIsDown() )
{
/* be sure there is a response to a left button release command
* even when a LeftUp event is not seen. This happens when a
* double click opens a dialog box, and the release mouse button
* is made when the dialog box is opened.
*/
//.........这里部分代码省略.........
示例6: GetActiveWin
wyInt32
EditorBase::OnContextMenuHelper(LPARAM lParam)
{
wyBool nmenuselect;
LONG lstyle=0;
HMENU hmenu, htrackmenu;
POINT pnt;
wyInt32 pos;
RECT rect;
MDIWindow* wnd = GetActiveWin();
VERIFY(hmenu = GetMenu(pGlobals->m_pcmainwin->m_hwndmain));
//lStyle = GetWindowLongPtr ( m_hwndparent, GWL_STYLE );
lstyle = GetWindowLongPtr(GetParent(m_hwndparent), GWL_STYLE);
if ((lstyle & WS_MAXIMIZE) && wyTheme::IsSysmenuEnabled(GetParent(m_hwndparent)))
VERIFY(htrackmenu = GetSubMenu(hmenu, 2));
else
VERIFY(htrackmenu = GetSubMenu(hmenu, 1));
//If we are pressing the context button,then lParam is -1.
if(lParam == -1)
{
//for getting the current cursor pos.
pos = SendMessage(m_hwnd, SCI_GETCURRENTPOS, 0, 0);
pnt.x = SendMessage(m_hwnd, SCI_POINTXFROMPOSITION, 0, pos) ;
pnt.y = SendMessage(m_hwnd, SCI_POINTYFROMPOSITION, 0, pos);
VERIFY(ClientToScreen(m_hwnd, &pnt));
}
else
{
pnt.x = GET_X_LPARAM(lParam);
pnt.y = GET_Y_LPARAM(lParam);
}
GetClientRect(m_hwnd, &rect);
MapWindowPoints(m_hwnd, NULL, (LPPOINT)&rect, 2);
if(!PtInRect(&rect, pnt))
{
return -1;
}
//VERIFY(ClientToScreen(m_hwnd, &pnt));
SetFocus(m_hwnd);
// Now change the menu item.
ChangeEditMenuItem(htrackmenu);
pGlobals->m_pcmainwin->m_connection->HandleTagsMenu((HMENU)hmenu);
if(wnd)
{
//FrameWindow::RecursiveMenuEnable(htrackmenu, wyFalse, MF_ENABLED);
if(wnd->m_executing == wyTrue || wnd->m_pingexecuting == wyTrue)
{
FrameWindow::RecursiveMenuEnable(htrackmenu, wyFalse, MF_DISABLED);
}
wyTheme::SetMenuItemOwnerDraw(htrackmenu);
nmenuselect = (wyBool)TrackPopupMenu(htrackmenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pnt.x, pnt.y, 0, pGlobals->m_pcmainwin->m_hwndmain, NULL);
}
return 1;
}
示例7: GetModuleHandle
void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
{
WNDCLASSEX wc;
DEVMODE dmScreenSettings;
int posX, posY;
ApplicationHandle = this;
// Get the instance of the application
m_hinstance = GetModuleHandle(NULL);
m_applicationName = L"Engine";
// default settings
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = m_hinstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hIconSm = wc.hIcon;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = m_applicationName;
wc.cbSize = sizeof(WNDCLASSEX);
RegisterClassEx(&wc);
screenWidth = GetSystemMetrics(SM_CXSCREEN);
screenHeight = GetSystemMetrics(SM_CYSCREEN);
if(FULL_SCREEN)
{
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = (unsigned long)screenWidth;
dmScreenSettings.dmPelsHeight = (unsigned long)screenHeight;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
posX = posY = 0;
}
else
{
screenWidth = 800;
screenHeight = 600;
posX = (GetSystemMetrics(SM_CXSCREEN) - screenWidth) / 2;
posY = (GetSystemMetrics(SM_CYSCREEN) - screenHeight) / 2;
}
m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, m_applicationName, m_applicationName,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP,
posX, posY, screenWidth, screenHeight, NULL, NULL, m_hinstance, NULL);
ShowWindow(m_hwnd, SW_SHOW);
SetForegroundWindow(m_hwnd);
SetFocus(m_hwnd);
ShowCursor(false);
return;
}
示例8: GetModuleHandle
// todo: akelmore - separate out the init with the command line versus regular init
bool WindowsPlatform::Init(int argc, char** argv)
{
SuperClass::Init(argc, argv);
_instance = GetModuleHandle(nullptr);
LPCWSTR app_name = L"Side Project";
// Setup the windows class with default settings.
_window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
_window_class.lpfnWndProc = WindowsMessageHandler;
_window_class.cbClsExtra = 0;
_window_class.cbWndExtra = 0;
_window_class.hInstance = _instance;
_window_class.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
_window_class.hIconSm = _window_class.hIcon;
_window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
_window_class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
_window_class.lpszMenuName = nullptr;
_window_class.lpszClassName = app_name;
_window_class.cbSize = sizeof(WNDCLASSEX);
// Register the window class.
RegisterClassEx(&_window_class);
// do the correct initialization based off of what we're doing (defaulting to OpenGL)
if (_platform_config->Renderer == "directx")
{
DBG_ASSERT_FAIL("I haven't created the DirectX part of the renderer yet.");
}
else
{
_ignore_window_messages = true;
_window = CreateWindowEx(WS_EX_APPWINDOW, app_name, app_name,
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
200, 200, _platform_config->Width, _platform_config->Height,
nullptr, nullptr, _instance, nullptr);
if (_window == nullptr)
return false;
// hide the window because it's only a temp one
ShowWindow(_window, SW_HIDE);
OpenGLGraphics* opengl_graphics = new OpenGLGraphics();
_graphics_renderer = opengl_graphics;
opengl_graphics->PreInitializeWindowsOpenGL(_window);
// destroy the temp window
DestroyWindow(_window);
_window = nullptr;
_ignore_window_messages = false;
}
DEVMODE dmScreenSettings;
if (_platform_config->Fullscreen)
{
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = (unsigned long)_platform_config->Width;
dmScreenSettings.dmPelsHeight = (unsigned long)_platform_config->Height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
}
// create the real window
// 200s are x/y position on screen
_window = CreateWindowEx(WS_EX_APPWINDOW, app_name, app_name,
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
200, 200, _platform_config->Width, _platform_config->Height,
nullptr, nullptr, _instance, nullptr);
if (_window == nullptr)
return false;
SetScreenDimensions(_platform_config->Width, _platform_config->Height);
if(!_graphics_renderer->Init())
return false;
ShowWindow(_window, SW_SHOW);
SetForegroundWindow(_window);
SetFocus(_window);
return true;
}
示例9: RebarLoadSettings
//.........这里部分代码省略.........
//SendMessage(RebarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"Media"); //Media/Communications/BrowserTabBar/Help
//SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"Media"); //Media/Communications/BrowserTabBar/Help
// Inset the toolbar into the rebar control.
RebarBandInsert(BandID_ToolBar, ToolBarHandle, HIWORD(toolbarButtonSize), LOWORD(toolbarButtonSize));
ToolbarInitialized = TRUE;
}
// Initialize the Searchbox and TreeNewFilters.
if (EnableSearchBox && !SearchboxHandle)
{
SearchboxText = PhReferenceEmptyString();
ProcessTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportProcessTreeList(), (PPH_TN_FILTER_FUNCTION)ProcessTreeFilterCallback, NULL);
ServiceTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportServiceTreeList(), (PPH_TN_FILTER_FUNCTION)ServiceTreeFilterCallback, NULL);
NetworkTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportNetworkTreeList(), (PPH_TN_FILTER_FUNCTION)NetworkTreeFilterCallback, NULL);
// Create the Searchbox control.
SearchboxHandle = CreateSearchControl(ID_SEARCH_CLEAR);
}
// Initialize the Statusbar control.
if (EnableStatusBar && !StatusBarHandle)
{
// Create the StatusBar window.
StatusBarHandle = CreateWindowEx(
0,
STATUSCLASSNAME,
NULL,
WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP | SBARS_TOOLTIPS,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
PhMainWndHandle,
NULL,
NULL,
NULL
);
}
// Hide or show controls (Note: don't unload or remove at runtime).
if (EnableToolBar)
{
if (RebarHandle && !IsWindowVisible(RebarHandle))
ShowWindow(RebarHandle, SW_SHOW);
}
else
{
if (RebarHandle && IsWindowVisible(RebarHandle))
ShowWindow(RebarHandle, SW_HIDE);
}
if (EnableSearchBox)
{
// Add the Searchbox band into the rebar control.
if (!RebarBandExists(BandID_SearchBox))
RebarBandInsert(BandID_SearchBox, SearchboxHandle, 20, 180);
if (SearchboxHandle && !IsWindowVisible(SearchboxHandle))
ShowWindow(SearchboxHandle, SW_SHOW);
}
else
{
// Remove the Searchbox band from the rebar control.
if (RebarBandExists(BandID_SearchBox))
RebarBandRemove(BandID_SearchBox);
if (SearchboxHandle)
{
// Clear search text and reset search filters.
SetFocus(SearchboxHandle);
Static_SetText(SearchboxHandle, L"");
if (IsWindowVisible(SearchboxHandle))
ShowWindow(SearchboxHandle, SW_HIDE);
}
}
// TODO: Fix above code...
if (SearchBoxDisplayMode == SearchBoxDisplayHideInactive)
{
if (RebarBandExists(BandID_SearchBox))
RebarBandRemove(BandID_SearchBox);
}
else
{
if (!RebarBandExists(BandID_SearchBox))
RebarBandInsert(BandID_SearchBox, SearchboxHandle, 20, 180);
}
if (EnableStatusBar)
{
if (StatusBarHandle && !IsWindowVisible(StatusBarHandle))
ShowWindow(StatusBarHandle, SW_SHOW);
}
else
{
if (StatusBarHandle && IsWindowVisible(StatusBarHandle))
ShowWindow(StatusBarHandle, SW_HIDE);
}
}
示例10: RamWatchProc
//.........这里部分代码省略.........
// because it interferes with some of the accelerators
// and it isn't very useful here anyway
SetWindowLong(hDlg, DWL_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)));
return 1;
}
}
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case RAMMENU_FILE_SAVE:
QuickSaveWatches();
break;
case RAMMENU_FILE_SAVEAS:
//case IDC_C_SAVE:
return Save_Watches();
case RAMMENU_FILE_OPEN:
return Load_Watches(true);
case RAMMENU_FILE_APPEND:
//case IDC_C_LOAD:
return Load_Watches(false);
case RAMMENU_FILE_NEW:
//case IDC_C_RESET:
ResetWatches();
return true;
case IDC_C_WATCH_REMOVE:
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
RemoveWatch(watchIndex);
ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
RWfileChanged=true;
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
return true;
case IDC_C_WATCH_EDIT:
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex);
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
return true;
case IDC_C_WATCH:
rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0;
rswatches[WatchCount].Size = 'b';
rswatches[WatchCount].Type = 's';
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount);
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
return true;
case IDC_C_WATCH_DUPLICATE:
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
rswatches[WatchCount].Address = rswatches[watchIndex].Address;
rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian;
rswatches[WatchCount].Size = rswatches[watchIndex].Size;
rswatches[WatchCount].Type = rswatches[watchIndex].Type;
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount);
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
return true;
case IDC_C_WATCH_UP:
{
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
if(watchIndex == 0 || watchIndex == -1)
return true;
void *tmp = malloc(sizeof(AddressWatcher));
memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher));
memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher));
memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher));
free(tmp);
示例11: MessageBoxProc
/*
* Window procedure for the dialog box
*/
static BOOL MessageBoxProc( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
int i;
PMSGBOXINFO mbi;
//HELPINFO hi;
//HWND owner;
switch(message) {
case WM_INITDIALOG:
mbi = (PMSGBOXINFO)lParam;
if(!GetProp(hwnd, "ROS_MSGBOX"))
{
SetProp(hwnd, "ROS_MSGBOX", (HANDLE)lParam);
if(mbi->Icon)
SendDlgItemMessage(hwnd, MSGBOX_IDICON, STM_SETICON, (WPARAM)mbi->Icon, 0);
#if 0
SetWindowContextHelpId(hwnd, mbi->ContextHelpId);
#endif
/* set control fonts */
SendDlgItemMessage(hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)mbi->Font, 0);
for(i = 0; i < mbi->nButtons; i++)
{
SendDlgItemMessage(hwnd, mbi->Btns[i], WM_SETFONT, (WPARAM)mbi->Font, 0);
}
#if 0
switch(mbi->Style & MB_TYPEMASK)
{
case MB_ABORTRETRYIGNORE:
case MB_YESNO:
RemoveMenu(GetSystemMenu(hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND);
break;
}
#endif
SetFocus(GetDlgItem(hwnd, mbi->DefBtn));
if(mbi->Timeout && (mbi->Timeout != (UINT)-1))
SetTimer(hwnd, 0, mbi->Timeout, NULL);
}
return 0;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
case IDABORT:
case IDRETRY:
case IDIGNORE:
case IDYES:
case IDNO:
case IDTRYAGAIN:
case IDCONTINUE:
EndDialog(hwnd, wParam);
return TRUE;
#if 0
case IDHELP:
/* send WM_HELP message to messagebox window */
hi.cbSize = sizeof(HELPINFO);
hi.iContextType = HELPINFO_WINDOW;
hi.iCtrlId = LOWORD(wParam);
hi.hItemHandle = (HANDLE)lParam;
hi.dwContextId = 0;
GetCursorPos(&hi.MousePos);
SendMessageW(hwnd, WM_HELP, 0, (LPARAM)&hi);
return 0;
#endif
}
return 0;
#if 0
case WM_HELP:
mbi = (PMSGBOXINFO)GetProp(hwnd, "ROS_MSGBOX");
if(!mbi)
return 0;
memcpy(&hi, (void *)lParam, sizeof(hi));
hi.dwContextId = GetWindowContextHelpId(hwnd);
if (mbi->Callback)
mbi->Callback(&hi);
else
{
owner = GetWindow(hwnd, GW_OWNER);
if(owner)
SendMessageW(GetWindow(hwnd, GW_OWNER), WM_HELP, 0, (LPARAM)&hi);
}
return 0;
#endif
case WM_CLOSE:
mbi = (PMSGBOXINFO)GetProp(hwnd, "ROS_MSGBOX");
if(!mbi)
return 0;
switch(mbi->Style & MB_TYPEMASK)
{
case MB_ABORTRETRYIGNORE:
case MB_YESNO:
return 1;
}
//.........这里部分代码省略.........
示例12: ReplayDialogProc
//.........这里部分代码省略.........
//fp->stream = fp->stream->memwrap(); - no need to load whole movie to memory! We only need to read movie header!
HandleScan(hwndDlg, fp, items);
delete fp;
}
} else
{
asr.files.FilterByExtension(fm2ext);
for(uint32 i=0;i<asr.files.size();i++)
{
FCEUFILE* fp = FCEU_fopen(filename,0,"rb",0,asr.files[i].index);
if(fp)
{
HandleScan(hwndDlg,fp, items);
delete fp;
}
}
}
} while(FindNextFile(hFind, &wfd));
FindClose(hFind);
}
}
for(int j = 0; j < NUM_OF_MOVIEGLOB_PATHS; j++)
free(findGlob[j]);
if(items>0)
SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_SETCURSEL, items-1, 0);
SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_INSERTSTRING, items++, (LPARAM)"Browse...");
UpdateReplayDialog(hwndDlg);
}
SetFocus(GetDlgItem(hwndDlg, IDC_COMBO_FILENAME));
return FALSE;
case WM_COMMAND:
if (HIWORD(wParam) == EN_CHANGE)
{
if (LOWORD(wParam) == IDC_EDIT_STOPFRAME) // Check if Stop movie at value has changed
{
if (stopframeWasEditedByUser)
{
HWND hwnd1 = GetDlgItem(hwndDlg,IDC_CHECK_STOPMOVIE);
Button_SetCheck(hwnd1,BST_CHECKED);
stopframeWasEditedByUser = true;
}
else
stopframeWasEditedByUser = true;
}
}
if (HIWORD(wParam) == CBN_SELCHANGE)
{
UpdateReplayDialog(hwndDlg);
} else if(HIWORD(wParam) == CBN_CLOSEUP)
{
LONG lCount = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_GETCOUNT, 0, 0);
LONG lIndex = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_GETCURSEL, 0, 0);
if (lIndex != CB_ERR && lIndex == lCount-1)
SendMessage(hwndDlg, WM_COMMAND, (WPARAM)IDOK, 0); // send an OK notification to open the file browser
} else
{
int wID = LOWORD(wParam);
switch(wID)
{
示例13: MainWndCommand
static VOID
MainWndCommand(PMAIN_WND_INFO Info,
WORD CmdId,
HWND hControl)
{
UNREFERENCED_PARAMETER(hControl);
switch (CmdId)
{
case ID_PROP:
{
if (Info->SelectedItem != NO_ITEM_SELECTED)
{
Info->bDlgOpen = TRUE;
OpenPropSheet(Info);
Info->bDlgOpen = FALSE;
SetMenuAndButtonStates(Info);
}
}
break;
case ID_REFRESH:
{
RefreshServiceList(Info);
Info->SelectedItem = NO_ITEM_SELECTED;
/* disable menus and buttons */
SetMenuAndButtonStates(Info);
/* clear the service in the status bar */
SendMessage(Info->hStatus,
SB_SETTEXT,
1,
_T('\0'));
}
break;
case ID_EXPORT:
{
ExportFile(Info);
SetFocus(Info->hListView);
}
break;
case ID_CREATE:
{
INT ret;
ret = DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_DLG_CREATE),
Info->hMainWnd,
CreateDialogProc,
(LPARAM)Info);
if (ret == IDOK)
RefreshServiceList(Info);
SetFocus(Info->hListView);
}
break;
case ID_DELETE:
{
if (Info->pCurrentService->ServiceStatusProcess.dwCurrentState != SERVICE_RUNNING)
{
DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_DLG_DELETE),
Info->hMainWnd,
DeleteDialogProc,
(LPARAM)Info);
}
else
{
TCHAR Buf[60];
LoadString(hInstance,
IDS_DELETE_STOP,
Buf,
sizeof(Buf) / sizeof(TCHAR));
DisplayString(Buf);
}
SetFocus(Info->hListView);
}
break;
case ID_START:
{
if (DoStart(Info, NULL))
{
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
SetMenuAndButtonStates(Info);
SetFocus(Info->hListView);
}
}
break;
case ID_STOP:
if (DoStop(Info))
{
//.........这里部分代码省略.........
示例14: switch
// callback function for the splitter window.
LRESULT CALLBACK
TabEditorSplitter::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
TabEditorSplitter *ptabsplitter =(TabEditorSplitter*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
HBRUSH hbr;
RECT rc;
switch(message)
{
case WM_NCCREATE:
// Get the initial creation pointer to the window object
ptabsplitter = (TabEditorSplitter *)((CREATESTRUCT *)lparam)->lpCreateParams;
ptabsplitter->m_hwnd = hwnd;
SetWindowLongPtr(hwnd, GWLP_USERDATA,(LONG_PTR)ptabsplitter);
break;
case WM_PAINT:
return ptabsplitter->OnPaint();
case WM_MOUSEMOVE:
ptabsplitter->MouseMove();
return 0;
case WM_MOVE:
//return ptabsplitter->OnPaint();
InvalidateRect(ptabsplitter->m_hwnd, NULL, FALSE); // hav to test it
UpdateWindow(hwnd);
return 0;
case WM_LBUTTONDOWN:
ptabsplitter->m_hwndprevfocus = GetFocus();
ptabsplitter->m_prevstyle = GetWindowLongPtr(ptabsplitter->m_hwndparent, GWL_STYLE);
SetWindowLongPtr(ptabsplitter->m_hwndparent, GWL_STYLE, ptabsplitter->m_prevstyle & ~WS_CLIPCHILDREN);
SetFocus(hwnd);
SetCapture(hwnd);
ptabsplitter->m_isdragged = wyTrue;
ptabsplitter->MouseMove(wyTrue);
break;
case WM_LBUTTONUP:
ReleaseCapture();
break;
case WM_CAPTURECHANGED:
if(ptabsplitter->m_isdragged == wyTrue)
{
ptabsplitter->EndDrag(wyTrue);
SetWindowLongPtr(ptabsplitter->m_hwndparent, GWL_STYLE, ptabsplitter->m_prevstyle);
if(ptabsplitter->m_isdlgsplitter == wyTrue)
PostMessage(GetParent(hwnd), UM_SPLITTERRESIZED, 0, 0);
else
{
ptabsplitter->Resizeall();
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
ptabsplitter->m_isdragged = wyFalse;
if(ptabsplitter->m_hwndprevfocus)
{
SetFocus(ptabsplitter->m_hwndprevfocus);
ptabsplitter->m_hwndprevfocus = NULL;
}
}
break;
case WM_ERASEBKGND:
if(ptabsplitter->m_isdlgsplitter == wyFalse &&
wyTheme::GetBrush(BRUSH_HSPLITTER, &hbr))
{
GetClientRect(hwnd, &rc);
FillRect((HDC)wparam, &rc, hbr);
return 1;
}
}
return(DefWindowProc(hwnd, message, wparam, lparam));
}
示例15: MainWndProc
static LRESULT CALLBACK
MainWndProc(HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
PMAIN_WND_INFO Info;
LRESULT Ret = 0;
/* Get the window context */
Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd,
GWLP_USERDATA);
if (Info == NULL && msg != WM_CREATE)
{
goto HandleDefaultMessage;
}
switch(msg)
{
case WM_CREATE:
{
Info = (PMAIN_WND_INFO)(((LPCREATESTRUCT)lParam)->lpCreateParams);
/* Initialize the main window context */
Info->hMainWnd = hwnd;
Info->SelectedItem = NO_ITEM_SELECTED;
SetWindowLongPtr(hwnd,
GWLP_USERDATA,
(LONG_PTR)Info);
if (!InitMainWnd(Info))
return -1;
/* Fill the list-view before showing the main window */
RefreshServiceList(Info);
/* Show the window */
ShowWindow(hwnd,
Info->nCmdShow);
SetFocus(Info->hListView);
}
break;
case WM_SIZE:
{
MainWndResize(Info,
LOWORD(lParam),
HIWORD(lParam));
}
break;
case WM_NOTIFY:
{
LPNMHDR pnmhdr = (LPNMHDR)lParam;
switch (pnmhdr->code)
{
case NM_DBLCLK:
{
POINT pt;
RECT rect;
GetCursorPos(&pt);
GetWindowRect(Info->hListView, &rect);
if (PtInRect(&rect, pt))
{
SendMessage(hwnd,
WM_COMMAND,
//ID_PROP,
MAKEWPARAM((WORD)ID_PROP, (WORD)0),
0);
}
//OpenPropSheet(Info);
}
break;
case NM_RETURN:
{
SendMessage(hwnd,
WM_COMMAND,
//ID_PROP,
MAKEWPARAM((WORD)ID_PROP, (WORD)0),
0);
}
break;
case LVN_COLUMNCLICK:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
(void)ListView_SortItems(Info->hListView,
CompareFunc,
pnmv->iSubItem);
bSortAscending = !bSortAscending;
}
break;
//.........这里部分代码省略.........