FLTK logo

Re: [fltk.general] Use worker thread to call Fl_Window and Fl_run - [General Use]

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Use worker thread to call Fl_Window and Fl_run - [General Use] "anmol.... Oct 03, 2020  
 
Found it. This method is a hack but it works consistently and the progress bar pops up - which is IMO a benefit.

#ifdef _OS_WIN
//----------------------------------------------------------------------------
void Show_Topmost(Fl_Window* pWindow) {
    HWND hWnd = fl_xid(pWindow);
    ShowWindow(hWnd, SW_MINIMIZE);
    ShowWindow(hWnd, SW_RESTORE);
    ShowWindow(hWnd, SW_SHOWNORMAL);
    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

// Progress callback updates label
void Topmost_CB(void* userdata) {
    Fl_Progress* progress = (Fl_Progress*)userdata;
    int val;
    val = AEC_progress;
    progress->value((float)val);              // update progress bar with 0.0 ~ 100 value
    char percent[10] = { "" };
    sprintf_s(percent, "%d%%", val);
    progress->copy_label(percent);
    Show_Topmost(progress->window());

    Fl::repeat_timeout(2.0, Update_CB, (void*)progress);
}
#endif

And in main code,

    win.end();
#ifdef _OS_WIN
    Fl::add_timeout(2.0, Topmost_CB, (void*)&progress);
#else
    Fl::add_timeout(2.0, Callback_CB, (void*)&progress);
#endif
    win.set_non_modal();
    win.show();
    AEC_progress = 0;
    Fl::check();

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/7aecbadd-15c5-43a0-97c6-a6b4ffbe339fn%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.