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

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


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.


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click





-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click





-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click





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