October 30, 2025, 03:33:37 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Dialog Beeps on Closure

Started by Bruce Peaslee, October 01, 2009, 02:50:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

I have one dialog out of many that causes a "beep" when it closes. Everything appears to be working. Any ideas?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Bruce Peaslee

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.   ???
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

No code to look at, so no solution can be guessed at ;)
Ionic Wind Support Team

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library