void sip_completion_enable(void) { SIPINFO info; SHSipInfo(SPI_GETSIPINFO, 0, &info, 0); info.fdwFlags &= ~SIPF_DISABLECOMPLETION; SHSipInfo(SPI_SETSIPINFO, 0, &info, 0); }
BOOL CUIDialog::LowerSip() { BOOL fRes = FALSE; SIPINFO si; memset( &si, 0, sizeof( si ) ); si.cbSize = sizeof( si ); if( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0 ) ) { si.fdwFlags &= ~SIPF_ON; fRes = SHSipInfo( SPI_SETSIPINFO, 0, &si, 0 ); } return fRes; }
static void updateVisibleDesktop() { SIPINFO sipinfo; memset(&sipinfo, 0, sizeof(sipinfo)); sipinfo.cbSize = sizeof(SIPINFO); SHSipInfo(SPI_GETSIPINFO, 0, &sipinfo, 0); rcVisibleDesktop = sipinfo.rcVisibleDesktop; }
BOOL GetSipInfo(SIPINFO * si) { // Setup the SIPINFO structure. memset(si, 0, sizeof(SIPINFO)); si->cbSize = sizeof(SIPINFO); return SHSipInfo(SPI_GETSIPINFO, 0, si, 0); }
/** \brief Método de reposicionamento da barra de rolagem \details A barra de rolagem é posicionada de acordo com a visibilidade do SIP \param int cx: Posição x da barra de rolagem \param int cy: Posição y da barra de rolagem */ void CUIDialog::_OnSize(int cx, int cy) { #ifdef _WIN32_WCE // Reposicionar o scrollbar... if(IsWindow(m_scroll.GetSafeHwnd()) && IsWindow(m_banner.GetSafeHwnd())) { BOOL bSIPVisible = FALSE; // Recupera os dados do banner... CRect rect; rect.SetRectEmpty(); m_banner.GetWindowRect(&rect); // Dados da area de trabalho... CRect r; VERIFY(SystemParametersInfo(SPI_GETWORKAREA, 0, &r, NULL) == 1); // Dados do SIP... SIPINFO si = {0}; si.cbSize = sizeof(si); SHSipInfo(SPI_GETSIPINFO, 0, &si, 0); bSIPVisible = si.fdwFlags & SIPF_ON; CRect rectScroll = CRect(cx-SCROLL_WIDTH, rect.Height(), cx, bSIPVisible ? cy : r.Height()); m_scroll.MoveWindow(rectScroll); } #endif }
BOOL SHSipInfo_(HWND hWnd, UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni) { DWORD ticks = GetTickCount(); if (lastChange.hWnd == hWnd) { if ((ticks - lastChange.timeStamp) < 500) { lastChange.num++; } else { lastChange.num = 0; } lastChange.timeStamp = ticks; } else { lastChange.hWnd = hWnd; lastChange.timeStamp = ticks; lastChange.num = 0; } if (lastChange.num == 0) { return SHSipInfo(uiAction, uiParam, pvParam, fWinIni); } return FALSE; };
BOOL CUIDialog::RaiseSip( void ) { BOOL fRes ; SIPINFO si; memset( &si, 0, sizeof( si ) ); si.cbSize = sizeof( si ); if( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0 ) ) { si.fdwFlags |= SIPF_ON; fRes = SHSipInfo( SPI_SETSIPINFO, 0, &si, 0 ); } return fRes; }
bool InitInstance(HINSTANCE hInstance, int CmdShow) { _hwndMain = CreateWindowEx(WS_EX_CAPTIONOKBTN, _szAppName, _szTitle, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (!_hwndMain) { return false; } DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL; int x = 0, y = 0; SIPINFO si = {0}; SHSipInfo(SPI_GETSIPINFO, 0, &si, 0); int cx = si.rcVisibleDesktop.right - si.rcVisibleDesktop.left; int cy = si.rcVisibleDesktop.bottom - si.rcVisibleDesktop.top - MENU_HEIGHT; // Create the window for the edit control window. _hwndEdit = CreateWindow(TEXT("edit"), // Class name NULL, // Window text dwStyle, // Window style x, // upper-left corner y, // upper-left corner cx, // Width of the window for the edit cy, // Height of the window for the edit _hwndMain, // Window handle to the parent window 0, // Control identifier _hAppInstance, // Instance handle NULL); SendMessage(_hwndEdit, EM_SETLIMITTEXT, 0x10000, 0); ShowWindow(_hwndMain, CmdShow ); UpdateWindow(_hwndMain); SetForegroundWindow((HWND)(((DWORD)_hwndMain) | 0x01)); return true; }
/* adjust windows to fit main window layout --------------------------- | Status | +-------------------------+ | | | | | MAP | | | | | +-------------------------+ | Command pad | +-------------------------+ | Messages | --------------------------- */ void mswin_layout_main_window(HWND changed_child) { winid i; RECT client_rt, wnd_rect; POINT status_org; SIZE status_size; POINT msg_org; SIZE msg_size; POINT map_org; SIZE map_size; POINT cmd_org; SIZE cmd_size; HWND wnd_status, wnd_msg; PNHMainWindow data; #if defined(WIN_CE_POCKETPC) SIPINFO sip; RECT menu_bar; RECT visible_rt; POINT pt; #endif GetClientRect(GetNHApp()->hMainWnd, &client_rt); #if defined(WIN_CE_POCKETPC) ZeroMemory(&sip, sizeof(sip)); sip.cbSize = sizeof(sip); SHSipInfo(SPI_GETSIPINFO, 0, &sip, 0); if (GetNHApp()->bFullScreen) sip.rcVisibleDesktop.top = 0; /* adjust client rectangle size */ GetWindowRect(GetNHApp()->hMenuBar, &menu_bar); client_rt.bottom -= menu_bar.bottom - menu_bar.top; /* calcuate visible rect in client coordinates */ pt.x = sip.rcVisibleDesktop.left; pt.y = sip.rcVisibleDesktop.top; ScreenToClient(GetNHApp()->hMainWnd, &pt); SetRect(&wnd_rect, pt.x, pt.y, pt.x + sip.rcVisibleDesktop.right - sip.rcVisibleDesktop.left, pt.y + sip.rcVisibleDesktop.bottom - sip.rcVisibleDesktop.top); IntersectRect(&visible_rt, &client_rt, &wnd_rect); #else #if !defined(WIN_CE_SMARTPHONE) client_rt.top += CommandBar_Height(GetNHApp()->hMenuBar); #else /* Smartphone only */ if (GetNHApp()->bFullScreen) { RECT menu_bar; GetWindowRect(GetNHApp()->hMenuBar, &menu_bar); client_rt.bottom -= menu_bar.bottom - menu_bar.top; } #endif #endif /* get window data */ data = (PNHMainWindow) GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA); /* get sizes of child windows */ wnd_status = mswin_hwnd_from_winid(WIN_STATUS); if (IsWindow(wnd_status)) { mswin_status_window_size(wnd_status, &status_size); } else { status_size.cx = status_size.cy = 0; } wnd_msg = mswin_hwnd_from_winid(WIN_MESSAGE); if (IsWindow(wnd_msg)) { mswin_message_window_size(wnd_msg, &msg_size); } else { msg_size.cx = msg_size.cy = 0; } cmd_size.cx = cmd_size.cy = 0; if (GetNHApp()->bCmdPad && IsWindow(GetNHApp()->hCmdWnd)) { mswin_command_window_size(GetNHApp()->hCmdWnd, &cmd_size); } /* set window positions */ /* calculate the application windows size */ #if defined(WIN_CE_POCKETPC) SetRect(&wnd_rect, visible_rt.left, visible_rt.top, visible_rt.right, visible_rt.bottom); if (sip.fdwFlags & SIPF_ON) cmd_size.cx = cmd_size.cy = 0; /* hide keypad window */ #else SetRect(&wnd_rect, client_rt.left, client_rt.top, client_rt.right, client_rt.bottom); #endif #if !defined(WIN_CE_SMARTPHONE) /* other ports have it at the bottom of the screen */ cmd_size.cx = (wnd_rect.right - wnd_rect.left); cmd_org.x = wnd_rect.left; cmd_org.y = wnd_rect.bottom - cmd_size.cy; wnd_rect.bottom -= cmd_size.cy; #endif /* status window */ switch (iflags.wc_align_status) { case ALIGN_LEFT: status_size.cx = (wnd_rect.right - wnd_rect.left) / 4; status_size.cy = (wnd_rect.bottom - wnd_rect.top); // that won't look good status_org.x = wnd_rect.left; status_org.y = wnd_rect.top; wnd_rect.left += status_size.cx; break; case ALIGN_RIGHT: status_size.cx = (wnd_rect.right - wnd_rect.left) / 4; status_size.cy = (wnd_rect.bottom - wnd_rect.top); // that won't look good status_org.x = wnd_rect.right - status_size.cx; status_org.y = wnd_rect.top; wnd_rect.right -= status_size.cx; break; case ALIGN_TOP: status_size.cx = (wnd_rect.right - wnd_rect.left); status_org.x = wnd_rect.left; status_org.y = wnd_rect.top; wnd_rect.top += status_size.cy; break; case ALIGN_BOTTOM: default: status_size.cx = (wnd_rect.right - wnd_rect.left); status_org.x = wnd_rect.left; status_org.y = wnd_rect.bottom - status_size.cy; wnd_rect.bottom -= status_size.cy; break; } /* message window */ switch (iflags.wc_align_message) { case ALIGN_LEFT: #if defined(WIN_CE_SMARTPHONE) /* smartphone has a keypad window on the right (bottom) side of the * message window */ msg_size.cx = cmd_size.cx = max(msg_size.cx, cmd_size.cx); msg_size.cy = (wnd_rect.bottom - wnd_rect.top) - cmd_size.cy; msg_org.x = cmd_org.x = wnd_rect.left; msg_org.y = wnd_rect.top; cmd_org.y = msg_org.y + msg_size.cy; #else msg_size.cx = (wnd_rect.right - wnd_rect.left) / 4; msg_size.cy = (wnd_rect.bottom - wnd_rect.top); msg_org.x = wnd_rect.left; msg_org.y = wnd_rect.top; #endif wnd_rect.left += msg_size.cx; break; case ALIGN_RIGHT: #if defined(WIN_CE_SMARTPHONE) /* smartphone has a keypad window on the right (bottom) side of the * message window */ msg_size.cx = cmd_size.cx = max(msg_size.cx, cmd_size.cx); msg_size.cy = (wnd_rect.bottom - wnd_rect.top) - cmd_size.cy; msg_org.x = cmd_org.x = wnd_rect.right - msg_size.cx; msg_org.y = wnd_rect.top; cmd_org.y = msg_org.y + msg_size.cy; #else msg_size.cx = (wnd_rect.right - wnd_rect.left) / 4; msg_size.cy = (wnd_rect.bottom - wnd_rect.top); msg_org.x = wnd_rect.right - msg_size.cx; msg_org.y = wnd_rect.top; #endif wnd_rect.right -= msg_size.cx; break; case ALIGN_TOP: #if defined(WIN_CE_SMARTPHONE) /* smartphone has a keypad window on the right side of the message * window */ msg_size.cy = cmd_size.cy = max(msg_size.cy, cmd_size.cy); msg_size.cx = (wnd_rect.right - wnd_rect.left) - cmd_size.cx; msg_org.x = wnd_rect.left; cmd_org.x = msg_org.x + msg_size.cx; msg_org.y = cmd_org.y = wnd_rect.bottom - msg_size.cy; #else msg_size.cx = (wnd_rect.right - wnd_rect.left); msg_org.x = wnd_rect.left; msg_org.y = wnd_rect.top; #endif wnd_rect.top += msg_size.cy; break; case ALIGN_BOTTOM: default: #if defined(WIN_CE_SMARTPHONE) /* smartphone has a keypad window on the right side of the message * window */ msg_size.cy = cmd_size.cy = max(msg_size.cy, cmd_size.cy); msg_size.cx = (wnd_rect.right - wnd_rect.left) - cmd_size.cx; msg_org.x = wnd_rect.left; cmd_org.x = msg_org.x + msg_size.cx; msg_org.y = cmd_org.y = wnd_rect.bottom - msg_size.cy; #else msg_size.cx = (wnd_rect.right - wnd_rect.left); msg_org.x = wnd_rect.left; msg_org.y = wnd_rect.bottom - msg_size.cy; #endif wnd_rect.bottom -= msg_size.cy; break; } map_org.x = wnd_rect.left; map_org.y = wnd_rect.top; map_size.cx = wnd_rect.right - wnd_rect.left; map_size.cy = wnd_rect.bottom - wnd_rect.top; /* go through the windows list and adjust sizes */ for (i = 0; i < MAXWINDOWS; i++) { if (GetNHApp()->windowlist[i].win && !GetNHApp()->windowlist[i].dead) { switch (GetNHApp()->windowlist[i].type) { case NHW_MESSAGE: MoveWindow(GetNHApp()->windowlist[i].win, msg_org.x, msg_org.y, msg_size.cx, msg_size.cy, TRUE); break; case NHW_MAP: MoveWindow(GetNHApp()->windowlist[i].win, map_org.x, map_org.y, map_size.cx, map_size.cy, TRUE); break; case NHW_STATUS: MoveWindow(GetNHApp()->windowlist[i].win, status_org.x, status_org.y, status_size.cx, status_size.cy, TRUE); break; case NHW_TEXT: case NHW_MENU: case NHW_RIP: { POINT menu_org; SIZE menu_size; menu_org.x = client_rt.left; menu_org.y = client_rt.top; #if defined(WIN_CE_POCKETPC) menu_size.cx = min(sip.rcVisibleDesktop.right - sip.rcVisibleDesktop.left, client_rt.right - client_rt.left); menu_size.cy = min(sip.rcVisibleDesktop.bottom - sip.rcVisibleDesktop.top, client_rt.bottom - client_rt.top); #else menu_size.cx = client_rt.right - client_rt.left; menu_size.cy = client_rt.bottom - client_rt.top; #endif #if defined(WIN_CE_SMARTPHONE) /* leave room for the command window */ if (GetNHApp()->windowlist[i].type == NHW_MENU) { menu_size.cy -= cmd_size.cy; } /* dialogs are popup windows unde SmartPhone so we need to convert to screen coordinates */ ClientToScreen(GetNHApp()->hMainWnd, &menu_org); #endif MoveWindow(GetNHApp()->windowlist[i].win, menu_org.x, menu_org.y, menu_size.cx, menu_size.cy, TRUE); } break; } ShowWindow(GetNHApp()->windowlist[i].win, SW_SHOW); InvalidateRect(GetNHApp()->windowlist[i].win, NULL, TRUE); } } if (IsWindow(GetNHApp()->hCmdWnd)) { /* show command window only if it exists and the game is ready (plname is set) */ if (GetNHApp()->bCmdPad && cmd_size.cx > 0 && cmd_size.cy > 0 && *plname) { MoveWindow(GetNHApp()->hCmdWnd, cmd_org.x, cmd_org.y, cmd_size.cx, cmd_size.cy, TRUE); ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW); } else { ShowWindow(GetNHApp()->hCmdWnd, SW_HIDE); } } }
// asynchronous position fix improves stability ULONG AsyncFixThread( LPVOID pParam ) { HWND hWnd = (HWND) pParam; // little delay is needed to guarantee that window is ready for (int x = 0; x < 20; x++) { Sleep(100); if (IsWindow(hWnd) == FALSE) return 0; if (IsWindowVisible(hWnd) == TRUE) break; } Sleep(100); __try { if (IsWindow(hWnd) == TRUE) { if ((GetParent(hWnd) == NULL || ((GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) == NULL)) && IsWindowVisible(hWnd) == TRUE) { wchar_t className[50]; ZeroString(className, 50); GetClassName(hWnd, className, 50); if (wcslen(className)) { RECT rect = {0, 0, 0, 0}; GetWindowRect(hWnd, &rect); int newY = rect.top; int newHeight = rect.bottom - rect.top; if (FixPosition(hWnd, className, 0, &newY, &newHeight) == TRUE) { SetWindowPos(hWnd, NULL, rect.left, newY, rect.right - rect.left, newHeight, SWP_NOZORDER); } wchar_t windowName[50]; ZeroString(windowName, 50); GetWindowText(hWnd, windowName, 50); DWORD isDoubleFix = IsDoubleFixWindow(hWnd); if (isDoubleFix && (IsSipWindowVisible() == TRUE || isDoubleFix == 2) && ShouldBeProcessed(className) == TRUE) { //RECT rect = {0, 0, 0, 0}; //GetWindowRect(hWnd, &rect); //SetWindowPos(hWnd, NULL, rect.left, rect.top, // rect.right - rect.left, rect.bottom - rect.top, // SWP_NOZORDER); SIPINFO si; GetSipInfo(&si); SHSipInfo(SPI_SETSIPINFO, 0, &si, 0); } } } } } __except (GetExceptionCode()) { } return 0; };
BOOL CALLBACK DlgProcResourcePwd( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { PNETUI_RESPWD pResPwd; DWORD dwStyle; SIPINFO si; TCHAR StrBuf[100], ResFmtBuf[RMLEN + 30]; static BOOL fReEnable = FALSE; switch( message ) { case WM_INITDIALOG: pResPwd = (PNETUI_RESPWD)lParam; SetWindowLong (hDlg, DWL_USER, (LONG)pResPwd); // Display resource we are connecting to if (LoadString(HINST_RESDLL,IDS_NETUI_RESFMT_STR,StrBuf,sizeof(StrBuf)/sizeof(StrBuf[0]))) { wsprintf(ResFmtBuf,StrBuf,pResPwd->szResourceName); SetDlgItemText(hDlg,IDC_NETUI_CMDTEXT,ResFmtBuf); } dwStyle = GetWindowLong (hDlg, GWL_EXSTYLE); SetWindowLong (hDlg, GWL_EXSTYLE, dwStyle | WS_EX_CAPTIONOKBTN|WS_EX_TOPMOST); SetDlgItemText( hDlg, IDC_NETUI_PASSWORD, pResPwd->szPassword ); SetFocus(GetDlgItem(hDlg, IDC_NETUI_PASSWORD)); return FALSE; case WM_COMMAND: pResPwd = (PNETUI_RESPWD)GetWindowLong (hDlg, DWL_USER); switch( LOWORD( wParam ) ) { case IDCANCEL: // Ignore values EndDialog( hDlg, FALSE ); break; case IDOK: // Get the dialog values GetDlgItemText( hDlg, IDC_NETUI_PASSWORD, pResPwd->szPassword, PWLEN ); EndDialog( hDlg, TRUE ); break; case IDC_NETUI_PASSWORD: if ((HIWORD(wParam) == EN_SETFOCUS) || ((HIWORD(wParam) == EN_KILLFOCUS) && fReEnable)) { memset(&si, 0, sizeof(SIPINFO)); si.cbSize = sizeof(SIPINFO); if (SHSipInfo(SPI_GETSIPINFO, 0, &si, 0)) { // Toggle password completion, but keep track of // whether or not this flag was set a priori when setting focus if (HIWORD(wParam) == EN_SETFOCUS) { fReEnable = !(si.fdwFlags & SIPF_DISABLECOMPLETION); si.fdwFlags |= SIPF_DISABLECOMPLETION; } else { si.fdwFlags &= ~SIPF_DISABLECOMPLETION; } SHSipInfo(SPI_SETSIPINFO, 0, &si, 0); } } break; } return FALSE; case WM_DESTROY: return( FALSE ); default: return( FALSE ); break; } }