static int MessageBoxTimeoutIndirect(const MSGBOXPARAMS *lpMsgBoxParams, UINT Timeout) { DLGTEMPLATE *tpl; DLGITEMTEMPLATE *iico, *itxt; #if 0 NONCLIENTMETRICSW nclm; #endif char capbuf[32]; HMODULE hUser32 = 0; LPVOID buf; BYTE *dest; LPCSTR caption, text; HFONT hFont; HICON Icon = (HICON)0; HDC hDC; int bufsize, ret, caplen, textlen, btnlen, i, btnleft, btntop, lmargin, nButtons = 0; LONG Buttons[MSGBOXEX_MAXBTNS]; char ButtonText[MSGBOXEX_MAXBTNS][MSGBOXEX_MAXBTNSTR]; DLGITEMTEMPLATE *ibtn[MSGBOXEX_MAXBTNS]; RECT btnrect, txtrect, rc; SIZE btnsize; MSGBOXINFO mbi; BOOL defbtn = FALSE; DWORD units = GetDialogBaseUnits(); #if 0 hUser32 = GetModuleHandle(L"USER32"); #endif if(!lpMsgBoxParams->lpszCaption || !*lpMsgBoxParams->lpszCaption) { _LoadString(hUser32, IDS_ERROR, &capbuf[0], 32); caption = &capbuf[0]; } else caption = (LPCSTR)lpMsgBoxParams->lpszCaption; if(!lpMsgBoxParams->lpszText || !*lpMsgBoxParams->lpszText) text = ""; else text = (LPCSTR)lpMsgBoxParams->lpszText; caplen = strlen(caption); textlen = strlen(text); /* Create selected buttons */ switch(lpMsgBoxParams->dwStyle & MB_TYPEMASK) { case MB_OKCANCEL: Buttons[0] = IDOK; Buttons[1] = IDCANCEL; nButtons = 2; break; case MB_CANCELTRYCONTINUE: Buttons[0] = IDCANCEL; Buttons[1] = IDTRYAGAIN; Buttons[2] = IDCONTINUE; nButtons = 3; break; case MB_ABORTRETRYIGNORE: Buttons[0] = IDABORT; Buttons[1] = IDRETRY; Buttons[2] = IDIGNORE; nButtons = 3; break; case MB_YESNO: Buttons[0] = IDYES; Buttons[1] = IDNO; nButtons = 2; break; case MB_YESNOCANCEL: Buttons[0] = IDYES; Buttons[1] = IDNO; Buttons[2] = IDCANCEL; nButtons = 3; break; case MB_RETRYCANCEL: Buttons[0] = IDRETRY; Buttons[1] = IDCANCEL; nButtons = 2; break; case MB_OK: /* fall through */ default: Buttons[0] = IDOK; nButtons = 1; break; } /* Create Help button */ if(lpMsgBoxParams->dwStyle & MB_HELP) Buttons[nButtons++] = IDHELP; #if 0 switch(lpMsgBoxParams->dwStyle & MB_ICONMASK) { case MB_ICONEXCLAMATION: Icon = _LoadIcon(0, IDI_EXCLAMATION); MessageBeep(MB_ICONEXCLAMATION); break; case MB_ICONQUESTION: Icon = _LoadIcon(0, IDI_QUESTION); MessageBeep(MB_ICONQUESTION); break; case MB_ICONASTERISK: Icon = _LoadIcon(0, IDI_ASTERISK); MessageBeep(MB_ICONASTERISK); break; case MB_ICONHAND: Icon = _LoadIcon(0, IDI_HAND); MessageBeep(MB_ICONHAND); break; case MB_USERICON: Icon = _LoadIcon(lpMsgBoxParams->hInstance, (LPCWSTR)lpMsgBoxParams->lpszIcon); MessageBeep(MB_OK); break; default: /* By default, Windows 95/98/NT does not associate an icon to message boxes. * So ReactOS should do the same. */ Icon = (HICON)0; MessageBeep(MB_OK); break; } #endif /* Basic space */ bufsize = DLGTEMPLATE_SIZE + 2 * sizeof(WORD) + /* menu and class */ (caplen + 1) * sizeof(WCHAR); /* title */ /* Space for icon */ #if 0 if (NULL != Icon) { bufsize = (bufsize + 3) & ~3; bufsize += DLGITEMTEMPLATE_SIZE + 4 * sizeof(WORD) + sizeof(WCHAR); } #endif /* Space for text */ bufsize = (bufsize + 3) & ~3; bufsize += DLGITEMTEMPLATE_SIZE + 3 * sizeof(WORD) + (textlen + 1) * sizeof(WCHAR); for(i = 0; i < nButtons; i++) { switch(Buttons[i]) { case IDOK: _LoadString(hUser32, IDS_OK, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDCANCEL: _LoadString(hUser32, IDS_CANCEL, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDYES: _LoadString(hUser32, IDS_YES, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDNO: _LoadString(hUser32, IDS_NO, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDTRYAGAIN: _LoadString(hUser32, IDS_TRYAGAIN, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDCONTINUE: _LoadString(hUser32, IDS_CONTINUE, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDABORT: _LoadString(hUser32, IDS_ABORT, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDRETRY: _LoadString(hUser32, IDS_RETRY, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDIGNORE: _LoadString(hUser32, IDS_IGNORE, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; case IDHELP: _LoadString(hUser32, IDS_HELP, ButtonText[i], MSGBOXEX_MAXBTNSTR - 1); break; default: ButtonText[i][0] = 0; break; } /* Space for buttons */ bufsize = (bufsize + 3) & ~3; bufsize += DLGITEMTEMPLATE_SIZE + 3 * sizeof(WORD) + (strlen(ButtonText[i]) + 1) * sizeof(WCHAR); } if (!(buf = calloc( 1, bufsize + SAFETY_MARGIN))) return 0; iico = itxt = NULL; hDC = CreateCompatibleDC(0); #if 0 nclm.cbSize = sizeof(nclm); SystemParametersInfo (SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0); hFont = CreateFontIndirect (&nclm.lfMessageFont); #else hFont = GetStockObject(DEFAULT_GUI_FONT); #endif tpl = (DLGTEMPLATE *)buf; tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | DS_CENTER | DS_MODALFRAME | DS_NOIDLEMSG; tpl->dwExtendedStyle = WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT; if(lpMsgBoxParams->dwStyle & MB_TOPMOST) tpl->dwExtendedStyle |= WS_EX_TOPMOST; if(lpMsgBoxParams->dwStyle & MB_RIGHT) tpl->dwExtendedStyle |= WS_EX_RIGHT; tpl->x = 100; tpl->y = 100; tpl->cdit = nButtons + (Icon != (HICON)0) + 1; dest = ((BYTE *)tpl + DLGTEMPLATE_SIZE); *(WORD*)dest = 0; /* no menu */ *(((WORD*)dest) + 1) = 0; /* use default window class */ dest += 2 * sizeof(WORD); dest += CopyToWchar ((PWCHAR)dest, caption, caplen); #if 0 /* Create icon */ if(Icon) { dest = (BYTE*)(((ULONG)dest + 3) & (~3)); iico = (DLGITEMTEMPLATE *)dest; iico->style = WS_CHILD | WS_VISIBLE | SS_ICON; iico->dwExtendedStyle = 0; iico->id = MSGBOX_IDICON; dest += DLGITEMTEMPLATE_SIZE; *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); *(WORD*)dest = 0x0082; /* static control */ dest += sizeof(WORD); *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); *(WCHAR*)dest = 0; dest += sizeof(WCHAR); *(WORD*)dest = 0; dest += sizeof(WORD); } #endif /* create static for text */ dest = (BYTE*)(((DWORD)dest + 3) & ~3); itxt = (DLGITEMTEMPLATE *)dest; itxt->style = WS_CHILD | WS_VISIBLE | SS_NOPREFIX; if(lpMsgBoxParams->dwStyle & MB_RIGHT) itxt->style |= SS_RIGHT; else itxt->style |= SS_LEFT; itxt->dwExtendedStyle = 0; itxt->id = MSGBOX_IDTEXT; dest += DLGITEMTEMPLATE_SIZE; *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); *(WORD*)dest = 0x0082; /* static control */ dest += sizeof(WORD); dest += CopyToWchar ((PWCHAR)dest, text, textlen); *(WORD*)dest = 0; dest += sizeof(WORD); /* create buttons */ btnsize.cx = BTN_CX; btnsize.cy = BTN_CY; btnrect.left = btnrect.top = 0; for(i = 0; i < nButtons; i++) { dest = (BYTE*)(((DWORD)dest + 3) & ~3); ibtn[i] = (DLGITEMTEMPLATE *)dest; ibtn[i]->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP; if(!defbtn && (i == ((lpMsgBoxParams->dwStyle & MB_DEFMASK) >> 8))) { ibtn[i]->style |= BS_DEFPUSHBUTTON; mbi.DefBtn = Buttons[i]; defbtn = TRUE; } else ibtn[i]->style |= BS_PUSHBUTTON; ibtn[i]->dwExtendedStyle = 0; ibtn[i]->id = Buttons[i]; dest += DLGITEMTEMPLATE_SIZE; *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); *(WORD*)dest = 0x0080; /* button control */ dest += sizeof(WORD); btnlen = strlen(ButtonText[i]); dest += CopyToWchar ((PWCHAR)dest, ButtonText[i], btnlen); *(WORD*)dest = 0; dest += sizeof(WORD); SelectObject(hDC, hFont); DrawText(hDC, ButtonText[i], btnlen, &btnrect, DT_LEFT | DT_SINGLELINE | DT_CALCRECT); btnsize.cx = max(btnsize.cx, btnrect.right); btnsize.cy = max(btnsize.cy, btnrect.bottom); }
FORCE_INLINE int NSISCALL ui_doinstall(void) { header *header = g_header; static WNDCLASS wc; // richedit subclassing and bgbg creation // detect default language // more information at: // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_0xrn.asp LANGID (WINAPI *GUDUIL)(); GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage); if (GUDUIL) { // Windows ME/2000+ myitoa(state_language, GUDUIL()); } else { static const TCHAR reg_9x_locale[] = _T("Control Panel\\Desktop\\ResourceLocale"); static const TCHAR reg_nt_locale_key[] = _T(".DEFAULT\\Control Panel\\International"); const TCHAR *reg_nt_locale_val = ®_9x_locale[30]; // = _T("Locale") with opt *(DWORD*)state_language = CHAR4_TO_DWORD(_T('0'), _T('x'), 0, 0); { // Windows 9x myRegGetStr(HKEY_CURRENT_USER, reg_9x_locale, NULL, g_tmp, 0); } if (!g_tmp[0]) { // Windows NT // This key exists on 9x as well, so it's only read if ResourceLocale wasn't found myRegGetStr(HKEY_USERS, reg_nt_locale_key, reg_nt_locale_val, g_tmp, 0); } mystrcat(state_language, g_tmp); } // set default language set_language(); // initialize auto close flag g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE; #ifdef NSIS_CONFIG_PLUGIN_SUPPORT // initialize plugin api g_exec_flags.plugin_api_version=NSISPIAPIVER_CURR; #endif // read install directory from registry if (!is_valid_instpath(state_install_directory)) { if (header->install_reg_key_ptr) { myRegGetStr( (HKEY)header->install_reg_rootkey, GetNSISStringNP(header->install_reg_key_ptr), GetNSISStringNP(header->install_reg_value_ptr), ps_tmpbuf, 0 ); if (ps_tmpbuf[0]) { TCHAR *p=ps_tmpbuf; TCHAR *e; if (p[0]==_T('\"')) { TCHAR *p2; p++; p2 = findchar(p, _T('"')); *p2 = 0; } // p is the path now, check for .exe extension e=p+mystrlen(p)-4; if (e > p) { // if filename ends in .exe, and is not a directory, remove the filename if (!lstrcmpi(e, _T(".exe"))) // check extension { DWORD d; d=GetFileAttributes(p); if (d == INVALID_FILE_ATTRIBUTES || !(d&FILE_ATTRIBUTE_DIRECTORY)) { // if there is no back-slash, the string will become empty, but that's ok because // it would make an invalid instdir anyway trimslashtoend(p); } } } mystrcpy(state_install_directory,addtrailingslash(p)); } } } if (!is_valid_instpath(state_install_directory)) { GetNSISString(state_install_directory,header->install_directory_ptr); } #ifdef NSIS_CONFIG_LOG if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller) { #if !defined(NSIS_CONFIG_LOG_ODS) && !defined(NSIS_CONFIG_LOG_STDOUT) build_g_logfile(); #endif log_dolog=1; } #endif #ifdef NSIS_CONFIG_VISIBLE_SUPPORT g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED); #ifdef NSIS_SUPPORT_BGBG if (header->bg_color1 != -1) { DWORD cn = CHAR4_TO_DWORD(_T('_'), _T('N'), _T('b'), 0); RECT vp; extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM); wc.lpfnWndProc = BG_WndProc; wc.hInstance = g_hInstance; wc.hIcon = g_hIcon; //wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.lpszClassName = (LPCTSTR)&cn; if (!RegisterClass(&wc)) return 0; SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,(LPCTSTR)&cn,0,WS_POPUP, vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL); } #endif//NSIS_SUPPORT_BGBG #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_SUPPORT_CODECALLBACKS // Select language if (ExecuteCallbackFunction(CB_ONINIT)) return 2; set_language(); #endif #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT if (!g_exec_flags.silent) #endif//NSIS_CONFIG_SILENT_SUPPORT { #ifdef NSIS_SUPPORT_BGBG ShowWindow(m_bgwnd, SW_SHOW); #endif//NSIS_SUPPORT_BGBG #ifdef NSIS_CONFIG_LICENSEPAGE { // load richedit DLL static const TCHAR riched20[]=_T("RichEd20"); static const TCHAR riched32[]=_T("RichEd32"); static const TCHAR richedit20a[]=_T("RichEdit20A"); static const TCHAR richedit[]=_T("RichEdit"); if (!LoadLibrary(riched20)) { LoadLibrary(riched32); } // make richedit20a point to RICHEDIT if (!GetClassInfo(NULL,richedit20a,&wc)) { GetClassInfo(NULL,richedit,&wc); wc.lpszClassName = richedit20a; RegisterClass(&wc); } } #endif { int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc); #if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) ExecuteCallbackFunction(CB_ONGUIEND); #endif #ifdef NSIS_CONFIG_PLUGIN_SUPPORT Plugins_SendMsgToAllPlugins(NSPIM_GUIUNLOAD); #endif return ret; } } #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT else #endif//NSIS_CONFIG_VISIBLE_SUPPORT { if (install_thread(NULL)) { #ifdef NSIS_SUPPORT_CODECALLBACKS if (!g_quit_flag) ExecuteCallbackFunction(CB_ONINSTFAILED); #endif//NSIS_SUPPORT_CODECALLBACKS return 2; } #ifdef NSIS_SUPPORT_CODECALLBACKS ExecuteCallbackFunction(CB_ONINSTSUCCESS); #endif//NSIS_SUPPORT_CODECALLBACKS return 0; } #endif//NSIS_CONFIG_SILENT_SUPPORT }
void STDCALL OSCriticalExit() { SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, 0, 0); TerminateProcess(GetCurrentProcess(), INVALID); }
void CColourPopup::Initialise() { //set size if it has not been set already if(colourArrayPassed==NULL) m_nNumColours = sizeof(m_crColours)/sizeof(ColourTableEntry); ASSERT(m_nNumColours <= MAX_COLOURS); if (m_nNumColours > MAX_COLOURS) m_nNumColours = MAX_COLOURS; m_nNumColumns = 0; m_nNumRows = 0; m_nBoxSize = 18; m_nMargin = ::GetSystemMetrics(SM_CXEDGE); m_nCurrentSel = INVALID_COLOUR; m_nChosenColourSel = INVALID_COLOUR; m_pParent = NULL; m_crColour = m_crInitialColour = RGB(0,0,0); m_bChildWindowVisible = FALSE; // Idiot check: Make sure the colour square is at least 5 x 5; if (m_nBoxSize - 2*m_nMargin - 2 < 5) m_nBoxSize = 5 + 2*m_nMargin + 2; // Create the font NONCLIENTMETRICS ncm; ncm.cbSize = sizeof(NONCLIENTMETRICS); VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)); m_Font.CreateFontIndirect(&(ncm.lfMessageFont)); // Create the palette struct { LOGPALETTE LogPalette; PALETTEENTRY PalEntry[MAX_COLOURS]; } pal; LOGPALETTE* pLogPalette = (LOGPALETTE*) &pal; pLogPalette->palVersion = 0x300; pLogPalette->palNumEntries = (WORD) m_nNumColours; if(colourArrayPassed==NULL) {//use default array for (int i = 0; i < m_nNumColours; i++) { pLogPalette->palPalEntry[i].peRed = GetRValue(m_crColours[i].crColour); pLogPalette->palPalEntry[i].peGreen = GetGValue(m_crColours[i].crColour); pLogPalette->palPalEntry[i].peBlue = GetBValue(m_crColours[i].crColour); pLogPalette->palPalEntry[i].peFlags = 0; } } else {//if an array has been passed use it for(int i=0;i<m_nNumColours;i++) { pLogPalette->palPalEntry[i].peRed = GetRValue(colourArrayPassed[i]); pLogPalette->palPalEntry[i].peGreen = GetGValue(colourArrayPassed[i]); pLogPalette->palPalEntry[i].peBlue = GetBValue(colourArrayPassed[i]); pLogPalette->palPalEntry[i].peFlags = 0; } } m_Palette.CreatePalette(pLogPalette); }
void CWebWindow::OnCmdNewWindow(long x, long y, long cx, long cy, LPCTSTR title, LPCTSTR url, BOOL bModal, BOOL bTopMost, BOOL bResizable ) { CString strUrl = url; strUrl.MakeLower(); int iIncident = strUrl.Find(_T("incidents%2fincidentedit.aspx")); int iToDo = strUrl.Find(_T("todo%2ftodoedit.aspx")); int iCalendar = strUrl.Find(_T("events%2feventedit.aspx")); int iFileUpload = strUrl.Find(_T("filelibrary%2fdefault.aspx")); int iFileUpload2 = strUrl.Find(_T("filelibrary%2fdefault.aspx%3f")); int iProject = strUrl.Find(_T("projects%2fprojectedit.aspx")); int iList = strUrl.Find(_T("lists%2flistedit.aspx")); int iIncidentCapture = strUrl.Find(_T("incidents%2fincidentscreencaptureedit.aspx")); if(((CMainDlg*)GetMessageParent())->IsToolboxIstalled() && (iIncident>=0|| iToDo>=0 || iCalendar>=0 || (iFileUpload>=0 && iFileUpload!=iFileUpload2)|| iProject>=0 || iIncidentCapture>=0 || iList>=0) ) { // Run Toolbox [3/26/2004] CString strToolboxPath = ((CMainDlg*)GetMessageParent())->ToolboxPath(); CString strParametrs; if(iIncident>=0) { strParametrs.Format(_T("/CREATEINCIDENT /L \"%s\" /P \"%s\""),((CMainDlg*)GetMessageParent())->m_DlgLog.m_LoginStr, ((CMainDlg*)GetMessageParent())->m_DlgLog.m_PasswordStr); } else if(iToDo>=0) { strParametrs.Format(_T("/CREATETODO /L \"%s\" /P \"%s\""),((CMainDlg*)GetMessageParent())->m_DlgLog.m_LoginStr, ((CMainDlg*)GetMessageParent())->m_DlgLog.m_PasswordStr); } else if(iCalendar>=0) { strParametrs.Format(_T("/CREATEEVENT /L \"%s\" /P \"%s\""),((CMainDlg*)GetMessageParent())->m_DlgLog.m_LoginStr, ((CMainDlg*)GetMessageParent())->m_DlgLog.m_PasswordStr); } else if(iFileUpload>=0) { strParametrs.Format(_T("/UPLOAD /L \"%s\" /P \"%s\""),((CMainDlg*)GetMessageParent())->m_DlgLog.m_LoginStr, ((CMainDlg*)GetMessageParent())->m_DlgLog.m_PasswordStr); } else if(iProject>=0) { strParametrs.Format(_T("/CREATEPROJECT /L \"%s\" /P \"%s\""),((CMainDlg*)GetMessageParent())->m_DlgLog.m_LoginStr, ((CMainDlg*)GetMessageParent())->m_DlgLog.m_PasswordStr); } else if(iIncidentCapture>=0) { CScreenShotDlg *pScreenShotDlg = new CScreenShotDlg(((CMainDlg*)GetMessageParent()),CScreenShotDlg::CreateIssue); pScreenShotDlg->Create(CScreenShotDlg::IDD,GetDesktopWindow()); pScreenShotDlg->ShowWindow(SW_NORMAL); AddWindowToClose(pScreenShotDlg); return; } else if(iList>=0) { strParametrs.Format(_T("/CREATELIST /L \"%s\" /P \"%s\""),((CMainDlg*)GetMessageParent())->m_DlgLog.m_LoginStr, ((CMainDlg*)GetMessageParent())->m_DlgLog.m_PasswordStr); } if(((CMainDlg*)GetMessageParent())->IsSSLMode()) strParametrs += _T(" /USESSL"); ShellExecute(::GetDesktopWindow(),NULL,strToolboxPath,strParametrs,NULL,SW_SHOWNORMAL); } else { int m_lIBNActionBrowser = 1;//GetOptionInt(IDS_OFSMESSENGER,IDS_IBNACTIONBROWSER,1); if(m_lIBNActionBrowser==0) { if(cx==0&&cy==0) { CRect rd; SystemParametersInfo(SPI_GETWORKAREA, 0, &rd, 0); cx = rd.Width()-256; cy = rd.Height()-128; } CWebWindow *pNewWindow = new CWebWindow; pNewWindow->CreateAutoKiller(_T("/Browser/Common/skin.xml"), GetMessageParent(), GetDesktopWindow(), x, y, cx, cy, title, url, bModal, bTopMost, bResizable); if(IsBadReadPtr(NULL,sizeof(COfsDhtmlEditCtrl))) { ASSERT(FALSE); } if(GetOptionInt(IDS_OFSMESSENGER,IDS_OPENINMAXIMAZE, TRUE)) { pNewWindow->ShowWindow(SW_MAXIMIZE); } } else { if(S_OK!=this->NavigateNewWindow(url)) ShellExecute(NULL,_T("open"),url,NULL,NULL,SW_SHOWNORMAL); } } }
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { RECT rect; int cc; wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = wc.cbWndExtra = 0; wc.hInstance = 0; wc.hIcon = NULL; wc.hCursor = LoadCursor(0,IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = "raytracer"; if (!RegisterClass(&wc)) return FALSE; rect.left = rect.top = 0; rect.right = SCRWIDTH, rect.bottom = SCRHEIGHT; AdjustWindowRect( &rect, WS_POPUP|WS_SYSMENU|WS_CAPTION, 0 ); rect.right -= rect.left, rect.bottom -= rect.top; wnd = CreateWindowEx( 0, "raytracer", "raytracer", WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME, CW_USEDEFAULT, CW_USEDEFAULT, rect.right, rect.bottom, 0, 0, 0, 0 ); ShowWindow(wnd,SW_NORMAL); for ( cc = 0; cc < sizeof( BITMAPINFOHEADER ) + 16; cc++ ) bitmapbuffer[cc] = 0; bh = (BITMAPINFO *)&bitmapbuffer; bh->bmiHeader.biSize = sizeof( BITMAPINFOHEADER ); bh->bmiHeader.biPlanes = 1; bh->bmiHeader.biBitCount = 32; bh->bmiHeader.biCompression = BI_BITFIELDS; bh->bmiHeader.biWidth = SCRWIDTH, bh->bmiHeader.biHeight = -SCRHEIGHT; ((unsigned long*)bh->bmiColors)[0] = 255 << 16; ((unsigned long*)bh->bmiColors)[1] = 255 << 8; ((unsigned long*)bh->bmiColors)[2] = 255; window_hdc = GetDC(wnd); SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, 0); initConf(config); // prepare output canvas surface = new Surface(SCRWIDTH,SCRHEIGHT); buffer = surface->GetBuffer(); surface->Clear(0); AllocConsole(); //Sortie Console freopen("CONOUT$","wb",stdout); clock_scene.begin(); // ---> start clock_scene // prepare renderer Scene* maScene = new Scene(); maScene->chargerScene(config.filename); maScene->afficherScene(); tracer = new Engine(config); tracer->SetScene(maScene); tracer->SetTarget(surface->GetBuffer(),SCRWIDTH, SCRHEIGHT ); int tpos = 60; clock_scene.end(); // ---> end clock_scene system("Pause"); tracer->InitRender(); clock_render.begin(); // ---> start clock_render tracer->Render(); //calcul de l'image clock_render.end(); // ---> end clock_render SaveImage("test.ppm",tracer->GetImage()); SaveLogFile("Resultat.log",config); afficherClock(); while (1) { DrawWindow(); } FreeConsole(); // Close the console window return 1; }
WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { WebMouseWheelEvent result; //(WebInputEvent::Uninitialized()); result.type = WebInputEvent::MouseWheel; // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that // GetMessageTime() refers to is the same one that we're passed in? Perhaps // one of the construction parameters should be the time passed by the // caller, who would know for sure. result.timeStampSeconds = GetMessageTime() / 1000.0; result.button = WebMouseEvent::ButtonNone; // Get key state, coordinates, and wheel delta from event. typedef SHORT (WINAPI *GetKeyStateFunction)(int key); GetKeyStateFunction getKeyState; UINT keyState; float wheelDelta; bool horizontalScroll = false; if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) { // Synthesize mousewheel event from a scroll event. This is needed to // simulate middle mouse scrolling in some laptops. Use GetAsyncKeyState // for key state since we are synthesizing the input event. getKeyState = GetAsyncKeyState; keyState = 0; if (getKeyState(VK_SHIFT)) keyState |= MK_SHIFT; if (getKeyState(VK_CONTROL)) keyState |= MK_CONTROL; // NOTE: There doesn't seem to be a way to query the mouse button state // in this case. POINT cursorPosition = {0}; GetCursorPos(&cursorPosition); result.globalX = cursorPosition.x; result.globalY = cursorPosition.y; switch (LOWORD(wparam)) { case SB_LINEUP: // == SB_LINELEFT wheelDelta = WHEEL_DELTA; break; case SB_LINEDOWN: // == SB_LINERIGHT wheelDelta = -WHEEL_DELTA; break; case SB_PAGEUP: wheelDelta = 1; result.scrollByPage = true; break; case SB_PAGEDOWN: wheelDelta = -1; result.scrollByPage = true; break; default: // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here. wheelDelta = 0; break; } if (message == WM_HSCROLL) horizontalScroll = true; } else { // Non-synthesized event; we can just read data off the event. getKeyState = GetKeyState; keyState = GET_KEYSTATE_WPARAM(wparam); result.globalX = static_cast<short>(LOWORD(lparam)); result.globalY = static_cast<short>(HIWORD(lparam)); wheelDelta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam)); if (message == WM_MOUSEHWHEEL) { horizontalScroll = true; wheelDelta = -wheelDelta; // Windows is <- -/+ ->, WebKit <- +/- ->. } } if (keyState & MK_SHIFT) horizontalScroll = true; // Set modifiers based on key state. if (keyState & MK_SHIFT) result.modifiers |= WebInputEvent::ShiftKey; if (keyState & MK_CONTROL) result.modifiers |= WebInputEvent::ControlKey; if (getKeyState(VK_MENU) & 0x8000) result.modifiers |= WebInputEvent::AltKey; if (keyState & MK_LBUTTON) result.modifiers |= WebInputEvent::LeftButtonDown; if (keyState & MK_MBUTTON) result.modifiers |= WebInputEvent::MiddleButtonDown; if (keyState & MK_RBUTTON) result.modifiers |= WebInputEvent::RightButtonDown; SetToggleKeyState(&result); // Set coordinates by translating event coordinates from screen to client. POINT clientPoint = { result.globalX, result.globalY }; MapWindowPoints(0, hwnd, &clientPoint, 1); result.x = clientPoint.x; result.y = clientPoint.y; result.windowX = result.x; result.windowY = result.y; // Convert wheel delta amount to a number of pixels to scroll. // // How many pixels should we scroll per line? Gecko uses the height of the // current line, which means scroll distance changes as you go through the // page or go to different pages. IE 8 is ~60 px/line, although the value // seems to vary slightly by page and zoom level. Also, IE defaults to // smooth scrolling while Firefox doesn't, so it can get away with somewhat // larger scroll values without feeling as jerky. Here we use 100 px per // three lines (the default scroll amount is three lines per wheel tick). // Even though we have smooth scrolling, we don't make this as large as IE // because subjectively IE feels like it scrolls farther than you want while // reading articles. static const float scrollbarPixelsPerLine = 100.0f / 3.0f; wheelDelta /= WHEEL_DELTA; float scrollDelta = wheelDelta; if (horizontalScroll) { unsigned long scrollChars = defaultScrollCharsPerWheelDelta; SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0); // TODO(pkasting): Should probably have a different multiplier // scrollbarPixelsPerChar here. scrollDelta *= static_cast<float>(scrollChars) * scrollbarPixelsPerLine; } else { unsigned long scrollLines = defaultScrollLinesPerWheelDelta; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); if (scrollLines == WHEEL_PAGESCROLL) result.scrollByPage = true; if (!result.scrollByPage) scrollDelta *= static_cast<float>(scrollLines) * scrollbarPixelsPerLine; } // Set scroll amount based on above calculations. WebKit expects positive // deltaY to mean "scroll up" and positive deltaX to mean "scroll left". if (horizontalScroll) { result.deltaX = scrollDelta; result.wheelTicksX = wheelDelta; } else { result.deltaY = scrollDelta; result.wheelTicksY = wheelDelta; } return result; }
void GMouse::ShowCursor(void) { #if defined(GWIN) SystemParametersInfo(SPI_SETCURSORS, 0, 0, 0); #endif }
static VOID SetScreenSaver(HWND hwndDlg, PDATA pData) { HKEY regKey; BOOL DeleteMode = FALSE; if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop"), 0, KEY_ALL_ACCESS, ®Key) == ERROR_SUCCESS) { INT Time; BOOL bRet; TCHAR Sec; UINT Ret; /* Set the screensaver */ if (pData->ScreenSaverItems[pData->Selection].bIsScreenSaver) { RegSetValueEx(regKey, _T("SCRNSAVE.EXE"), 0, REG_SZ, (PBYTE)pData->ScreenSaverItems[pData->Selection].szFilename, _tcslen(pData->ScreenSaverItems[pData->Selection].szFilename) * sizeof(TCHAR)); SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_UPDATEINIFILE); } else { /* Windows deletes the value if no screensaver is set */ RegDeleteValue(regKey, _T("SCRNSAVE.EXE")); DeleteMode = TRUE; SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, 0, SPIF_UPDATEINIFILE); } /* Set the secure value */ Ret = SendDlgItemMessage(hwndDlg, IDC_SCREENS_USEPASSCHK, BM_GETCHECK, 0, 0); Sec = (Ret == BST_CHECKED) ? _T('1') : _T('0'); RegSetValueEx(regKey, _T("ScreenSaverIsSecure"), 0, REG_SZ, (PBYTE)&Sec, sizeof(TCHAR)); /* Set the screensaver time delay */ Time = GetDlgItemInt(hwndDlg, IDC_SCREENS_TIMEDELAY, &bRet, FALSE); if (Time == 0) Time = 60; else Time *= 60; SystemParametersInfoW(SPI_SETSCREENSAVETIMEOUT, Time, 0, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE); RegCloseKey(regKey); } }
LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) { // handle a few messages switch (message) { // paint: draw bezels as necessary case WM_PAINT: { PAINTSTRUCT pstruct; HDC dc = BeginPaint(m_wnd, &pstruct); draw_contents(dc); EndPaint(m_wnd, &pstruct); break; } // keydown: handle debugger keys case WM_KEYDOWN: if (handle_key(wparam, lparam)) set_ignore_char_lparam(lparam); break; // char: ignore chars associated with keys we've handled case WM_CHAR: if (check_ignore_char_lparam(lparam)) { if (waiting_for_debugger() || !seq_pressed()) return DefWindowProc(m_wnd, message, wparam, lparam); } break; // activate: set the focus case WM_ACTIVATE: if (wparam != WA_INACTIVE) set_default_focus(); break; // get min/max info: set the minimum window size case WM_GETMINMAXINFO: { MINMAXINFO *minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = m_minwidth; minmax->ptMinTrackSize.y = m_minheight; minmax->ptMaxSize.x = minmax->ptMaxTrackSize.x = m_maxwidth; minmax->ptMaxSize.y = minmax->ptMaxTrackSize.y = m_maxheight; break; } // sizing: recompute child window locations case WM_SIZE: case WM_SIZING: recompute_children(); InvalidateRect(m_wnd, NULL, FALSE); break; // mouse wheel: forward to the first view case WM_MOUSEWHEEL: { static int units_carryover = 0; UINT lines_per_click; if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines_per_click, 0)) lines_per_click = 3; int const units = GET_WHEEL_DELTA_WPARAM(wparam) + units_carryover; int const clicks = units / WHEEL_DELTA; units_carryover = units % WHEEL_DELTA; int const delta = clicks * lines_per_click; int viewnum = 0; POINT point; // figure out which view we are hovering over GetCursorPos(&point); ScreenToClient(m_wnd, &point); HWND const child = ChildWindowFromPoint(m_wnd, point); if (child) { for (viewnum = 0; viewnum < MAX_VIEWS; viewnum++) { if ((m_views[viewnum] != NULL) && m_views[viewnum]->owns_window(child)) break; } if (viewnum == MAX_VIEWS) break; } // send the appropriate message to this view's scrollbar if (m_views[viewnum] != NULL) m_views[viewnum]->send_vscroll(delta); break; } // activate: set the focus case WM_INITMENU: update_menu(); break; // command: handle a comment case WM_COMMAND: if (!handle_command(wparam, lparam)) return DefWindowProc(m_wnd, message, wparam, lparam); break; // close: close the window if it's not the main console case WM_CLOSE: if (m_is_main_console) { debugger().hide_all(); debug_cpu_get_visible_cpu(machine())->debug()->go(); } else { destroy(); } break; // destroy: close down the window case WM_NCDESTROY: m_wnd = NULL; debugger().remove_window(*this); break; // everything else: defaults default: return DefWindowProc(m_wnd, message, wparam, lparam); } return 0; }
void CComputerListView::OnClientShortMessage(SHORT_MESSAGE_INFO& shortMsgInfo) { //{ 2011/11/15-8210-gxx: CString str = CA2T(shortMsgInfo.shortMsg.message); int nSpl = str.Find(_T('|')); if (nSpl > 0 && str.Left(nSpl).CompareNoCase(_T("p-ddnparam")) == 0) { // 购买点卡的消息 CString strTmp(CA2T(shortMsgInfo.shortMsg.message)); strTmp = strTmp.Mid(11); CString strTerm(CA2T(shortMsgInfo.shortMsg.termID)); if (strTmp.Find(_T('?')) >= 0) { strTmp.AppendFormat(_T("&TermId=%s"), strTerm); } else { strTmp.AppendFormat(_T("?TermId=%s"), strTerm); } CActiveMember ActiveMember; if (CLocalServer::GetInstance()->ActiveMemberList.GetActiveMember(shortMsgInfo.shortMsg.memberID,ActiveMember)) { strTmp.AppendFormat(_T("&UserName=%s"), ActiveMember.GetUserName()); } else { strTmp += _T("&UserName=未知姓名"); } IBA_LOG(_T("客户端请求购买点卡,URL=%s"), strTmp); CCashierHelper::CashSellDianka(strTmp); } //} else if (shortMsgInfo.shortMsg.messageType !=2 ) // 非余额不足消息 { //弹出式 CBCGPPopupWindow* pPopup = new CMsgPopupWindow; //这里不需要删除,框架会自动删除的 // Create indirect: CBCGPPopupWndParams params;//设置窗口参数 CString strMsg, strTermId, strTermIP, strTmp; strTermId = CA2W(shortMsgInfo.shortMsg.termID);//终端ID // 2011/06/17-gxx: 打补丁,IP长度等于15时,拷贝字符串出问题 char IP[LEN_IPADDR+1]; memcpy(IP, shortMsgInfo.shortMsg.computerIP, LEN_IPADDR); IP[LEN_IPADDR] = '\0'; strTermIP = CA2W(IP);//终端IP strTermId.Trim(); strTermIP.Trim(); if (!strTermIP.IsEmpty())//IP 不是空 表示是客户端信息 { strTmp = LOAD_STRING(IDS_CLIENTINFO); strMsg.Format(LOAD_STRING(IDS_FORMTERMIP), strTermId, strTermIP);//设置终端的URL params.m_nURLCmdID = (UINT)CLocalServer::GetInstance()->ComputerList.Find(strTermId, strTermIP); params.m_hIcon = AfxGetApp()->LoadIcon(IDR_UDO); } else { params.m_nURLCmdID = 10000; strTmp = LOAD_STRING(IDS_CASHIERINFO); params.m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } //接受客户端消息 strMsg.Append(CA2W(shortMsgInfo.shortMsg.message)); params.m_strText = strMsg; RECT rt = {-1, -1, -1, -1}; if (CIBAConfig::GetInstance()->GetMsgLeftBottom())// 从左下角弹出 { SystemParametersInfo(SPI_GETWORKAREA, 0, &rt, 0); } if (!CIBAConfig::GetInstance()->GetMsgAutoHide()) { pPopup->SetAutoCloseTime(0); } pPopup->Create(NULL, params, 0, CPoint(rt.left, rt.bottom));//创建窗体 pPopup->SetWindowText(strTmp);//显示消息 } CClientShortMessage csm; csm.SetMemberId( shortMsgInfo.shortMsg.memberID); csm.SetMsgBody( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.message)); csm.SetMsgID( shortMsgInfo.shortMsg.ID); csm.SetMsgType( shortMsgInfo.shortMsg.messageType); csm.SetRevTime( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.sendTime)); csm.SetTermID( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.termID)); csm.SetTermIP( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.computerIP)); if (csm.GetMsgType() == 2) { if (CNetBarConfig::GetInstance()->GetReminderBalance()) { static DWORD nTimeCount = GetTickCount() - 10000; if (GetTickCount()-nTimeCount > 10000)// 防止在10秒连续播放 { NS_TTS::CIBATTS::GetInstance()->SpeakReminderBalance(csm.GetTermID()); nTimeCount = GetTickCount(); } } csm.SetMsgBody(LOAD_STRING(IDS_BALANCE_REMINDER)); // 余额不足 } //写到信息对话框中 //((CMainFrame*)AfxGetMainWnd())->m_wndOutput.UpdateMsgLog(); ((CMainFrame*)AfxGetMainWnd())->m_wndOutput.AddMsgLog(csm); }
void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey) { int j,n; POINT pt; int itemHeight; char str[MAX_PATH]; if (dataListEdit) dataListEdit->EndListEdit(0); pt.x=pt.y=0; ClientToScreen(hwndList,&pt); OffsetRect(rc,pt.x,pt.y); InflateRect(rc,-2,-2); rc->left-=2; iEditItem = iItem; ListView_RedrawItems(hwndList, iEditItem, iEditItem); UpdateWindow(hwndList); dataListEdit = this; hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST, _T("LISTBOX"), _T(""), WS_POPUP|WS_BORDER|WS_VSCROLL, rc->left, rc->bottom, rc->right - rc->left, 150, NULL, NULL, hInst, NULL); SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0); itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0); FieldNamesItem *list = (FieldNamesItem*)setting[iSetting].pList; if (list == countryField) { // some country codes were changed leaving old details uknown, convert it for the user if (settingData[iSetting].value == 420) settingData[iSetting].value = 42; // conversion of obsolete codes (OMG!) else if (settingData[iSetting].value == 421) settingData[iSetting].value = 4201; else if (settingData[iSetting].value == 102) settingData[iSetting].value = 1201; } n = ListBoxAddStringUtf(hwndListEdit, "Unspecified"); for (j=0; ; j++) if (!list[j].text) { SendMessage(hwndListEdit, LB_SETITEMDATA, n, j); if ((settingData[iSetting].value == 0 && list[j].code == 0) || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code)) SendMessage(hwndListEdit, LB_SETCURSEL, n, 0); break; } for (j=0; list[j].text; j++) { n = ListBoxAddStringUtf(hwndListEdit, list[j].text); SendMessage(hwndListEdit, LB_SETITEMDATA, n, j); if ((setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, list[j].text)) || (setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH)))) || ((char*)settingData[iSetting].value == NULL && list[j].code == 0)) || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code)) SendMessage(hwndListEdit, LB_SETCURSEL, n, 0); } SendMessage(hwndListEdit, LB_SETTOPINDEX, SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0) - 3, 0); int listCount = SendMessage(hwndListEdit, LB_GETCOUNT, 0, 0); if (itemHeight * listCount < 150) SetWindowPos(hwndListEdit, 0, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER|SWP_NOMOVE); OldListEditProc = (WNDPROC)SetWindowLongPtr(hwndListEdit, GWLP_WNDPROC, (LONG_PTR)ListEditSubclassProc); if (MyAnimateWindow = (BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(GetModuleHandleA("user32"), "AnimateWindow")) { BOOL enabled; SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &enabled, FALSE); if (enabled) MyAnimateWindow(hwndListEdit, 200, AW_SLIDE|AW_ACTIVATE|AW_VER_POSITIVE); } ShowWindow(hwndListEdit, SW_SHOW); SetFocus(hwndListEdit); if (wVKey) PostMessage(hwndListEdit, WM_KEYDOWN, wVKey, 0); }
/** * Initialize input. * * @return @c true, if successful. */ boolean I_Init(void) { HRESULT hr; if(initIOk) return true; // Already initialized. if(ArgCheck("-nowsk")) // No Windows system keys? { // Disable Alt-Tab, Alt-Esc, Ctrl-Alt-Del. A bit of a hack... SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, 0, 0); Con_Message("Windows system keys disabled.\n"); } // We'll create the DirectInput object. The only required input device // is the keyboard. The others are optional. dInput = NULL; if(FAILED (hr = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8, &dInput)) || FAILED(hr = IDirectInput8_Initialize(dInput, app.hInstance, DIRECTINPUT_VERSION))) { Con_Message("I_Init: DirectInput 8 init failed (0x%x).\n", hr); // Try DInput3 instead. // I'm not sure if this works correctly. if(FAILED (hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput2W, &dInput)) || FAILED(hr = IDirectInput2_Initialize(dInput, app.hInstance, 0x0300))) { Con_Message ("I_Init: Failed to create DirectInput 3 object (0x%x).\n", hr); return false; } Con_Message("I_Init: Using DirectInput 3.\n"); } if(!dInput) { Con_Message("I_Init: DirectInput init failed.\n"); return false; } if(!I_InitKeyboard()) return false; // We must have a keyboard! // Acquire the keyboard. IDirectInputDevice_Acquire(didKeyb); // Create the mouse and joystick devices. It doesn't matter if the init // fails for them. I_InitMouse(); I_InitJoystick(); initIOk = true; return true; }
int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line, int show_code) { timer::init(); QueryPerformanceCounter((LARGE_INTEGER *)&mem.profile); timer::start(Timer_Startup); mem.is_running = true; // Set current path to this executable's path { HMODULE module = GetModuleHandleA(NULL); char path_string[MAX_PATH]; uint32 path_len = GetModuleFileNameA(module, path_string, MAX_PATH); if (path_len != -1) { char *last_slash = strrchr(path_string, '\\'); if (last_slash) { *last_slash = '\0'; } SetCurrentDirectoryA(path_string); } } HWND window; // Create window { WNDCLASSA window_class = {}; window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; window_class.lpfnWndProc = Win32MainWindowCallback; window_class.hInstance = instance; const char* ico_path = "papaya.ico"; window_class.hIcon = (HICON)LoadImage(0, ico_path, IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED); window_class.lpszClassName = "PapayaWindowClass"; if (!RegisterClassA(&window_class)) { // TODO: Log: Register window class failed return 0; } window = CreateWindowExA( 0, // Extended window style window_class.lpszClassName, // Class name, "Papaya", // Name, WS_POPUP | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE, // window style CW_USEDEFAULT, // X, CW_USEDEFAULT, // Y, CW_USEDEFAULT, // width, CW_USEDEFAULT, // height, 0, // window Parent, 0, // Menu, instance, // Handle to the instance, 0); // lpParam if (!window) { // TODO: Log: Create window failed return 0; } SystemParametersInfo(SPI_GETWORKAREA, 0, &windows_work_area, 0); #ifdef PAPAYARELEASE SetWindowPos(window, HWND_TOP, 0, 0, 600, 600, NULL); ShowWindow(window, SW_MAXIMIZE); #else uint32 screen_width = GetSystemMetrics(SM_CXSCREEN); uint32 screen_height = GetSystemMetrics(SM_CYSCREEN); mem.window.width = (uint32)((float)screen_width * 0.5); mem.window.height = (uint32)((float)screen_height * 0.8); uint32 window_x = (screen_width - mem.window.width) / 2; uint32 window_y = (screen_height - mem.window.height) / 2; SetWindowPos(window, HWND_TOP, window_x, window_y, mem.window.width, mem.window.height, NULL); #endif // PAPAYARELEASE // Get window size { RECT window_rect = { 0 }; BOOL foo = GetClientRect(window, &window_rect); mem.window.width = window_rect.right - window_rect.left; mem.window.height = window_rect.bottom - window_rect.top; } } // Initialize OpenGL { device_context = GetDC(window); // Setup pixel format { PIXELFORMATDESCRIPTOR pixel_format_desc = { 0 }; // TODO: Program seems to work perfectly fine without all other params except dwFlags. // Can we skip other params for the sake of brevity? pixel_format_desc.nSize = sizeof(PIXELFORMATDESCRIPTOR); pixel_format_desc.nVersion = 1; pixel_format_desc.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; pixel_format_desc.iPixelType = PFD_TYPE_RGBA; pixel_format_desc.cColorBits = 32; pixel_format_desc.cDepthBits = 32; pixel_format_desc.dwLayerMask = PFD_MAIN_PLANE; // int32 pixel_format = ChoosePixelFormat(device_context, &pixel_format_desc); if (!pixel_format) { exit(1); } // TODO: Log: Choose pixel format failed if (!SetPixelFormat(device_context, pixel_format, &pixel_format_desc)) { exit(1); } // TODO: Log: Set pixel format failed } // Create rendering context { // TODO: Create "proper" context? // https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)#Proper_Context_Creation HGLRC rendering_context = wglCreateContext(device_context); wglMakeCurrent(device_context, rendering_context); if (!gl_lite_init()) { exit(1); } glGetIntegerv(GL_MAJOR_VERSION, &mem.system.gl_version[0]); glGetIntegerv(GL_MINOR_VERSION, &mem.system.gl_version[1]); } // Disable vsync //if (wglewIsSupported("WGL_EXT_swap_control")) { wglSwapIntervalEXT(0); } } // Initialize tablet EasyTab_Load(window); core::init(&mem); // Initialize ImGui { ImGuiIO& io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime. io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = VK_UP; io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN; io.KeyMap[ImGuiKey_Home] = VK_HOME; io.KeyMap[ImGuiKey_End] = VK_END; io.KeyMap[ImGuiKey_Delete] = VK_DELETE; io.KeyMap[ImGuiKey_Backspace] = VK_BACK; io.KeyMap[ImGuiKey_Enter] = VK_RETURN; io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; io.KeyMap[ImGuiKey_A] = 'A'; io.KeyMap[ImGuiKey_C] = 'C'; io.KeyMap[ImGuiKey_V] = 'V'; io.KeyMap[ImGuiKey_X] = 'X'; io.KeyMap[ImGuiKey_Y] = 'Y'; io.KeyMap[ImGuiKey_Z] = 'Z'; io.RenderDrawListsFn = core::render_imgui; io.ImeWindowHandle = window; } mem.window.menu_horizontal_offset = 32; mem.window.title_bar_buttons_width = 109; mem.window.title_bar_height = 30; timer::stop(Timer_Startup); // Handle command line arguments (if present) if (strlen(cmd_line)) { // Remove double quotes from string if present char* ptr_read = cmd_line; char* ptr_write = cmd_line; while (*ptr_read) { *ptr_write = *ptr_read++; if (*ptr_write != '\"') { ptr_write++; } } *ptr_write = '\0'; core::open_doc(cmd_line, &mem); } #ifdef PAPAYA_DEFAULT_IMAGE core::open_doc(PAPAYA_DEFAULT_IMAGE, &mem); #endif // PAPAYA_DEFAULT_IMAGE while (mem.is_running) { timer::start(Timer_Frame); // Windows message handling { MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { mem.is_running = false; } TranslateMessage(&msg); DispatchMessageA(&msg); } } // Tablet input // TODO: Put this in papaya.cpp { mem.tablet.pressure = EasyTab->Pressure; mem.tablet.pos.x = EasyTab->PosX; mem.tablet.pos.y = EasyTab->PosY; mem.tablet.buttons = EasyTab->Buttons; } BOOL is_maximized = IsMaximized(window); if (IsIconic(window)) { goto EndOfFrame; } // Start new ImGui frame { ImGuiIO& io = ImGui::GetIO(); // Setup display size (every frame to accommodate for window resizing) RECT rect; GetClientRect(window, &rect); io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top)); // Read keyboard modifiers inputs io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; // Setup time step INT64 current_time; QueryPerformanceCounter((LARGE_INTEGER *)¤t_time); io.DeltaTime = (float)(current_time - mem.profile.current_time) * (float)timer::get_freq() / 1000.0f; mem.profile.current_time = current_time; // TODO: Move Imgui timers from Debug to their own struct // Hide OS mouse cursor if ImGui is drawing it //SetCursor(io.MouseDrawCursor ? NULL : LoadCursor(NULL, IDC_ARROW)); // Start the frame ImGui::NewFrame(); } // Title Bar Icon { ImGui::SetNextWindowSize(ImVec2((float)mem.window.menu_horizontal_offset,(float)mem.window.title_bar_height)); ImGui::SetNextWindowPos(ImVec2(1.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(2,2)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0,0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); ImGui::PushStyleColor(ImGuiCol_WindowBg, mem.colors[PapayaCol_Transparent]); bool bTrue = true; ImGui::Begin("Title Bar Icon", &bTrue, mem.window.default_imgui_flags); #define CALCUV(X, Y) ImVec2((float)X/256.0f, (float)Y/256.0f) ImGui::Image((void*)(intptr_t)mem.textures[PapayaTex_UI], ImVec2(28,28), CALCUV(0,200), CALCUV(28,228)); #undef CALCUV ImGui::End(); ImGui::PopStyleColor(1); ImGui::PopStyleVar(5); } // Title Bar Buttons { ImGui::SetNextWindowSize(ImVec2((float)mem.window.title_bar_buttons_width,24.0f)); ImGui::SetNextWindowPos(ImVec2((float)mem.window.width - mem.window.title_bar_buttons_width, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0,0)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0,0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); ImGui::PushStyleColor(ImGuiCol_Button, mem.colors[PapayaCol_Transparent]); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, mem.colors[PapayaCol_ButtonHover]); ImGui::PushStyleColor(ImGuiCol_ButtonActive, mem.colors[PapayaCol_ButtonActive]); ImGui::PushStyleColor(ImGuiCol_WindowBg, mem.colors[PapayaCol_Transparent]); bool bTrue = true; #define CALCUV(X, Y) ImVec2((float)X/256.0f, (float)Y/256.0f) ImGui::Begin("Title Bar Buttons", &bTrue, mem.window.default_imgui_flags); ImGui::PushID(0); if(ImGui::ImageButton((void*)(size_t)mem.textures[PapayaTex_UI], ImVec2(34,26), CALCUV(62,200), CALCUV(96,226), 1, ImVec4(0,0,0,0))) { ShowWindow(window, SW_MINIMIZE); } ImVec2 start_uv = is_maximized ? CALCUV(28,226) : CALCUV(62,226); ImVec2 end_uv = is_maximized ? CALCUV(62,252) : CALCUV(96,252); ImGui::PopID(); ImGui::SameLine(); ImGui::PushID(1); if(ImGui::ImageButton((void*)(size_t)mem.textures[PapayaTex_UI], ImVec2(34,26), start_uv, end_uv, 1, ImVec4(0,0,0,0))) { if (is_maximized) { ShowWindow(window, SW_RESTORE); } else { ShowWindow(window, SW_MAXIMIZE); } } ImGui::PopID(); ImGui::SameLine(); ImGui::PushID(2); if(ImGui::ImageButton((void*)(size_t)mem.textures[PapayaTex_UI], ImVec2(34,26), CALCUV(28,200), CALCUV(62,226), 1, ImVec4(0,0,0,0))) { SendMessage(window, WM_CLOSE, 0, 0); } ImGui::PopID(); ImGui::End(); #undef CALCUV ImGui::PopStyleVar(5); ImGui::PopStyleColor(4); } // ImGui::ShowTestWindow(); core::update(&mem); SwapBuffers(device_context); EndOfFrame: timer::stop(Timer_Frame); double frame_rate = (mem.current_tool == PapayaTool_Brush && mem.mouse.is_down[0]) ? 500.0 : 60.0; double frame_time = 1000.0 / frame_rate; double sleep_time = frame_time - timers[Timer_Frame].elapsed_ms; timers[Timer_Sleep].elapsed_ms = sleep_time; if (sleep_time > 0) { Sleep((int32)sleep_time); } } core::destroy(&mem); EasyTab_Unload(); return 0; }
__forceinline int NSISCALL ui_doinstall(void) { header *header = g_header; static WNDCLASS wc; // richedit subclassing and bgbg creation g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE; set_language(); if (!is_valid_instpath(state_install_directory)) { if (header->install_reg_key_ptr) { myRegGetStr( (HKEY)header->install_reg_rootkey, GetNSISStringNP(header->install_reg_key_ptr), GetNSISStringNP(header->install_reg_value_ptr), ps_tmpbuf ); if (ps_tmpbuf[0]) { char *p=ps_tmpbuf; char *e; if (p[0]=='\"') { char *p2=CharNext(p); p=p2; while (*p2 && *p2 != '\"') p2=CharNext(p2); *p2=0; } // p is the path now, check for .exe extension e=p+mystrlen(p)-4; if (e > p) { // if filename ends in .exe, and is not a directory, remove the filename if (!lstrcmpi(e, ".exe")) // check extension { DWORD d; d=GetFileAttributes(p); if (d == (DWORD)-1 || !(d&FILE_ATTRIBUTE_DIRECTORY)) { // if there is no back-slash, the string will become empty, but that's ok because // it would make an invalid instdir anyway trimslashtoend(p); } } } mystrcpy(state_install_directory,p); } } } if (!is_valid_instpath(state_install_directory)) { GetNSISString(state_install_directory,header->install_directory_ptr); } #ifdef NSIS_CONFIG_LOG if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller) { #ifndef NSIS_CONFIG_LOG_ODS build_g_logfile(); #endif log_dolog=1; } #endif #ifdef NSIS_CONFIG_VISIBLE_SUPPORT g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED); #ifdef NSIS_SUPPORT_BGBG if (header->bg_color1 != -1) { RECT vp; extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM); wc.lpfnWndProc = BG_WndProc; wc.hInstance = g_hInstance; wc.hIcon = g_hIcon; //wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.lpszClassName = "_Nb"; if (!RegisterClass(&wc)) return 0; SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,"_Nb",0,WS_POPUP, vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL); } #ifdef NSIS_SUPPORT_CODECALLBACKS g_hwnd=m_bgwnd; #endif//NSIS_SUPPORT_CODECALLBACKS #endif//NSIS_SUPPORT_BGBG #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_SUPPORT_CODECALLBACKS // Select language if (ExecuteCodeSegment(header->code_onInit,NULL)) return 1; set_language(); #endif #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_SUPPORT_BGBG g_hwnd=NULL; #endif//NSIS_SUPPORT_BGBG #endif//NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_CONFIG_SILENT_SUPPORT if (!g_exec_flags.silent) #endif//NSIS_CONFIG_SILENT_SUPPORT { #ifdef NSIS_SUPPORT_BGBG ShowWindow(m_bgwnd, SW_SHOW); #endif//NSIS_SUPPORT_BGBG #ifdef NSIS_CONFIG_LICENSEPAGE { // load richedit DLL static char str1[]="RichEd20.dll"; static char str2[]="RichEdit20A"; if (!LoadLibrary(str1)) { *(WORD*)(str1+6) = CHAR2_TO_WORD('3','2'); LoadLibrary(str1); } // make richedit20a point to RICHEDIT if (!GetClassInfo(NULL,str2,&wc)) { str2[8]=0; GetClassInfo(NULL,str2,&wc); wc.lpszClassName = str2; str2[8]='2'; RegisterClass(&wc); } } #endif { int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc); #if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) ExecuteCodeSegment(header->code_onGUIEnd,NULL); #endif return ret; } } #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT else #endif//NSIS_CONFIG_VISIBLE_SUPPORT { if (install_thread(NULL)) { #ifdef NSIS_SUPPORT_CODECALLBACKS if (!g_quit_flag) ExecuteCodeSegment(header->code_onInstFailed,NULL); #endif//NSIS_SUPPORT_CODECALLBACKS return 1; } #ifdef NSIS_SUPPORT_CODECALLBACKS ExecuteCodeSegment(header->code_onInstSuccess,NULL); #endif//NSIS_SUPPORT_CODECALLBACKS return 0; } #endif//NSIS_CONFIG_SILENT_SUPPORT }
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { // this is the winmain function WNDCLASS winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // generic dc PAINTSTRUCT ps; // generic paintstruct // first fill in the window class stucture winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; // register the window class if (!RegisterClass(&winclass)) return(0); // create the window, note the test to see if WINDOWED_APP is // true to select the appropriate window flags if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class WINDOW_TITLE, // title (WINDOWED_APP ? (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION) : (WS_POPUP | WS_VISIBLE)), 0,0, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hinstance,// instance NULL))) // creation parms return(0); // save the window handle and instance in a global main_window_handle = hwnd; main_instance = hinstance; // resize the window so that client is really width x height if (WINDOWED_APP) { // now resize the window, so the client area is the actual size requested // since there may be borders and controls if this is going to be a windowed app // if the app is not windowed then it won't matter RECT window_rect = {0,0,WINDOW_WIDTH-1,WINDOW_HEIGHT-1}; // make the call to adjust window_rect AdjustWindowRectEx(&window_rect, GetWindowStyle(main_window_handle), GetMenu(main_window_handle) != NULL, GetWindowExStyle(main_window_handle)); // save the global client offsets, they are needed in DDraw_Flip() window_client_x0 = -window_rect.left; window_client_y0 = -window_rect.top; // now resize the window with a call to MoveWindow() MoveWindow(main_window_handle, 0, // x position 0, // y position window_rect.right - window_rect.left, // width window_rect.bottom - window_rect.top, // height FALSE); // show the window, so there's no garbage on first render ShowWindow(main_window_handle, SW_SHOW); } // end if windowed // perform all game console specific initialization Game_Init(); // disable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, NULL, 0); // enter main event loop while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // shutdown game and release all resources Game_Shutdown(); // enable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, NULL, 0); // return to Windows like this return(msg.wParam); } // end WinMain
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow) { int success = 0; HANDLE helper = NULL; HMODULE hookdll = NULL; set_hooks_proc_t set_hooks_fn; remove_hooks_proc_t remove_hooks_fn; get_instance_count_proc_t instance_count_fn; inc_conn_serial_t inc_conn_serial_fn; int check_counter; if (strlen(cmdline) != 0) { messageW (L"Seamless RDP Shell should be started without any arguments."); return -1; } SYSTEM_INFO si; GetSystemInfo(&si); switch (si.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_INTEL: hookdll = LoadLibrary("seamlessrdp32.dll"); break; case PROCESSOR_ARCHITECTURE_AMD64: hookdll = LoadLibrary("seamlessrdp64.dll"); break; default: messageW(L"Unsupported processor architecture."); break; } if (!hookdll) { messageW(L"Could not load hook DLL. Unable to continue."); goto bail_out; } inc_conn_serial_fn = (inc_conn_serial_t) GetProcAddress(hookdll, "IncConnectionSerial"); set_hooks_fn = (set_hooks_proc_t) GetProcAddress(hookdll, "SetHooks"); remove_hooks_fn = (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); g_move_window_fn = (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); g_zchange_fn = (zchange_proc_t) GetProcAddress(hookdll, "SafeZChange"); g_focus_fn = (focus_proc_t) GetProcAddress(hookdll, "SafeFocus"); g_set_state_fn = (set_state_proc_t) GetProcAddress(hookdll, "SafeSetState"); g_vchannel_reopen_fn = (vchannel_reopen_t) GetProcAddress(hookdll, "vchannel_reopen"); g_vchannel_block_fn = (vchannel_block_t) GetProcAddress(hookdll, "vchannel_block"); g_vchannel_unblock_fn = (vchannel_unblock_t) GetProcAddress(hookdll, "vchannel_unblock"); g_vchannel_write_fn = (vchannel_write_t) GetProcAddress(hookdll, "vchannel_write"); g_vchannel_read_fn = (vchannel_read_t) GetProcAddress(hookdll, "vchannel_read"); g_vchannel_strfilter_unicode_fn = (vchannel_strfilter_unicode_t) GetProcAddress(hookdll, "vchannel_strfilter_unicode"); g_vchannel_debug_fn = (vchannel_debug_t) GetProcAddress(hookdll, "vchannel_debug"); if (!set_hooks_fn || !remove_hooks_fn || !instance_count_fn || !g_move_window_fn || !g_zchange_fn || !g_focus_fn || !g_set_state_fn || !g_vchannel_reopen_fn || !g_vchannel_block_fn || !g_vchannel_unblock_fn || !g_vchannel_write_fn || !g_vchannel_read_fn || !g_vchannel_strfilter_unicode_fn || !g_vchannel_debug_fn) { messageW (L"Hook DLL doesn't contain the correct functions. Unable to continue."); goto close_hookdll; } /* Check if the DLL is already loaded */ switch (instance_count_fn()) { case 0: messageW(L"Hook DLL failed to initialize."); goto close_hookdll; break; case 1: break; default: messageW(L"Another running instance of Seamless RDP detected."); goto close_hookdll; } helper = launch_helper(); ProcessIdToSessionId(GetCurrentProcessId(), &g_session_id); build_startup_procs(); build_system_procs(); g_connected = is_connected(); g_desktop_hidden = is_desktop_hidden(); g_vchannel_write_fn("HELLO", "0x%08x", g_desktop_hidden ? SEAMLESS_HELLO_HIDDEN : 0); set_hooks_fn(); /* Since we don't see the entire desktop we must resize windows immediatly. */ SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0); /* Disable screen saver since we cannot catch its windows. */ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0); /* We don't want windows denying requests to activate windows. */ SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0); g_session_disconnect_ts = 0; g_persistent_mode = 1; check_counter = 5; while (check_counter-- || !should_terminate()) { BOOL connected; MSG msg; connected = is_connected(); if (!connected && !g_session_disconnect_ts) g_session_disconnect_ts = time(NULL); if (connected && g_session_disconnect_ts) g_session_disconnect_ts = 0; if (connected && !g_connected) { int flags; /* These get reset on each reconnect */ SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0); SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0); g_persistent_mode = 1; inc_conn_serial_fn(); g_vchannel_reopen_fn(); flags = SEAMLESS_HELLO_RECONNECT; if (g_desktop_hidden) flags |= SEAMLESS_HELLO_HIDDEN; g_vchannel_write_fn("HELLO", "0x%08x", flags); } g_connected = connected; if (check_counter < 0) { BOOL hidden; hidden = is_desktop_hidden(); if (hidden && !g_desktop_hidden) g_vchannel_write_fn("HIDE", "0x%08x", 0); else if (!hidden && g_desktop_hidden) g_vchannel_write_fn("UNHIDE", "0x%08x", 0); g_desktop_hidden = hidden; check_counter = 5; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } process_cmds(); Sleep(100); } success = 1; remove_hooks_fn(); free_system_procs(); free_startup_procs(); if (helper) { // Terminate seamlessrdphook32.exe kill_15_9(helper, "SeamlessRDPHook", HELPER_TIMEOUT); } close_hookdll: FreeLibrary(hookdll); bail_out: // Logoff the user. This is necessary because the session may // have started processes that are not included in Microsofts // list of processes to ignore. Typically ieuser.exe. // FIXME: Only do this if WTSQuerySessionInformation indicates // that we are the initial program. ExitWindows(0, 0); if (success) return 1; else return -1; }
LRESULT EmoticonsDlg::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { ShowWindow(SW_HIDE); WNDPROC temp = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(EmoticonsDlg::m_hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(NewWndProc))); if (!g_MFCWndProc) g_MFCWndProc = temp; g_pDialog = this; ::EnableWindow(WinUtil::g_mainWnd, true); bool bUseAnimation = BOOLSETTING(SMILE_SELECT_WND_ANIM_SMILES); if (CAGEmotionSetup::g_pEmotionsSetup) { const CAGEmotion::Array& Emoticons = CAGEmotionSetup::g_pEmotionsSetup->getEmoticonsArray(); unsigned int pocet = 0; int l_count_emotion = 0; string lastEmotionPath, lastAnimEmotionPath; for (auto pEmotion = Emoticons.cbegin(); pEmotion != Emoticons.cend() && l_count_emotion < CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions; ++pEmotion, ++l_count_emotion) { if (bUseAnimation) { if ((*pEmotion)->getEmotionBmpPath() != lastEmotionPath || (*pEmotion)->getEmotionGifPath() != lastAnimEmotionPath) pocet++; lastEmotionPath = (*pEmotion)->getEmotionBmpPath(); lastAnimEmotionPath = (*pEmotion)->getEmotionGifPath(); } else { if ((*pEmotion)->getEmotionBmpPath() != lastEmotionPath) pocet++; lastEmotionPath = (*pEmotion)->getEmotionBmpPath(); } } // x, y jen pro for cyklus const unsigned int l_Emoticons_size = CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions; unsigned int i = (unsigned int)sqrt(double(l_Emoticons_size)); unsigned int nXfor = i; unsigned int nYfor = i; if ((i * i) != l_Emoticons_size) //[+]PPA { nXfor = i + 1; if ((i * nXfor) < l_Emoticons_size) nYfor = i + 1; else nYfor = i; } // x, y pro korektni vkladani ikonek za sebou i = (unsigned int)sqrt((double)pocet); unsigned int nX = i; unsigned int nY = i; if ((i * i) != pocet) //[+]PPA { nX = i + 1; if ((i * nX) < pocet) nY = i + 1; else nY = i; } if (Emoticons.empty() || !*Emoticons.begin()) //[+]PPA return 0; // [~] brain-ripper // If first icon failed to load, h_bm will be zero, and all icons will be drawn extremely small. // So cycle through Emoticons and find first loaded icon. //HBITMAP h_bm = (*Emoticons.begin())->getEmotionBmp(GetSysColor(COLOR_BTNFACE)); DWORD iSW = 0, iSH = 0, dwCount = 0; l_count_emotion = 0; for (auto i = Emoticons.cbegin(); i != Emoticons.cend() && l_count_emotion < CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions; ++i, ++l_count_emotion) { int w = 0, h = 0; CGDIImage *pImage = nullptr; if (bUseAnimation) pImage = (*i)->getAnimatedImage(MainFrame::getMainFrame()->m_hWnd, WM_ANIM_CHANGE_FRAME); if (pImage) { w = pImage->GetWidth(); h = pImage->GetHeight(); dwCount++; } else { if ((*i)->getDimensions(&w, &h)) { if (bUseAnimation) dwCount++; else { iSW = w; iSH = h; break; } } } iSW += w * w; iSH += h * h; } if (bUseAnimation && dwCount) { // Get mean square of all icon dimensions iSW = DWORD(sqrt(float(iSW / dwCount))); iSH = DWORD(sqrt(float(iSH / dwCount))); } pos.bottom = pos.top - 3; pos.left = pos.right - nX * (iSW + EMOTICONS_ICONMARGIN) - 2; pos.top = pos.bottom - nY * (iSH + EMOTICONS_ICONMARGIN) - 2; // [+] brain-ripper // Fit window in screen's work area RECT rcWorkArea; SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0); if (pos.right > rcWorkArea.right) { pos.left -= pos.right - rcWorkArea.right; pos.right = rcWorkArea.right; } if (pos.bottom > rcWorkArea.bottom) { pos.top -= pos.bottom - rcWorkArea.bottom; pos.bottom = rcWorkArea.bottom; } if (pos.left < rcWorkArea.left) { pos.right += rcWorkArea.left - pos.left; pos.left = rcWorkArea.left; } if (pos.top < rcWorkArea.top) { pos.bottom += rcWorkArea.top - pos.top; pos.top = rcWorkArea.top; } MoveWindow(pos); lastEmotionPath.clear(); lastAnimEmotionPath.clear(); m_ctrlToolTip.Create(EmoticonsDlg::m_hWnd, rcDefault, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, WS_EX_TOPMOST); m_ctrlToolTip.SetDelayTime(TTDT_AUTOMATIC, 1000); pos.left = 0; pos.right = iSW + EMOTICONS_ICONMARGIN; pos.top = 0; pos.bottom = iSH + EMOTICONS_ICONMARGIN; cleanHandleList(); auto l_Emotion = Emoticons.begin(); for (unsigned int iY = 0; iY < nYfor; iY++) for (unsigned int iX = 0; iX < nXfor; iX++) { if (l_Emotion != Emoticons.end()) // TODO - merge { const auto i = *l_Emotion; if ((iY * nXfor) + iX + 1 > l_Emoticons_size) break; bool bNotDuplicated = (bUseAnimation ? (i->getEmotionBmpPath() != lastEmotionPath || i->getEmotionGifPath() != lastAnimEmotionPath) : i->getEmotionBmpPath() != lastEmotionPath); // dve stejne emotikony za sebou nechceme if (bNotDuplicated) { bool bCreated = false; CGDIImage *pImage = nullptr; if (bUseAnimation) pImage = i->getAnimatedImage(MainFrame::getMainFrame()->m_hWnd, WM_ANIM_CHANGE_FRAME); if (pImage) { const tstring smajl = i->getEmotionText(); CAnimatedButton *pemoButton = new CAnimatedButton(pImage); m_BtnList.push_back(pemoButton); pemoButton->Create(EmoticonsDlg::m_hWnd, pos, smajl.c_str(), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_FLAT | BS_BITMAP, WS_EX_TRANSPARENT); m_ctrlToolTip.AddTool(*pemoButton, smajl.c_str()); bCreated = true; } else { if (const HBITMAP l_h_bm = i->getEmotionBmp(GetSysColor(COLOR_BTNFACE))) { CButton emoButton; const tstring smajl = i->getEmotionText(); emoButton.Create(EmoticonsDlg::m_hWnd, pos, smajl.c_str(), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_FLAT | BS_BITMAP | BS_CENTER); m_HandleList.push_back(l_h_bm); emoButton.SetBitmap(l_h_bm); m_ctrlToolTip.AddTool(emoButton, smajl.c_str()); DeleteObject((HGDIOBJ)emoButton); bCreated = true; } } if (bCreated) { // Calculate position of next button pos.left = pos.left + iSW + EMOTICONS_ICONMARGIN; pos.right = pos.left + iSW + EMOTICONS_ICONMARGIN; if (pos.left >= (LONG)(nX * (iSW + EMOTICONS_ICONMARGIN))) { pos.left = 0; pos.right = iSW + EMOTICONS_ICONMARGIN; pos.top = pos.top + iSH + EMOTICONS_ICONMARGIN; pos.bottom = pos.top + iSH + EMOTICONS_ICONMARGIN; } } } lastEmotionPath = i->getEmotionBmpPath(); if (bUseAnimation) lastAnimEmotionPath = i->getEmotionGifPath(); ++l_Emotion; } } pos.left = -128; pos.right = pos.left; pos.top = -128; pos.bottom = pos.top; CButton emoButton; emoButton.Create(EmoticonsDlg::m_hWnd, pos, _T(""), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_FLAT); emoButton.SetFocus(); DeleteObject((HGDIOBJ)emoButton); ShowWindow(SW_SHOW); for (auto i = m_BtnList.cbegin(); i != m_BtnList.cend(); ++i) { (*i)->Update(); } } else PostMessage(WM_CLOSE); return 0; }
void glWindow::RecreateWindow ( bool fullScreen, bool border, int width, int height, int bpp, bool stencil, std::string title, bool allowResizing, bool fitToWorkArea) { // Save window settings m_fullScreen = fullScreen; m_border = border; m_width = width; m_height = height; m_bpp = bpp; m_title = title; m_allowResizing = allowResizing; m_fitToWorkArea = fitToWorkArea; m_stencil = stencil; // Delete existing window KillWindow (); // Create new one GLuint PixelFormat; // Holds The Results After Searching For A Match DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values WindowRect.left =(long)0; // Set Left Value To 0 WindowRect.right =(long)m_width; // Set Right Value To Requested Width WindowRect.top =(long)0; // Set Top Value To 0 WindowRect.bottom =(long)m_height; // Set Bottom Value To Requested Height if (m_fullScreen) // Attempt Fullscreen Mode? { memset(&m_screenSettings,0,sizeof(m_screenSettings)); // Makes Sure Memory's Cleared m_screenSettings.dmSize=sizeof(m_screenSettings); // Size Of The Devmode Structure m_screenSettings.dmPelsWidth = m_width; // Selected Screen Width m_screenSettings.dmPelsHeight = m_height; // Selected Screen Height m_screenSettings.dmBitsPerPel = m_bpp; // Selected Bits Per Pixel m_screenSettings.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT; if (m_bpp) m_screenSettings.dmFields |= DM_BITSPERPEL; } if (m_fullScreen || !m_border) // Are We Still In Fullscreen Mode? { // Borderless window dwExStyle=WS_EX_APPWINDOW; dwStyle=WS_POPUP; } else { // Standard window dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style if (allowResizing) dwStyle = WS_OVERLAPPEDWINDOW; else dwStyle = WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX | WS_MAXIMIZEBOX); // Windows Style if (m_fitToWorkArea) dwStyle |= WS_MAXIMIZE; } if (!m_fullScreen && !m_fitToWorkArea) { // Get the screen resolution HWND desktop = GetDesktopWindow (); RECT desktopRect; GetWindowRect (desktop, &desktopRect); int xoffs, yoffs; if (WindowRect.right > desktopRect.right) xoffs = -WindowRect.left; else xoffs = (desktopRect.right - WindowRect.right) / 2; if (WindowRect.bottom > desktopRect.bottom) yoffs = -WindowRect.top; else yoffs = (desktopRect.bottom - WindowRect.bottom) / 2; WindowRect.left += xoffs; WindowRect.right += xoffs; WindowRect.top += yoffs; WindowRect.bottom += yoffs; // Adjust window size to allow for border if (m_border) AdjustWindowRectEx(&WindowRect, dwStyle, false, dwExStyle); } // Fitting to work area? if (m_fitToWorkArea) { SystemParametersInfo(SPI_GETWORKAREA, 0, &WindowRect, 0); // Gets the desktop work area m_width = WindowRect.right - WindowRect.left; m_height = WindowRect.bottom - WindowRect.top; } // Create The Window if (!(m_HWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window "gbOpenGL", // Class Name m_title.c_str (), // Window Title dwStyle | // Defined Window Style WS_CLIPSIBLINGS | // Required Window Style WS_CLIPCHILDREN, // Required Window Style WindowRect.left, WindowRect.top, // Window Position WindowRect.right-WindowRect.left, // Calculate Window Width WindowRect.bottom-WindowRect.top, // Calculate Window Height NULL, // No Parent Window NULL, // No Menu m_HInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE { SetError ("Window creation error"); return; } // Register window (for window procedure) glWindows [m_HWnd] = this; // Stencil buffer depth GLint stencilBits = m_stencil ? 8 : 0; static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, // Request An RGBA Format m_bpp, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) stencilBits, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(m_HDC=GetDC(m_HWnd))) // Did We Get A Device Context? { SetError ("Failed to get window device context"); return; } if (!(PixelFormat=ChoosePixelFormat(m_HDC,&pfd))) // Did Windows Find A Matching Pixel Format? { SetError ("Could not find a suitable pixel format"); return; } // Determine whether pixel format will be hardware accellerated. PIXELFORMATDESCRIPTOR pfd_new; DescribePixelFormat (m_HDC, PixelFormat, sizeof (PIXELFORMATDESCRIPTOR), &pfd_new); if ((pfd_new.dwFlags & PFD_GENERIC_FORMAT) != 0 // Generic && (pfd_new.dwFlags & PFD_GENERIC_ACCELERATED) == 0) { // Non accellerated // Warn user that OpenGL will proceed in software mode! if (MessageBox(NULL, "Hardware 3D acceleration is not available for this display mode.\nProceed in software mode?","Warning",MB_YESNO|MB_ICONEXCLAMATION)==IDNO) { SetError ("Aborted"); return; } } if(!SetPixelFormat(m_HDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { SetError ("Set pixel format failed"); return; } // Setup OpenGL RecreateGLContext (); }
LRESULT APIENTRY ProToolsProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { LONG_PTR action = 0, command = 0, hitArea = 0, styleChg = 0; pLL currentLink, prevLink; RECT rect, clientRect, workingAreaRect; LONG_PTR x = 0, y = 0, xFrame, yFrame; INT_PTR mnuItemCount, i; HMENU hMenu; BOOL bFuncReturn; LPMINMAXINFO lpmmi; //01/18/03 static LONG_PTR InCommand = 0; // 01/18/03 POINT pt; // 01/19/03 LPWINDOWPOS lpwp; LPNCCALCSIZE_PARAMS lpcalcsize; static HWND currentChildMaxed = NULL, prevChildMaxed = NULL; //char* minimizedWindows[32]; char title[128]; INT_PTR n = 0, err = 0; INT_PTR minimizedPerRow; // REB 8/11/08 #16207 currentLink = NULL; prevLink = NULL; if (toolBarRestrictions.toolBarOnDeck == 1) { // 01/17/03 xFrame = GetSystemMetrics(SM_CXSIZEFRAME); yFrame = GetSystemMetrics(SM_CYSIZEFRAME); // REB 8/11/08 #16207 minimizedPerRow = ((GetSystemMetrics(SM_CXVIRTUALSCREEN) - (toolBarRestrictions.clientOffsetx + toolBarRestrictions.left + toolBarRestrictions.right)) / GetSystemMetrics(SM_CXMINSPACING)); //err = GetWindowText(hwnd, title , 128); //**DEBUG** switch (uMsg) { case WM_SYSCOMMAND : //this tells a subsequent WM_GETMINMAXINFO command // that it is okay to proceed if we are in the process of a maximize command. command = wParam & 0xFFF0; if (SC_MAXIMIZE == command) { InCommand = IN_SYSCOMMAND_MAX; GetWindowRect(hwnd, &toolBarRestrictions.origWindowRect); GetWindowRect(windowHandles.MDIhWnd, &rect); toolBarRestrictions.clientOffsetx = rect.left; toolBarRestrictions.clientOffsety = rect.top; currentChildMaxed = hwnd; if (IsZoomed(hwnd) == 0){ // REB 8/11/08 #16207 //minimizePositions[toolBarRestrictions.numMinimized] = 0; err = GetWindowText(hwnd, title , 128); for (n=0; n < SMLBUF; n++) { if(strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0){ strcpy(toolBarRestrictions.minimizedWindows[n], ""); //break; } } } } // REB 8/11/08 #16207 if (SC_MINIMIZE == command) { InCommand = IN_SYSCOMMAND_MIN; GetWindowRect(hwnd, &toolBarRestrictions.origWindowRect); GetWindowRect(windowHandles.MDIhWnd, &rect); //Debug //GetWindowRect(windowHandles.MDIs_4DhWnd, &rect); //GetWindowRect(windowHandles.fourDhWnd, &rect); //End Debug toolBarRestrictions.clientOffsetx = rect.left; toolBarRestrictions.clientOffsety = rect.top; } if (SC_RESTORE == command) { //|| (toolBarRestrictions.appBeingMaxed > 0)) { InCommand = IN_SYSCOMMAND_RESTORE; if (IsZoomed(hwnd) != 0){ // REB 8/11/08 #16207 Only clear these if we are restoring a window that was already maximized. currentChildMaxed = NULL; // REB 3/26/10 #22878 Move the previous window back. MoveWindow(prevChildMaxed, toolBarRestrictions.previousWindowRect.left, toolBarRestrictions.previousWindowRect.top, (toolBarRestrictions.previousWindowRect.right - toolBarRestrictions.previousWindowRect.left), (toolBarRestrictions.previousWindowRect.bottom - toolBarRestrictions.previousWindowRect.top), 1); prevChildMaxed = NULL; }else{ err = GetWindowText(hwnd, title , 128); for (n=0; n < SMLBUF; n++) { if(strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0){ strcpy(toolBarRestrictions.minimizedWindows[n], ""); //break; } } } toolBarRestrictions.appBeingMaxed = 0; } //if (SC_NEXTWINDOW == command) { //toolBarRestrictions.appBeingMaxed = XCHANGING_MAX_WINDOWS; //} if (SC_CLOSE == command) { if (IsZoomed(hwnd) == 0){ // REB 8/11/08 #16207 err = GetWindowText(hwnd, title , 128); for (n=0; n < SMLBUF; n++) { if(strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0){ strcpy(toolBarRestrictions.minimizedWindows[n], ""); //break; } } } break; }; break; case WM_WINDOWPOSCHANGING : lpwp = (LPWINDOWPOS)lParam; GetWindowRect(windowHandles.MDIhWnd, &rect); if ((InCommand == IN_SYSCOMMAND_MAX) && (toolBarRestrictions.appWindowState == APP_MAXIMIZED)) { lpwp->x = lpwp->x - toolBarRestrictions.clientOffsetx - toolBarRestrictions.left; lpwp->y = lpwp->y - toolBarRestrictions.clientOffsety - toolBarRestrictions.top - yFrame; lpwp->cx = toolBarRestrictions.origWindowRect.right - toolBarRestrictions.origWindowRect.left; lpwp->cy = toolBarRestrictions.origWindowRect.bottom - toolBarRestrictions.origWindowRect.top; return 0; } // REB 8/11/08 #16207 if ((InCommand == IN_SYSCOMMAND_MIN) ){ // Minimizing the windows err = GetWindowText(hwnd, title , 128); for (n=0; n < SMLBUF; n++) { if((strcmp(toolBarRestrictions.minimizedWindows[n], "") == 0) || (strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0)){ strcpy(toolBarRestrictions.minimizedWindows[n], title); break; } } lpwp->x = toolBarRestrictions.clientOffsetx + toolBarRestrictions.left + ((n % minimizedPerRow) * GetSystemMetrics(SM_CXMINSPACING)); SystemParametersInfo(SPI_GETWORKAREA, 0, &workingAreaRect, 0); lpwp->y = workingAreaRect.bottom - yFrame - toolBarRestrictions.clientOffsety - toolBarRestrictions.bottom - (((n / (minimizedPerRow) ) + 1) * GetSystemMetrics(SM_CYMINSPACING)); return 0; } if ((toolBarRestrictions.appBeingMaxed == APP_MAXIMIZING) || (toolBarRestrictions.appBeingMaxed == APP_RESTORING) || (toolBarRestrictions.appBeingMaxed == APP_SIZING_W_CHLDMAX)) { lpwp->x = toolBarRestrictions.left - xFrame; lpwp->y = toolBarRestrictions.top - yFrame; lpwp->cx = rect.right - rect.left + (2 * xFrame) - toolBarRestrictions.left - toolBarRestrictions.right; lpwp->cy = rect.bottom - rect.top + (2 * yFrame) - toolBarRestrictions.top - toolBarRestrictions.bottom; return 0; } if (currentChildMaxed == hwnd) { //(toolBarRestrictions.appBeingMaxed == (LONG_PTR)hwnd) { lpwp->x = toolBarRestrictions.left - xFrame; lpwp->y = toolBarRestrictions.top - yFrame; lpwp->cx = rect.right - rect.left + (2 * xFrame) - toolBarRestrictions.left - toolBarRestrictions.right; lpwp->cy = rect.bottom - rect.top + (2 * yFrame) - toolBarRestrictions.top - toolBarRestrictions.bottom; return 0; } break; case WM_GETMINMAXINFO : if ((InCommand == IN_SYSCOMMAND_MAX) || (toolBarRestrictions.appBeingMaxed > 0) || (currentChildMaxed == hwnd) ) { lpmmi = (LPMINMAXINFO) lParam; lpmmi->ptMaxSize.x = lpmmi->ptMaxSize.x - toolBarRestrictions.left - toolBarRestrictions.right; lpmmi->ptMaxSize.y = lpmmi->ptMaxSize.y - toolBarRestrictions.top - toolBarRestrictions.bottom; lpmmi->ptMaxPosition.x = - xFrame + toolBarRestrictions.left; // maxPosition x&y seem to be static values -- hmmm! lpmmi->ptMaxPosition.y = - yFrame + toolBarRestrictions.top; lpmmi->ptMaxTrackSize.x = lpmmi->ptMaxTrackSize.x - toolBarRestrictions.left - toolBarRestrictions.right; lpmmi->ptMaxTrackSize.y = lpmmi->ptMaxTrackSize.y - toolBarRestrictions.top - toolBarRestrictions.bottom; return 0; // return 0 telling OS that we have processed this command } // end if break; case WM_NCCALCSIZE : if ( ((currentChildMaxed != NULL) || (prevChildMaxed != NULL)) && ((BOOL)wParam == TRUE) ) { lpcalcsize = (LPNCCALCSIZE_PARAMS)lParam; lpwp = lpcalcsize->lppos; rect = lpcalcsize->rgrc[0]; clientRect = lpcalcsize->rgrc[1]; toolBarRestrictions.appBeingMaxed = 0; //new } break; case WM_NCACTIVATE : if ((currentChildMaxed != NULL) && (currentChildMaxed != hwnd)) { //bFuncReturn = IsZoomed(currentChildMaxed); // REB 3/26/10 #22878 Here we need to capture the size of the newly activated window before it's resized to the max. // This window will become the new original window and we'll save the previous window position to be resized later. if (wParam){ toolBarRestrictions.previousWindowRect = toolBarRestrictions.origWindowRect; GetWindowRect(hwnd, &toolBarRestrictions.origWindowRect); prevChildMaxed = currentChildMaxed; currentChildMaxed = hwnd; } toolBarRestrictions.appBeingMaxed = (LONG_PTR)currentChildMaxed; //was XCHANGING_MAX_WINDOWS } break; case WM_SETFOCUS : // msg received by window getting focus //if (prevChildMaxed == (HWND)wParam) { //use the following in lieu of XCHANGING.. to restore all on window change //SendMessage((HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0L); //use this to keep maxed window when using CRTL-TAB. But 4D has an ugy bug in window // resize when called from a menu (Bring to Front). //toolBarRestrictions.appBeingMaxed = XCHANGING_MAX_WINDOWS; break; case WM_SIZE : if (toolBarRestrictions.appBeingMaxed != APP_SIZING_W_CHLDMAX) { toolBarRestrictions.appBeingMaxed = 0; } InCommand = 0; break; case WM_SIZING : case WM_MOVING : // restrict sizing or moving to prevent GetClientRect(windowHandles.MDIhWnd, &clientRect); //clientRect.right contains width of client area //clientRect.bottom contains height of client area //convert this rect to screen coordinates for comparison to movingRect pt.x = clientRect.left; pt.y = clientRect.top; ClientToScreen(windowHandles.MDIhWnd, &pt); clientRect.left = pt.x; clientRect.top = pt.y; pt.x = clientRect.right; pt.y = clientRect.bottom; ClientToScreen(windowHandles.MDIhWnd, &pt); clientRect.right = pt.x; clientRect.bottom = pt.y; clientRect.left += toolBarRestrictions.left; if (toolBarRestrictions.trackingRestriction == 0) { clientRect.top += toolBarRestrictions.top; } else { clientRect.top += toolBarRestrictions.trackingRestriction; } clientRect.right -= toolBarRestrictions.right; clientRect.bottom -= toolBarRestrictions.bottom; ClipCursor(&clientRect); break; case WM_EXITSIZEMOVE : rect.left = 0; rect.top = 0; rect.right = GetSystemMetrics(SM_CXVIRTUALSCREEN);// REB 6/6/08 #16838 (Fix Provided by Keith White) rect.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN);// REB 6/6/08 #16838 (Fix Provided by Keith White) ClipCursor(&rect); break; default : if((uMsg!=WM_ERASEBKGND)&&(uMsg!=WM_NCPAINT)&&(uMsg!=WM_PAINT)&&(uMsg!=WM_IME_SETCONTEXT)&&(uMsg!=WM_IME_NOTIFY)&&(uMsg!=WM_SETFOCUS)&&(uMsg!=WM_NCACTIVATE)&&(uMsg!=WM_KILLFOCUS)&&(uMsg!=WM_GETTEXT)){ break; }; } // end switch (uMsg) } // end if (toolBarRestrictions.toolBarOnDeck == 1) if (startOfList != NULL) { if ((uMsg == WM_SYSCOMMAND) || (uMsg == WM_NCHITTEST) || (uMsg == WM_INITMENU)) { if (search_list( &startOfList, ¤tLink, &prevLink, LL_hWnd, LL_Restrict, (LONG_PTR *) &hwnd)) { action = currentLink->dataLong1; switch (uMsg) { case (WM_SYSCOMMAND) : command = wParam & 0xFFF0; switch (command) { case (SC_SIZE) : if (RW_NO_SIZE == (action & RW_NO_SIZE)) { wParam = 0x000F; } break; case (SC_MOVE) : if (RW_NO_MOVE == (action & RW_NO_MOVE)) { wParam = 0x000F; } break; case (SC_MINIMIZE) : if (RW_NO_MIN == (action & RW_NO_MIN)) { wParam = 0x000F; } break; case (SC_MAXIMIZE) : if (RW_NO_MAX == (action & RW_NO_MAX)) { wParam = 0x000F; } break; } // end switch break; case (WM_NCHITTEST) : if (RW_NO_SIZE == (action & RW_NO_SIZE)) { hitArea = DefWindowProc(hwnd, uMsg, wParam, lParam); if ((hitArea >= HTLEFT) && (hitArea <= HTBOTTOMRIGHT)) { uMsg = HTNOWHERE; } else { // test for coordinates of lower right GetWindowRect(hwnd, &rect); x = LOWORD (lParam); y = HIWORD (lParam); if ((x <= rect.right) && (x >= (rect.right - 25 )) && (y <= rect.bottom) && (y >= (rect.bottom - 25))) { uMsg = HTNOWHERE; } } } break; case (WM_INITMENU): hMenu = GetSystemMenu(hwnd, FALSE); if (RW_NO_SIZE == (action & RW_NO_SIZE)) { bFuncReturn = EnableMenuItem(hMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED); } if (RW_NO_MOVE == (action & RW_NO_MOVE)) { bFuncReturn = EnableMenuItem(hMenu, SC_MOVE, MF_BYCOMMAND | MF_GRAYED); } if (RW_NO_MIN == (action & RW_NO_MIN)) { bFuncReturn = EnableMenuItem(hMenu, SC_MINIMIZE, MF_BYCOMMAND | MF_GRAYED); } if (RW_NO_MAX == (action & RW_NO_MAX)) { bFuncReturn = EnableMenuItem(hMenu, SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED); } if (RW_NO_NEXT == (action & RW_NO_NEXT)) { mnuItemCount = GetMenuItemCount(hMenu); for (i = (mnuItemCount - 1); i >= 0; i--) { if (GetMenuItemID(hMenu, i) == SC_NEXTWINDOW) { bFuncReturn = DeleteMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND); // is next higher menu item a separator line? if (GetMenuItemID(hMenu, i - 1) == 0) { bFuncReturn = DeleteMenu(hMenu, i - 1, MF_BYPOSITION); } } else if (GetMenuItemID(hMenu, i) == SC_PREVWINDOW) { bFuncReturn = DeleteMenu(hMenu, SC_PREVWINDOW, MF_BYCOMMAND); // is next higher menu item a separator line? if (GetMenuItemID(hMenu, i - 1) == 0) { bFuncReturn = DeleteMenu(hMenu, i - 1, MF_BYPOSITION); } } } } // end if (RW_NO_NEXT == (action & RW_NO_NEXT)) break; case (WM_DESTROY) : delete_list(&startOfList, LL_hWnd, LL_Restrict, (LONG_PTR *) &hwnd); break; } // end switch (uMsg) } // end if (search_list( &startOfList, ¤tLink, &prevLink, LL_hWnd, LL_Restrict, (LONG_PTR *) &hwnd)) } // end if ((uMsg == WM_SYSCOMMAND) || (uMsg == WM_NCHITTEST) || (uMsg == WM_INITMENU)) } // end if (startOfList != NULL) return CallWindowProc(processHandles.wpProToolsOrigProc, hwnd, uMsg, wParam, lParam); }
INT_PTR CALLBACK DialogMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static THREAD_DATA sThreadData[2]; static HANDLE hThread[2]; static DWORD dwTid[2]; RECT rcWindow; HWND hWndLeft; HWND hWndRight; int nCount = CCameraDS::CameraCount(); LONG lWindowStyle; SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&rcWindow, 0); switch(uMsg) { case WM_INITDIALOG: switch(nCount) { case 0: MessageBox(hwndDlg, TEXT("No webcam detected!"), TEXT("Info"), MB_ICONINFORMATION); break; case 1: sThreadData[0].nDevice = 0; sThreadData[0].strWindowName = "Video Output Window Left"; cvNamedWindow(sThreadData[0].strWindowName.c_str()); sThreadData[0].rcWindow = rcWindow; //GetClientRect(hWnd, &rcWindow); hWndLeft = FindWindow(TEXT("Main HighGUI class"), TEXT("Video Output Window Left")); _ASSERT(hWndLeft != NULL); lWindowStyle = GetWindowLong(hWndLeft, GWL_STYLE); lWindowStyle &= ~WS_CAPTION; SetWindowLong(hWndLeft, GWL_STYLE, lWindowStyle); MoveWindow(hWndLeft, rcWindow.left, rcWindow.top, rcWindow.right, rcWindow.bottom, TRUE); //SetParent(hWndLeft, hWnd); //MoveWindow(hWndLeft, rcWindow.left, rcWindow.right, rcWindow.right, rcWindow.bottom, TRUE); hThread[0] = CreateThread(NULL, 0, ThreadProc, (LPVOID)&sThreadData[0], 0, &dwTid[0]); break; case 2: for(int i = 0; i < nCount; ++i) { sThreadData[i].nDevice = i; switch(i) { case 0: sThreadData[i].strWindowName = "Video Output Window Left"; break; case 1: sThreadData[i].strWindowName = "Video Output Window Right"; break; } cvNamedWindow(sThreadData[i].strWindowName.c_str(), CV_WINDOW_AUTOSIZE); //GetWindowRect(hWnd, &sThreadData[0].rcWindow); sThreadData[i].rcWindow = rcWindow; hThread[i] = CreateThread(NULL, 0, ThreadProc, (LPVOID)&sThreadData[i], 0, &dwTid[i]); } //GetWindowRect(hWnd, &rcWindow); hWndLeft = FindWindow(TEXT("Main HighGUI class"), TEXT("Video Output Window Left")); hWndRight = FindWindow(TEXT("Main HighGUI class"), TEXT("Video Output Window Right")); _ASSERT(hWndLeft != NULL); _ASSERT(hWndRight != NULL); lWindowStyle = GetWindowLong(hWndLeft, GWL_STYLE); lWindowStyle &= ~WS_CAPTION; SetWindowLong(hWndLeft, GWL_STYLE, lWindowStyle); lWindowStyle = GetWindowLong(hWndRight, GWL_STYLE); lWindowStyle &= ~WS_CAPTION; SetWindowLong(hWndRight, GWL_STYLE, lWindowStyle); MoveWindow(hWndLeft, rcWindow.left, rcWindow.top, rcWindow.right / 2, rcWindow.bottom /2, TRUE); MoveWindow(hWndRight, rcWindow.right / 2, rcWindow.top, rcWindow.right / 2, rcWindow.bottom /2, TRUE); //SetParent(hWndLeft, hWnd); //SetParent(hWndRight, hWnd); break; default: MessageBox(hwndDlg, TEXT("Webcam count not supported!"), TEXT("Error"), MB_ICONSTOP); } return (INT_PTR)TRUE; case WM_CLOSE: switch(nCount) { case 1: PostThreadMessage(dwTid[0], WM_EXIT, NULL, NULL); cvDestroyWindow(sThreadData[0].strWindowName.c_str()); WaitForSingleObject(hThread[0], INFINITE); CloseHandle(hThread[0]); break; case 2: for(int i = 0; i < nCount; ++i) { PostThreadMessage(dwTid[i], WM_EXIT, NULL, NULL); cvDestroyWindow(sThreadData[i].strWindowName.c_str()); WaitForSingleObject(hThread[i], INFINITE); CloseHandle(hThread[i]); } } EndDialog(hwndDlg, 0); return (INT_PTR)TRUE; } return (INT_PTR)0; }
/* =========== IN_ActivateMouse Called when the window gains focus or changes in some way =========== */ void IN_ActivateMouse (qboolean clipcursor) { int width, height; static qboolean was_menu_active = false; // NiceAss: reset mouse settings if m_noaccel (formerly m_xp) changes if (m_noaccel->modified) { mouseactive = false; m_noaccel->modified = false; } if (!mouseinitialized) return; if (!in_mouse->value) { mouseactive = false; return; } // Check for a menu state change if (M_MenuActive() != was_menu_active) { mouseactive = false; was_menu_active = M_MenuActive(); } if (mouseactive) return; mouseactive = true; if (mouseparmsvalid) { if (m_noaccel->value) // jitmouse - ignore windows version checks so this works for Windows 7 and hopefully future versions. { restore_spi = SystemParametersInfo(SPI_SETMOUSE, 0, newmouseparms_noaccel, 0); } else { restore_spi = SystemParametersInfo(SPI_SETMOUSE, 0, originalmouseparms, 0); } } width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN); GetWindowRect(cl_hwnd, &window_rect); window_center_x = (window_rect.right + window_rect.left) / 2; window_center_y = (window_rect.top + window_rect.bottom) / 2; // jitmenu - in windowed mode, don't clip the cursor for the menu. if (clipcursor) { SetCursorPos(window_center_x, window_center_y); SetCapture(cl_hwnd); ClipCursor(&window_rect); } else { ReleaseCapture(); ClipCursor(NULL); } IN_HideCursor(); // jitmouse -- raw input support: { #ifndef HID_USAGE_PAGE_GENERIC #define HID_USAGE_PAGE_GENERIC ((USHORT) 0x01) #endif #ifndef HID_USAGE_GENERIC_MOUSE #define HID_USAGE_GENERIC_MOUSE ((USHORT) 0x02) #endif RAWINPUTDEVICE Rid[1]; Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC; Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE; Rid[0].dwFlags = RIDEV_INPUTSINK; Rid[0].hwndTarget = cl_hwnd; RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])); } }
void QDesktopWidgetPrivate::init(QDesktopWidget *that) { if (rects) return; rects = new QVector<QRect>(); workrects = new QVector<QRect>(); screenCount = 0; #ifndef Q_OS_WINCE QSystemLibrary user32Lib(QLatin1String("user32")); enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors"); getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW"); if (!enumDisplayMonitors || !getMonitorInfo) { screenCount = GetSystemMetrics(80); // SM_CMONITORS rects->resize(screenCount); for (int i = 0; i < screenCount; ++i) rects->replace(i, that->rect()); return; } // Calls enumCallback enumDisplayMonitors(0, 0, enumCallback, 0); enumDisplayMonitors = 0; getMonitorInfo = 0; #else QSystemLibrary coreLib(QLatin1String("coredll")); // CE >= 4.0 case enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors"); getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo"); if ((!enumDisplayMonitors || !getMonitorInfo)) { screenCount = GetSystemMetrics(SM_CMONITORS); return; } if (!coreLib.isLoaded() || !enumDisplayMonitors || !getMonitorInfo) { rects->resize(screenCount); for (int i = 0; i < screenCount; ++i) (*rects)[i] = that->rect(); RECT r; SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); QRect qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1)); #if defined(Q_WS_WINCE_WM) qt_get_sip_info(qr); #endif workrects->resize(screenCount); for (int j = 0; j < screenCount; ++j) (*workrects)[j] = qr; return; } // Calls enumCallback enumDisplayMonitors(0, 0, enumCallback, 0); enumDisplayMonitors = 0; getMonitorInfo = 0; #endif // Q_WS_WINCE }
bool CPrintFolder::CalcLayout(CDCHandle dcPrinter, const CRect &rcPage) { m_bHasPrinter = !dcPrinter.IsNull(); if(m_bHasPrinter) { if (rcPage.right > 0) { m_rcOutput = rcPage; } _sizeLogPixels.cx = dcPrinter.GetDeviceCaps(LOGPIXELSX); _sizeLogPixels.cy = dcPrinter.GetDeviceCaps(LOGPIXELSY); } if (m_fontTitle.m_hFont != 0) m_fontTitle.DeleteObject(); if (m_font.m_hFont != 0) m_font.DeleteObject(); int nTitleFontSize = 16; int nFontSize = 8; int nPaddingSize = 4; //Set up the font for the titles on the intro and ending pages NONCLIENTMETRICS ncm = {0}; ncm.cbSize = sizeof(ncm); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); //Create the intro/end title font LOGFONT lf = ncm.lfMessageFont; lf.lfHeight = 0 - ::MulDiv(_sizeLogPixels.cy, nTitleFontSize, 72); m_fontTitle.CreateFontIndirect(&lf); lf.lfHeight = 0 - ::MulDiv(_sizeLogPixels.cy, nFontSize, 72); m_font.CreateFontIndirect(&lf); /////////////////////// //convert from 1/1000" to twips _rectExtents.left = m_rcOutput.left + MulDiv(m_rcMargin.left, _sizeLogPixels.cx, 1000); _rectExtents.right = m_rcOutput.right - MulDiv(m_rcMargin.right, _sizeLogPixels.cx, 1000); _rectExtents.top = m_rcOutput.top + MulDiv(m_rcMargin.top, _sizeLogPixels.cy, 1000); _rectExtents.bottom = m_rcOutput.bottom - MulDiv(m_rcMargin.bottom, _sizeLogPixels.cy, 1000); m_nPadding = ::MulDiv(_sizeLogPixels.cy, nPaddingSize, 72); m_nFooterHeight = ::MulDiv(_sizeLogPixels.cy, nFontSize, 72) * 2; m_nHeaderHeight = ::MulDiv(_sizeLogPixels.cy, nTitleFontSize, 72) * 2; // Do we want footers and headers? int nFooterHeaderHeight = 0; if (m_bShowFooter || m_bShowPageNumbers) { nFooterHeaderHeight += m_nFooterHeight; } if (m_bShowHeader) { nFooterHeaderHeight += m_nHeaderHeight; } int nImageRows = m_bPrintOnePerPage ? 1 : _sizeRowsColumns.cy; int nImageColumns = m_bPrintOnePerPage ? 1 : _sizeRowsColumns.cx; // Calculate the thumbnail size _sizeSection.cx = ((_rectExtents.right - _rectExtents.left) / nImageColumns); _sizeSection.cy = (((_rectExtents.bottom - _rectExtents.top) - nFooterHeaderHeight) / nImageRows); if (_sizeSection.cx < 10 || _sizeSection.cy < 10) { return false; } _sizeThumbNail = _sizeSection; _sizeThumbNail.cy -= (m_nPadding * 2); _sizeThumbNail.cx -= (m_nPadding * 2); if (_sizeThumbNail.cy < 10) { return false; } m_nMaxPage = GetPageCount(); return true; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; RECT rc; TCHAR WndText[MAX_PATH]; DWORD Index; NONCLIENTMETRICS ncm; HFONT hFont; switch (message) { case WM_CREATE: hEditWnd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_AUTOHSCROLL|ES_LEFT|ES_MULTILINE, 0, 0, 0, 0, hWnd, NULL, hInst, NULL); hDisplayWnd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE, 0, 0, 0, 0, hWnd, NULL, hInst, NULL); memset(&ncm, 0, sizeof(NONCLIENTMETRICS)); ncm.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); hFont = CreateFontIndirect(&ncm.lfMessageFont); SendMessage(hEditWnd, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hDisplayWnd, WM_SETFONT, (WPARAM)hFont, TRUE); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); if (lParam == (LPARAM)hEditWnd && wmEvent == EN_CHANGE) { GetWindowText(hEditWnd, WndText, MAX_PATH); if (_tcslen(WndText) > 0) { SetWindowText(hEditWnd, TEXT("")); if (!bConnected) { MessageBox(hWnd, TEXT("You are not currently connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP); break; } for (Index=0; Index<_tcslen(WndText); Index++) { if (dwThreadId != 0) { PostThreadMessage(dwThreadId, WM_CHAR, (WPARAM)WndText[Index], (LPARAM)0); } } } } // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; case IDM_FILE_CLEARDISPLAY: SetWindowText(hDisplayWnd, TEXT("")); break; case IDM_FILE_CONNECT: if (bConnected) { MessageBox(hWnd, TEXT("You are already connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP); } else { if (DialogBox(hInst, (LPCTSTR)IDD_CONNECTION, hWnd, (DLGPROC)ConnectionDialogProc) == IDOK) { bConnected = TRUE; EnableFileMenuItemByID(IDM_FILE_DISCONNECT, TRUE); EnableFileMenuItemByID(IDM_FILE_CONNECT, FALSE); _beginthread(Rs232Thread, 0, NULL); } } break; case IDM_FILE_DISCONNECT: if (bConnected) { bConnected = FALSE; EnableFileMenuItemByID(IDM_FILE_DISCONNECT, FALSE); EnableFileMenuItemByID(IDM_FILE_CONNECT, TRUE); } else { MessageBox(hWnd, TEXT("You are not currently connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP); } break; case IDM_FILE_STARTCAPTURE: if (DialogBox(hInst, (LPCTSTR)IDD_CAPTURE, hWnd, (DLGPROC)CaptureDialogProc) == IDOK) { bCapturing = TRUE; EnableFileMenuItemByID(IDM_FILE_STOPCAPTURE, TRUE); EnableFileMenuItemByID(IDM_FILE_STARTCAPTURE, FALSE); hCaptureFile = CreateFile(strCaptureFileName, FILE_APPEND_DATA, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } break; case IDM_FILE_STOPCAPTURE: if (bCapturing) { bCapturing = FALSE; EnableFileMenuItemByID(IDM_FILE_STOPCAPTURE, FALSE); EnableFileMenuItemByID(IDM_FILE_STARTCAPTURE, TRUE); CloseHandle(hCaptureFile); hCaptureFile = NULL; } break; case IDM_FILE_LOCALECHO: if (bLocalEcho) { bLocalEcho = FALSE; CheckLocalEchoMenuItem(bLocalEcho); } else { bLocalEcho = TRUE; CheckLocalEchoMenuItem(bLocalEcho); } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); (void)hdc; // FIXME EndPaint(hWnd, &ps); break; case WM_SIZE: GetClientRect(hWnd, &rc); MoveWindow(hDisplayWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top - 20, TRUE); MoveWindow(hEditWnd, rc.left, rc.bottom - 20, rc.right - rc.left, 20, TRUE); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
HWND createWindow(HINSTANCE instance) { WNDCLASSEX wndClass; ZeroMemory(&wndClass,sizeof(WNDCLASSEX)); wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = 0; wndClass.lpfnWndProc = windowProc; wndClass.hInstance = instance; wndClass.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(100)); wndClass.hCursor = LoadCursor(0,IDC_ARROW); wndClass.lpszClassName = "DBWRender"; if (RegisterClassEx(&wndClass) == 0) fatal("Could not create window class"); wnd = CreateWindowEx(WS_EX_CLIENTEDGE,"DBWRender","DBW Render Display", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,0,0,width,height, 0,0,instance,0); if (wnd == 0) fatal("Could not create window"); NONCLIENTMETRICS ncm; ZeroMemory(&ncm,sizeof ncm); ncm.cbSize = sizeof ncm; SystemParametersInfo(SPI_GETNONCLIENTMETRICS,ncm.cbSize,&ncm,0); HFONT font = CreateFont(ncm.lfMessageFont.lfHeight,0,0,0,FW_NORMAL,0,0,0, ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH,ncm.lfMessageFont.lfFaceName); if (font == 0) fatal("Could not create font"); HDC dc = GetWindowDC(wnd); SIZE size; GetTextExtentPoint32(dc," Save ",8,&size); buttonWidth = size.cx; buttonHeight = (int)(1.25*size.cy); ReleaseDC(wnd,dc); createButton(instance,font,"&Save",IDC_SAVE,0); createButton(instance,font,"E&xit",IDC_QUIT,1); ACCEL accelt[2] = { { FALT,'s',IDC_SAVE }, { FALT,'x',IDC_QUIT }}; accel = CreateAcceleratorTable(accelt,2); if (accel == 0) fatal("Could not create accelerator table"); RECT wr, cr; GetWindowRect(wnd,&wr); GetClientRect(wnd,&cr); int w = width+(wr.right-wr.left)-(cr.right-cr.left); int h = height+buttonHeight+(wr.bottom-wr.top)-(cr.bottom-cr.top); int mw = GetSystemMetrics(SM_CXFULLSCREEN); int mh = GetSystemMetrics(SM_CYFULLSCREEN); int x = w < mw ? (mw-w)/2 : 0; int y = h < mh ? (mh-h)/2 : 0; MoveWindow(wnd,x,y,w,h,0); ShowWindow(wnd,SW_SHOW); return wnd; }
static void W32_WindowLayoutSetSize(HWND hWnd, RECT *pRect, int dwWidth, int dwHeight, bool bFullScrn, bool bResizable) // Must be in called at D3Dx window creation { DWORD dwStyle = GetWindowStyle(hWnd); DWORD dwExStyle = GetWindowExStyle( hWnd); RECT rc; // If we are still a WS_POPUP window we should convert to a normal app // window so we look like a windows app. if (!bFullScrn) { #if _WIN32_WCE dwExStyle|= bResizable ? WS_EX_WINDOWEDGE : 0; // Window Extended Style dwStyle|= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style #else dwExStyle|=WS_EX_APPWINDOW | (bResizable ? WS_EX_WINDOWEDGE : 0); // Window Extended Style dwStyle|= WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; // Windows Style if (bResizable) dwStyle|= WS_THICKFRAME | WS_MAXIMIZEBOX; #endif } else { dwStyle|= WS_POPUP; } SetWindowLong(hWnd, GWL_STYLE, dwStyle); SetWindowLong(hWnd, GWL_EXSTYLE, dwExStyle); if (!bFullScrn) { RECT rcWork; // Center Window SetRect( &rc, 0, 0, dwWidth, dwHeight ); SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 ); int cx = (rcWork.right - rcWork.left - (rc.right - rc.left)) >>1; int cy = (rcWork.bottom - rcWork.top - (rc.bottom - rc.top)) >>1; rc.left+=cx; rc.right+=cx; rc.top+=cy; rc.bottom+=cy; // Make sure our window does not hang outside of the work area if( rc.left < rcWork.left ) rc.left = rcWork.left; if( rc.top < rcWork.top ) rc.top = rcWork.top; AdjustWindowRectEx( &rc, GetWindowStyle(hWnd), #if _WIN32_WCE 0, #else GetMenu(hWnd) != NULL, #endif GetWindowExStyle(hWnd) ); SetWindowPos( hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER | SWP_NOACTIVATE ); }
BOOL CPeraProcessDesignerApp::InitInstance() { ZTools::InitZToolsLog(); if ( !m_CmdLine.Parse() ) { MessageBox( NULL, "解析命令行失败!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); return FALSE; } m_hMetux = CreateMutex(NULL,TRUE,"PeraProcessDesigner.exe"); if (m_hMetux) { if (ERROR_ALREADY_EXISTS== GetLastError()) { HWND hwndPeraProcessDesignerCopied = FindPeraProcessDesignerMainWindow(); //当有互斥,但是没找到窗口时,认为之前的进程还在启动中,简单处理,直接退出 if ( hwndPeraProcessDesignerCopied) { if ( !m_CmdLine.GetValue( NULL ).IsEmpty() ) { #define WS_OPENWS_SENDMSG #ifdef WS_OPENWS_SENDMSG DWORD dwProcessId = 0; GetWindowThreadProcessId(hwndPeraProcessDesignerCopied, &dwProcessId); if ( GetTopModalWindow( dwProcessId ) == NULL ) { CSharedMemory Mem; CString sMemData = g_lpszDoubleOpenWsMemStr; Mem.Init( g_lpszDoubleOpenWsMemName, sMemData.GetLength()+MAX_PATH ); SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_MAKESUREINFO, (LPVOID)NULL, 0 ); sMemData.Empty(); sMemData = (LPCTSTR)Mem.GetData(); if ( sMemData.CompareNoCase( g_lpszDoubleOpenWsMemStr ) == 0 ) { MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); } else { CString sCmdLine = ::GetCommandLine(); SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_OPENWS, (LPVOID)(LPCTSTR)sCmdLine, sCmdLine.GetLength()+1 ); } } else { MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); } #else MessageBox( hwndPeraProcessDesignerCopied, "建模环境已打开,请在建模环境中打开本文件!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); #endif } if (IsIconic(hwndPeraProcessDesignerCopied)) ShowWindow(hwndPeraProcessDesignerCopied,SW_RESTORE); SetForegroundWindow(hwndPeraProcessDesignerCopied); ZTools::WriteZToolsFormatLog("将已经运行的建模窗口激活,并前端显示..."); } CloseHandle(m_hMetux); m_hMetux = NULL; ZTools::WriteZToolsFormatLog("已经存在一个建模客户端,本运行实例将退出..."); return FALSE; } } m_LoginData.m_strRealName = m_CmdLine.GetValue( "realName" ); m_LoginData.m_strUser = m_CmdLine.GetValue( "userName" ); m_LoginData.m_strTicket = m_CmdLine.GetValue( "ticket-proxy" ); WriteShareMemoryLoginInfo(); CCrashHandler ch; ch.SetProcessExceptionHandlers(); ch.SetThreadExceptionHandlers(); //如果PeraTaskService进程不存在,自动启动 StartPeraTaskService(); //_CrtSetBreakAlloc(1300); // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); //hModule = ::LoadLibrary("C:\\Users\\kunmiao-li\\Desktop\\TestBuild\\PeraLicMgr\\Release\\PeraLicMgr.dll"); //#ifndef _DEBUG if (!InitLicense("PeraWorkSpace")) return FALSE; // if(!m_FlexNetMgr.CheckOutLicense("PeraWorkSpace")) // { // return FALSE; // } // hModule = ::LoadLibrary(ZTools::FormatString("%s\\PeraLicMgr.dll", GetFlexwareBinPathMethod()).c_str()); // if( hModule != NULL ) // { // lpFnDLLfunc = (LPFNDLLFUNC) ::GetProcAddress(hModule, "CheckOutLicense"); // if(lpFnDLLfunc != NULL) // { // if(!lpFnDLLfunc("PeraProcessDesigner")) // { // return FALSE; // } // } // else // { // return FALSE; // } // } // else // { // AfxMessageBox("检测到系统安装不完整,请联系管理员重新安装!", MB_OK|MB_ICONINFORMATION); // return FALSE; // } //#endif //if(!m_FlexNetMgr.InitNewJob("PeraProcessDesigner")) //{ // return FALSE; //} CWinApp::InitInstance(); InitGDIPlus(); LoadResLibImageSet(); //LoadDefaultFont(); //CBCGPPopupMenuBar::SetPeraPaint( g_crToolbarBg ); //CXmlBase xml; //MSXML2::IXMLDOMDocument2Ptr pdoc = xml.GetXmlDocPtrByFile(GetExecDir() + "\\Manifest.xml"); //MSXML2::IXMLDOMNodeListPtr pModels; //MSXML2::IXMLDOMNodePtr pModel; //long lModelCount; //HRESULT hr = S_OK; //map<CString, CString> mapAttrs; //map<CString, CString>::iterator iterAttrs; //CString str; //pModels = xml.GetNodeListPtr("/Manifest/Component", pdoc); //if (pModels != NULL) //{ // lModelCount = pModels->Getlength(); // for (long i=0; i<lModelCount; i++) // { // hr = pModels->get_item(i, &pModel); // if (FAILED(hr) || NULL == pModel) // { // continue; // } // if (0 == xml.GetAttrsOfNode(mapAttrs, pModel)) // { // continue; // } // iterAttrs = mapAttrs.find("RobotName"); // if (iterAttrs != mapAttrs.end()) str= iterAttrs->second; // } //} //CCxArray3D a3d(DT_ARRAY3D_INT); //CString str3d = "[1,2,3,4,5,](4,3,2)" //CString str = "[1e150,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24](2,3,4)"; // CString str = "[\"\\\\\\\",,1e150\",\"2\"](2)"; //{ // CString str1; // for (int a=0;a<2;a++) // { // for (int b=0;b<3;b++) // { // for (int c=0;c<4;c++) // { // } // } // } //} // //CxArrayND nd( DT_ARRAY1D_STRING ); //nd.Parse( str ); //vector<int> vPos; //vPos.push_back(0); ////vPos.push_back(0); ////vPos.push_back(0); //LPARAM lpData = nd.GetDataPtr( vPos ); //CString * pData = reinterpret_cast< CString * > ( lpData ); //nd.Clear(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskBarInteraction(FALSE); globalData.SetDPIAware (); //globalData.bDisableAero = TRUE; //Bar挺靠后,Slider宽度,由于Splitter最小宽度为4,所以此值不应小于4,否则与Splitter不协调。 CBCGPSlider::m_nDefaultWidth = 4; // All registry read/write operations will be produced via CBCGPXMLSettings gateway: CBCGPRegistrySP::SetRuntimeClass (RUNTIME_CLASS (CBCGPXMLSettings)); // Read settings: CBCGPXMLSettings::ReadXMLFromFile (FALSE, GetExecDir() + _T("\\user.xml")); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization //SetRegistryKey(_T("PeraProcessDesigner")); //LoadStdProfileSettings(0); // Load standard INI file options (including MRU) //SetRegistryBase (_T("Settings")); RECT rectDesktop; SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rectDesktop,0); m_rcLastWindowPlacement = rectDesktop; CRect rectDesktop2 = rectDesktop; int nFlag = 0; int nShowCmd = 0; LoadWindowPlacement( m_rcLastWindowPlacement, nFlag, nShowCmd ); StoreWindowPlacement (rectDesktop2, 2, SW_SHOWMAXIMIZED); theGlobalConfig.Load(); m_bAloneVersionWs = IsPeraProcessRunnerInstalled(); CCxBCGPVisualManager2007::SetStyle (CCxBCGPVisualManager2007::VS2007_Silver); CCxBCGPVisualManager2007::SetDefaultManager (RUNTIME_CLASS (CCxBCGPVisualManager2007)); //globalData.bDisableAero = TRUE; //globalData.bIsOSAlphaBlendingSupport = TRUE; // Initialize all Managers for usage. They are automatically constructed // if not yet present InitMouseManager(); //InitContextMenuManager(); InitKeyboardManager(); // Enable user-defined tools. If you want allow more than 10 tools, // add tools entry to resources (ID_USER_TOOL11, ID_USER_TOOL12,...) EnableUserTools (ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); // TODO: Remove this if you don't want extended tooltips: InitTooltipManager(); CBCGPToolTipParams params; params.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager ()->SetTooltipParams ( BCGP_TOOLTIP_TYPE_ALL, RUNTIME_CLASS (CBCGPToolTipCtrl), ¶ms); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MAIN, RUNTIME_CLASS(CPeraProcessDesignerDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CPeraProcessDesignerView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAIN)) return FALSE; m_bCreate = TRUE; m_pMainWnd = pMainFrame; //basehtmldialog中,屏蔽快捷键 g_hwndMainWindow = pMainFrame->GetSafeHwnd(); g_pLoadingWindow = new CLoadingWindow( TIMER_LOADING_WINDOW, IDD_DIALOG_LOGIN_BK, m_pMainWnd ); g_pLoadingWindow->Create( IDD_DIALOG_LOGIN_BK, m_pMainWnd ); g_pLoadingWindow->Init( GetExecDir() + "\\Res\\DlgProgress\\DlgProgress.png" ); pMainFrame->m_wndMenuBar.LoadData(); //pMainFrame->OnMenuModuleOpenjianmo(); // call DragAcceptFiles only if there's a suffix // In an MDI app, this should occur immediately after setting m_pMainWnd // Parse command line for standard shell commands, DDE, file open //CCommandLineInfo cmdInfo; //ParseCommandLine(cmdInfo); //if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) //{ // if (!pMainFrame->LoadMDIState (GetRegSectionPath ()) || // DYNAMIC_DOWNCAST(CMDIChildWnd, pMainFrame->GetActiveFrame()) == NULL) // { // if (!ProcessShellCommand(cmdInfo)) // return FALSE; // } //} //else //{ // // Dispatch commands specified on the command line // if (!ProcessShellCommand(cmdInfo)) // return FALSE; //} // The main window has been initialized, so show and update it pMainFrame->OnMenuModuleOpenjianmo(); m_bInitMDI = TRUE; m_nCmdShow = SW_SHOWMAXIMIZED; pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); ////////////////////////////////////////////////////////////////////////// //日志输出窗口 #ifdef USE_DLGLOG m_dlgLog.Create(CDlgLog::IDD, NULL); //m_dlgLog.ShowWindow(SW_SHOW); // int x, y; // x = GetSystemMetrics(SM_CXFULLSCREEN); //屏幕宽度 // y = GetSystemMetrics(SM_CYFULLSCREEN); //屏幕高度 CRect rectFull; SystemParametersInfo(SPI_GETWORKAREA,0,&rectFull,0); CRect rect; m_dlgLog.GetWindowRect(rect); rect.MoveToXY(0, rectFull.bottom - rect.Height()); m_dlgLog.MoveWindow(rect); #endif // USE_DLGLOG ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //延长票据有效期 StartKeepTicketThread(); ////////////////////////////////////////////////////////////////////////// //在线编辑用到的共享内存初始化 m_pSharedMemoryOnlineEdit = NULL; m_pSharedMemoryOnlineEdit = new SharedMemoryOnlineEdit(); ////////////////////////////////////////////////////////////////////////// g_ReadRobotDB.Load(); pMainFrame->m_wndLoginBar.RedrawWindow(); CString sParamFile = m_CmdLine.GetValue( NULL ); if ( !sParamFile.IsEmpty() ) { ZTools::WriteZToolsFormatLog( "--------------********打开文件[%s]**********-------------", sParamFile ); theApp.m_processMgr.Open( sParamFile ); } else { ZTools::WriteZToolsLog( "--------------********未打开文件逻辑**********-------------" ); CDlgStart lgn; lgn.DoModal(); } #ifdef USE_DLGLOG m_dlgLog.ShowWindow(SW_SHOW); #endif // USE_DLGLOG ////////////////////////////////////////////////////////////////////////// WINDOWPLACEMENT wp; memset(&wp, NULL, sizeof(wp)); wp.length = sizeof (WINDOWPLACEMENT); if (pMainFrame->GetWindowPlacement (&wp)) { wp.rcNormalPosition = m_rcLastWindowPlacement; RECT rectDesktop; SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rectDesktop,0); OffsetRect(&wp.rcNormalPosition, -rectDesktop.left, -rectDesktop.top); pMainFrame->SetWindowPlacement (&wp); } return TRUE; }
GdkDisplay * gdk_display_open (const gchar *display_name) { HMODULE user32; if (_gdk_display != NULL) return NULL; /* single display only */ _gdk_display = g_object_new (GDK_TYPE_DISPLAY, NULL); _gdk_screen = g_object_new (GDK_TYPE_SCREEN, NULL); #ifdef HAVE_MONITOR_INFO user32 = GetModuleHandle ("USER32.dll"); g_assert (user32 != NULL); p_EnumDisplayMonitors = (t_EnumDisplayMonitors) GetProcAddress (user32, "EnumDisplayMonitors"); p_GetMonitorInfoA = (t_GetMonitorInfoA) GetProcAddress (user32, "GetMonitorInfoA"); if (p_EnumDisplayMonitors != NULL && p_GetMonitorInfoA != NULL) { gint i, index; _gdk_num_monitors = 0; (*p_EnumDisplayMonitors) (NULL, NULL, count_monitor, (LPARAM) &_gdk_num_monitors); _gdk_monitors = g_new (GdkRectangle, _gdk_num_monitors); index = 0; (*p_EnumDisplayMonitors) (NULL, NULL, enum_monitor, (LPARAM) &index); #if 1 _gdk_offset_x = G_MININT; _gdk_offset_y = G_MININT; /* Calculate offset */ for (i = 0; i < _gdk_num_monitors; i++) { _gdk_offset_x = MAX (_gdk_offset_x, -_gdk_monitors[i].x); _gdk_offset_y = MAX (_gdk_offset_y, -_gdk_monitors[i].y); } GDK_NOTE (MISC, g_print ("Multi-monitor offset: (%d,%d)\n", _gdk_offset_x, _gdk_offset_y)); /* Translate monitor coords into GDK coordinate space */ for (i = 0; i < _gdk_num_monitors; i++) { _gdk_monitors[i].x += _gdk_offset_x; _gdk_monitors[i].y += _gdk_offset_y; GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d@+%d+%d\n", i, _gdk_monitors[i].width, _gdk_monitors[i].height, _gdk_monitors[i].x, _gdk_monitors[i].y)); } #endif } else #endif /* HAVE_MONITOR_INFO */ { RECT rect; _gdk_num_monitors = 1; _gdk_monitors = g_new (GdkRectangle, 1); SystemParametersInfo (SPI_GETWORKAREA, 0, &rect, 0); _gdk_monitors[0].x = rect.left; _gdk_monitors[0].y = rect.top; _gdk_monitors[0].width = rect.right - rect.left; _gdk_monitors[0].height = rect.bottom - rect.top; _gdk_offset_x = 0; _gdk_offset_y = 0; } _gdk_visual_init (); gdk_screen_set_default_colormap (_gdk_screen, gdk_screen_get_system_colormap (_gdk_screen)); _gdk_windowing_window_init (); _gdk_windowing_image_init (); _gdk_events_init (); _gdk_input_init (_gdk_display); _gdk_dnd_init (); g_signal_emit_by_name (gdk_display_manager_get (), "display_opened", _gdk_display); return _gdk_display; }
static void vboxExperienceSet (uint32_t level) { int i; for (i = 0; i < RT_ELEMENTS(parameters); i++) { if (parameters[i].level > level) { /* * The parameter has to be disabled. */ Log(("VBoxTray: vboxExperienceSet: Saving %s\n", parameters[i].name)); /* Save the current value. */ switch (parameters[i].type) { case VBOX_SPI_STRING: { /* The 2nd parameter is size in characters of the buffer. * The 3rd parameter points to the buffer. */ SystemParametersInfo (parameters[i].uActionGet, MAX_PATH, parameters[i].achSavedValue, 0); } break; case VBOX_SPI_BOOL: case VBOX_SPI_BOOL_PTR: { /* The 3rd parameter points to BOOL. */ SystemParametersInfo (parameters[i].uActionGet, 0, parameters[i].achSavedValue, 0); } break; case VBOX_SPI_PTR: { /* The 3rd parameter points to the structure. * The cbSize member of this structure must be set. * The uiParam parameter must alos be set. */ if (parameters[i].cbSavedValue > sizeof (parameters[i].achSavedValue)) { Log(("VBoxTray: vboxExperienceSet: Not enough space %d > %d\n", parameters[i].cbSavedValue, sizeof (parameters[i].achSavedValue))); break; } *(UINT *)¶meters[i].achSavedValue[0] = parameters[i].cbSavedValue; SystemParametersInfo (parameters[i].uActionGet, parameters[i].cbSavedValue, parameters[i].achSavedValue, 0); } break; default: break; } Log(("VBoxTray: vboxExperienceSet: Disabling %s\n", parameters[i].name)); /* Disable the feature. */ switch (parameters[i].type) { case VBOX_SPI_STRING: { /* The 3rd parameter points to the string. */ SystemParametersInfo (parameters[i].uActionSet, 0, parameters[i].pvDisable, SPIF_SENDCHANGE); } break; case VBOX_SPI_BOOL: { /* The 2nd parameter is BOOL. */ SystemParametersInfo (parameters[i].uActionSet, FALSE, NULL, SPIF_SENDCHANGE); } break; case VBOX_SPI_BOOL_PTR: { /* The 3rd parameter is NULL to disable. */ SystemParametersInfo (parameters[i].uActionSet, 0, NULL, SPIF_SENDCHANGE); } break; case VBOX_SPI_PTR: { /* The 3rd parameter points to the structure. */ SystemParametersInfo (parameters[i].uActionSet, 0, parameters[i].pvDisable, SPIF_SENDCHANGE); } break; default: break; } } } }