Announcement

Collapse
No announcement yet.

Animated Dialogs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Animated Dialogs

    On to the next question (without a breath in-between)

    When you see an animated dialog in Windows (Example: the paper flying from folder to folder when you copy files) what method are they using to create the animation with.

    The code is not really the important part to me at this time (though I won't yell if you post some!), but I'm interested more in the methodology.


    ------------------
    George W. Bleck
    Senior System Engineer
    KeySpan Corporation

    [This message has been edited by George Bleck (edited September 07, 2000).]
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

  • #2
    george --
    it seems to me that you are talking about avi.
    for example, inside visual studio you can find filecopy.avi.
    if so, look http://www.powerbasic.com/support/pb...ad.php?t=22720

    ------------------
    e-mail: [email protected]

    Comment


    • #3
      The general technique involves using a timer to trigger the code to do a "frame" update. For example, with the flying paper display, you could emulate it relatively easily.

      1. Design a series of "frames" (images) that make up the animation.
      2. Start the image timer using SetTimer()
      3. On receipt of each %WM_TIMER message, increment the frame counter and change the image (if using a static control (%SS_BITMAP style control) with a %STM_SETIMAGE message; or if you are using a DDT IMAGE control then use CONTROL SET IMAGE.

      You could also use a separate thread but is a design choice - there is no serious need to use more than one (primary) thread to handle the whole shooting match.


      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        George;

        Simply put, you are seeing a Common Control in action !

        It is the "Animation" control.

        The animation control is different than normal AVI playback
        (via MCI) in that it can not play sound. The control plays
        an AVI file that is "silent" (no sound allowed).

        The AVI file can be loaded from a disk file, but I would
        guess that the animation "could" be put into a Resource so
        it is embeded in the EXE.

        The Animation control is not very complex and should be easy to
        impliment.

        The following functions were taken from the common control inc file:


        Code:
        SUB Animate_Create(BYVAL hWndP AS LONG, BYVAL id AS LONG, BYVAL dwStyle AS LONG, BYVAL hInstance AS LONG)
         CreateWindow "SysAnimate32", BYVAL %NULL, dwStyle, _
                      0, 0, 0, 0, hWndP, id, hInstance, BYVAL %NULL
        END SUB
        
        FUNCTION Animate_Open(BYVAL hWnd AS LONG, szName AS ASCIIZ) AS LONG
         FUNCTION = SendMessage(hWnd, %ACM_OPEN, 0, VARPTR(szName))
        END FUNCTION
        
        FUNCTION Animate_Play(BYVAL hWnd AS LONG, BYVAL nFrom AS INTEGER, BYVAL nTo AS INTEGER, BYVAL rep AS LONG) AS LONG
          FUNCTION = SendMessage(hWnd, %ACM_PLAY, rep, MAKLNG(nFrom, nTo))
        END FUNCTION
        
        FUNCTION Animate_Stop(BYVAL hWnd AS LONG) AS LONG
          FUNCTION = SendMessage(hWnd, %ACM_STOP, 0, 0)
        END FUNCTION
        
        SUB Animate_Close(BYVAL hWnd AS LONG)
          Animate_Open hWnd, BYVAL %NULL
        END SUB
        
        SUB Animate_Seek(BYVAL hWnd AS LONG, BYVAL frame AS LONG)
          Animate_Play hWnd, frame, frame, 1
        END SUB

        ------------------
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"
        http://cwsof.com
        http://twitter.com/EZGUIProGuy

        Comment


        • #5
          Can't Start Stop Animation SYSANIMATE32
          I placed an animation on a dialog with PBWin7
          Show and Hide work fine but I can't get it to Start or Stop


          FUNCTION ShowMainDialog(BYVAL hParent AS DWORD) AS LONG
          CONTROL ADD "SysAnimate32", ghDlg, %IDC_SYSANIMATE32_1, "#" + _
          FORMAT$(%IDR_AVI1), 290, 215, 62, 43, %WS_CHILD OR %WS_VISIBLE OR _
          %ACS_TRANSPARENT '!! NO %ACS_AUTOPLAY !!

          CALLBACK FUNCTION MainCallBackProc()
          SELECT CASE CBMSG
          CASE %WM_INITDIALOG
          CONTROL SHOW STATE ghDlg, %IDC_SYSANIMATE32_1, %SW_HIDE
          CASE %WM_COMMAND
          SELECT CASE CBCTL
          CASE %IDC_Show_Cmd
          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
          CONTROL SHOW STATE ghDlg, %IDC_SYSANIMATE32_1, %SW_SHOW
          END IF
          END SELECT
          SELECT CASE CBCTL
          CASE %IDC_Start_Cmd
          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
          'these dont work
          CONTROL SHOW STATE ghDlg, %IDC_SYSANIMATE32_1, %ACM_PLAY OR %ACN_START
          Call Animate_Play(%IDC_SYSANIMATE32_1,"#" + FORMAT$(%IDR_AVI1))
          CALL Animate_Play(%IDC_SYSANIMATE32_1,"cogs2.avi")
          Animate_Play(%IDC_SYSANIMATE32_1, 1, 99, 1)
          DIALOG SEND ghDlg, %WM_SYSCOMMAND, %ACN_START, 0
          END IF
          END SELECT
          SELECT CASE CBCTL
          CASE %IDC_Stop_Cmd
          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
          'if it starts then I would stop it here
          CONTROL SHOW STATE ghDlg, %IDC_SYSANIMATE32_1, %ACM_STOP OR %ACN_STOP
          END IF
          END SELECT
          SELECT CASE CBCTL
          CASE %IDC_Hide_Cmd
          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
          CONTROL SHOW STATE ghDlg, %IDC_SYSANIMATE32_1, %SW_HIDE
          END IF
          END SELECT


          ------------------
          slowbob
          slowbob

          Comment


          • #6
            Bob,

            You are using the messages incorrectly. Try this...

            Sorry for the long example, only had 5 minutes, so used QTAB to generate the code.
            Rats, that was all the spare time I had too...

            HTH
            Regards,
            Jules

            [CODE]
            //////////////////////////////////////////////////////////////////////////////
            // PROJECT: Quick Tab Visual Designer generated code. Save as *.rc
            // FILE: Your file name
            // CREATED: On 09-05-2003 at 18:14:45
            ///////////////////////////////////////////////////////////////////////////////

            #include "resource.h"

            //---Constants...
            #define IMAGEAVI1 200

            //---Tab Page 1 images
            IMAGEAVI1 AVI DISCARDABLE "C:\\Projects\\QuickTab\\FileCopy.avi"
            [code]

            Example...

            Code:
            '******************************************************************************
            ' PROJECT: Quick Tab Visual Designer DDT generated code.
            ' FILE:    Your file name
            ' CREATED: On 09-05-2003 at 18:14:34
            '******************************************************************************
             
            #COMPILE  EXE
            #INCLUDE  "WIN32API.INC"
            #INCLUDE  "COMMCTRL.INC"
            #RESOURCE "ANIMATE.PBR"
             
            '---Main Tab Identifiers
            %IDTAB_MAIN      = 100
            %IDTAB_PAGE_1    = 101
            %IDC_OK          = 102
            %IDC_CANCEL      = 103
            %IDC_APPLY       = 104
             
            '---Resource image identifiers
            %IMAGEAVI1   = 200
             
            '---Page 1 control identifiers
            %IDC_ANIMATE_1 = 4000
            %IDC_BUTTON_1  = 4001
            %IDC_BUTTON_2  = 4002
            %IDC_BUTTON_3  = 4003
            %IDC_BUTTON_4  = 4004
             
            '---Declares
            DECLARE FUNCTION CreateMainDialog(BYVAL hParent AS LONG) AS LONG
            DECLARE FUNCTION CreateMainTabControl(BYVAL hDlg AS LONG) AS LONG
            DECLARE FUNCTION CreateDialogTabPage1(BYVAL hParent AS LONG) AS LONG
            DECLARE CALLBACK FUNCTION MainDialogProc()
            DECLARE CALLBACK FUNCTION TabPageDlgProc1()
            DECLARE FUNCTION EnumCharSet(elf AS ENUMLOGFONT,ntm AS NEWTEXTMETRIC,BYVAL FontType AS LONG,CharSet AS LONG) AS LONG
            DECLARE FUNCTION MakeFontEx(BYVAL sFont AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
                BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG, BYVAL StrikeThru AS LONG) AS LONG
            DECLARE SUB CreateMainDlgButtons(BYVAL hDlg AS LONG)
            DECLARE SUB DeleteControlFont(BYVAL hDlg AS LONG)
            DECLARE SUB SetCtlTooltip(BYVAL hCtl AS LONG,sText AS STRING)
            DECLARE SUB SetTabPageRectDDT(BYVAL hDlg AS LONG,rcRet AS RECT)
             
            '---Globals
            GLOBAL ghTab() AS LONG  'keep handles for each tab page
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            FUNCTION PBMAIN()
             
                LOCAL ticc AS INIT_COMMON_CONTROLSEX
             
                'Load the common controls library...
                ticc.dwSize = SIZEOF(ticc)
                ticc.dwICC = %ICC_WIN95_CLASSES OR %ICC_INTERNET_CLASSES OR %ICC_DATE_CLASSES
                CALL InitCommonControlsEx(ticc)
             
                CALL CreateMainDialog(%HWND_DESKTOP)
             
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            FUNCTION CreateMainDialog(BYVAL hParent AS LONG) AS LONG
             
                LOCAL lRslt AS LONG,hDlg AS LONG,hFont AS LONG
                LOCAL hIcon AS LONG,rc AS RECT
             
                CALL SetRect(rc,50,50,308,155)
             
                DIALOG NEW hParent, "Your Caption",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom, _
                    %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR _
                    %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
                    %WS_SYSMENU OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_3DLOOK, _
                    %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT, TO hDlg
             
                hFont = MakeFontEx("MS Sans Serif",8,400,0,0,0)
                DIALOG SEND hDlg, %WM_SETFONT, hFont, 0
             
                'load a system icon...
                hIcon = LoadIcon(%NULL,BYVAL %IDI_APPLICATION)
                CALL SetClassLong(hDlg,%GCL_HICON,hIcon)
             
                DIALOG SHOW MODAL hDlg, CALL MainDialogProc TO lRslt
             
                DeleteObject hFont
             
                FUNCTION = lRslt
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            CALLBACK FUNCTION MainDialogProc()
             
                LOCAL pNMHDR AS NMHDR PTR, PageNo AS LONG, hFontTab AS LONG
             
                SELECT CASE (CBMSG)
             
                    CASE %WM_INITDIALOG
                        'add the main tab control and tab pages...
                        DIM ghTab(0) AS GLOBAL LONG
                        CALL CreateMainTabControl(CBHNDL)
                        CALL CreateMainDlgButtons(CBHNDL)
                        CALL SetWindowPos(GetDlgItem(CBHNDL,%IDTAB_MAIN),%HWND_BOTTOM, _
                                 0,0,0,0,%SWP_NOMOVE OR %SWP_NOSIZE)
             
                    CASE %WM_COMMAND
                        SELECT CASE LOWRD(CBWPARAM)
                            CASE %IDC_OK
                                IF HIWRD(CBWPARAM) = %BN_CLICKED THEN
                                    DIALOG END CBHNDL
                                END IF
                            CASE %IDC_CANCEL,%IDCANCEL
                                IF HIWRD(CBWPARAM) = %BN_CLICKED THEN
                                    DIALOG END CBHNDL
                                END IF
                            CASE %IDC_APPLY
                                IF HIWRD(CBHNDL) = %BN_CLICKED THEN
                                    '
                                END IF
                        END SELECT
             
                    CASE %WM_NOTIFY
                        pNMHDR = CBLPARAM
                        IF @pNMHDR.hWndFrom = GetDlgItem(CBHNDL,%IDTAB_MAIN) THEN
                            SELECT CASE @pNMHDR.Code
                                CASE %TCN_SELCHANGING
                                    CONTROL SEND CBHNDL,%IDTAB_MAIN,%TCM_GETCURSEL,0,0 TO PageNo
                                    DIALOG SHOW STATE ghTab(PageNo),%SW_HIDE
                                CASE %TCN_SELCHANGE
                                    CONTROL SEND CBHNDL,%IDTAB_MAIN,%TCM_GETCURSEL,0,0 TO PageNo
                                    DIALOG SHOW STATE ghTab(PageNo),%SW_SHOW
                            END SELECT
                        END IF
             
                    CASE %WM_DESTROY
                        'destroy the tab control font...
                        CONTROL SEND CBHNDL,%IDTAB_MAIN,%WM_GETFONT,0,0 TO hFontTab
                        IF ISTRUE(hFontTab) THEN CALL DeleteObject(hFontTab)
             
                END SELECT
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            FUNCTION CreateDialogTabPage1(BYVAL hParent AS LONG) AS LONG
             
                LOCAL hDlg AS LONG,hFont AS LONG,rc AS RECT,sText AS STRING,lRslt AS LONG
                LOCAL Style AS DWORD,StyleEx AS DWORD,szCaption AS ASCIIZ*255
             
                DIALOG NEW hParent,"TabPage1",0,0,0,0,%WS_CHILD OR %DS_CONTROL _
                    OR %WS_CLIPSIBLINGS OR %DS_NOFAILCREATE OR %DS_SETFONT,0,TO hDlg
             
                '---
                szCaption = "Show"
                CALL SetRect(rc,36,20,50,15)
                Style   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                          %WS_VISIBLE OR %BS_PUSHBUTTON
                StyleEx = 0
                CONTROL ADD BUTTON,hDlg,%IDC_BUTTON_1,szCaption, _
                    rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,Style,StyleEx
                '---
                szCaption = "Hide"
                CALL SetRect(rc,36,40,50,15)
                Style   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                          %WS_VISIBLE OR %BS_PUSHBUTTON
                StyleEx = 0
                CONTROL ADD BUTTON,hDlg,%IDC_BUTTON_2,szCaption, _
                    rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,Style,StyleEx
                '---
                szCaption = "Start"
                CALL SetRect(rc,36,60,50,15)
                Style   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                          %WS_VISIBLE OR %BS_PUSHBUTTON
                StyleEx = 0
                CONTROL ADD BUTTON,hDlg,%IDC_BUTTON_3,szCaption, _
                    rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,Style,StyleEx
                '---
                szCaption = "Stop"
                CALL SetRect(rc,36,80,50,15)
                Style   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                          %WS_VISIBLE OR %BS_PUSHBUTTON
                StyleEx = 0
                CONTROL ADD BUTTON,hDlg,%IDC_BUTTON_4,szCaption, _
                    rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,Style,StyleEx
                '---
                szCaption = "#"+FORMAT$(%IMAGEAVI1)
                CALL SetRect(rc,108,40,172,30)
                Style   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
                          %ACS_CENTER OR %ACS_TRANSPARENT 'OR %ACS_AUTOPLAY
                StyleEx = 0
                CONTROL ADD "SysAnimate32",hDlg,%IDC_ANIMATE_1,szCaption, _
                    rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,Style,StyleEx
             
                ghTab(0) = hDlg
             
                CONTROL SHOW STATE hDlg, %IDC_ANIMATE_1, %SW_HIDE
                CONTROL DISABLE  hDlg, %IDC_BUTTON_2
                CONTROL DISABLE  hDlg, %IDC_BUTTON_3
                CONTROL DISABLE  hDlg, %IDC_BUTTON_4
                                     
                DIALOG SHOW MODELESS hDlg, CALL TabPageDlgProc1 TO lRslt
                DIALOG SHOW STATE hDlg,%SW_HIDE
             
                FUNCTION = lRslt
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            CALLBACK FUNCTION TabPageDlgProc1()
             
                LOCAL ptnmhdr AS NMHDR PTR
             
                SELECT CASE CBMSG
             
                    CASE %WM_COMMAND
                        SELECT CASE CBCTL
                            CASE %IDC_BUTTON_1
                                IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                    CONTROL SHOW STATE CBHNDL, %IDC_ANIMATE_1, %SW_SHOW
                                    CONTROL DISABLE CBHNDL, %IDC_BUTTON_1
                                    CONTROL ENABLE  CBHNDL, %IDC_BUTTON_2
                                    CONTROL ENABLE  CBHNDL, %IDC_BUTTON_3
                                    CONTROL ENABLE  CBHNDL, %IDC_BUTTON_4
                                END IF
                            CASE %IDC_BUTTON_2
                                IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                    CONTROL SEND CBHNDL, %IDC_ANIMATE_1, %ACM_STOP, 0, 0
                                    CONTROL SHOW STATE CBHNDL, %IDC_ANIMATE_1, %SW_HIDE
                                    CONTROL ENABLE CBHNDL, %IDC_BUTTON_1
                                    CONTROL DISABLE  CBHNDL, %IDC_BUTTON_2
                                    CONTROL DISABLE  CBHNDL, %IDC_BUTTON_3
                                    CONTROL DISABLE  CBHNDL, %IDC_BUTTON_4
                                END IF
                            CASE %IDC_BUTTON_3
                                IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                   CONTROL SEND CBHNDL, %IDC_ANIMATE_1, %ACM_PLAY, -1, MAKLNG(0, -1)
                                END IF
                            CASE %IDC_BUTTON_4
                                IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                   CONTROL SEND CBHNDL, %IDC_ANIMATE_1, %ACM_STOP, 0, 0
                                END IF
                        END SELECT
             
                    CASE %WM_DESTROY
                        CALL DeleteControlFont(CBHNDL)
             
                END SELECT
             
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            FUNCTION CreateMainTabControl(BYVAL hDlg AS LONG) AS LONG
             
                LOCAL hFontTab AS LONG,i AS LONG,Style AS DWORD,StyleEx AS DWORD
                LOCAL rc AS RECT,rcm AS RECT,ttc_item AS TC_ITEM,szItem AS ASCIIZ*255
             
                'position tab within the main window...
                DIALOG GET CLIENT hDlg TO rcm.nRight,rcm.nBottom
                CALL SetRect(rc,2,2,rcm.nRight-4,rcm.nBottom-24)
             
                Style = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
                        %TCS_TABS OR %TCS_SINGLELINE OR %TCS_FOCUSONBUTTONDOWN
                StyleEx = 0
                CONTROL ADD "SysTabControl32",hDlg,%IDTAB_MAIN,"", _
                    rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,Style,StyleEx
             
                hFontTab = MakeFontEx("MS Sans Serif",8,0,0,0,0)
                CONTROL SEND hDlg,%IDTAB_MAIN,%WM_SETFONT,hFontTab,%TRUE
             
                'Insert tabs in the tab control...
                DIM sText(0) AS STRING
                sText(0) = "Animation"
             
                FOR i = 0 TO 0
                    szItem              = sText(i)
                    ttc_item.mask       = %TCIF_TEXT
                    ttc_item.pszText    = VARPTR(szItem)
                    ttc_item.cchTextMax = LEN(szItem)
                    ttc_item.iImage     = -1
                    ttc_item.lParam     = 0
                    CONTROL SEND hDlg,%IDTAB_MAIN,%TCM_INSERTITEM,i,VARPTR(ttc_item)
                NEXT
             
                'create the tab pages...
                CALL CreateDialogTabPage1(hDlg)
             
                'allow the tab pages to fit evenly within the tab control...
                CALL SetTabPageRectDDT(hDlg,BYVAL VARPTR(rc))
                FOR i = 0 TO UBOUND(ghTab)
                    DIALOG SET LOC ghTab(i),rc.nLeft,rc.nTop
                    DIALOG SET SIZE ghTab(i),rc.nRight,rc.nBottom
                NEXT
             
                'only show the first dialog on tab 1...
                DIALOG SHOW STATE ghTab(0),%SW_SHOW
             
                FUNCTION = GetDlgItem(hDlg,%IDTAB_MAIN)
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '  ** Helper routines **
            '------------------------------------------------------------------------------
            SUB CreateMainDlgButtons(BYVAL hDlg AS LONG)
             
                'add buttons to the main dialog...
                LOCAL rc AS RECT, rcm AS RECT
                LOCAL cap AS LONG, bor AS LONG,tm AS LONG,gap AS LONG
             
                DIALOG GET CLIENT hDlg TO rcm.nRight, rcm.nBottom
             
                cap = GetSystemMetrics(%SM_CYCAPTION) [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]IALOG PIXELS hDlg,cap,cap TO UNITS cap,cap
                bor = GetSystemMetrics(%SM_CXBORDER)  [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]IALOG PIXELS hDlg,bor,bor TO UNITS bor,bor
                tm  = 6  [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]IALOG PIXELS hDlg,tm,tm   TO UNITS tm,tm
                gap = 6  [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]IALOG PIXELS hDlg,gap,gap TO UNITS gap,gap
             
                CALL SetRect(rc,rcm.nRight+bor-tm-120-gap*2,rcm.nBottom-cap-6,40,15)
                CONTROL ADD BUTTON,hDlg,%IDC_OK,"&OK",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom
                CALL SetRect(rc,rcm.nRight+bor-tm-80-gap,rcm.nBottom-cap-6,40,15)
                CONTROL ADD BUTTON,hDlg,%IDC_CANCEL,"&Cancel",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom
                CALL SetRect(rc,rcm.nRight+bor-tm-40,rcm.nBottom-cap-6,40,15)
                CONTROL ADD BUTTON,hDlg,%IDC_APPLY,"&Apply",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom
             
            END SUB
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            SUB SetTabPageRectDDT(BYVAL hDlg AS LONG,rcRet AS RECT)
             
                LOCAL tRect AS RECT,twRect AS RECT,pRect AS RECT,hTab AS LONG
                LOCAL b AS LONG,l AS LONG,r AS LONG,t AS LONG
                LOCAL lb AS LONG,tb AS LONG,c AS LONG,f AS LONG,tm AS LONG
             
                hTab = GetDlgItem(hDlg,%IDTAB_MAIN)
             
                CALL GetWindowRect(hTab,twRect)
                CALL GetWindowRect(GetParent(hTab),pRect)
             
                lb = twRect.nLeft-pRect.nLeft
                tb = twRect.nTop-pRect.nTop
                c  = GetSystemMetrics(%SM_CYCAPTION)
                f  = GetSystemMetrics(%SM_CXBORDER)
             
                CONTROL SEND hDlg,%IDTAB_MAIN,%TCM_GETITEMRECT,0,VARPTR(tRect)
             
                tm = 4
                l  = lb-2*f+tm
                t  = tb-c-f+tRect.nBottom+tm
                r  = twRect.nRight-twRect.nLeft-4*f-2*tm
                b  = twRect.nBottom-twRect.nTop-tRect.nBottom-4*f-2*tm
             
                CALL SetRect(rcRet,l,t,r,b)
             
                DIALOG PIXELS GetParent(hTab),rcRet.nLeft,rcRet.nTop TO UNITS rcRet.nLeft,rcRet.nTop
                DIALOG PIXELS GetParent(hTab),rcRet.nRight,rcRet.nBottom TO UNITS rcRet.nRight,rcRet.nBottom
             
            END SUB
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            SUB DeleteControlFont(BYVAL hDlg AS LONG)
             
                LOCAL hCtlChild AS LONG, hFontCtl AS LONG
             
                hCtlChild = GetWindow(hDlg,%GW_CHILD)
                hFontCtl = SendMessage(hCtlChild,%WM_GETFONT,0,0)
                IF ISTRUE(hFontCtl) THEN DeleteObject hFontCtl
                WHILE hCtlChild
                    hFontCtl = SendMessage(hCtlChild,%WM_GETFONT,0,0)
                    IF ISTRUE(hFontCtl) THEN DeleteObject hFontCtl
                    hCtlChild = GetWindow(hCtlChild, %GW_HWNDNEXT)
                WEND
             
            END SUB
             
            '------------------------------------------------------------------------------
            ' Get type of character set - ansi, symbol... a must for some fonts.
            '------------------------------------------------------------------------------
            FUNCTION EnumCharSet(elf AS ENUMLOGFONT,ntm AS NEWTEXTMETRIC,BYVAL FontType AS LONG,CharSet AS LONG) AS LONG
                CharSet = elf.elfLogFont.lfCharSet
            END FUNCTION
            '------------------------------------------------------------------------------
            ' Create a desirable font and return its handle.
            ' Enhanced with proper enumeration of character set via EnumCharSet.
            ' Original code by Dave Navarro, Enhancement by Borje Hagsten.
            '------------------------------------------------------------------------------
            FUNCTION MakeFontEx(BYVAL sFont AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
                                BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG, BYVAL StrikeThru AS LONG) AS LONG
             
                LOCAL hDC AS LONG, CharSet AS LONG, CyPixels AS LONG
             
                hDC = GetDC(%HWND_DESKTOP)
                    CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
                    EnumFontFamilies hDC, BYVAL STRPTR(sFont), CODEPTR(EnumCharSet), BYVAL VARPTR(CharSet)
                ReleaseDC %HWND_DESKTOP, hDC
             
                PointSize = 0 - (PointSize * CyPixels) \ 72
             
                FUNCTION = CreateFont(PointSize,0,0,0, fBold, _
                                      fItalic,fUnderline,StrikeThru,CharSet, _
                                      %OUT_TT_PRECIS,%CLIP_DEFAULT_PRECIS, _
                                      %DEFAULT_QUALITY,%FF_DONTCARE, _
                                      BYCOPY sFont)
             
            END FUNCTION
             
            '------------------------------------------------------------------------------
            '
            '------------------------------------------------------------------------------
            SUB SetCtlTooltip(BYVAL hCtl AS LONG,sText AS STRING)
             
                STATIC hTooltip AS LONG,hInst AS LONG
                LOCAL ti AS TOOLINFO,szText AS ASCIIZ*255
             
                hInst = GetModuleHandle(BYVAL %NULL)
             
                IF hTooltip  = 0 THEN
                    hToolTip = CreateWindowEx(0,"tooltips_class32","",%TTS_ALWAYSTIP, _
                                              0,0,0,0,0,BYVAL %NULL,hInst,BYVAL %NULL)
                END IF
             
                IF hTooltip THEN
                    szText      = sText
                    ti.cbSize   = LEN(ti)
                    ti.uFlags   = %TTF_SUBCLASS OR %TTF_IDISHWND
                    ti.hWnd     = GetParent(hCtl)
                    ti.uId      = hCtl
                    ti.lpszText = VARPTR(szText)
                    CALL SendMessage(hToolTip,%TTM_ADDTOOL,0,BYVAL VARPTR(ti))
                END IF
             
            END SUB
            Best regards
            Jules
            www.rpmarchildon.com

            Comment


            • #7
              George,

              If you want you could use a WinLIFT animated bitmap.
              Sic:
              FUNCTION skAnimate(BYVAL hParent&, BYVAL hBitmap&, BYVAL x&, BYVAL y&)AS LONG


              ------------------
              Patrice Terrier
              mailto[email protected][email protected]</A>
              http://www.zapsolution.com
              Toolkit: WinLIFT (Skin Engine), GDI+ helper (Graphic package), dvBTree (Index manager)
              Freeware: ZAP Audio Player, ZAP Picture Browser.
              Artwork on demand.
              Patrice Terrier
              www.zapsolution.com
              www.objreader.com
              Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

              Comment


              • #8
                If you want you could use a WinLIFT animated bitmap...
                Brings to mind a related question: How/where does one create/purchase animated bitmaps?

                Are there special 'create animated bitmap' software tools, like "super-paint?" Or are you supposed to create animations the same way you'd create a movie, as a series of 'still' pictures displayed rapidly in sequence? Can you buy a CD full of 'animations' the same as you can by a CD full of "stock clip art?" Do I need to locate a graphic artist with the right tools?

                I have recently been doing some work with 'really large' inputs and an animation might be a nice alternative to a progress bar. I'd like to at least see what it might look like.

                MCM
                mailto:[email protected][email protected]</A>
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  MCM,

                  The picture.exe GDI+ demo that is provided togther with the WinLIFT trial version,
                  has a built-in function that allows you to turn any GIF animated file into a WinLIFT
                  animated bitmap.
                  You can see it as a kind of imagelist using the &hFF00FF color as the transparent
                  color.

                  You can use a WinLIFT animated bitmap with either the WinLIFT Standard version or the
                  new WinLIFT Simplified API.

                  ------------------
                  Patrice Terrier
                  mailto[email protected][email protected]</A>
                  http://www.zapsolution.com
                  Toolkit: WinLIFT (Skin Engine), GDI+ helper (Graphic package), dvBTree (Index manager)
                  Freeware: ZAP Audio Player, ZAP Picture Browser.
                  Artwork on demand.
                  Patrice Terrier
                  www.zapsolution.com
                  www.objreader.com
                  Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                  Comment


                  • #10
                    Thank you Jules Marchildon

                    Start stop animation now works ok.

                    I understand that some places you use the window dialog handle
                    and some places the CBHNDL handle
                    What I don't grasp is how you know which to use where?

                    CONTROL SHOW STATE ghDlg, %IDC_SYSANIMATE32_1, %SW_SHOW
                    CONTROL SHOW STATE CBHNDL, %IDC_SYSANIMATE32_1, %SW_SHOW

                    Quoting from PB help

                    CONTROL SHOW STATE hDlg, id&, showstate&
                    identified by the parent dialog handle hDlg, and control id& combination.

                    WindowHandle& = CBHNDL
                    In a Callback Function, return the window handle of the caller
                    CBHNDL can be used to make a clear distinction between each dialog.

                    Having only one dialog in the program shouldn't neccesatate a
                    differenciation between dialogs?



                    ------------------
                    slowbob
                    slowbob

                    Comment


                    • #11
                      Rereading my question even I don't understand it.
                      Trying again.

                      CONTROL SET COLOR ghDlg, %IDC_Status1, %RED, -1
                      CONTROL SET TEXT ghDlg, %IDC_Status1, "STOPP"
                      use the main window handle to change a control

                      CONTROL SEND CBHNDL, %IDC_SYSANIMATE32_1, %ACM_STOP, 0, 0
                      Uses the CBHNDLto change a control

                      How do I know when to use SET or SEND?

                      'create animated bitmap' software tools
                      Paintshop Pro with Animation Shop will make your designs quickly and easily.



                      ------------------
                      slowbob
                      slowbob

                      Comment


                      • #12
                        There are several ways to keep track of your window and control handles.

                        First to reduce the number of globals or static variables, you obtain
                        the window or control handle within a callback or window procedure by using
                        what DDT or SDK code provides. The necessary handles and ID's depend of course
                        on what message you are using, ie. a SDK or DDT. Both have their own set of
                        requirements. If a window handle or vise versa an ID is required and not
                        supplied withing the callback or window procedure, then you need to get it
                        else where. That's why you probably see a mix, if it was not available, then
                        I obtained from someplace else, either a global, or GetDlgItem() or control ID,
                        etc...

                        But for sure, it can get confusing to follow and maintain later. My QTAB example
                        above may not be the best example of perfect code.

                        When to use SET or SEND depends on the requirements of the message you are using.

                        For instance...

                        SDK API version SetWindowText() <- directly uses window/control handle
                        PB DDT version CONTROL SET TEXT ghDlg, %IDC_Status1, "STOPP"
                        <-also uses window/control handle, but is obtained by Parent
                        dialog handle and the controls ID, IOW GetDlgItem(ghDlg,%IDC_Status1)
                        acheives the same thing.

                        SDK API version, SendMessage GetDlgItem(CBHNDL,%IDC_SYSANIMATE32_1),%ACM_STOP,0,0
                        PB DDT version, CONTROL SEND CBHNDL, %IDC_SYSANIMATE32_1, %ACM_STOP, 0, 0

                        You must follow the needs of the message itself, that determines if SET or SEND.

                        Not sure if this helps? Since my mind has not been programmatically excercised
                        for a long time, I have lots of cobwebs to clear out before I can be certain on this.

                        Best Regards,
                        Jules
                        Best regards
                        Jules
                        www.rpmarchildon.com

                        Comment


                        • #13
                          I wasn't refering specifically to your example but more to general concepts.
                          "You must follow the needs of the message itself, that determines if SET or SEND"
                          Isn't there some rules which indicates what the needs are?
                          Right now I must test the code, if it doesn't work try the other way.
                          This doesn't seem correct to me.
                          I does look somewhat like 'the more complex a control the greater
                          probabilty that you need the CBHNDL not the dialog handle.



                          ------------------
                          slowbob
                          slowbob

                          Comment


                          • #14
                            Originally posted by Bob Clarke:
                            ..
                            I does look somewhat like 'the more complex a control the greater
                            probabilty that you need the CBHNDL not the dialog handle.
                            Bob,
                            It might help to think of CBHNDL as a DDT 'Alias' for hDlg.
                            CBHNDL can only be use inside a CallBack Function - it is equal to
                            the handle of the calling dialog (same callback function
                            can be used by >1 dialog)

                            Regards Dave



                            ------------------
                            Rgds, Dave

                            Comment


                            • #15
                              Personally, I think it helps a lot to "translate" all these abbreviations
                              in head when one encounter them, like:

                              CBHNDL = CallBack Handle
                              CBCTLMSG = CallBack Control Message (from child control)
                              CBLPARAM = CallBack's Last Parameter
                              (I know - LONG parameter, but "last" tells me better in what order
                              wParam and lParam are placed..

                              Etc, etc. Similar with Windows API equates:

                              WS_SYSMENU = Window Style System Menu
                              WM_COMMAND = Window Message Command
                              ..

                              ------------------
                              http://www.tolkenxp.com/pb
                              Download: incLean, PBcodec, custom controls and code, etc.
                              Borje Hagsten - [email protected]

                              Comment


                              • #16
                                Originally posted by Borje Hagsten:
                                (I know - LONG parameter, but "last" tells me better in what order
                                wParam and lParam are placed..
                                wparam = wirst Param ?"



                                ------------------
                                You gotta run, and don't loop back.
                                You gotta run, and don't loop back.

                                Comment


                                • #17
                                  Thanks guys,
                                  That de-mystified things a bit.



                                  ------------------
                                  slowbob
                                  slowbob

                                  Comment

                                  Working...
                                  X