Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Daniele Godi

@Daniele Godi
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Disabling dialog button from within the ON_BN_CLICKED handler
    D Daniele Godi

    Dear all, I found the solution and I like to share it with you. I took the idea from an article I have found on your site, http://www.codeproject.com/cpp/cppforumfaq.asp#ui\_workerthread I implemented this code within the button handler and... wonder!, it works. OnButtonClicked() { m_crtlButton->Enable(FALSE); while (Do_A_Bit_Of_Work()) { MSG msk; while(PeekMessage(&msg, NULL, NULL, PM_NOREMOVE) { AfxGetApp()->PumpMessage(); } } m_crtlButton->Enable(TRUE); return; } Ciao and thanks for your kind help. Daniele

    C / C++ / MFC data-structures help question

  • Disabling dialog button from within the ON_BN_CLICKED handler
    D Daniele Godi

    Hi all, I have a problem. I need to start a long computing work when the user clicks a dialog button. During this time the button needs to be disabled. The following simple code doesn't work. Despite the fact that the button changes state from enable to disabled (grayed), it actually gets the mouse inputs. Some of you knows the reason? I wasn't able to disable this button and then I had to write a workaround. Thanks, Daniele Godi /////////////////////////////////////////////////////////////// Sample code void CMyDlg::OnBnClickedButton1() { // disable the button m_ctrlButton1.EnableWindow(FALSE); BeginWaitCursor(); DoSomeLongWork(); EndWaitCursor(); // workaround, I have to remove manually the mouse input from // the message queue if (::GetInputState()) { MSG msg; while ( ::PeekMessage( &msg, NULL, NULL, NULL, PM_NOREMOVE ) ) { // found a mouse message, remove it if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST)) { ::PeekMessage( &msg, NULL, NULL, NULL, PM_REMOVE); } else { if ( !::AfxGetThread()->PumpMessage() ) { // if FALSE exit both dialog and application EndDialog(FALSE); ::PostQuitMessage( -1 ); return; } } } } m_ctrlButton1.EnableWindow(TRUE); return; } Daniele Godi

    C / C++ / MFC data-structures help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups