MacArthur, Ian (SELEX) (UK) wrote:
>> Well, but how can I get a hwnd to my fltk-window? Because I
>> want to tell the dialog box that my window is its owner.
>> I can``t find a useful method at the fltk/win32.h. Any idea?
>
> You could read the docs... win32.html says:
> "HWND fltk::xid(const fltk::Window*)
>
> Returns the window handle for a fltk::Window, or zero if not shown()."
I think I was able to avoid that call in Fl_Native_File_Chooser
by using the WIN32 function GetForegroundWindow(). (I was trying
to keep it as 'pure native' as possible.)
> Which is what you want I think. Still, I think you would probably be
> better off just porting Greg's fl_native_file_chooser code from fltk-1.
> Greg says it works for fltk-2 with only trivial mods, so that's likely
> your best bet.
Yes, compiled and ran on WIN32.
Here's the FLTK2 version of 'simple-app.cxx' (test program that
comes with Fl_Native_File_Chooser) that I used to test it..
basically a 'quickie' rewrite of the original fltk1 version.
I didn't give it a 'hard' test, I just stopped when I saw the
browser came up, and could open and close OK. But I imagine
it should be fine.. all the browser code is apparently pure win32..
it's so disconnected from FLTK that it didn't seem to matter at all
what rev of FLTK it was compiled with:
#include <stdio.h>
#include <fltk/run.h>
#include <fltk/Widget.h>
#include <fltk/Window.h>
#include <fltk/Button.h>
#include <fltk/Input.h>
#include <FL/Fl_Native_File_Chooser.H>
using namespace fltk;
// GLOBALS
Input *G_filename = 0;
void Butt_CB(Widget*, void*) {
// Create native chooser
Fl_Native_File_Chooser native;
native.title("Pick a file");
native.type(Fl_Native_File_Chooser::BROWSE_FILE);
native.filter("Text\t*.txt\nC Files\t*.{cxx,h,c}");
native.preset_file(G_filename->value());
// Show native chooser
switch ( native.show() ) {
case -1: fprintf(stderr, "ERROR: %s\n", native.errmsg()); break;
// ERROR
case 1: fprintf(stderr, "*** CANCEL\n"); break;
// CANCEL
default:
// PICKED FILE
if ( native.filename() )
G_filename->value(native.filename());
else
G_filename->value("NULL");
break;
}
}
int main() {
Window *win = new Window(600, 100);
int y = 10;
G_filename = new Input(80, y, win->w()-80-10, 25, "Filename");
G_filename->value(".");
G_filename->tooltip("Default filename");
y += G_filename->h() + 5;
Button *but = new Button(win->w()-80-10, win->h()-25-10, 80, 25, "Pick
File");
but->callback(Butt_CB);
win->resizable(win);
win->show();
return(fltk::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk