I have one dialog out of many that causes a "beep" when it closes. Everything appears to be working. Any ideas?
The program now has advanced to where you can close the dialog through a menu item:
Case FILE_CLOSE
CloseDialog myDialog, @IDCANCEL
No beep. Clicking the close box, on this dialog only, gives a beep. ???
No code to look at, so no solution can be guessed at ;)
Quote from: Ionic Wind Support Team on November 19, 2009, 11:18:32 AM
No code to look at, so no solution can be guessed at ;)
I've rewritten how the dialog is created and called, but it still happens as decribed. Here is some code:
Select @MESSAGE
Case @IDCLOSEWINDOW
CloseDialog dlgMap, @IDOK 'BEEPS
Case @IDINITDIALOG
dlgMap_Initialize()
Case WM_CTLCOLORDLG
return CreateSolidBrush(BLACK)
Case @IDMENUPICK
Select @MENUNUM
Case MAP_FILE_CLOSE
CloseDialog dlgMap, @IDOK ' NO BEEP
EndSelect
EndSelect
Someone once said that @IDCLOSEWINDOW does not trigger for dialogs.
Did a little research on closing dialogs.
1. The @IDCLOSEWINDOW message IS sent to dialogs just like it is to windows.
2. The @IDCLOSEWINDOW message is triggered when the system CANCEL button is clicked.
3. For a modal dialog, the dialog is automatically closed with internal code and with a return status equal to @IDCANCEL
With your code of: Case @IDCLOSEWINDOW
CloseDialog dlgMap, @IDOK 'BEEPS
I never heard a beep but the print statement never worked.
A little trial an error replacing the @IDOK with any number other than 1 (@IDOK ) resulted in everything working correctly (but I don't know about the beep since I never heard it to start with).
The CLOSEDIALOG command uses the API EndDialog(d1.hwnd,ret) to close a modal dialog and return the code.
As best I can determine the internal code to close the dialog is using the same function.
So, if you put a CLOSEDIALOG inside a Case @IDCLOSEWINDOW you are actually trying to close the dialog twice.
And that appears to be a problem only if you are trying to return @IDOK
It appears that you can use any other value you want to pass back a status.