Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Floating ToolBar Demo

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

  • Floating ToolBar Demo

    A floating toolbar demo using the PBDLL50 Skeleton.bas Template.

    The Challenge:
    Can anyone come up with additonal source for a dockable Toolbar?


    Have Fun! Regards, Jules

    Code:
    '**Modified for floating toolbar demo
    '  By Jules Marchildon, 99-10-04, Compiled with PBDLL50
    '  Note: Use Skeleton.RC/Skeleton.PBR from your sample directory.
                  
    '-------------------------------------------------------------------------------
    '
    '   SKELETON.BAS for 32-bit PB/DLL
    '   Copyright (c) 1997 by PowerBASIC, Inc.
    '
    '   A simple program skeleton
    '
    '-------------------------------------------------------------------------------
      
    ' ** Eliminate unnecessary macros
    %NOANIMATE    = 1
    %NODRAGLIST   = 1
    %NOHEADER     = 1
    %NOIMAGELIST  = 1
    %NOLISTVIEW   = 1
    %NOTABCONTROL = 1
    %NOTRACKBAR   = 1
    %NOTREEVIEW   = 1
    %NOUPDOWN     = 1
    
    '---
     
    $DIM ALL
    $COMPILE EXE
    $OPTION VERSION4
     
    $INCLUDE "WIN32API.INC"
    $INCLUDE "COMMCTRL.INC"
    $RESOURCE "SKELETON.PBR"
     
    DECLARE Function FloatProc(Byval hWnd as long,Byval Msg as long, _
                               Byval wParam as long,Byval lParam as long) as long
     
    '---
    
    %ID_TOOLBAR           = %WM_USER       + 1024
    %IDB_BUTTONS          = %ID_TOOLBAR    + 1
     
    '* FILE
    %IDM_NEW              = %WM_USER       + 2048    ' New File
    %IDM_OPEN             = %IDM_NEW       + 1       ' Open File
    %IDM_CLOSE            = %IDM_OPEN      + 1       ' Close
    %IDM_SAVE             = %IDM_CLOSE     + 1       ' Save
    %IDM_EXIT             = %IDM_SAVE      + 1       ' Exit
     
    '* EDIT
    %IDM_CUT              = %IDM_EXIT      + 1       ' Cut
    %IDM_COPY             = %IDM_CUT       + 1       ' Copy
    %IDM_PASTE            = %IDM_COPY      + 1       ' Paste
     
    '* HELP
    %IDM_HELP             = %IDM_PASTE     + 1       ' Help
    %IDM_ABOUT            = %IDM_HELP      + 1       ' About Program.Exe
    
    '---
     
    GLOBAL hInst       AS LONG
    GLOBAL hStatus     AS LONG
    GLOBAL hToolbar    AS LONG
    GLOBAL hWndTool    AS LONG
    GLOBAL hWndMain    AS LONG
    'GLOBAL hWnd       AS LONG
    GLOBAL lpToolTip   AS TOOLTIPTEXT PTR
    GLOBAL zText       AS ASCIIZ * 255
    'GLOBAL hBmp       AS LONG
    
    '---
     
    DECLARE SUB CenterWindow(BYVAL hWnd AS LONG)
     
    '------------------------------------------------------------------------------
    FUNCTION WinMain (BYVAL hInstance     AS LONG, _
                      BYVAL hPrevInstance AS LONG, _
                      lpCmdLine           AS ASCIIZ PTR, _
                      BYVAL iCmdShow      AS LONG) AS LONG
     
      LOCAL Msg         AS tagMsg
      LOCAL wndclass    AS WndClassEx
      LOCAL szClassName AS ASCIIZ * 80
      Local szChildName AS ASCIIZ * 80
      LOCAL hWnd        AS LONG
      LOCAL hMenu       AS LONG
     
      hInst                  = hInstance
     
      szClassName            = "MYPROGRAM32"
      wndclass.cbSize        = SIZEOF(WndClass)
      wndclass.style         = %CS_HREDRAW OR %CS_VREDRAW
      wndclass.lpfnWndProc   = CODEPTR( WndProc )
      wndclass.cbClsExtra    = 0
      wndclass.cbWndExtra    = 0
      wndclass.hInstance     = hInstance
      wndclass.hIcon         = LoadIcon( hInstance, "PROGRAM" )
      wndclass.hCursor       = LoadCursor( %NULL, BYVAL %IDC_ARROW )
      wndclass.hbrBackground = GetStockObject( %WHITE_BRUSH )
      wndclass.lpszMenuName  = %NULL
      wndclass.lpszClassName = VARPTR( szClassName )
      wndclass.hIconSm       = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
      RegisterClassEx wndclass
    
     
      '**Register Floating toolbar window
      szChildName            = "FLOATTOOLBAR"
      wndclass.cbSize        = SIZEOF(WndClass)
      wndclass.style         = %CS_HREDRAW OR %CS_VREDRAW
      wndclass.lpfnWndProc   = CODEPTR(FloatProc)
      wndclass.cbClsExtra    = 0
      wndclass.cbWndExtra    = 0
      wndclass.hInstance     = hInstance
      wndclass.hIcon         = LoadIcon(hInstance, "PROGRAM")
      wndclass.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
      wndclass.hbrBackground = GetStockObject(%WHITE_BRUSH)
      wndclass.lpszMenuName  = %NULL
      wndclass.lpszClassName = VARPTR(szChildName)
      wndclass.hIconSm       = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
      RegisterClassEx wndclass
    
     
    '---
      hMenu = LoadMenu(hInstance, "MAINMENU")
     
      ' Create a window using the registered class
      hWndMain = CreateWindow(szClassName, _               ' window class name
                              "Simple Program Skeleton", _ ' window caption
                              %WS_OVERLAPPEDWINDOW, _      ' window style
                              %CW_USEDEFAULT, _            ' initial x position
                              %CW_USEDEFAULT, _            ' initial y position
                              %CW_USEDEFAULT, _            ' initial x size
                              %CW_USEDEFAULT, _            ' initial y size
                              %HWND_DESKTOP, _             ' parent window handle
                              hMenu, _                     ' window menu handle
                              hInstance, _                 ' program instance handle
                              BYVAL %NULL)                 ' creation parameters
     
      ShowWindow hWndMain, iCmdShow
      UpdateWindow hWndMain
     
      WHILE GetMessage(Msg, %NULL, 0, 0)
        TranslateMessage Msg
        DispatchMessage Msg
      WEND
     
      FUNCTION = msg.wParam
     
    END FUNCTION  ' WinMain
      
    '------------------------------------------------------------------------------
    FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                      BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
     
      LOCAL tbab        AS TBADDBITMAP
      'LOCAL lpToolTip   AS TOOLTIPTEXT PTR
     
      'STATIC zText      AS ASCIIZ * 255
      STATIC hBmp       AS LONG
     
      SELECT CASE wMsg
     
        CASE %WM_CREATE
     
          ' Create a Foating toobar window
          hWndTool = CreateWindowEx( %WS_EX_TOOLWINDOW OR %WS_EX_WINDOWEDGE OR %WS_EX_TOPMOST, _
                                    "FLOATTOOLBAR", _
                                    "ToolBar",BYVAL %NULL, _
                                    500, 100, 68, 150,_
                                    hWndMain, BYVAL %NULL, hInst, BYVAL %NULL)
    
     
          ShowWindow hWndTool,%SW_SHOW
          UpdateWindow hWndTool
     
          DIM tbb(0 to 6) AS TBBUTTON
     
          InitCommonControls
     
          ' Fill the TBBUTTON array with button information
          tbb(0).iBitmap   = 0
          tbb(0).idCommand = %IDM_NEW
          tbb(0).fsState   = %TBSTATE_ENABLED
          tbb(0).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(0).dwData    = 0
          tbb(0).iString   = 0
     
          tbb(1).iBitmap   = 1
          tbb(1).idCommand = %IDM_OPEN
          tbb(1).fsState   = %TBSTATE_ENABLED
          tbb(1).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(1).dwData    = 0
          tbb(1).iString   = 0
     
          tbb(2).iBitmap   = 2
          tbb(2).idCommand = %IDM_SAVE
          tbb(2).fsState   = %TBSTATE_ENABLED
          tbb(2).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(2).dwData    = 0
          tbb(2).iString   = 0
     
          tbb(3).iBitmap   = 3    'currently no tooltip support
          tbb(3).idCommand = 0
          tbb(3).fsState   = %TBSTATE_ENABLED
          tbb(3).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(3).dwData    = 0
          tbb(3).iString   = 0
     
          tbb(4).iBitmap   = 4
          tbb(4).idCommand = %IDM_CUT
          tbb(4).fsState   = %TBSTATE_ENABLED
          tbb(4).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(4).dwData    = 0
          tbb(4).iString   = 0
     
          tbb(5).iBitmap   = 5
          tbb(5).idCommand = %IDM_COPY
          tbb(5).fsState   = %TBSTATE_ENABLED
          tbb(5).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(5).dwData    = 0
          tbb(5).iString   = 0
     
          tbb(6).iBitmap   = 6
          tbb(6).idCommand = %IDM_PASTE
          tbb(6).fsState   = %TBSTATE_ENABLED
          tbb(6).fsStyle   = %TBSTYLE_CHECKGROUP
          tbb(6).dwData    = 0
          tbb(6).iString   = 0
     
          hBmp = LoadBitmap(hInst, "TOOLBAR")
     
          ' Create the toolbar window
          hToolbar = CreateToolbarEx(hWndTool,%WS_CHILD _
                                     OR %WS_VISIBLE _
                                     OR %TBSTYLE_WRAPABLE  _
                                     OR %TBSTYLE_TOOLTIPS, _
                                     %ID_TOOLBAR, 21, %NULL, hBmp, _
                                     tbb(0), 7, 0, 0, 24, 24, _
                                     LEN(TBBUTTON))
     
          ' Display the toolbar
          SendMessage hToolbar, %TB_AUTOSIZE, 0, 0
          ShowWindow  hToolbar, %SW_SHOW
    
     
    
          ' Create the status bar window
          hStatus = CreateStatusWindow(%WS_CHILD OR %WS_BORDER OR %WS_VISIBLE OR %SBS_SIZEGRIP, _
                                       "", hWnd, 200)
     
    
          Function=0
          Exit Function
    
     
        CASE %WM_MENUSELECT
          LoadString hInst, wParam, zText, SIZEOF(zText)
          SendMessage hStatus, %WM_SETTEXT, 0, VARPTR(zText)
          FUNCTION = 0
          EXIT FUNCTION
     
        CASE %WM_MOUSEMOVE
          zText = "Mouse Position:" + STR$(LOWRD(lParam)) + ","+STR$(HIWRD(lParam))
          SendMessage hStatus, %WM_SETTEXT, 0, VARPTR(zText)
          FUNCTION = 0
          EXIT FUNCTION
     
        CASE %WM_SIZE
          SendMessage hStatus, wMsg, wParam, lParam
     
        CASE %WM_COMMAND
          SELECT CASE LOWRD(wParam)
     
            CASE %IDM_NEW
              MsgBox "NEW selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_OPEN
              MsgBox "OPEN selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_CLOSE
              MsgBox "CLOSE selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_SAVE
              MsgBox "SAVE selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_EXIT
              SendMessage hWnd, %WM_DESTROY, wParam, lParam
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_CUT
              MsgBox "CUT selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_COPY
              MsgBox "COPY selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_PASTE
              MsgBox "PASTE selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_HELP
              MsgBox "There is no help, we are all doomed!"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_ABOUT
              DialogBox hInst, "ABOUT", hWnd, CODEPTR(AboutProc)
              FUNCTION = 0
              EXIT FUNCTION
     
          END SELECT
     
        CASE %WM_PAINT
     
        CASE %WM_DESTROY
          DeleteObject hBmp
          PostQuitMessage 0
          FUNCTION = 0
          EXIT FUNCTION
     
      END SELECT
     
      FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
      
    END FUNCTION
      
    '------------------------------------------------------------------------------ 
    FUNCTION AboutProc(BYVAL hDlg AS LONG, BYVAL wMsg AS LONG, _
                       BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
     
      STATIC hTimer AS LONG
    
     
      SELECT CASE wMsg
     
        CASE %WM_INITDIALOG
          ' Time-out About box after 4 seconds
          hTimer = SetTimer(hDlg, BYVAL &H0000FEED, 4000, BYVAL %NULL)
     
        CASE %WM_TIMER
          SendMessage hDlg, %WM_COMMAND, %IDOK, %NULL
     
        CASE %WM_COMMAND
          SELECT CASE LOWRD(wParam)
     
            CASE %IDCANCEL
              KillTimer %NULL, hTimer
              EndDialog hDlg, 0
              FUNCTION = 1
     
            CASE %IDOK, 103
              KillTimer %NULL, hTimer
              EndDialog hDlg, 1
              FUNCTION = 1
     
          END SELECT
     
      END SELECT
     
    END FUNCTION
     
    '--------------------------------------------------------------------
    Function FloatProc(Byval hWnd as long,Byval Msg as long, _
                       Byval wParam as long,Byval lParam as long) as long
    
     
      SELECT CASE Msg
     
        CASE %WM_CREATE
    
     
       Function=0
       Exit Function
     
        'Replace MsgBox calls with SendMessage if toolbar is
        'duplicate of main menu. Or assign different ID's
        'for select case and add custom code.
        CASE %WM_COMMAND
          SELECT CASE LOWRD(wParam)
     
            CASE %IDM_NEW
              MsgBox "NEW selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_OPEN
              MsgBox "OPEN selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_CLOSE
              MsgBox "CLOSE selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_SAVE
              MsgBox "SAVE selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_EXIT
              SendMessage hWnd, %WM_DESTROY, wParam, lParam
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_CUT
              MsgBox "CUT selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_COPY
              MsgBox "COPY selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_PASTE
              MsgBox "PASTE selected"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_HELP
              MsgBox "There is no help, we are all doomed!"
              FUNCTION = 0
              EXIT FUNCTION
     
            CASE %IDM_ABOUT
              DialogBox hInst, "ABOUT", hWnd, CODEPTR(AboutProc)
              FUNCTION = 0
              EXIT FUNCTION
     
          END SELECT
     
       Case %WM_SIZE
     
       Function=0
       Exit Function
     
        CASE %WM_NOTIFY
          lpToolTip = lParam
          IF @lpToolTip.hdr.code = %TTN_NEEDTEXT THEN
            LoadString hInst, @lpToolTip.hdr.idFrom, zText, SIZEOF(zText)
            @lpToolTip.lpszText = VARPTR(zText)
          END IF
          FUNCTION = 0
          EXIT FUNCTION
     
    End Select
    Function = DefWindowProc(hWnd,Msg,wParam,lParam)
    End Function
    '---
    Best regards
    Jules
    www.rpmarchildon.com

  • #2
    Forgot one more style...

    Code:
    ' Create a Foating toobar window
          hWndTool = CreateWindowEx( %WS_EX_TOOLWINDOW OR %WS_EX_WINDOWEDGE OR %WS_EX_TOPMOST, _
                                    "FLOATTOOLBAR", _
                                    "ToolBar",%WS_SYSMENU, _
                                    500, 100, 68, 150,_
                                    hWndMain, BYVAL %NULL, hInst, BYVAL %NULL)
    Adding %WS_SYSMENU gives you the Close Button and Click right
    for the popup "system menu".

    Regards, Jules

    [This message has been edited by Jules Marchildon (edited October 05, 1999).]
    Best regards
    Jules
    www.rpmarchildon.com

    Comment


    • #3
      Just to let you know, I have almost completed the Docking Handler
      for a Child window and Floating toolbar. I have to figure out some
      math for positioning the toolbar/child to the client edges.
      Grade 3 math was the longest 3 years of my life!
      So be patient, I will post the source soon.

      Regards, Jules
      Best regards
      Jules
      www.rpmarchildon.com

      Comment


      • #4
        Jules,

        I'm trying to run this demo, but I keep getting Error 478,
        Resource File Error. The line indicated (in the demo code) is below the last line.
        I'm using PBDLL60, and I'm new at it. PB/DOS (and a little of PBDK) were my prior compilers.
        Can you give me any help?

        Thanks,
        Bill

        Comment


        • #5
          Ralph,
          Change the $RESOURCE line to this:
          $RESOURCE "C:\pbdll60\samples\skeleton\SKELETON.PBR"
          It just uses the skeleton samples resource file for the icons on the toolbar.

          Jules Very nice demo. Let me know when you get the Docking toolbar demo done.
          Kevin

          -------------
          mailto:[email protected][email protected]</A>


          Comment


          • #6
            Kevin, thanks for the reply to Ralph!

            I have not completed it yet. I left it at docking a toolbar and child
            window, doing it manually using a menu item. I need to add the code while
            the window is dragged to an edge to dock it using the mouse. Once I clean
            up my pet project, once again, I can get back at it.

            Thanks!
            Regards, Jules

            Added 10/22/2006 For reference: Docking window code.... http://www.powerbasic.com/files/pub/...ls/Dock-It.zip


            [This message has been edited by Jules Marchildon (edited October 22, 2006).]
            Best regards
            Jules
            www.rpmarchildon.com

            Comment


            • #7
              Updated to work with PBWIN 8.0+

              Code:
              '**Modified for floating toolbar demo
              '  By Jules Marchildon, 99-10-04, Compiled with PBDLL50
              '  Note: Use Skeleton.RC/Skeleton.PBR from your sample directory.
              
              '-------------------------------------------------------------------------------
              '
              '   SKELETON.BAS for 32-bit PB/DLL
              '   Copyright (c) 1997 by PowerBASIC, Inc.
              '
              '   A simple program skeleton
              '
              '-------------------------------------------------------------------------------
              
              ' ** Eliminate unnecessary macros
              %NOANIMATE    = 1
              %NODRAGLIST   = 1
              %NOHEADER     = 1
              %NOIMAGELIST  = 1
              %NOLISTVIEW   = 1
              %NOTABCONTROL = 1
              %NOTRACKBAR   = 1
              %NOTREEVIEW   = 1
              %NOUPDOWN     = 1
              
              '---
              
              #DIM ALL
              #COMPILE EXE
              #OPTION VERSION4
              
              #INCLUDE "WIN32API.INC"
              #INCLUDE "COMMCTRL.INC"
              #RESOURCE "SKELETON.PBR"
              
              DECLARE FUNCTION FloatProc(BYVAL hWnd AS LONG,BYVAL Msg AS LONG, _
                                         BYVAL wParam AS LONG,BYVAL lParam AS LONG) AS LONG
              
              '---
              
              %ID_TOOLBAR           = %WM_USER       + 1024
              %IDB_BUTTONS          = %ID_TOOLBAR    + 1
              
              '* FILE
              %IDM_NEW              = %WM_USER       + 2048    ' New File
              %IDM_OPEN             = %IDM_NEW       + 1       ' Open File
              %IDM_CLOSE            = %IDM_OPEN      + 1       ' Close
              %IDM_SAVE             = %IDM_CLOSE     + 1       ' Save
              %IDM_EXIT             = %IDM_SAVE      + 1       ' Exit
              
              '* EDIT
              %IDM_CUT              = %IDM_EXIT      + 1       ' Cut
              %IDM_COPY             = %IDM_CUT       + 1       ' Copy
              %IDM_PASTE            = %IDM_COPY      + 1       ' Paste
              
              '* HELP
              %IDM_HELP             = %IDM_PASTE     + 1       ' Help
              %IDM_ABOUT            = %IDM_HELP      + 1       ' About Program.Exe
              
              '---
              
              GLOBAL hInst       AS LONG
              GLOBAL hStatus     AS LONG
              GLOBAL hToolbar    AS LONG
              GLOBAL hWndTool    AS LONG
              GLOBAL hWndMain    AS LONG
              'GLOBAL hWnd       AS LONG
              GLOBAL lpToolTip   AS TOOLTIPTEXT PTR
              GLOBAL zText       AS ASCIIZ * 255
              'GLOBAL hBmp       AS LONG
              
              '---
              
              DECLARE SUB CenterWindow(BYVAL hWnd AS LONG)
              
              '------------------------------------------------------------------------------
              FUNCTION WINMAIN (BYVAL hInstance     AS LONG, _
                                BYVAL hPrevInstance AS LONG, _
                                BYVAL lpCmdLine     AS ASCIIZ PTR, _
                                BYVAL iCmdShow      AS LONG) AS LONG
              
                LOCAL Msg         AS tagMsg
                LOCAL wcex        AS WndClassEx
                LOCAL szClassName AS ASCIIZ * 80
                LOCAL szChildName AS ASCIIZ * 80
                LOCAL hWnd        AS LONG
                LOCAL hMenu       AS LONG
              
                hInst              = hInstance
              
                szClassName        = "MYPROGRAM32"
                wcex.cbSize        = SIZEOF(wcex)
                wcex.style         = %CS_HREDRAW OR %CS_VREDRAW
                wcex.lpfnWndProc   = CODEPTR( WndProc )
                wcex.cbClsExtra    = 0
                wcex.cbWndExtra    = 0
                wcex.hInstance     = hInstance
                wcex.hIcon         = LoadIcon( hInstance, "PROGRAM" )
                wcex.hCursor       = LoadCursor( %NULL, BYVAL %IDC_ARROW )
                wcex.hbrBackground = GetStockObject( %WHITE_BRUSH )
                wcex.lpszMenuName  = %NULL
                wcex.lpszClassName = VARPTR( szClassName )
                wcex.hIconSm       = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
                RegisterClassEx wcex
              
              
                '**Register Floating toolbar window
                szChildName        = "FLOATTOOLBAR"
                wcex.cbSize        = SIZEOF(wcex)
                wcex.style         = %CS_HREDRAW OR %CS_VREDRAW
                wcex.lpfnWndProc   = CODEPTR(FloatProc)
                wcex.cbClsExtra    = 0
                wcex.cbWndExtra    = 0
                wcex.hInstance     = hInstance
                wcex.hIcon         = LoadIcon(hInstance, "PROGRAM")
                wcex.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
                wcex.hbrBackground = GetStockObject(%WHITE_BRUSH)
                wcex.lpszMenuName  = %NULL
                wcex.lpszClassName = VARPTR(szChildName)
                wcex.hIconSm       = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
                RegisterClassEx wcex
              
              
              '---
                hMenu = LoadMenu(hInstance, "MAINMENU")
              
                ' Create a window using the registered class
                hWndMain = CreateWindow(szClassName, _               ' window class name
                                        "Simple Program Skeleton", _ ' window caption
                                        %WS_OVERLAPPEDWINDOW, _      ' window style
                                        %CW_USEDEFAULT, _            ' initial x position
                                        %CW_USEDEFAULT, _            ' initial y position
                                        %CW_USEDEFAULT, _            ' initial x size
                                        %CW_USEDEFAULT, _            ' initial y size
                                        %HWND_DESKTOP, _             ' parent window handle
                                        hMenu, _                     ' window menu handle
                                        hInstance, _                 ' program instance handle
                                        BYVAL %NULL)                 ' creation parameters
              
                ShowWindow hWndMain, iCmdShow
                UpdateWindow hWndMain
              
                WHILE GetMessage(Msg, %NULL, 0, 0)
                  TranslateMessage Msg
                  DispatchMessage Msg
                WEND
              
                FUNCTION = msg.wParam
              
              END FUNCTION  ' WinMain
              
              '------------------------------------------------------------------------------
              FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                                BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
              
                LOCAL tbab        AS TBADDBITMAP
                'LOCAL lpToolTip   AS TOOLTIPTEXT PTR
              
                'STATIC zText      AS ASCIIZ * 255
                STATIC hBmp       AS LONG
              
                SELECT CASE wMsg
              
                  CASE %WM_CREATE
              
                    ' Create a Foating toobar window
                    hWndTool = CreateWindowEx( %WS_EX_TOOLWINDOW OR %WS_EX_WINDOWEDGE OR %WS_EX_TOPMOST, _
                                              "FLOATTOOLBAR", _
                                              "ToolBar",BYVAL %NULL, _
                                              500, 100, 68, 150,_
                                              hWndMain, BYVAL %NULL, hInst, BYVAL %NULL)
              
                    ShowWindow hWndTool,%SW_SHOW
                    UpdateWindow hWndTool
              
                    DIM tbb(0 TO 6) AS TBBUTTON
              
                    InitCommonControls
              
                    ' Fill the TBBUTTON array with button information
                    tbb(0).iBitmap   = 0
                    tbb(0).idCommand = %IDM_NEW
                    tbb(0).fsState   = %TBSTATE_ENABLED
                    tbb(0).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(0).dwData    = 0
                    tbb(0).iString   = 0
              
                    tbb(1).iBitmap   = 1
                    tbb(1).idCommand = %IDM_OPEN
                    tbb(1).fsState   = %TBSTATE_ENABLED
                    tbb(1).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(1).dwData    = 0
                    tbb(1).iString   = 0
              
                    tbb(2).iBitmap   = 2
                    tbb(2).idCommand = %IDM_SAVE
                    tbb(2).fsState   = %TBSTATE_ENABLED
                    tbb(2).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(2).dwData    = 0
                    tbb(2).iString   = 0
              
                    tbb(3).iBitmap   = 3    'currently no tooltip support
                    tbb(3).idCommand = 0
                    tbb(3).fsState   = %TBSTATE_ENABLED
                    tbb(3).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(3).dwData    = 0
                    tbb(3).iString   = 0
              
                    tbb(4).iBitmap   = 4
                    tbb(4).idCommand = %IDM_CUT
                    tbb(4).fsState   = %TBSTATE_ENABLED
                    tbb(4).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(4).dwData    = 0
                    tbb(4).iString   = 0
              
                    tbb(5).iBitmap   = 5
                    tbb(5).idCommand = %IDM_COPY
                    tbb(5).fsState   = %TBSTATE_ENABLED
                    tbb(5).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(5).dwData    = 0
                    tbb(5).iString   = 0
              
                    tbb(6).iBitmap   = 6
                    tbb(6).idCommand = %IDM_PASTE
                    tbb(6).fsState   = %TBSTATE_ENABLED
                    tbb(6).fsStyle   = %TBSTYLE_CHECKGROUP
                    tbb(6).dwData    = 0
                    tbb(6).iString   = 0
              
                    hBmp = LoadBitmap(hInst, "TOOLBAR")
              
                    ' Create the toolbar window
                    hToolbar = CreateToolbarEx(hWndTool,%WS_CHILD _
                                               OR %WS_VISIBLE _
                                               OR %TBSTYLE_WRAPABLE  _
                                               OR %TBSTYLE_TOOLTIPS, _
                                               %ID_TOOLBAR, 21, %NULL, hBmp, _
                                               tbb(0), 7, 0, 0, 24, 24, _
                                               LEN(TBBUTTON))
              
                    ' Display the toolbar
                    SendMessage hToolbar, %TB_AUTOSIZE, 0, 0
                    ShowWindow  hToolbar, %SW_SHOW
              
              
                    ' Create the status bar window
                    hStatus = CreateStatusWindow(%WS_CHILD OR %WS_BORDER OR %WS_VISIBLE OR %SBS_SIZEGRIP, _
                                                 "", hWnd, 200)
              
              
                    FUNCTION=0
                    EXIT FUNCTION
              
              
                  CASE %WM_MENUSELECT
                    LoadString hInst, wParam, zText, SIZEOF(zText)
                    SendMessage hStatus, %WM_SETTEXT, 0, VARPTR(zText)
                    FUNCTION = 0
                    EXIT FUNCTION
              
                  CASE %WM_MOUSEMOVE
                    zText = "Mouse Position:" + STR$(LOWRD(lParam)) + ","+STR$(HIWRD(lParam))
                    SendMessage hStatus, %WM_SETTEXT, 0, VARPTR(zText)
                    FUNCTION = 0
                    EXIT FUNCTION
              
                  CASE %WM_SIZE
                    SendMessage hStatus, wMsg, wParam, lParam
              
                  CASE %WM_COMMAND
                    SELECT CASE LOWRD(wParam)
              
                      CASE %IDM_NEW
                        MSGBOX "NEW selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_OPEN
                        MSGBOX "OPEN selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_CLOSE
                        MSGBOX "CLOSE selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_SAVE
                        MSGBOX "SAVE selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_EXIT
                        SendMessage hWnd, %WM_DESTROY, wParam, lParam
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_CUT
                        MSGBOX "CUT selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_COPY
                        MSGBOX "COPY selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_PASTE
                        MSGBOX "PASTE selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_HELP
                        MSGBOX "There is no help, we are all doomed!"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_ABOUT
                        DialogBox hInst, "ABOUT", hWnd, CODEPTR(AboutProc)
                        FUNCTION = 0
                        EXIT FUNCTION
              
                    END SELECT
              
                  CASE %WM_PAINT
              
                  CASE %WM_DESTROY
                    DeleteObject hBmp
                    PostQuitMessage 0
                    FUNCTION = 0
                    EXIT FUNCTION
              
                END SELECT
              
                FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
              
              END FUNCTION
              
              '------------------------------------------------------------------------------
              FUNCTION AboutProc(BYVAL hDlg AS LONG, BYVAL wMsg AS LONG, _
                                 BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
              
                STATIC hTimer AS LONG
              
              
                SELECT CASE wMsg
              
                  CASE %WM_INITDIALOG
                    ' Time-out About box after 4 seconds
                    hTimer = SetTimer(hDlg, BYVAL &H0000FEED, 4000, BYVAL %NULL)
              
                  CASE %WM_TIMER
                    SendMessage hDlg, %WM_COMMAND, %IDOK, %NULL
              
                  CASE %WM_COMMAND
                    SELECT CASE LOWRD(wParam)
              
                      CASE %IDCANCEL
                        KillTimer %NULL, hTimer
                        EndDialog hDlg, 0
                        FUNCTION = 1
              
                      CASE %IDOK, 103
                        KillTimer %NULL, hTimer
                        EndDialog hDlg, 1
                        FUNCTION = 1
              
                    END SELECT
              
                END SELECT
              
              END FUNCTION
              
              '--------------------------------------------------------------------
              FUNCTION FloatProc(BYVAL hWnd AS LONG,BYVAL Msg AS LONG, _
                                 BYVAL wParam AS LONG,BYVAL lParam AS LONG) AS LONG
              
              
                SELECT CASE Msg
              
                  CASE %WM_CREATE
              
              
                 FUNCTION=0
                 EXIT FUNCTION
              
                  'Replace MsgBox calls with SendMessage if toolbar is
                  'duplicate of main menu. Or assign different ID's
                  'for select case and add custom code.
                  CASE %WM_COMMAND
                    SELECT CASE LOWRD(wParam)
              
                      CASE %IDM_NEW
                        MSGBOX "NEW selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_OPEN
                        MSGBOX "OPEN selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_CLOSE
                        MSGBOX "CLOSE selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_SAVE
                        MSGBOX "SAVE selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_EXIT
                        SendMessage hWnd, %WM_DESTROY, wParam, lParam
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_CUT
                        MSGBOX "CUT selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_COPY
                        MSGBOX "COPY selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_PASTE
                        MSGBOX "PASTE selected"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_HELP
                        MSGBOX "There is no help, we are all doomed!"
                        FUNCTION = 0
                        EXIT FUNCTION
              
                      CASE %IDM_ABOUT
                        DialogBox hInst, "ABOUT", hWnd, CODEPTR(AboutProc)
                        FUNCTION = 0
                        EXIT FUNCTION
              
                    END SELECT
              
                 CASE %WM_SIZE
              
                 FUNCTION=0
                 EXIT FUNCTION
              
                  CASE %WM_NOTIFY
                    lpToolTip = lParam
                    IF @lpToolTip.hdr.code = %TTN_NEEDTEXT THEN
                      LoadString hInst, @lpToolTip.hdr.idFrom, zText, SIZEOF(zText)
                      @lpToolTip.lpszText = VARPTR(zText)
                    END IF
                    FUNCTION = 0
                    EXIT FUNCTION
              
              END SELECT
              FUNCTION = DefWindowProc(hWnd,Msg,wParam,lParam)
              END FUNCTION

              ------------------
              Website: http://com.it-berater.org
              SED Editor, TypeLib Browser, COM Wrappers.
              Forum: http://www.forum.it-berater.org
              Forum: http://www.jose.it-berater.org/smfforum/index.php

              Comment

              Working...
              X