Jump to page: 1 2 3
Thread overview
File Picker
Dec 07, 2013
Malkierian
Dec 07, 2013
Adam D. Ruppe
Dec 08, 2013
Malkierian
Dec 08, 2013
Marco Leise
Dec 08, 2013
Malkierian
Dec 08, 2013
Adam D. Ruppe
Dec 08, 2013
Adam D. Ruppe
Dec 08, 2013
Malkierian
Dec 08, 2013
Malkierian
Dec 09, 2013
Jeremy DeHaan
Dec 09, 2013
Adam D. Ruppe
Dec 09, 2013
Malkierian
Dec 09, 2013
Malkierian
Dec 09, 2013
Jeremy DeHaan
Dec 09, 2013
Malkierian
Dec 09, 2013
Jeremy DeHaan
Dec 09, 2013
Malkierian
Dec 10, 2013
Jeremy DeHaan
Dec 10, 2013
Malkierian
Dec 12, 2013
Malkierian
Dec 12, 2013
Jeremy DeHaan
December 07, 2013
Is there anything in D that currently brings up a window to find and choose a file, or am I going to have to make it myself?  Isn't there a built-in something or other I can hook into in Windows?
December 07, 2013
On Saturday, 7 December 2013 at 23:00:00 UTC, Malkierian wrote:
> Is there anything in D that currently brings up a window to find and choose a file, or am I going to have to make it myself?  Isn't there a built-in something or other I can hook into in Windows?

Yeah, on Windows, you can just call the GetOpenFileName function (or GetSaveFileName if saving) and use the common dialog.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927(v=vs.85).aspx


I wrote this quick example to show how you can use it in D:

http://arsdnet.net/dcode/open.d


Since the windows headers distributed with dmd are woefully incomplete, the first thing I did was copy/paste the struct and file definition from MSDN.

Then, below that, is the main() function which shows how to call it. There's a lot of customization you can do there, see the Microsoft docs for more info (or search the web for any C examples, the function works the same way in D.)
December 08, 2013
On Saturday, 7 December 2013 at 23:18:18 UTC, Adam D. Ruppe wrote:
> On Saturday, 7 December 2013 at 23:00:00 UTC, Malkierian wrote:
>> Is there anything in D that currently brings up a window to find and choose a file, or am I going to have to make it myself?  Isn't there a built-in something or other I can hook into in Windows?
>
> Yeah, on Windows, you can just call the GetOpenFileName function (or GetSaveFileName if saving) and use the common dialog.
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927(v=vs.85).aspx
>
>
> I wrote this quick example to show how you can use it in D:
>
> http://arsdnet.net/dcode/open.d
>
>
> Since the windows headers distributed with dmd are woefully incomplete, the first thing I did was copy/paste the struct and file definition from MSDN.
>
> Then, below that, is the main() function which shows how to call it. There's a lot of customization you can do there, see the Microsoft docs for more info (or search the web for any C examples, the function works the same way in D.)

Man, that's great, thanks.  However, I have it set up in my application, and when I first call it, I get this window:

http://gyazo.com/02bc18bdc23fdf3c24aa4ff70b46be1f

Then, if I cancel and open it again, I get the actual browser, but then my program freezes up:

http://gyazo.com/4e5e873e57cd7a234d56c7a42198ab89

Any idea why it doesn't work the first time, but then does the second and freezes?
December 08, 2013
Am Sun, 08 Dec 2013 05:49:34 +0100
schrieb "Malkierian" <rhydonj@gmail.com>:

> On Saturday, 7 December 2013 at 23:18:18 UTC, Adam D. Ruppe wrote:
> > On Saturday, 7 December 2013 at 23:00:00 UTC, Malkierian wrote:
> >> Is there anything in D that currently brings up a window to find and choose a file, or am I going to have to make it myself?  Isn't there a built-in something or other I can hook into in Windows?
> >
> > Yeah, on Windows, you can just call the GetOpenFileName
> > function (or GetSaveFileName if saving) and use the common
> > dialog.
> > http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927(v=vs.85).aspx
> >
> >
> > I wrote this quick example to show how you can use it in D:
> >
> > http://arsdnet.net/dcode/open.d
> >
> >
> > Since the windows headers distributed with dmd are woefully incomplete, the first thing I did was copy/paste the struct and file definition from MSDN.
> >
> > Then, below that, is the main() function which shows how to call it. There's a lot of customization you can do there, see the Microsoft docs for more info (or search the web for any C examples, the function works the same way in D.)
> 
> Man, that's great, thanks.  However, I have it set up in my application, and when I first call it, I get this window:
> 
> http://gyazo.com/02bc18bdc23fdf3c24aa4ff70b46be1f
> 
> Then, if I cancel and open it again, I get the actual browser, but then my program freezes up:
> 
> http://gyazo.com/4e5e873e57cd7a234d56c7a42198ab89
> 
> Any idea why it doesn't work the first time, but then does the second and freezes?

