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 01, 2020  
 
I could not get set_non_modal to work. Perhaps I am missing something..

>>
Fl::add_timeout(2.0, Update_CB, (void*)&progress);
    win.set_non_modal();
    win.show();
>>

I found an old thread with some info, Greg - from 16 years ago.
https://fltk.easysw.narkive.com/zcptoTmB/always-on-top
>>
if you can obtain hWnd, than with WinAPI function SetWindowPos() you can set
it to be on top of all windows by something like:

SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
>>

Also,
>>
This was also covered in a previous thread from April:

Subject: How to make a window "Stay On Top"
>>
But I could not find that thread.

I found this thread - https://fltk.easysw.narkive.com/zRSNyFX3/can-i-make-a-top-most-window-by-fltk
I will copy the code in case we lose that archive.

>>
//===============================================================================
#include <FL/Fl.H>
#include <FL/x.H>
#include <Fl/Fl_Window.H>
#include <windows.h>

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

//----------------------------------------------------------------------------
bool Is_Topmost(Fl_Window* pWindow)
{
HWND hWnd= fl_xid(pWindow);
WINDOWINFO pwi;
if (GetWindowInfo(hWnd, &pwi)) return pwi.dwExStyle & WS_EX_TOPMOST;
else return false;
}

//----------------------------------------------------------------------------
void Clear_Topmost(Fl_Window* pWindow)
{
HWND hWnd= fl_xid(pWindow);
ShowWindow(hWnd, SW_SHOWNORMAL);
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

//----------------------------------------------------------------------------
void Show_Foreground(Fl_Window* pWindow)
{
HWND hWnd= fl_xid(pWindow);
ShowWindow(hWnd, SW_SHOWNORMAL);
if (GetForegroundWindow() != hWnd)
{
DWORD fgwpid = GetWindowThreadProcessId(GetForegroundWindow(),NULL);
DWORD mypid = GetWindowThreadProcessId(hWnd, NULL);
AttachThreadInput(mypid, fgwpid, TRUE);
BringWindowToTop(hWnd);
SetForegroundWindow(hWnd);
AttachThreadInput(mypid, fgwpid, FALSE);
}
}

//----------------------------------------------------------------------------
bool Is_Foreground(Fl_Window* pWindow)
{
return GetForegroundWindow()== fl_xid(pWindow);
}

//----------------------------------------------------------------------------
void Show_Background(Fl_Window* pWindow)
{
HWND hWnd= fl_xid(pWindow);
ShowWindow(hWnd, SW_SHOWNORMAL);
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
>>
On Thursday, October 1, 2020 at 8:35:20 PM UTC+5:30 anmol....@gmail.com wrote:
copy_label() fixed the problem. Thanks!
Calling show() in the loop or changing /subsytem:windows in linker options did not work either.
Stackexchange tells me CreateProcess() is the only reliable way to stop the console window from starting.
But I'm not going that route.

Almost as if microsoft intended this to mess with our minds. Hmm..

I'll try the " modify the window attributes to make it always on top, but non-modal so it does not prevent events passing to your other windows" method and report back.

On Thursday, October 1, 2020 at 3:37:38 PM UTC+5:30 Albrecht Schlosser wrote:
On 10/1/20 11:52 AM 'MacArthur, Ian' wrote:

> Also, you can tell windows not to throw the CMD window at all for the pipe, though off-hand I can’t remember the magical invocation for that. It's a linker option though, IIRC. might be "-mwindows" with gcc, can't recall what VS uses...

If it's /that/ linker option ("-mwindows") then it's likely
"/subsystem:windows" (as opposed to "/subsystem:console") with MSVC, but
don't rely on the exact syntax.

--
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/9694987a-f240-4dfc-aaa9-0b709dbcf494n%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'.