BOOL EdSearch_Init (void) { /*************************************/ /* Initialize find/replace structure */ /*************************************/ ZeroMemory (&stFindReplace, sizeof (FINDREPLACE)); stFindReplace.lStructSize = sizeof (FINDREPLACE); stFindReplace.lpstrFindWhat = stFindWhat; stFindReplace.wFindWhatLen = FIND_STRING_LEN; stFindReplace.lpstrReplaceWith = stReplaceWith; stFindReplace.wReplaceWithLen = FIND_STRING_LEN; stFindReplace.lpfnHook = MyFindDialogProcedure; stFindReplace.Flags = FR_DOWN | FR_MATCHCASE | FR_ENABLEHOOK; EdSearch_FindReplaceMessage = RegisterWindowMessage (FINDMSGSTRING); if (EdSearch_FindReplaceMessage == 0) { EdFail_Warn (IDS_REGISTERWINDOWMESSAGEFAIL, __FILE__, __LINE__, GetLastError ()); return FALSE; } return TRUE; } // EdSearch_Init
//--------------------------------------------------------------------------- __fastcall ::TTrayIcon::TTrayIcon(unsigned int Id) { FVisible = false; FOnClick = NULL; FOnBalloonClick = NULL; FBalloonUserData = NULL; FTrayIcon = new NOTIFYICONDATA; memset(FTrayIcon, 0, sizeof(*FTrayIcon)); FTrayIcon->cbSize = sizeof(*FTrayIcon); FTrayIcon->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; // LoadIconMetric is available from Windows Vista only HMODULE ComCtl32Dll = GetModuleHandle(comctl32); if (ALWAYS_TRUE(ComCtl32Dll)) { typedef HRESULT WINAPI (* TLoadIconMetric)(HINSTANCE hinst, PCWSTR pszName, int lims, __out HICON *phico); TLoadIconMetric LoadIconMetric = (TLoadIconMetric)GetProcAddress(ComCtl32Dll, "LoadIconMetric"); if (LoadIconMetric != NULL) { // Prefer not to use Application->Icon->Handle as that shows 32x32 scaled down to 16x16 for some reason LoadIconMetric(MainInstance, L"MAINICON", LIM_SMALL, &FTrayIcon->hIcon); } } if (FTrayIcon->hIcon == 0) { FTrayIcon->hIcon = Application->Icon->Handle; } FTrayIcon->uID = Id; FTrayIcon->hWnd = AllocateHWnd(WndProc); FTrayIcon->uCallbackMessage = WM_TRAY_ICON; FTaskbarCreatedMsg = RegisterWindowMessage(L"TaskbarCreated"); }
QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) : hIcon(0), q(object), ignoreNextMouseRelease(false) { if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) { notifyIconSize = sizeof(NOTIFYICONDATA); version = NOTIFYICON_VERSION_4; } else { notifyIconSize = NOTIFYICONDATA_V2_SIZE; version = NOTIFYICON_VERSION; } maxTipLength = 128; // For restoring the tray icon after explorer crashes if (!MYWM_TASKBARCREATED) { MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated"); } // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx = (PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx"); if (pChangeWindowMessageFilterEx) { // Call the safer ChangeWindowMessageFilterEx API if available pChangeWindowMessageFilterEx(winId(), MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0); } else { static PtrChangeWindowMessageFilter pChangeWindowMessageFilter = (PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter"); if (pChangeWindowMessageFilter) { // Call the deprecated ChangeWindowMessageFilter API otherwise pChangeWindowMessageFilter(MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW); } } }
void PCLVisualizerInteractor::stopLoop () { #if defined _WIN32 || defined VTK_USE_COCOA || defined VTK_USE_CARBON BreakLoopFlagOn (); // Send a VTK_BreakWin32Loop ClientMessage event to be sure we pop out of the // event loop. This "wakes up" the event loop. Otherwise, it might sit idle // waiting for an event before realizing an exit was requested. #if defined _WIN32 SendMessage (this->WindowId, RegisterWindowMessage (TEXT ("VTK_BreakWin32Loop")), 0, 0); #endif #else BreakLoopFlagOn (); XClientMessageEvent client; memset (&client, 0, sizeof (client)); client.type = ClientMessage; client.display = DisplayId; client.window = WindowId; client.message_type = XInternAtom (client.display, "spinOnce exit", false); client.format = 32; // indicates size of data chunks: 8, 16 or 32 bits... XSendEvent (client.display, client.window, True, NoEventMask, reinterpret_cast<XEvent *>(&client)); XFlush (client.display); #endif }
LRESULT CSystemTray::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { static UINT s_uTaskbarRestart; switch(message) { case WM_CREATE: s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); break; default: if(message == s_uTaskbarRestart && !m_bHidden && m_bEnabled) { m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; m_bEnabled = Shell_NotifyIcon(NIM_ADD, &m_tnd); } break; } if (message == m_tnd.uCallbackMessage) return OnTrayNotification(wParam, lParam); return CWnd::WindowProc(message, wParam, lParam); }
bool MonitorCommand::Execute() { CAutoGeneralHandle hReloadProtection = ::CreateMutex(NULL, FALSE, L"TSVN_Monitor_" + GetMonitorID()); if ((!hReloadProtection) || (GetLastError() == ERROR_ALREADY_EXISTS)) { // An instance of the commit monitor is already running HWND hWnd = FindWindow(NULL, CString(MAKEINTRESOURCE(IDS_MONITOR_DLGTITLE))); if (hWnd) { UINT TSVN_COMMITMONITOR_SHOWDLGMSG = RegisterWindowMessage(L"TSVNCommitMonitor_ShowDlgMsg"); PostMessage(hWnd, TSVN_COMMITMONITOR_SHOWDLGMSG, 0, 0); //open the window of the already running app SetForegroundWindow(hWnd); //set the window to front } CTraceToOutputDebugString::Instance()(__FUNCTION__ ": TSVN Commit Monitor ignoring restart\n"); return 0; } CLogDlg dlg; theApp.m_pMainWnd = &dlg; dlg.SetMonitoringMode(!!parser.HasKey(L"tray")); dlg.DoModal(); return true; }
IntegratedMainWindow::IntegratedMainWindow(QWidget *parent) : QMainWindow(parent), d(new Private()) { d->window = this; #ifdef Q_WS_WIN d->m_thumbBarManager = new ThumbBar(this); d->m_taskbarMessageId = RegisterWindowMessage(TEXT("TaskbarButtonCreated")); if (DesktopWindowManager::isCompositionEnabled()) { DesktopWindowManager::extendFrameIntoClientArea(this); } #elif defined(Q_WS_X11) this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_NoSystemBackground, false); QPalette pal = this->palette(); QColor bg = pal.window().color(); bg.setAlpha(180); pal.setColor(QPalette::Window, bg); this->setPalette(pal); this->ensurePolished(); // workaround Oxygen filling the background this->setAttribute(Qt::WA_StyledBackground, false); #endif }
/* init_directx_window: * If the user called win_set_window, the user window will be hooked to receive * messages from Allegro. Otherwise a thread is created to own the new window. */ int init_directx_window(void) { union { POINT p; RECT r; } win_rect; HANDLE events[2]; long result; /* setup globals */ msg_call_proc = RegisterWindowMessage("Allegro call proc"); msg_suicide = RegisterWindowMessage("Allegro window suicide"); if (user_wnd) { /* initializes input module and requests dedicated thread */ _win_input_init(TRUE); /* hook the user window */ user_wnd_proc = (WNDPROC) SetWindowLong(user_wnd, GWL_WNDPROC, (long)directx_wnd_proc); if (!user_wnd_proc) return -1; allegro_wnd = user_wnd; /* retrieve the window dimensions */ GetWindowRect(allegro_wnd, &win_rect.r); ClientToScreen(allegro_wnd, &win_rect.p); ClientToScreen(allegro_wnd, &win_rect.p + 1); wnd_x = win_rect.r.left; wnd_y = win_rect.r.top; wnd_width = win_rect.r.right - win_rect.r.left; wnd_height = win_rect.r.bottom - win_rect.r.top; } else { /* initializes input module without dedicated thread */ _win_input_init(FALSE); /* create window thread */ events[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* acknowledges that thread is up */ events[1] = (HANDLE) _beginthread(wnd_thread_proc, 0, events[0]); result = WaitForMultipleObjects(2, events, FALSE, INFINITE); CloseHandle(events[0]); switch (result) { case WAIT_OBJECT_0: /* window was created successfully */ wnd_thread = events[1]; SetThreadPriority(wnd_thread, THREAD_PRIORITY_ABOVE_NORMAL); break; default: /* thread failed to create window */ return -1; } } /* initialize gfx critical section */ InitializeCriticalSection(&gfx_crit_sect); /* save window style */ old_style = GetWindowLong(allegro_wnd, GWL_STYLE); return 0; }
//--------------------------------------------------------------------------- __fastcall TFormLog::TFormLog(TComponent* Owner): TForm(Owner) { IZ8BLY = RegisterWindowMessage("IZ8BLY"); }
static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static UINT s_uTaskbarRestart; switch (uMsg) { case WM_CREATE: { s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); AddTrayIcon (hWnd); break; } case WM_CLOSE: { RemoveTrayIcon (hWnd); KillTimer (hWnd, FRAME_UPDATE_TIMER); KillTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER); KillTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER); PostQuitMessage (0); break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case ID_ABOUT: { std::stringstream text; text << "Version: " << I2PD_VERSION << " " << CODENAME; MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); return 0; } case ID_EXIT: { PostMessage (hWnd, WM_CLOSE, 0, 0); return 0; } case ID_ACCEPT_TRANSIT: { i2p::context.SetAcceptsTunnels (true); std::stringstream text; text << "I2Pd now accept transit tunnels"; MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); return 0; } case ID_DECLINE_TRANSIT: { i2p::context.SetAcceptsTunnels (false); std::stringstream text; text << "I2Pd now decline new transit tunnels"; MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); return 0; } case ID_GRACEFUL_SHUTDOWN: { i2p::context.SetAcceptsTunnels (false); SetTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER, 10*60*1000, nullptr); // 10 minutes SetTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER, 1000, nullptr); // check tunnels every second GracefulShutdownEndtime = GetTickCount() + 10*60*1000; i2p::util::DaemonWin32::Instance ().isGraceful = true; return 0; } case ID_STOP_GRACEFUL_SHUTDOWN: { i2p::context.SetAcceptsTunnels (true); KillTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER); KillTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER); GracefulShutdownEndtime = 0; i2p::util::DaemonWin32::Instance ().isGraceful = false; return 0; } case ID_RELOAD: { i2p::client::context.ReloadConfig(); std::stringstream text; text << "I2Pd reloading configs..."; MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); return 0; } case ID_CONSOLE: { char buf[30]; std::string httpAddr; i2p::config::GetOption("http.address", httpAddr); uint16_t httpPort; i2p::config::GetOption("http.port", httpPort); snprintf(buf, 30, "http://%s:%d", httpAddr.c_str(), httpPort); ShellExecute(NULL, "open", buf, NULL, NULL, SW_SHOWNORMAL); return 0; } case ID_APP: { ShowWindow(hWnd, SW_SHOW); SetTimer(hWnd, FRAME_UPDATE_TIMER, 3000, NULL); return 0; } } break; } case WM_SYSCOMMAND: { switch (wParam) { case SC_MINIMIZE: { ShowWindow(hWnd, SW_HIDE); KillTimer (hWnd, FRAME_UPDATE_TIMER); return 0; } case SC_CLOSE: { std::string close; i2p::config::GetOption("close", close); if (0 == close.compare("ask")) switch(::MessageBox(hWnd, "Would you like to minimize instead of exiting?" " You can add 'close' configuration option. Valid values are: ask, minimize, exit.", "Minimize instead of exiting?", MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON1)) { case IDYES: close = "minimize"; break; case IDNO: close = "exit"; break; default: return 0; } if (0 == close.compare("minimize")) { ShowWindow(hWnd, SW_HIDE); KillTimer (hWnd, FRAME_UPDATE_TIMER); return 0; } if (0 != close.compare("exit")) { ::MessageBox(hWnd, close.c_str(), "Unknown close action in config", MB_OK | MB_ICONWARNING); return 0; } } } } case WM_TRAYICON: { switch (lParam) { case WM_LBUTTONUP: case WM_RBUTTONUP: { SetForegroundWindow (hWnd); ShowPopupMenu(hWnd, NULL, -1); PostMessage (hWnd, WM_APP + 1, 0, 0); break; } } break; } case WM_TIMER: { switch(wParam) { case IDT_GRACEFUL_SHUTDOWN_TIMER: { GracefulShutdownEndtime = 0; PostMessage (hWnd, WM_CLOSE, 0, 0); // exit return 0; } case FRAME_UPDATE_TIMER: { InvalidateRect(hWnd, NULL, TRUE); return 0; } case IDT_GRACEFUL_TUNNELCHECK_TIMER: { if (i2p::tunnel::tunnels.CountTransitTunnels() == 0) PostMessage (hWnd, WM_CLOSE, 0, 0); else SetTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER, 1000, nullptr); return 0; } } break; } case WM_PAINT: { HDC hDC; PAINTSTRUCT ps; RECT rp; HFONT hFont; std::stringstream s; PrintMainWindowText (s); hDC = BeginPaint (hWnd, &ps); GetClientRect(hWnd, &rp); SetTextColor(hDC, 0x00D43B69); hFont = CreateFont(18,0,0,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,0,TEXT("Times New Roman")); SelectObject(hDC,hFont); DrawText(hDC, TEXT(s.str().c_str()), s.str().length(), &rp, DT_CENTER|DT_VCENTER); DeleteObject(hFont); EndPaint(hWnd, &ps); break; } default: { if (uMsg == s_uTaskbarRestart) AddTrayIcon (hWnd); break; } } return DefWindowProc( hWnd, uMsg, wParam, lParam); }
IDS_MU_SHOW_SNAPSHOT, IDS_MU_SHOW_MS_FADE, IDS_MU_SHOW_TEMPO, IDS_MU_SET_DEFAULTS, IDS_MU_EDIT_AUTO }; // must match dialog bar enum; order determines initial docking order const CMixereView::DLGBAR_INFO CMixereView::m_DlgBarInfo[DLGBARS] = { {IDD_VOLUME_BAR, UCODE_SHOW_VOLUME}, {IDD_SNAPSHOT_BAR, UCODE_SHOW_SNAPSHOT}, {IDD_MS_FADE_BAR, UCODE_SHOW_MS_FADE}, {IDD_TEMPO_BAR, UCODE_SHOW_TEMPO} }; const UINT CMixereView::WM_FINDREPLACE = RegisterWindowMessage(FINDMSGSTRING); IMPLEMENT_DYNCREATE(CMixereView, CFormListView) ///////////////////////////////////////////////////////////////////////////// // CMixereView construction/destruction CMixereView::CMixereView() : #pragma warning(disable : 4355) // 'this' used in base member initializer list // these ctors don't access 'this', they only copy it to a member var m_VolumeBar(this), m_TempoBar(this), m_MSFadeBar(this), m_SnapshotBar(this) #pragma warning(default : 4355) {
//============================================================================================== // FUNCTION: CMCTeleClientDlg // PURPOSE: // CMCTeleClientDlg::CMCTeleClientDlg(CWnd* pParent /*=NULL*/) : CDialog(CMCTeleClientDlg::IDD, pParent), m_bIsConnected ( FALSE ), m_bIsConnecting ( FALSE ), m_bScanning ( FALSE ), m_bRequestPending ( FALSE ) { //{{AFX_DATA_INIT(CMCTeleClientDlg) m_cstrMode = _T(""); m_cstrPriSignal = _T(""); m_cstrPriAlpha = _T(""); m_cstrPriScaleFactor = _T(""); m_cstrPriLPFCutoff = _T(""); m_cstrSecSignal = _T(""); m_cstrSecAlpha = _T(""); m_cstrSecScaleFactor = _T(""); m_cstrSecLPFCutoff = _T(""); m_cstrMembraneCap = _T(""); m_cstrExtCmdSens = _T(""); m_cstrAppVer = _T(""); m_cstrDSPVer = _T(""); m_cstrFirmwareVer = _T(""); m_cstrSN = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_vSerialNum.clear(); s_uMCTGOpenMessage = RegisterWindowMessage( MCTG_OPEN_MESSAGE_STR ); ASSERT( s_uMCTGOpenMessage != 0 ); s_uMCTGCloseMessage = RegisterWindowMessage( MCTG_CLOSE_MESSAGE_STR ); ASSERT( s_uMCTGCloseMessage != 0 ); s_uMCTGRequestMessage = RegisterWindowMessage( MCTG_REQUEST_MESSAGE_STR ); ASSERT( s_uMCTGRequestMessage != 0 ); s_uMCTGReconnectMessage = RegisterWindowMessage( MCTG_RECONNECT_MESSAGE_STR ); ASSERT( s_uMCTGReconnectMessage != 0 ); s_uMCTGBroadcastMessage = RegisterWindowMessage( MCTG_BROADCAST_MESSAGE_STR ); ASSERT( s_uMCTGBroadcastMessage != 0 ); s_uMCTGIdMessage = RegisterWindowMessage( MCTG_ID_MESSAGE_STR ); ASSERT( s_uMCTGIdMessage != 0 ); // initialize the current telegraph state // this bit will zero out the padding in the structure MC_TELEGRAPH_DATA* pmctd = &m_mctdCurrentState; memset(pmctd, 0, sizeof(MC_TELEGRAPH_DATA)); m_mctdCurrentState.uVersion = MCTG_API_VERSION; m_mctdCurrentState.uStructSize = sizeof(MC_TELEGRAPH_DATA); m_mctdCurrentState.uComPortID = 1; m_mctdCurrentState.uAxoBusID = 0; m_mctdCurrentState.uChannelID = 1; m_mctdCurrentState.uOperatingMode = MCTG_MODE_VCLAMP; m_mctdCurrentState.uScaledOutSignal = AXMCD_OUT_PRI_VC_GLDR_V_CMD_EXT; m_mctdCurrentState.dAlpha = 0.0; m_mctdCurrentState.dScaleFactor = 0.0; m_mctdCurrentState.uScaleFactorUnits = MCTG_UNITS_VOLTS_PER_VOLT; m_mctdCurrentState.dRawScaleFactor = 0.0; m_mctdCurrentState.uRawScaleFactorUnits = MCTG_UNITS_VOLTS_PER_VOLT; m_mctdCurrentState.dLPFCutoff = 0.0; m_mctdCurrentState.dMembraneCap = 0.0; m_mctdCurrentState.dExtCmdSens = 0.0; m_mctdCurrentState.dSecondaryAlpha = 0.0; m_mctdCurrentState.dSecondaryLPFCutoff = 0.0; }
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: g_hInstance = hInst; if(hSynhroMutex==0) { hSynhroMutex = CreateMutex(NULL, FALSE, "GoldenDictTextOutSpyMutex"); if(hSynhroMutex==0) { return(FALSE); } } if(hHookMutex==0) { hHookMutex = CreateMutex(NULL, FALSE, "GoldenDictTextOutHookMutex"); } ThTypes_Init(); uGdAskMessage = RegisterWindowMessage(GD_MESSAGE_NAME); FindGetPhysicalCursorPos(); break; case DLL_PROCESS_DETACH: // if(hSynhroMutex) WaitForSingleObject(hSynhroMutex, INFINITE); if(hSynhroMutex) WaitForSingleObject(hSynhroMutex, 2000); if (TimerID) { if (KillTimer(0, TimerID)) TimerID=0; } if(hSynhroMutex) { ReleaseMutex(hSynhroMutex); CloseHandle(hSynhroMutex); hSynhroMutex=0; } { MSG msg ; while (PeekMessage (&msg, 0, WM_TIMER, WM_TIMER, PM_REMOVE)) {} } if ((hGetWordLib != 0)&&(hGetWordLib != (HINSTANCE)(-1))) { FreeLibrary(hGetWordLib); } if(hHookMutex) { DWORD wso = WaitForSingleObject(hHookMutex, 5000); if (wso == WAIT_OBJECT_0 || wso == WAIT_ABANDONED) { ReleaseMutex(hHookMutex); CloseHandle(hHookMutex); hHookMutex=0; } } Thtypes_End(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; }
void Windows7ThumbBar::HandleWinEvent(MSG* msg) { #ifdef Q_OS_WIN32 if (button_created_message_id_ == 0) { // Compute the value for the TaskbarButtonCreated message button_created_message_id_ = RegisterWindowMessage("TaskbarButtonCreated"); qLog(Debug) << "TaskbarButtonCreated message ID registered" << button_created_message_id_; } if (msg->message == button_created_message_id_) { HRESULT hr; qLog(Debug) << "Button created"; // Unref the old taskbar list if we had one if (taskbar_list_) { qLog(Debug) << "Releasing old taskbar list"; reinterpret_cast<ITaskbarList3*>(taskbar_list_)->Release(); taskbar_list_ = NULL; } // Create the taskbar list hr = CoCreateInstance(CLSID_ITaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**) &taskbar_list_); if (hr != S_OK) { qLog(Warning) << "Error creating the ITaskbarList3 interface" << hex << DWORD (hr); return; } ITaskbarList3* taskbar_list = reinterpret_cast<ITaskbarList3*>(taskbar_list_); hr = taskbar_list->HrInit(); if (hr != S_OK) { qLog(Warning) << "Error initialising taskbar list" << hex << DWORD (hr); taskbar_list->Release(); taskbar_list_ = NULL; return; } // Add the buttons qLog(Debug) << "Initialising" << actions_.count() << "buttons"; THUMBBUTTON buttons[kMaxButtonCount]; for (int i=0 ; i<actions_.count() ; ++i) { const QAction* action = actions_[i]; THUMBBUTTON* button = &buttons[i]; button->iId = i; SetupButton(action, button); } qLog(Debug) << "Adding buttons"; hr = taskbar_list->ThumbBarAddButtons(widget_->winId(), actions_.count(), buttons); if (hr != S_OK) qLog(Debug) << "Failed to add buttons" << hex << DWORD (hr); for (int i = 0; i < actions_.count(); i++) { if (buttons[i].hIcon > 0) DestroyIcon (buttons[i].hIcon); } } else if (msg->message == WM_COMMAND) { const int button_id = LOWORD(msg->wParam); if (button_id >= 0 && button_id < actions_.count()) { if (actions_[button_id]) { qLog(Debug) << "Button activated"; actions_[button_id]->activate(QAction::Trigger); } } } #endif // Q_OS_WIN32 }
#include <CommCtrl.h> #include <Commdlg.h> #include "TortoiseIDiff.h" #include "MainWindow.h" #include "AboutDlg.h" #include "TaskbarUUID.h" #pragma comment(lib, "comctl32.lib") tstring CMainWindow::leftpicpath; tstring CMainWindow::leftpictitle; tstring CMainWindow::rightpicpath; tstring CMainWindow::rightpictitle; const UINT TaskBarButtonCreated = RegisterWindowMessage(L"TaskbarButtonCreated"); bool CMainWindow::RegisterAndCreateWindow() { WNDCLASSEX wcx; // Fill in the window class structure with default parameters wcx.cbSize = sizeof(WNDCLASSEX); wcx.style = CS_HREDRAW | CS_VREDRAW; wcx.lpfnWndProc = CWindow::stWinMsgHandler; wcx.cbClsExtra = 0; wcx.cbWndExtra = 0; wcx.hInstance = hResource; wcx.hCursor = LoadCursor(NULL, IDC_SIZEWE); ResString clsname(hResource, IDS_APP_TITLE); wcx.lpszClassName = clsname;
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) { /* Variables initialisation */ bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL; stackCentralOldWidget= NULL; #ifndef HAVE_MAEMO sysTray = NULL; #endif fullscreenControls = NULL; cryptedLabel = NULL; controls = NULL; inputC = NULL; b_hideAfterCreation = false; // --qt-start-minimized playlistVisible = false; input_name = ""; /* Ask for Privacy */ FirstRun::CheckAndRun( this, p_intf ); /** * Configuration and settings * Pre-building of interface **/ /* Main settings */ setFocusPolicy( Qt::StrongFocus ); setAcceptDrops( true ); setWindowRole( "vlc-main" ); setWindowIcon( QApplication::windowIcon() ); setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) ); #ifdef Q_WS_MAC setAttribute( Qt::WA_MacBrushedMetal ); #endif /* Is video in embedded in the UI or not */ b_videoEmbedded = var_InheritBool( p_intf, "embedded-video" ); /* Does the interface resize to video size or the opposite */ b_autoresize = var_InheritBool( p_intf, "qt-video-autoresize" ); /* Are we in the enhanced always-video mode or not ? */ b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" ); /* Do we want anoying popups or not */ b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" ); /* Set the other interface settings */ settings = getSettings(); settings->beginGroup( "MainWindow" ); /* */ b_plDocked = getSettings()->value( "pl-dock-status", true ).toBool(); settings->endGroup( ); /************** * Status Bar * **************/ createStatusBar(); /************************** * UI and Widgets design **************************/ setVLCWindowsTitle(); /************ * Menu Bar * ************/ QVLCMenu::createMenuBar( this, p_intf ); CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, destroyPopupMenu() ); createMainWidget( settings ); /********************************* * Create the Systray Management * *********************************/ initSystray(); /******************** * Input Manager * ********************/ MainInputManager::getInstance( p_intf ); #ifdef WIN32 himl = NULL; p_taskbl = NULL; taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated"); #endif /************************************************************ * Connect the input manager to the GUI elements it manages * ************************************************************/ /** * Connects on nameChanged() * Those connects are different because options can impeach them to trigger. **/ /* Main Interface statusbar */ CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, setName( const QString& ) ); /* and systray */ #ifndef HAVE_MAEMO if( sysTray ) { CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, updateSystrayTooltipName( const QString& ) ); } #endif /* and title of the Main Interface*/ if( var_InheritBool( p_intf, "qt-name-in-title" ) ) { CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, setVLCWindowsTitle( const QString& ) ); }
DWORD WINAPI CThread::ThreadProc(LPVOID lpParameter) { UpdateInfo(true); // Скопируем имена папок в новые переменные что бы не затереть исходные значения m_sSrcFolder = m_TaskInfo.sSrcFolder; m_sDestFolder = m_TaskInfo.sDestFolder; DelSlash(m_sSrcFolder); // Отформатируем имя папки назначения (раскроем макросы) CString sFormatedGenName = FormatDateTime(m_TaskInfo.sDestGenName.C()); // Сформируем окончательное имя папки назначения m_sDestFolder += sFormatedGenName; DelSlash(m_sDestFolder); // Начало лога - запишем информацию о выполняемой задаче AddLog(TEXT("[i] Начало выполнения задачи, параметры:\r\n")); AddLog(TEXT("========================================\r\n")); AddLog(TEXT("[i] Задача: %s\r\n"), m_TaskInfo.sName.C()); AddLog(TEXT("[i] Исходная папка: %s\r\n"), m_TaskInfo.sSrcFolder.C()); AddLog(TEXT("[i] Папка назначения: %s\r\n"), (m_TaskInfo.sDestFolder + m_TaskInfo.sDestGenName).C()); AddLog(TEXT("[i] Папка назначения: %s\r\n"), m_sDestFolder.C()); AddLog(TEXT("[i] Включать файлы: %s\r\n"), m_TaskInfo.sIncludeMask.C()); AddLog(TEXT("[i] Исключать файлы: %s\r\n"), m_TaskInfo.sExcludeMask.C()); AddLog(TEXT("========================================\r\n")); // Если выполнение задачи не прервали - продолжаем if (!IsTerminated()) { // Проверяем что бы папка назначения не была подпапкой исходной папки if (IsSubFolder(m_TaskInfo.sSrcFolder, m_sDestFolder)) { AddLog(TEXT("[!] Папка назначения является подпапкой исходной папки\r\n")); AddLog(TEXT("[x] Невозможно продолжить выполнение задачи\r\n")); } // Проверка что папка назначения существует (или успешно создана) else if (!CheckDestFolder()) { AddLog(TEXT("[!] Не могу создать папку назначения (%s)\r\n"), m_TaskInfo.sDestFolder.C()); AddLog(TEXT("[x] Невозможно продолжить выполнение задачи\r\n")); } else { if (m_TaskInfo.bDoArchive) { // Получим временное (и уникальное) имя файла во временной папке TCHAR cTempPath[MAX_PATH]; // получим временную папку GetTempPath(MAX_PATH, cTempPath); // получим уникальное имя для времнного файла, так же система создаст этот файл GetTempFileName(cTempPath, TEXT("smb"), 0, (LPTSTR) m_sFileList.Buf()); if (!PathFileExists(m_sFileList.C())) { AddLog(TEXT("[!] Не могу создать файл-список (%s)\r\n"), m_sFileList.C()); AddLog(TEXT("[!] Задача будет выполнена без архивирования\r\n")); } } // Сделаем предв. сканирование исходной папки m_bLevel = 0; m_dwPrescanFolders = 1; // Если работа с подпапками - предсканируем их if (m_TaskInfo.bSubFolders) { DoPrescan(m_sSrcFolder); // Узнаем сколько процентов занимает каждая "предсканированная" папка m_fPercentInc = (float) 100 / m_dwPrescanFolders; } // иначе просто подсчитаем кол-во файлов в исходной папке else { DWORD dwFiles = FilesInFolder(m_sSrcFolder); m_fPercentInc = (float) 100 / dwFiles; } UpdateInfo(true); MakeList(m_TaskInfo.sIncludeMask, m_aIncludeList); MakeList(m_TaskInfo.sExcludeMask, m_aExcludeList); // Создадим объект, в который будем записывать файл-лист для архиватора m_pFileList = new CMemTextFile(); // Запускаем копирование файлов m_bLevel = 0; m_fPercents = 0; DoSubFolders(m_sSrcFolder, m_sDestFolder); // Сохраним файл-лист из памяти на диск m_pFileList->SaveFile(m_sFileList.C()); delete m_pFileList; // Это последний вызов updateinfo, пускай получатели сообщения знают об этом m_TaskProgress.bLastInfo = true; UpdateInfo(true); // если задача не прервана - выполняем архивацию, если надо if (!IsTerminated() && m_TaskInfo.bDoArchive) { if (!PathFileExists(m_sArchiverEXE.C())) { AddLog(TEXT("[!] Не найден файл архиватора\r\n")); AddLog(TEXT("[x] Отмена запуска архиватора\r\n")); } else if (PathFileExists(m_sFileList.C())) { CString sArch = FormatC(TEXT("\"%s\" %s"), m_sArchiverEXE.C(), ParseArchiverCmdLine().C()); AddLog(TEXT("[i] Вызов архиватора: %s\r\n"), sArch.C()); PROCESS_INFORMATION pi = {0}; STARTUPINFO si = {0}; si.cb = sizeof(si); TCHAR cmd[MAX_PATH]; lstrcpy(cmd, sArch.C()); // Создаём процесс - запускаем архиватор if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { // И ждём пока он не завершит работу WaitForSingleObject(pi.hProcess, INFINITE); DWORD dwExitCode; GetExitCodeProcess(pi.hProcess, &dwExitCode); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); AddLog(TEXT("[i] Архиватор завершил работу с кодом %d\r\n"), dwExitCode); // Если указано - удалим скопированный файлы (их имена занесены в список) if (m_TaskInfo.bArchDelFiles) { for (int i = 0; i < m_lFileList.Size(); i++) DelFiles(m_lFileList[i]); } } else AddLog(TEXT("[!] Ошибка при вызове архиватора\r\n")); } // Удалим файл-список для архиватора DeleteFile(m_sFileList.C()); } AddLog(TEXT("========================================\r\n")); if (IsTerminated()) AddLog(TEXT("[i] Выполнение задачи прервано\r\n")); else AddLog(TEXT("[i] Выполнение задачи завершено\r\n")); } } // пошлём сообщения всем подписавшимся слушателям что работа завершена for (int i = 0; i < m_ProgressListenrs.Size(); i++) PostMessage(m_ProgressListenrs[i], RegisterWindowMessage(ThreadDoneMessage), 0, 0); return 0; }
#include "../../ExTool/ex_basics.h" #include "../../MutiLanguage/CGDICommon.h" #include "../../SQLite3/CppSQLite3.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif void TTSSpeaking(CString csText); //是否有新的中心信息 BOOL CDlgAnswerList::m_bSMSCenter = FALSE; BOOL CDlgAnswerList::m_bIsOpen = FALSE; UINT CDlgAnswerList::WM_DlgAnswerList_Refresh = RegisterWindowMessage(_T("WM_DlgAnswerList_Refresh")); CDlgAnswerList::CDlgAnswerList(int nIndexCurr, CWnd* pParent /*=NULL*/) : CDialogBase(CDlgAnswerList::IDD, pParent) { m_nPageIndex = 0; m_nPageCount = 1; m_nRecordCount = 0; m_nQuestionIndex= nIndexCurr; } void CDlgAnswerList::DoDataExchange(CDataExchange* pDX) { CDialogBase::DoDataExchange(pDX); }
HRESULT C[!output Safe_root]::FinalConstruct() { HRESULT hr = S_OK; ATLTRACE2("%x: FinalConstruct\n", GetCurrentThreadId()); m_msgDownloadBatch = RegisterWindowMessage( L"DownloadBatch" ); if(0 == m_msgDownloadBatch) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgBuy = RegisterWindowMessage( L"Buy" ); if(0 == m_msgBuy) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgRefreshLicense = RegisterWindowMessage( L"RefreshLicense" ); if(0 == m_msgRefreshLicense) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgLogin = RegisterWindowMessage( L"Login" ); if(0 == m_msgLogin) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgAuthenticate = RegisterWindowMessage( L"Authenticate" ); if(0 == m_msgAuthenticate) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgLogout = RegisterWindowMessage( L"Logout" ); if(0 == m_msgLogout) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgVerifyPermission = RegisterWindowMessage( L"VerifyPermission" ); if(0 == m_msgVerifyPermission) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgSendMessage = RegisterWindowMessage( L"SendMessage" ); if(0 == m_msgSendMessage) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgGetListContents = RegisterWindowMessage( L"GetListContents" ); if(0 == m_msgGetListContents) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } m_msgExitMessageLoop = RegisterWindowMessage( L"ExitMessageLoop" ); if(0 == m_msgExitMessageLoop) { hr = HRESULT_FROM_WIN32(GetLastError()); ATLTRACE2("FinalConstruct: RegisterWindowMessage failed. %x\n", hr); goto cleanup; } hr = this->CreateCredentialsFilePath(); if(FAILED(hr)) { ATLTRACE2("FinalConstruct: CreateCredentialsFilePath failed. %x\n", hr); goto cleanup; } // Determine whether we have cached credentials. HANDLE hInfoFile = INVALID_HANDLE_VALUE; hInfoFile = CreateFile( g.credentialsFile, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE != hInfoFile) { // The file exists. // We have cached credentials. g.haveCachedCredentials = 1; } CloseHandle(hInfoFile); cleanup: return hr; }
void iupdrvDialogInitClass(Iclass* ic) { if (!iupwinClassExist("IupDialog")) { winDialogRegisterClass(0); winDialogRegisterClass(1); winDialogRegisterClass(2); winDialogRegisterClass(-1); WM_HELPMSG = RegisterWindowMessage(HELPMSGSTRING); } /* Driver Dependent Class functions */ ic->Map = winDialogMapMethod; ic->UnMap = winDialogUnMapMethod; ic->LayoutUpdate = winDialogLayoutUpdateMethod; ic->Release = winDialogReleaseMethod; /* Callback Windows Only*/ iupClassRegisterCallback(ic, "MDIACTIVATE_CB", ""); /* Callback Windows and GTK Only */ iupClassRegisterCallback(ic, "TRAYCLICK_CB", "iii"); /* Driver Dependent Attribute functions */ /* Visual */ iupClassRegisterAttribute(ic, "BGCOLOR", NULL, winDialogSetBgColorAttrib, IUPAF_SAMEASSYSTEM, "DLGBGCOLOR", IUPAF_DEFAULT); /* Special */ iupClassRegisterAttribute(ic, "TITLE", iupdrvBaseGetTitleAttrib, iupdrvBaseSetTitleAttrib, NULL, NULL, IUPAF_NO_DEFAULTVALUE|IUPAF_NO_INHERIT); /* Base Container */ iupClassRegisterAttribute(ic, "CLIENTSIZE", winDialogGetClientSizeAttrib, iupDialogSetClientSizeAttrib, NULL, NULL, IUPAF_NO_SAVE|IUPAF_NO_DEFAULTVALUE|IUPAF_NO_INHERIT); /* dialog is the only not read-only */ iupClassRegisterAttribute(ic, "CLIENTOFFSET", winDialogGetClientOffsetAttrib, NULL, NULL, NULL, IUPAF_NO_DEFAULTVALUE|IUPAF_READONLY|IUPAF_NO_INHERIT); /* IupDialog only */ iupClassRegisterAttribute(ic, "BACKGROUND", NULL, winDialogSetBackgroundAttrib, IUPAF_SAMEASSYSTEM, "DLGBGCOLOR", IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "ICON", NULL, winDialogSetIconAttrib, NULL, NULL, IUPAF_IHANDLENAME|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "FULLSCREEN", NULL, winDialogSetFullScreenAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "SAVEUNDER", NULL, NULL, IUPAF_SAMEASSYSTEM, "YES", IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MINSIZE", NULL, iupBaseSetMinSizeAttrib, IUPAF_SAMEASSYSTEM, "1x1", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MAXSIZE", NULL, iupBaseSetMaxSizeAttrib, IUPAF_SAMEASSYSTEM, "65535x65535", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT); /* IupDialog Windows Only */ iupClassRegisterAttribute(ic, "HWND", iupBaseGetWidAttrib, NULL, NULL, NULL, IUPAF_NO_STRING|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDIARRANGE", NULL, winDialogSetMdiArrangeAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDIACTIVATE", NULL, winDialogSetMdiActivateAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDICLOSEALL", NULL, winDialogSetMdiCloseAllAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDIACTIVE", winDialogGetMdiActiveAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDINEXT", winDialogGetMdiNextAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "OPACITY", NULL, winDialogSetOpacityAttrib, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "LAYERALPHA", NULL, winDialogSetOpacityAttrib, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "BRINGFRONT", NULL, winDialogSetBringFrontAttrib, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "COMPOSITED", NULL, NULL, NULL, NULL, IUPAF_NOT_MAPPED); iupClassRegisterAttribute(ic, "CONTROL", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "HELPBUTTON", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "TOOLBOX", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDIFRAME", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDICLIENT", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDIMENU", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "MDICHILD", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT); /* IupDialog Windows and GTK Only */ iupClassRegisterAttribute(ic, "ACTIVEWINDOW", winDialogGetActiveWindowAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "TOPMOST", NULL, winDialogSetTopMostAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "TOPMOST", NULL, winDialogSetTopMostAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "TRAY", NULL, winDialogSetTrayAttrib, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "TRAYIMAGE", NULL, winDialogSetTrayImageAttrib, NULL, NULL, IUPAF_NO_INHERIT); iupClassRegisterAttribute(ic, "TRAYTIP", NULL, winDialogSetTrayTipAttrib, NULL, NULL, IUPAF_NO_INHERIT); /* IupDialog Windows Only */ iupClassRegisterAttribute(ic, "TRAYTIPDELAY", NULL, NULL, IUPAF_SAMEASSYSTEM, NULL, IUPAF_NOT_MAPPED); iupClassRegisterAttribute(ic, "TRAYTIPBALLOON", NULL, NULL, IUPAF_SAMEASSYSTEM, NULL, IUPAF_NOT_MAPPED); iupClassRegisterAttribute(ic, "TRAYTIPBALLOONTITLE", NULL, NULL, IUPAF_SAMEASSYSTEM, NULL, IUPAF_NOT_MAPPED); iupClassRegisterAttribute(ic, "TRAYTIPBALLOONTITLEICON", NULL, NULL, IUPAF_SAMEASSYSTEM, NULL, IUPAF_NOT_MAPPED); /* Not Supported */ iupClassRegisterAttribute(ic, "DIALOGHINT", NULL, NULL, NULL, NULL, IUPAF_NOT_SUPPORTED|IUPAF_NO_INHERIT); }
typedef struct { uint8_t type; uint8_t number; } rfbSetSessionMsg; #define sz_rfbKeepAliveMsg 1 #define sz_rfbRequestSessionMsg 1 #define sz_rfbSetSessionMsg 2 #include "vncclient.cpp" #include "vncdesktop.cpp" #ifdef IPV6V4 const UINT MENU_ADD_CLIENT6_MSG_INIT = RegisterWindowMessage("WinVNC.AddClient6.Message.Init"); const UINT MENU_ADD_CLIENT6_MSG = RegisterWindowMessage("WinVNC.AddClient6.Message"); #endif const UINT MENU_ADD_CLIENT_MSG_INIT = RegisterWindowMessage("WinVNC.AddClient.Message.Init"); const UINT MENU_ADD_CLIENT_MSG = RegisterWindowMessage("WinVNC.AddClient.Message"); const UINT MENU_AUTO_RECONNECT_MSG = RegisterWindowMessage("WinVNC.AddAutoClient.Message"); const UINT MENU_STOP_RECONNECT_MSG = RegisterWindowMessage("WinVNC.AddStopClient.Message"); const UINT MENU_STOP_ALL_RECONNECT_MSG = RegisterWindowMessage("WinVNC.AddStopAllClient.Message"); const UINT MENU_REPEATER_ID_MSG = RegisterWindowMessage("WinVNC.AddRepeaterID.Message"); // adzm 2009-07-05 - Tray icon balloon tips // adzm 2010-02-10 - Changed this window message (added 2) to prevent receiving the same message from older UltraVNC builds // which will send this message between processes with process-local pointers to strings as the wParam and lParam const UINT MENU_TRAYICON_BALLOON_MSG = RegisterWindowMessage("WinVNC.TrayIconBalloon2.Message");
void AwtDesktopProperties::GetOtherParameters() { // TODO BEGIN: On NT4, some setttings don't trigger WM_SETTINGCHANGE -- // check whether this has been fixed on Windows 2000 and Windows 98 // ECH 10/6/2000 seems to be fixed on NT4 SP5, but not on 98 SetBooleanProperty(TEXT("win.frame.fullWindowDragsOn"), GetBooleanParameter(SPI_GETDRAGFULLWINDOWS)); SetBooleanProperty(TEXT("win.text.fontSmoothingOn"), GetBooleanParameter(SPI_GETFONTSMOOTHING)); // TODO END if (IS_WINXP) { SetIntegerProperty(TEXT("win.text.fontSmoothingType"), GetIntegerParameter(SPI_GETFONTSMOOTHINGTYPE)); SetIntegerProperty(TEXT("win.text.fontSmoothingContrast"), GetIntegerParameter(SPI_GETFONTSMOOTHINGCONTRAST)); SetIntegerProperty(TEXT("win.text.fontSmoothingOrientation"), GetLCDSubPixelOrder()); } int cxdrag = GetSystemMetrics(SM_CXDRAG); int cydrag = GetSystemMetrics(SM_CYDRAG); SetIntegerProperty(TEXT("win.drag.width"), cxdrag); SetIntegerProperty(TEXT("win.drag.height"), cydrag); SetIntegerProperty(TEXT("DnD.gestureMotionThreshold"), max(cxdrag, cydrag)/2); SetIntegerProperty(TEXT("awt.mouse.numButtons"), GetSystemMetrics(SM_CMOUSEBUTTONS)); SetIntegerProperty(TEXT("awt.multiClickInterval"), GetDoubleClickTime()); // BEGIN cross-platform properties // Note that these are cross-platform properties, but are being stuck into // WDesktopProperties. WToolkit.lazilyLoadDesktopProperty() can find them, // but if a Toolkit subclass uses the desktopProperties // member, these properties won't be there. -bchristi, echawkes // This property is called "win.frame.fullWindowDragsOn" above // This is one of the properties that don't trigger WM_SETTINGCHANGE SetBooleanProperty(TEXT("awt.dynamicLayoutSupported"), GetBooleanParameter(SPI_GETDRAGFULLWINDOWS)); // 95 MouseWheel support // More or less copied from the MSH_MOUSEWHEEL MSDN entry if (IS_WIN95 && !IS_WIN98) { HWND hdlMSHWHEEL = NULL; UINT msgMSHWheelSupported = NULL; BOOL wheelSupported = FALSE; msgMSHWheelSupported = RegisterWindowMessage(MSH_WHEELSUPPORT); hdlMSHWHEEL = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE); if (hdlMSHWHEEL && msgMSHWheelSupported) { wheelSupported = (BOOL)::SendMessage(hdlMSHWHEEL, msgMSHWheelSupported, 0, 0); } SetBooleanProperty(TEXT("awt.wheelMousePresent"), wheelSupported); } else { SetBooleanProperty(TEXT("awt.wheelMousePresent"), ::GetSystemMetrics(SM_MOUSEWHEELPRESENT)); } // END cross-platform properties if (IS_WIN98 || IS_WIN2000) { //DWORD menuShowDelay; //SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &menuShowDelay, 0); // SetIntegerProperty(TEXT("win.menu.showDelay"), menuShowDelay); SetBooleanProperty(TEXT("win.frame.captionGradientsOn"), GetBooleanParameter(SPI_GETGRADIENTCAPTIONS)); SetBooleanProperty(TEXT("win.item.hotTrackingOn"), GetBooleanParameter(SPI_GETHOTTRACKING)); } if (IS_WIN2000) { SetBooleanProperty(TEXT("win.menu.keyboardCuesOn"), GetBooleanParameter(SPI_GETKEYBOARDCUES)); } // High contrast accessibility property HIGHCONTRAST contrast; contrast.cbSize = sizeof(HIGHCONTRAST); if (SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &contrast, 0) != 0 && (contrast.dwFlags & HCF_HIGHCONTRASTON) == HCF_HIGHCONTRASTON) { SetBooleanProperty(TEXT("win.highContrast.on"), TRUE); } else { SetBooleanProperty(TEXT("win.highContrast.on"), FALSE); } if (fn_SHGetSettings != NULL) { SHELLFLAGSTATE sfs; fn_SHGetSettings(&sfs, SSF_SHOWALLOBJECTS | SSF_SHOWATTRIBCOL); if (sfs.fShowAllObjects) { SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), TRUE); } else { SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), FALSE); } if (sfs.fShowAttribCol) { SetBooleanProperty(TEXT("awt.file..showAttribCol"), TRUE); } else { SetBooleanProperty(TEXT("awt.file.showAttribCol"), FALSE); } } LPTSTR value; DWORD valueType; // Shell Icon BPP - only honored on platforms before XP value = getWindowsPropFromReg(TEXT("Control Panel\\Desktop\\WindowMetrics"), TEXT("Shell Icon BPP"), &valueType); if (value != NULL) { if (valueType == REG_SZ) { SetStringProperty(TEXT("win.icon.shellIconBPP"), value); } free(value); } // The following registry settings control the file chooser places bar // under the Windows L&F. These settings are not present by default, but // can be enabled using the TweakUI tool from Microsoft. For more info, // see http://msdn.microsoft.com/msdnmag/issues/1100/Registry/ // NoPlacesBar is a REG_DWORD, with values 0 or 1 value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32"), TEXT("NoPlacesBar"), &valueType); if (value != NULL) { if (valueType == REG_DWORD) { SetBooleanProperty(TEXT("win.comdlg.noPlacesBar"), (BOOL)((int)*value != 0)); } free(value); } LPTSTR valueName = TEXT("PlaceN"); LPTSTR valueNameBuf = (LPTSTR)safe_Malloc((lstrlen(valueName) + 1) * sizeof(TCHAR)); lstrcpy(valueNameBuf, valueName); LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN"); LPTSTR propKeyBuf = (LPTSTR)safe_Malloc((lstrlen(propKey) + 1) * sizeof(TCHAR)); lstrcpy(propKeyBuf, propKey); int i = 0; do { valueNameBuf[5] = _T('0' + i++); propKeyBuf[25] = valueNameBuf[5]; LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar"); if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) { if (valueType == REG_DWORD) { // Value is a CSIDL SetIntegerProperty(propKeyBuf, (int)*value); } else { // Value is a path SetStringProperty(propKeyBuf, value); } free(value); } } while (value != NULL); free(valueNameBuf); free(propKeyBuf); }
static void doSaver (HWND hwndParent) { HDC hdc; MSG msg; HWND hwnd; WNDCLASS cls; HANDLE hOther; RECT rcParent; int nx, ny, cx, cy; PSTR pszWindowTitle; UINT uExStyle, uStyle; // Define screensaver¡¯s window class. cls.style = CS_OWNDC | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW; cls.lpfnWndProc = (WNDPROC) RealScreenSaverProc; cls.cbClsExtra = 0; cls.cbWndExtra = 0; cls.hInstance = g_hinstance; cls.hIcon = LoadIcon (g_hinstance, MAKEINTRESOURCE(ID_APP)); cls.hCursor = NULL; cls.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = g_szClassName; // If hwndParent is not NULL, we are running in preview mode. Otherwise, we // are running in saver mode. if (hwndParent != NULL) { // Specify appropriate title for preview mode screensaver window. pszWindowTitle = "Preview"; // Get the parent window rectangle. GetClientRect (hwndParent, &rcParent); // Compute width and position information for preview window, relative to // the parent window. cx = rcParent.right; cy = rcParent.bottom; nx = 0; ny = 0; // No extended style required for preview window, which is a child of its // non-desktop parent window. uExStyle = 0; // Set the preview window style -- child window, visible, exclude the // area occupied by child windows when drawing in parent window. uStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN; } else { // Specify appropriate title for saver mode screensaver window. pszWindowTitle = "Screen Saver"; // Search for existing screensaver window. hOther = FindWindow (g_szClassName, pszWindowTitle); // If this window exists, make it the foreground window and return. We // don¡¯t execute more than one screensaver at the same time. What would // be the point of doing that? if (hOther != NULL && IsWindow ((HWND) hOther)) { SetForegroundWindow (hOther); return; } // Get the desktop window rectangle. hdc = GetDC (HWND_DESKTOP); GetClipBox (hdc, &rcParent); ReleaseDC (HWND_DESKTOP, hdc); // Compute width and position information for screensaver window, // relative to the desktop window -- the entire screen. cx = rcParent.right - rcParent.left; cy = rcParent.bottom - rcParent.top; nx = rcParent.left; ny = rcParent.top; // The screensaver window occupies the entire screen and must be the // topmost window -- no other window can be located on top of the // screensaver window. uExStyle = WS_EX_TOPMOST; // Set the screensaver window style -- popup, visible, exclude the area // occupied by child windows when drawing in parent window, clip child // windows relative to each other. uStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; } // Attempt to register the screensaver¡¯s window class. if (!RegisterClass (&cls)) return; if (g_fOnWin95) { // Load the password DLL (found in password.cpl -- a DLL with a .cpl // file extension. loadPwdDLL (); // Register the QueryCancelAutoPlay message with Windows. uShellMessage = RegisterWindowMessage ("QueryCancelAutoPlay"); } // Disable the Alt+Tab, Ctrl+Alt+Delete, and Windows keys. hogMachine (TRUE); // Create either preview mode or saver mode screensaver window. hwnd = CreateWindowEx (uExStyle, g_szClassName, pszWindowTitle, uStyle, nx, ny, cx, cy, hwndParent, NULL, g_hinstance, NULL); // If we were successful ... if (hwnd) { // Either a preview window or a window occupying the entire desktop has // been created. In the latter case, make that window the foreground // window. Nothing can supersede a window occuping the entire desktop. if (g_scrmode != smPreview) SetForegroundWindow (hwnd); // Enter the screensaver¡¯s message loop. Loop ends when // RealScreenSaverProc() responds to the WM_DESTROY message by calling // PostQuitMessage (0). while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } } // Enable the Alt+Tab, Ctrl+Alt+Delete, and Windows keys. hogMachine (FALSE); if (g_fOnWin95) { // Unload the password DLL. unloadPwdDLL (); } }
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { (void) reserved; switch (reason) { case DLL_PROCESS_ATTACH: g_hInstance = hInst; ThTypes_Init(); #ifdef __WIN64 if( GlobalData == NULL || GlobalData32 == NULL ) { #else if( GlobalData == NULL ) { #endif ThTypes_End(); return FALSE; } ourProcessID = GetCurrentProcessId(); if(hSynhroMutex==0) { hSynhroMutex = CreateMutex(NULL, FALSE, "GoldenDictTextOutSpyMutex"); if(hSynhroMutex==0) { return(FALSE); } } uGdAskMessage = RegisterWindowMessage(GD_MESSAGE_NAME); FindGetPhysicalCursorPos(); break; case DLL_PROCESS_DETACH: // if(hSynhroMutex) WaitForSingleObject(hSynhroMutex, INFINITE); if(hSynhroMutex) WaitForSingleObject(hSynhroMutex, 2000); if (TimerID) { KillTimer(0, TimerID); TimerID=0; } if(hSynhroMutex) { ReleaseMutex(hSynhroMutex); CloseHandle(hSynhroMutex); hSynhroMutex=0; } { MSG msg ; while (PeekMessage (&msg, 0, WM_TIMER, WM_TIMER, PM_REMOVE)); } if ( (hGetWordLib != 0) && (hGetWordLib != INVALID_HANDLE_VALUE) ) { FreeLibrary(hGetWordLib); } ThTypes_End(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; }
ArchDaemonWindows::ArchDaemonWindows() : m_daemonThreadID(0) { m_quitMessage = RegisterWindowMessage("SynergyDaemonExit"); }
//================================================================================================ //--------------------------------------------------==-+++--> Entry Point of Program Using WinMain: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS wndclass; HWND hwndMain; MSG msg; int updated; (void)hPrevInstance; (void)nCmdShow; #if defined(__GNUC__) && defined(_DEBUG) # ifdef _WIN64 # define LoadExcHndl() LoadLibraryExA("dbg\\64\\exchndl", NULL, LOAD_WITH_ALTERED_SEARCH_PATH) # else # define LoadExcHndl() LoadLibraryExA("dbg\\exchndl", NULL, LOAD_WITH_ALTERED_SEARCH_PATH) # endif #else # define LoadExcHndl() #endif LoadExcHndl(); // LOAD_WITH_ALTERED_SEARCH_PATH works :P At least since Win2k g_instance = hInstance; if(LoadClockAPI("misc/T-Clock" ARCH_SUFFIX, &api)){ MessageBox(NULL, "Error loading: T-Clock" ARCH_SUFFIX ".dll", "API error", MB_OK|MB_ICONERROR); return 2; } chdir(api.root); // make sure we've got the right working directory // Make sure we're running Windows 2000 and above if(!api.OS) { MessageBox(NULL,"T-Clock requires Windows 2000 or newer","old OS",MB_OK|MB_ICONERROR); return 1; } // make sure ObjectBar isn't running -> From Original Code/Unclear if This is Still a Conflict. (test suggested not really.. no crash but no clock either :P) if(FindWindow("ObjectBar Main","ObjectBar")) { MessageBox(NULL,"ObjectBar and T-Clock can't be run together","ObjectBar detected!",MB_OK|MB_ICONERROR); return 1; } // Load ALL of the Global Resources g_hIconTClock = LoadIcon(api.hInstance, MAKEINTRESOURCE(IDI_MAIN)); g_hIconPlay = LoadImage(g_instance, MAKEINTRESOURCE(IDI_PLAY), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIconStop = LoadImage(g_instance, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIconDel = LoadImage(g_instance, MAKEINTRESOURCE(IDI_DEL), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); // FindTrayServer(hwndMain); // Make sure we're not running 32bit on 64bit OS / start the other one #ifndef _WIN64 if(IsWow64()){ hwndMain = FindWindow(g_szClassName, NULL); if(hwndMain) { // send commands to existing instance ProcessCommandLine(hwndMain,lpCmdLine); }else{ // start new instance char clock64[MAX_PATH]; memcpy(clock64, api.root, api.root_len+1); add_title(clock64,"Clock" ARCH_SUFFIX_64 ".exe"); api.Exec(clock64,lpCmdLine,NULL); } return 0; } #endif // _WIN64 // Do Not Allow the Program to Execute Twice! updated = 25; /**< wait up to 5 sec in 1/5th seconds for other instance */ do{ HANDLE processlock=CreateMutex(NULL,FALSE,g_szClassName); // we leak handle here, but Windows closes on process exit anyway (so why do it manually?) if(processlock && GetLastError()==ERROR_ALREADY_EXISTS){ CloseHandle(processlock); hwndMain = FindWindow(g_szClassName, NULL); if(hwndMain) { // This One Sends Commands to the Instance ProcessCommandLine(hwndMain,lpCmdLine); // That is Currently Running. return 0; } Sleep(200); continue; } break; }while(updated--); // Update settings if required and setup defaults if((updated=CheckSettings())<0){ return 1; } CancelAllTimersOnStartUp(); // Message of the taskbar recreating - Special thanks to Mr.Inuya g_WM_TaskbarCreated = RegisterWindowMessage("TaskbarCreated"); // register a window class wndclass.style = 0; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = g_instance; wndclass.hIcon = g_hIconTClock; wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(intptr_t)(COLOR_WINDOW+1); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = g_szClassName; g_atomTClock = RegisterClass(&wndclass); if(api.OS >= TOS_VISTA) { // allow non elevated processes to send control messages (eg, App with admin rights, explorer without) #define MSGFLT_ADD 1 #define MSGFLT_REMOVE 2 typedef BOOL (WINAPI* ChangeWindowMessageFilter_t)(UINT message,DWORD dwFlag); ChangeWindowMessageFilter_t ChangeWindowMessageFilter=(ChangeWindowMessageFilter_t)GetProcAddress(GetModuleHandle("user32"), "ChangeWindowMessageFilter"); if(ChangeWindowMessageFilter){ int msgid; ChangeWindowMessageFilter(g_WM_TaskbarCreated,MSGFLT_ADD); ChangeWindowMessageFilter(WM_COMMAND,MSGFLT_ADD); for(msgid=WM_MOUSEFIRST; msgid<=WM_MOUSELAST; ++msgid) ChangeWindowMessageFilter(msgid,MSGFLT_ADD); for(msgid=MAINMFIRST; msgid<=MAINMLAST; ++msgid) ChangeWindowMessageFilter(msgid,MSGFLT_ADD); } } // create a hidden window g_hwndTClockMain = hwndMain = CreateWindowEx(WS_EX_NOACTIVATE, MAKEINTATOM(g_atomTClock),NULL, 0, 0,0,0,0, NULL,NULL,g_instance,NULL); // This Checks for First Instance Startup Options ProcessCommandLine(hwndMain,lpCmdLine); GetHotKeyInfo(hwndMain); if(api.OS > TOS_2000) { if(api.GetInt("Desktop", "MonOffOnLock", 0)) RegisterSession(hwndMain); } if(updated==1){ PostMessage(hwndMain,WM_COMMAND,IDM_SHOWPROP,0); } while(GetMessage(&msg, NULL, 0, 0)) { if(!(g_hwndSheet && IsWindow(g_hwndSheet) && PropSheet_IsDialogMessage(g_hwndSheet,&msg)) && !(g_hDlgTimer && IsWindow(g_hDlgTimer) && IsDialogMessage(g_hDlgTimer,&msg)) && !(g_hDlgTimerWatch && IsWindow(g_hDlgTimerWatch) && IsDialogMessage(g_hDlgTimerWatch,&msg)) && !(g_hDlgStopWatch && IsWindow(g_hDlgStopWatch) && IsDialogStopWatchMessage(g_hDlgStopWatch,&msg))){ TranslateMessage(&msg); DispatchMessage(&msg); } } UnregisterHotKey(hwndMain, HOT_TIMER); UnregisterHotKey(hwndMain, HOT_WATCH); UnregisterHotKey(hwndMain, HOT_STOPW); UnregisterHotKey(hwndMain, HOT_PROPR); UnregisterHotKey(hwndMain, HOT_CALEN); UnregisterHotKey(hwndMain, HOT_TSYNC); UnregisterSession(hwndMain); EndNewAPI(NULL); return (int)msg.wParam; }
CUploadsWnd::CUploadsWnd() { m_nUplsDeletedMsg = RegisterWindowMessage (_pszUploadsDeletedNotifyMsg); }
__declspec(dllexport) void download (HWND parent, int string_size, TCHAR *variables, stack_t **stacktop) { char buf[1024]; char url[1024]; char filename[1024]; static char proxy[1024]; BOOL bSuccess=FALSE; int timeout_ms=30000; int getieproxy=1; int manualproxy=0; int translation_version; const char *error=NULL; // translation version 2 & 1 static char szDownloading[1024]; // "Downloading %s" static char szConnecting[1024]; // "Connecting ..." static char szSecond[1024]; // " (1 second remaining)" for v2 // "second" for v1 static char szMinute[1024]; // " (1 minute remaining)" for v2 // "minute" for v1 static char szHour[1024]; // " (1 hour remaining)" for v2 // "hour" for v1 static char szProgress[1024]; // "%skB (%d%%) of %skB at %u.%01ukB/s" for v2 // "%dkB (%d%%) of %dkB at %d.%01dkB/s" for v1 // translation version 2 only static char szSeconds[1024]; // " (%u seconds remaining)" static char szMinutes[1024]; // " (%u minutes remaining)" static char szHours[1024]; // " (%u hours remaining)" // translation version 1 only static char szPlural[1024]; // "s"; static char szRemaining[1024]; // " (%d %s%s remaining)"; EXDLL_INIT(); PopStringA(url); if (!lstrcmpiA(url, "/TRANSLATE2")) { PopStringA(szDownloading); PopStringA(szConnecting); PopStringA(szSecond); PopStringA(szMinute); PopStringA(szHour); PopStringA(szSeconds); PopStringA(szMinutes); PopStringA(szHours); PopStringA(szProgress); PopStringA(url); translation_version=2; } else if (!lstrcmpiA(url, "/TRANSLATE")) { PopStringA(szDownloading); PopStringA(szConnecting); PopStringA(szSecond); PopStringA(szMinute); PopStringA(szHour); PopStringA(szPlural); PopStringA(szProgress); PopStringA(szRemaining); PopStringA(url); translation_version=1; } else { lstrcpyA(szDownloading, "Downloading %s"); lstrcpyA(szConnecting, "Connecting ..."); lstrcpyA(szSecond, " (1 second remaining)"); lstrcpyA(szMinute, " (1 minute remaining)"); lstrcpyA(szHour, " (1 hour remaining)"); lstrcpyA(szSeconds, " (%u seconds remaining)"); lstrcpyA(szMinutes, " (%u minutes remaining)"); lstrcpyA(szHours, " (%u hours remaining)"); lstrcpyA(szProgress, "%skB (%d%%) of %skB at %u.%01ukB/s"); translation_version=2; } lstrcpynA(buf, url, 10); if (!lstrcmpiA(buf, "/TIMEOUT=")) { timeout_ms=my_atoi(url+9); PopStringA(url); } if (!lstrcmpiA(url, "/PROXY")) { getieproxy=0; manualproxy=1; PopStringA(proxy); PopStringA(url); } if (!lstrcmpiA(url, "/NOIEPROXY")) { getieproxy=0; PopStringA(url); } PopStringA(filename); HANDLE hFile = CreateFileA(filename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); if (hFile == INVALID_HANDLE_VALUE) { wsprintfA(buf, "Unable to open %s", filename); error = buf; } else { if (parent) { uMsgCreate = RegisterWindowMessage(_T("nsisdl create")); lpWndProcOld = (WNDPROC)SetWindowLongPtr(parent,GWLP_WNDPROC,(LONG_PTR)ParentWndProc); SendMessage(parent, uMsgCreate, TRUE, (LPARAM) parent); // set initial text char *p = filename; while (*p) p++; while (*p !='\\' && p != filename) p = CharPrevA(filename, p); wsprintfA(buf, szDownloading, p != filename ? p + 1 : p); SetDlgItemTextA(childwnd, 1006, buf); SetWindowTextA(g_hwndStatic, szConnecting); } { WSADATA wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); JNL_HTTPGet *get = 0; static char main_buf[8192]; char *buf=main_buf; char *p=NULL; HKEY hKey; if (getieproxy && RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",0,KEY_READ,&hKey) == ERROR_SUCCESS) { DWORD l = 4; DWORD t; DWORD v; if (RegQueryValueExA(hKey,"ProxyEnable",NULL,&t,(unsigned char*)&v,&l) == ERROR_SUCCESS && t == REG_DWORD && v) { l=8192; if (RegQueryValueExA(hKey,"ProxyServer",NULL,&t,(unsigned char *)buf,&l ) == ERROR_SUCCESS && t == REG_SZ) { p=strstr(buf,"http="); if (!p) p=buf; else { p+=5; } char *tp=strstr(p,";"); if (tp) *tp=0; char *p2=strstr(p,"="); if (p2) p=0; // we found the wrong proxy } } buf[8192-1]=0; RegCloseKey(hKey); } if (manualproxy == 1) { p = proxy; } DWORD start_time=GetTickCount(); get=new JNL_HTTPGet(JNL_CONNECTION_AUTODNS,16384,(p&&p[0])?p:NULL); int st; int has_printed_headers = 0; __int64 cl = 0; int len; __int64 sofar = 0; DWORD last_recv_time=start_time; get->addheader ("User-Agent: NSISDL/1.2 (Mozilla)"); get->addheader ("Accept: */*"); get->connect (url); while (1) { if (g_cancelled) error = "cancel"; if (error) { if (parent) { SendMessage(parent, uMsgCreate, FALSE, (LPARAM) parent); SetWindowLongPtr(parent, GWLP_WNDPROC, (LONG_PTR)lpWndProcOld); } break; } st = get->run (); if (st == -1) { lstrcpynA(url, get->geterrorstr(), sizeof(url)); error = url; } else if (st == 1) { if (sofar < cl || get->get_status () != 2) error="download incomplete"; else { bSuccess=TRUE; error = "success"; } } else { if (get->get_status () == 0) { // progressFunc ("Connecting ...", 0); if (last_recv_time+timeout_ms < GetTickCount()) error = "Timed out on connecting."; else Sleep(10); // don't busy-loop while connecting } else if (get->get_status () == 1) { progress_callback("Reading headers", 0); if (last_recv_time+timeout_ms < GetTickCount()) error = "Timed out on getting headers."; else Sleep(10); // don't busy-loop while reading headers } else if (get->get_status () == 2) { if (! has_printed_headers) { has_printed_headers = 1; last_recv_time=GetTickCount(); cl = get->content_length (); if (cl == 0) error = "Server did not specify content length."; else if (g_hwndProgressBar) { SendMessage(g_hwndProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 30000)); g_file_size = cl; } } int data_downloaded = 0; while ((len = get->bytes_available ()) > 0) { data_downloaded++; if (len > 8192) len = 8192; len = get->get_bytes (buf, len); if (len > 0) { last_recv_time=GetTickCount(); DWORD dw; WriteFile(hFile,buf,len,&dw,NULL); sofar += len; int time_sofar=(GetTickCount()-start_time)/1000; int bps = (int)(sofar/(time_sofar?time_sofar:1)); int remain = MulDiv64(time_sofar, cl, sofar) - time_sofar; if (translation_version == 2) { char *rtext=remain==1?szSecond:szSeconds;; if (remain >= 60) { remain/=60; rtext=remain==1?szMinute:szMinutes; if (remain >= 60) { remain/=60; rtext=remain==1?szHour:szHours; } } char sofar_str[128]; char cl_str[128]; myitoa64(sofar/1024, sofar_str); myitoa64(cl/1024, cl_str); wsprintfA (buf, szProgress, //%skB (%d%%) of %skB @ %u.%01ukB/s sofar_str, MulDiv64(100, sofar, cl), cl_str, bps/1024,((bps*10)/1024)%10 ); if (remain) wsprintfA(buf+lstrlenA(buf),rtext, remain ); } else if (translation_version == 1) { char *rtext=szSecond; if (remain >= 60) { remain/=60; rtext=szMinute; if (remain >= 60) { remain/=60; rtext=szHour; } } wsprintfA (buf, szProgress, //%dkB (%d%%) of %dkB @ %d.%01dkB/s int(sofar/1024), MulDiv64(100, sofar, cl), int(cl/1024), bps/1024,((bps*10)/1024)%10 ); if (remain) wsprintfA(buf+lstrlenA(buf),szRemaining, remain, rtext, remain==1?"":szPlural ); } progress_callback(buf, sofar); } else { if (sofar < cl) error = "Server aborted."; } } if (GetTickCount() > last_recv_time+timeout_ms) { if (sofar != cl) { error = "Downloading timed out."; } else { // workaround for bug #1713562 // buggy servers that wait for the client to close the connection. // another solution would be manually stopping when cl == sofar, // but then buggy servers that return wrong content-length will fail. bSuccess = TRUE; error = "success"; } } else if (!data_downloaded) Sleep(10); } else { error = "Bad response status."; } } } // Clean up the connection then release winsock if (get) delete get; WSACleanup(); } CloseHandle(hFile); } if (g_cancelled || !bSuccess) { DeleteFileA(filename); } PushStringA(error); }
#include "FreeCompose.h" #include "OptionsPropSheet.h" #include "Utils.h" IMPLEMENT_DYNAMIC( COptionsPropSheet, CPropertySheet ) BEGIN_MESSAGE_MAP( COptionsPropSheet, CPropertySheet ) //{{AFX_MSG_MAP( COptionsPropSheet ) ON_WM_CREATE( ) ON_COMMAND( ID_APPLY_NOW, OnApplyNow ) //}}AFX_MSG_MAP END_MESSAGE_MAP() const UINT APP_RECONFIGURE = RegisterWindowMessage( _T("FreeCompose.APP_RECONFIGURE") ); COptionsPropSheet::COptionsPropSheet( const COptionsData& options, CWnd* pParentWnd, UINT iSelectPage ): CPropertySheet ( CString( (LPCWSTR) IDS_OPTIONSPROPSHEET_TITLE ), pParentWnd, iSelectPage ), m_CurOptions ( options ), m_NewOptions ( m_CurOptions ), m_KeySequences ( m_NewOptions ), m_Features ( m_NewOptions ) { AddPage( &m_KeySequences ); AddPage( &m_Features ); } COptionsPropSheet::~COptionsPropSheet( ) { }
/*********************************************************************** * * WinMain */ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show) { MSG msg; HACCEL hAccel; WNDCLASSEX wndclass; HMONITOR monitor; MONITORINFO info; INT x, y; static const TCHAR className[] = _T("NPClass"); static const TCHAR winName[] = _T("Notepad"); UNREFERENCED_PARAMETER(prev); aFINDMSGSTRING = (ATOM) RegisterWindowMessage(FINDMSGSTRING); ZeroMemory(&Globals, sizeof(Globals)); Globals.hInstance = hInstance; LoadSettings(); ZeroMemory(&wndclass, sizeof(wndclass)); wndclass.cbSize = sizeof(wndclass); wndclass.lpfnWndProc = NOTEPAD_WndProc; wndclass.hInstance = Globals.hInstance; wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NPICON)); wndclass.hCursor = LoadCursor(0, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndclass.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU); wndclass.lpszClassName = className; wndclass.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NPICON), IMAGE_ICON, 16, 16, 0); if (!RegisterClassEx(&wndclass)) return FALSE; /* Setup windows */ monitor = MonitorFromRect( &Globals.main_rect, MONITOR_DEFAULTTOPRIMARY ); info.cbSize = sizeof(info); GetMonitorInfoW( monitor, &info ); x = Globals.main_rect.left; y = Globals.main_rect.top; if (Globals.main_rect.left >= info.rcWork.right || Globals.main_rect.top >= info.rcWork.bottom || Globals.main_rect.right < info.rcWork.left || Globals.main_rect.bottom < info.rcWork.top) x = y = CW_USEDEFAULT; Globals.hMainWnd = CreateWindow(className, winName, WS_OVERLAPPEDWINDOW, x, y, Globals.main_rect.right - Globals.main_rect.left, Globals.main_rect.bottom - Globals.main_rect.top, NULL, NULL, Globals.hInstance, NULL); if (!Globals.hMainWnd) { ShowLastError(); ExitProcess(1); } DoCreateEditWindow(); NOTEPAD_InitData(); DIALOG_FileNew(); ShowWindow(Globals.hMainWnd, show); UpdateWindow(Globals.hMainWnd); DragAcceptFiles(Globals.hMainWnd, TRUE); DIALOG_ViewStatusBar(); HandleCommandLine(cmdline); hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) ); while (GetMessage(&msg, 0, 0, 0)) { if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) && !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }