- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TheOpen/SaveAs dlg box(explorer style) does not behave like a normal modal dlg box. It has it's own window in the task bar, when you click on the apps main window the Open/SaveAs dlg disappears, and when minimized and another app is activated it pops up behing the new app., also when activated with a modeless dlg box it prevents the tab and return keys from working properly in the modeless dlg. Is there a way to get the Open/SaveAs Dlg box to behave more like a modal dlg box. I have triedthe folowing in the Open/SaveAs, explorer style hook procedure:
iStyles =GetWindowLong(GetParent(hDlg), GWL_STYLE)
iNewStyles = ior(iStyles, WS_POPUP)
iret = SetWindowLong(GetParent(hDlg), GWL_STYLE, iNewStyles)
Although iNewStyles was .NE. iStyles, there was no change in the behavor
of the Open/SaveAs dlg. Stumped! Any help would be appreciated. Thanks.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The key is the OFN%hWndOwner member -- the OFN dialog will disable its owner on launch, and that's how all dialogs work. If you set it to NULL or something else, you'll get the behaviour you describe. WS_POPUP is not the problem.
By the way, by default, "modal" dialogs (including OFN) are not "task-modal", i.e. they don't disable modeless dialogs which are outside of their parent/owner chain. If you want that behaviour, you have to call EnumThreadWindows and disable/enable all non-child windows (except "yourself") before/after the dialog.
Jugoslav
By the way, by default, "modal" dialogs (including OFN) are not "task-modal", i.e. they don't disable modeless dialogs which are outside of their parent/owner chain. If you want that behaviour, you have to call EnumThreadWindows and disable/enable all non-child windows (except "yourself") before/after the dialog.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply JugoSlavDujic, it helped me zero in on the problem.
Iwas initializing the OPENFILENAME structure during case (WM_CREATE) in the main wnd proc, and setting Ofn%hwndowner = ghWndMain which of course was 0.Changed ghWndMain to hWnd (a valid file handle) and the problem went away! I had worked on this problem for several days, and just didn't seethe solution. Thanks, also for the info about EnumThreadWindows().
One additional question. I only want one instance ofmy application to run atany given time. I was looking at your web site (a few months ago) and you had a discussion about this, but when I clicked onyour link nothing happened.Iassume one just checks theapp instance handle, and if another copy of the app is present then just abort the current copy.Thanks for anyinfo!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The page in question (Win32 FAQ) was screwed when I "upgraded" to FrontPage 2000 and I uploaded it as such, and never found the old version, and was lazy to rewrite it :-(.
For an .exe, hInstance always has value of 0x00400000 -- that's the address where image loader places the .exe's module in the virtual address space (2GB). Thus, it's a value local to the program.
The trick is to use a named mutex using CreateMutex API with any (unique) name you like. If a mutex already exists, the function still succeeds but GetLastError returns ERROR_ALREADY_EXISTS -- that's the sign you have an instance already running.
The system automatically destroys the mutex on process' exit, and you can do it explicitly using CloseHandle.
Jugoslav
For an .exe, hInstance always has value of 0x00400000 -- that's the address where image loader places the .exe's module in the virtual address space (2GB). Thus, it's a value local to the program.
The trick is to use a named mutex using CreateMutex API with any (unique) name you like. If a mutex already exists, the function still succeeds but GetLastError returns ERROR_ALREADY_EXISTS -- that's the sign you have an instance already running.
The system automatically destroys the mutex on process' exit, and you can do it explicitly using CloseHandle.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! Your help is really appreciated.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page