Maybe it requires a working Windows® event loop in your
application, as is typical for GUI applications on any
platform. Windows typically generate all sorts of events, like
mouse clicks, key strokes, resize events etc. They add up in
the event queue and a white window like yours is typical of
Windows® to indicate that "this application is no longer
working off its event loop. (Or in your case never started to
do so.)
If that is indeed the problem, worry not, because most events
can be handled by the default handler, but you'll need to
write an simple event loop. I'm not sure, but it could be that
you'll need to create a dummy window as well since event loops
work with window handles. Maybe it is ok to pass 0 everywhere,
maybe you need a valid handle.

-- 
Marco

December 08, 2013
On Sunday, 8 December 2013 at 09:17:37 UTC, Marco Leise wrote:
>
> Maybe it requires a working Windows® event loop in your
> application, as is typical for GUI applications on any
> platform. Windows typically generate all sorts of events, like
> mouse clicks, key strokes, resize events etc. They add up in
> the event queue and a white window like yours is typical of
> Windows® to indicate that "this application is no longer
> working off its event loop. (Or in your case never started to
> do so.)
> If that is indeed the problem, worry not, because most events
> can be handled by the default handler, but you'll need to
> write an simple event loop. I'm not sure, but it could be that
> you'll need to create a dummy window as well since event loops
> work with window handles. Maybe it is ok to pass 0 everywhere,
> maybe you need a valid handle.

That's rather unfortunate, as I was using DSFML as my main event generator and handler.  I had a DSFML window up already that I was calling that function from.  I don't know how to make the crossover between the two in D.  I think I'll have to look into GtkD instead.  Thanks for the idea, though.
December 08, 2013
On Sunday, 8 December 2013 at 04:49:35 UTC, Malkierian wrote:
> Any idea why it doesn't work the first time, but then does the second and freezes?

Could be a missing argument to the function, I did a quick test on Windows XP and it looks like you're on Vista.

Later today, I'll be on my other Windows computer and I'll try it there and see what's going on.
December 08, 2013
Hmm, I just tried from my Windows 7 computer and it worked.  If you do my sample program without changes

http://arsdnet.net/dcode/open.d

does it work, or is the problem after copy/pasting it into the rest of your program? Also are you compiling 64 bit? I only tried 32 bit since my laptop has a 32 bit processor so that could be a problem too.
December 08, 2013
On Sunday, 8 December 2013 at 22:26:11 UTC, Adam D. Ruppe wrote:
> Hmm, I just tried from my Windows 7 computer and it worked.  If you do my sample program without changes
>
> http://arsdnet.net/dcode/open.d
>
> does it work, or is the problem after copy/pasting it into the rest of your program? Also are you compiling 64 bit? I only tried 32 bit since my laptop has a 32 bit processor so that could be a problem too.

No, I'm not building in 64bit.  However, I just tried it, copy paste into my main, no additional libs or includes, only main.d compiling.  Still get a window like that first image, and if I put another one in after it, it does the same not responding issue.
December 08, 2013
On Sunday, 8 December 2013 at 23:17:46 UTC, Malkierian wrote:
> On Sunday, 8 December 2013 at 22:26:11 UTC, Adam D. Ruppe wrote:
>> Hmm, I just tried from my Windows 7 computer and it worked.  If you do my sample program without changes
>>
>> http://arsdnet.net/dcode/open.d
>>
>> does it work, or is the problem after copy/pasting it into the rest of your program? Also are you compiling 64 bit? I only tried 32 bit since my laptop has a 32 bit processor so that could be a problem too.
>
> No, I'm not building in 64bit.  However, I just tried it, copy paste into my main, no additional libs or includes, only main.d compiling.  Still get a window like that first image, and if I put another one in after it, it does the same not responding issue.

I am working in Xamarin, though, if that makes a difference.
December 09, 2013
On Sunday, 8 December 2013 at 23:32:54 UTC, Malkierian wrote:
> On Sunday, 8 December 2013 at 23:17:46 UTC, Malkierian wrote:
>> On Sunday, 8 December 2013 at 22:26:11 UTC, Adam D. Ruppe wrote:
>>> Hmm, I just tried from my Windows 7 computer and it worked.  If you do my sample program without changes
>>>
>>> http://arsdnet.net/dcode/open.d
>>>
>>> does it work, or is the problem after copy/pasting it into the rest of your program? Also are you compiling 64 bit? I only tried 32 bit since my laptop has a 32 bit processor so that could be a problem too.
>>
>> No, I'm not building in 64bit.  However, I just tried it, copy paste into my main, no additional libs or includes, only main.d compiling.  Still get a window like that first image, and if I put another one in after it, it does the same not responding issue.
>
> I am working in Xamarin, though, if that makes a difference.

I just tested it myself building in Xamarin. Worked like it is supposed to, so I'm not sure what's up. I'm running Win7 though.

When I get home I can see if running this along side DSFML's event stuff is a problem, but I hope it isn't something specific to your computer. That would blow.
« First   ‹ Prev
1 2 3