Re: [AD] problem with windows dialogs/ Win XP

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


tried my code snippet again, in mingw 3.4.2
winXP, sp1,  this time in release build.

window opens, on top of the allegro window.
its opens to the "My Documents" folder
i can see a .bmp file there.

it all looks good.






Daniel Sauder wrote:
Don't work correct for me. When I change the file type the dialog is putting an empty file list in the dialog. It is then just showing the files correctly when I change and rechange the directory... I'm using mingw 3.4.2, WinXP SP2.

AJ wrote:

this code (that i copy-pasted from your message below) worked in WinXP, Sp1, msvc7.1 build. debug_s


so whats is the problem ?

{
    OPENFILENAME ofn;
    //ofn.hwndOwner=win_get_window();   BAD
    memset(&ofn,0,sizeof(ofn));
    ofn.lStructSize=sizeof(OPENFILENAME);
    ofn.hwndOwner=win_get_window();   //GOOD
    char szFile[260]="";
    ofn.nMaxFile=sizeof(szFile);
    ofn.lpstrFile=szFile;
    ofn.lpstrFilter="Bitmaps\0*.bmp\0All Files\0*.*\0\0";
    GetOpenFileName(&ofn);
}






Daniel Sauder wrote:

The main problem is that the code below is working with Win98 and wine but not XP. But I didn't know that it is working like you described it. I had a short text for the faq but now I'll rewrite it. Maybe you can give a short example?
Dan

AJ wrote:

i have not followed thread about this topic, so excuse me if im off-topic, but...

i have added my own windows file dialog code to my app, by placing it into its own thread, then feeding the return values back into the main app via a set of critical sections. i dont have any trouble with it.
if this is on-topic let me know.

aj.




Daniel Sauder wrote:

I made some more research and have a question:
- GetOpenFilename works correct when I changed the call of _CoInitializeEx(NULL, _COINIT_MULTITHREADED); to _CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); or to CoInitialize(NULL); in wthread.c (or when it isn't called,
see below)
Anybody knows what's exactly the difference between _COINIT_MULTITHREADED and COINIT_APARTMENTTHREADED?

- GetOpenFilename dialog and MessageBox apear behind the main window when called, with the the changes above too. I made a mistake with this (I should be more careful). It's working alright:
#include <allegro.h>
#include <winalleg.h>

int main(int argc, char **argv) {
   allegro_init();
   install_keyboard();
   set_color_depth(16);
   set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);

   //set_gfx_mode(GFX_GDI,640,480,0,0);
   set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
   OPENFILENAME ofn;
     //ofn.hwndOwner=win_get_window();   BAD
     memset(&ofn,0,sizeof(ofn));
   ofn.lStructSize=sizeof(OPENFILENAME);
   ofn.hwndOwner=win_get_window();   //GOOD
   char szFile[260]="";

   ofn.nMaxFile=sizeof(szFile);
ofn.lpstrFile=szFile; ofn.lpstrFilter="Bitmaps\0*.bmp\0All Files\0*.*\0\0";
   GetOpenFileName(&ofn);

}
END_OF_MAIN()

-Since I don't find a solution except changing the threading model when calling _CoInitializeEx, I'll write a small text for the FAQ.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/