Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Chris Chancellor on November 25, 2018, 04:56:32 PM

Title: Simple DDT dialog with animated fading when exit
Post by: Chris Chancellor on November 25, 2018, 04:56:32 PM
Hello All

here's a Simple DDT dialog, that when user press the exit button, the dialog will fade away

in O2 64bit codes


' SimpleDDT.O2bas
'====================================================================
' Simple DDT style dialogs in OxygenBasic
' Thanxx to Roland and Charles
'  Added AnimateWindow
' Nov 25 2018

$ filename "SimpleDDT.exe"

uses rtl64
uses dialogs
#lookahead   

' for Animate
%  AW_HIDE         = &H00010000
%  AW_ACTIVATE     = &H00020000
%  AW_SLIDE        = &H00040000
%  AW_BLEND        = &H00080000



' Equates
% IDC_TEXTBOX1     = 1001
% IDC_TEXTBOX2     = 1002
% IDC_LABEL1          = 1003
% IDC_BUTTON1      = 1006
%  IDC_ExitBtn         = 1008   

  sys  hDlg




'=====================================
sub winmain()


  Dialog( 151, 118, 201, 133, "DDT style in OxygenBasic",
          WS_OVERLAPPEDWINDOW  or DS_SETFONT,
          8, "MS Sans Serif" )

  EDITTEXT("TextBox 1", IDC_TEXTBOX1, 10, 5, 55, 30 )

  EDITTEXT("TextBox 2", IDC_TEXTBOX2, 10, 45, 55, 30 )


  LText( "Label 1 ", IDC_LABEL1, 95, 5, 65, 30)

  PushButton( "Button1" , IDC_Button1, 125, 45, 50, 20)

  PushButton( "Fade out and Exit" , IDC_ExitBtn, 10, 95, 65, 20)

  CreateModalDialog( null, @DlgProc, 0)

end sub




=============================================
function DlgProc( sys hDlg, uint uMsg, sys wParam, lParam ) as int callback

  select case uMsg

    case WM_INITDIALOG
     

    case WM_COMMAND
      select case loword(wParam)

       case IDC_Button1
                    mbox " Button 1 is clicked"

        case IDC_ExitBtn
             '  Firstly fade out the dialog window
                AnimateWindow hDlg, 4200, AW_BLEND OR AW_HIDE
             '  Exit the program
                EndDialog( hDlg, null )

      end select

     
    case WM_CLOSE
         '  Firstly fade out the dialog window
            AnimateWindow hDlg, 4200, AW_BLEND OR AW_HIDE
           EndDialog( hDlg, null )
               
  end select

  return 0
end function




==============================================
'MAIN CODE start
winmain()






note that the equivalent codes in PB  is below , so be happy with your translation!   
sorry that it is in still 32bit only   :(


' Simple DDT.bas
' Added animation to Fade upon exit
' Nov 25 2018

#COMPILE EXE
#DIM ALL
#INCLUDE "WIN32API.INC"


' Equates
%IDC_TEXTBOX1        = 1001
%IDC_TEXTBOX2        = 1002
%IDC_LABEL1          = 1003
%IDC_BUTTON1         = 1006
%IDC_ExitBtn         = 1008


GLOBAL hDlg  AS DWORD


'====================================
FUNCTION PBMAIN()


    DIALOG NEW 0, "Simple DDT ", 151, 118, 201, 133,_
                  %WS_OVERLAPPEDWINDOW TO hDlg


    CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "TextBox 1", 10, 5, 55, 30
    CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "TextBox 2", 10, 45, 55, 30


    CONTROL ADD LABEL,   hDlg, %IDC_LABEL1, "This is Label 1", 95, 5, 65, 30

    CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "Button1", 125, 45, 50, 20

    ' Fade out the dialog and then exit the program
    CONTROL ADD BUTTON,  hDlg, %IDC_ExitBtn, "Fade out and Exit", 10, 95, 65, 20

    DIALOG SHOW MODAL hDlg, CALL DlgProc


END FUNCTION





'============================================
CALLBACK FUNCTION DlgProc()

    SELECT CASE AS LONG CBMSG

       CASE %WM_INITDIALOG


       CASE %WM_COMMAND
         SELECT CASE AS LONG CB.CTL
            CASE %IDC_BUTTON1
               IF CB.CTLMSG = %BN_CLICKED THEN
                  ? " Button 1 is clicked "
               END IF


           CASE %IDC_ExitBtn
               IF CB.CTLMSG = %BN_CLICKED THEN
                '  Firstly fade out the dialog window
                   AnimateWindow hDlg, 4200,%AW_BLEND OR %AW_HIDE
                '  exit the program
                   DIALOG END CBHNDL
               END IF

         END SELECT


         CASE %WM_CLOSE
              '  Firstly fade out the dialog window
                 AnimateWindow hDlg, 4200,%AW_BLEND OR %AW_HIDE
              '  exit the program
                 DIALOG END CBHNDL


    END SELECT
END FUNCTION



Title: Re: Simple DDT dialog with animated fading when exit
Post by: Brian Alvarez on November 25, 2018, 08:52:46 PM
 The powerbasic one hangs in the taskbar after fading out. Sometimes it crashes.
Title: Re: Simple DDT dialog with animated fading when exit
Post by: Chris Chancellor on November 25, 2018, 09:05:25 PM
Thanxx Brian

the trouble lies with PB command
DIALOG END CBHNDL

replace these lines with


  postquitmessage 0
   Destroywindow hDlg



then it won't crash anymore

that is why we should be moving to O2 instead as  the author of  DIALOG END CBHNDL  is dead

Title: Re: Simple DDT dialog with animated fading when exit
Post by: Chris Chancellor on November 25, 2018, 09:08:02 PM
This is NO JOKE   ;D

Seriously, that the PB author had died and PB is dying

i'm sure SB  ( Shripzo Basic) is going that way soonest ???

Title: Re: Simple DDT dialog with animated fading when exit
Post by: Brian Alvarez on November 25, 2018, 09:25:45 PM
Hehe, thanks Chris.

Yes, that fixed it. This is a neat feature i wasn't aware of. I might end up using it soon!
Title: Re: Simple DDT dialog with animated fading when exit
Post by: Brian Alvarez on November 25, 2018, 09:28:11 PM
By the way, i need to update the progress of the implementation....
Title: Re: Simple DDT dialog with animated fading when exit
Post by: Brian Alvarez on December 24, 2018, 09:33:07 AM

Just wanted to post that the original example is now compilable with PluriBASIC.
Absolutely no changes required besides specifying the compiler (Oxygen).

Title: Re: Simple DDT dialog with animated fading when exit
Post by: Chris Chancellor on December 24, 2018, 02:49:43 PM
Good to hear that about Pluribasic.   anychance you can help me to get a listview cell highlighted ?

please see my requests at http://www.jose.it-berater.org/smfforum/index.php?topic=5438.0 (http://www.jose.it-berater.org/smfforum/index.php?topic=5438.0)