Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Funktion wie DoEvents in Basic

Empfohlene Antworten

Veröffentlicht

Hallo,

Kennt einer von euch zufällig eine Funktion in der MFC in der ich eine for-oder auch andere Schleife ausführen kann und gleichzeitig den Dialog bewegen und Steuerelemente anzeigen lassen. Anhand einer for-Schleife will ich nämlich in einem anderen Dialog eine ProgressBar aktualisieren, aber dann lässt sich der Dialog nicht mehr bewegen, wegen der Prozessauslastung.

Kann mir jemand helfen ???

Für einen Tip wäre ich sehr dankbar.

Jeff Prosise beschreibt in 'Programming Windows with MFC' eine Möglichkeit

This problem is easily solved with a message pump. Here's the proper way to execute a lengthy procedure in a single-threaded MFC program:

void CMainWindow::OnStartDrawing ()

{

m_bQuit = FALSE;

for (int i=0; i<NUMELLIPSES && !m_bQuit; i++) {

DrawRandomEllipse ();

if (!PeekAndPump ()) // PeekAndPump entspricht DoEvents

break;

}

}

void CMainWindow::OnStopDrawing ()

{

m_bQuit = TRUE;

}

BOOL CMainWindow::PeekAndPump ()

{

MSG msg;

while (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {

if (!AfxGetApp ()->PumpMessage ()) {

::PostQuitMessage (0);

return FALSE;

}

}

LONG lIdle = 0;

while (AfxGetApp ()->OnIdle (lIdle++));

return TRUE;

}

PeekAndPump enacts a message loop within a message loop. Called at the conclusion of each iteration through OnStartDrawing's for loop, PeekAndPump first calls CWinThread::PumpMessage to retrieve and dispatch messages if ::PeekMessage indicates that messages are waiting in the queue. A 0 return from PumpMessage indicates that the last message retrieved and dispatched was a WM_QUIT message, which calls for special handling because the application won't terminate unless the WM_QUIT message is retrieved by the main message loop. That's why PeekAndPump posts another WM_QUIT message to the queue if PumpMessage returns 0, and why the for loop in OnStartDrawing falls through if PeekAndPump returns 0. If a WM_QUIT message doesn't prompt an early exit, PeekAndPump simulates the framework's idle mechanism by calling the application object's OnIdle function before returning.

funktioniert prinzipiell, habe es auch schon mal verwendet, kann aber je nach verwendung etwas umständlich werden. ich weiß nicht, ob sich dein problem so lösen lässt. vielleicht solltest du über einen worker thread nachdenken.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.