Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Power Basic

Страница: 1 |

 

  Вопрос: Как разместить ToolBar у нижней границы формы? Добавлено: 29.11.06 14:59  

Автор вопроса:  alex
В примере размещенном ниже, тулбар расположен в левой части формы, подскажите, как его разместить у нижней границы формы?


' First, eliminate some unnecessary macros in COMMCTRL.INC
'--------------------------------------------------------------------
 %NOANIMATE       = 1
 %NOBUTTON        = 1
 %NOCOMBO         = 1
 %NODATETIMEPICK  = 1
 %NODRAGLIST      = 1
 %NOEDIT          = 1
 %NOFLATSBAPIS    = 1
 %NOHEADER        = 1
 %NOHOTKEY        = 1
 %NOIMAGELIST     = 1
 %NOIPADDRESS     = 1
 %NOLIST          = 1
 %NOLISTVIEW      = 1
 %NOMONTHCAL      = 1
 %NONATIVEFONTCTL = 1
 %NOPAGESCROLLER  = 1
 %NOPROGRESS      = 1
 %NOREBAR         = 1
 %NOSTATUSBAR     = 1
 %NOTABCONTROL    = 1
' %NOTOOLBAR       = 1
 %NOTOOLTIPS      = 1
 %NOTRACKBAR      = 1
 %NOTREEVIEW      = 1
 %NOUPDOWN        = 1
'--------------------------------------------------------------------
#Compile Exe
#Include  "WIN32API.INC"
#Include  "COMMCTRL.INC"
'--------------------------------------------------------------------
%ID_NEW     = 101
%ID_OPEN    = 102
%ID_TOOL    = 103
%ID_TOOLBAR = 200
%ID_POPUPTB = 300
'--------------------------------------------------------------------
Global hDlg As Long, ghTBar As Long, ghPopupTBar As Long, gTBBRC As RECT
'--------------------------------------------------------------------
Declare CallBack Function DlgCallback

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Main procedure
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Function PBMain() As Long
  Local s As String, rc As RECT

  Dialog New %HWND_DESKTOP, "Vertical Toolbar demo",,, 320, 200, _
             %WS_OVERLAPPEDWINDOW To hDlg

  'no other controls here, so add a dummy control, to avoid first
  'button in toolbar from starting in rasied mode (DDT focus problem)
  Control Add Label, hDlg, -1, "", 0, 0, 0, 0

'-------------------------------------------------------------------
' Build simple toolbar
'-------------------------------------------------------------------
  Local icc As INIT_COMMON_CONTROLSEX
  Dim Tbb(5) As Local TBBUTTON

  icc.dwSize= SizeOf(icc)
  icc.dwIcc = %ICC_BAR_CLASSES
  InitCommonControlsEx icc     'initiate toolbar class

  Tbb(0).fsState = %TBSTATE_ENABLED : Tbb(0).fsStyle   = %TBSTYLE_BUTTON
  Tbb(0).iBitmap = %STD_FILENEW     : Tbb(0).idCommand = %ID_NEW   : Tbb(1).iString = 0
  Tbb(1).fsState = %TBSTATE_ENABLED : Tbb(1).fsStyle   = %TBSTYLE_BUTTON
  Tbb(1).iBitmap = %STD_FILEOPEN    : Tbb(1).idCommand = %ID_OPEN  : Tbb(1).iString = 1
  Tbb(2).fsState = %TBSTATE_ENABLED : Tbb(2).fsStyle   = %TBSTYLE_SEP
  Tbb(3).fsState = %TBSTATE_ENABLED : Tbb(3).fsStyle   = %TBSTYLE_CHECK
  Tbb(3).iBitmap = %STD_HELP        : Tbb(3).idCommand = %ID_TOOL : Tbb(3).iString = 2
  Tbb(4).fsState = %TBSTATE_ENABLED : Tbb(4).fsStyle   = %TBSTYLE_SEP
  Tbb(5).fsState = %TBSTATE_ENABLED : Tbb(5).fsStyle   = %TBSTYLE_BUTTON
  Tbb(5).iBitmap = %STD_DELETE      : Tbb(5).idCommand = %IDCANCEL : Tbb(5).iString = 3

  ghTBar = CreateToolbarEx(hDlg, %WS_CHILD Or %WS_VISIBLE Or %WS_THICKFRAME Or _
                                 %TBSTYLE_LIST Or %CCS_NORESIZE Or %CCS_NODIVIDER, _
                                 %ID_TOOLBAR, 26, %HINST_COMMCTRL, %IDB_STD_LARGE_COLOR, _
                                 tbb(0), 6, 0, 0, 0, 0, Len(TBBUTTON))

  Call SetWindowLong(ghTBar, %GWL_STYLE, _
                     GetWindowLong(ghTBar, %GWL_STYLE) Or %TBSTYLE_FLAT)     'set flat style

  s = "  &New " & $Nul & "  &Open " & $Nul & _
      "  &Popup  " & $Nul & "  &Close " & $Nul & $Nul                         'build textstring for buttons
  Control Send hDlg, %ID_TOOLBAR, %TB_ADDSTRING, 0, StrPtr(s)                'add text to buttons
  Control Send hDlg, %ID_TOOLBAR, %TB_SETROWS, MakLng(6, 0), VarPtr(gTBBRC)  'rc gets size of a button

'-------------------------------------------------------------------
' Build popup toolbar (non-visible at this stage)
' Here I borrow buttons from tbb array above, but should
' of course be own, uniqe ones. This is just a demo, so..
'-------------------------------------------------------------------
  ghPopupTBar = CreateToolbarEx(hDlg, %WS_CHILD Or %WS_THICKFRAME Or _
                                 %CCS_NORESIZE Or %CCS_NODIVIDER, _
                                 %ID_POPUPTB, 26, %HINST_COMMCTRL, %IDB_STD_LARGE_COLOR, _
                                 tbb(0), 2, 0, 0, 0, 0, Len(TBBUTTON))
  Call SetWindowLong(ghPopupTBar, %GWL_STYLE, _
       GetWindowLong(ghPopupTBar, %GWL_STYLE) Or %TBSTYLE_FLAT)  'set flat style

  Control Send hDlg, %ID_POPUPTB, %TB_GETITEMRECT, 0, VarPtr(rc) 'get size of first button
  SetWindowPos ghPopupTBar, 0, 0, 0, _                           'resize toolbar to buttons
                2 * rc.nRight + 7, _                             '2 buttons + some for edges
                rc.nBottom + 7, _
                %SWP_NOMOVE Or %SWP_NOZORDER
'-------------------------------------------------------------------

  Dialog Show Modal hDlg Call DlgCallback

End Function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Main Callback procedure
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
CallBack Function DlgCallback
   Select Case CbMsg
      Case %WM_INITDIALOG
         Local rc As RECT

      Case %WM_CTLCOLORDLG
         Function = GetSysColorBrush(%COLOR_3DSHADOW) 'set dialog color

      Case %WM_SIZE
         MoveWindow ghTBar, -2, -2, gTBBRC.nRight + 7, HiWrd(CbLParam) + 4, 0

      Case %WM_LBUTTONDOWN                     'mouse click anywhere in dialog
         If IsWindowVisible(ghPopupTBar) Then  'if popup is visible
            ShowWindow ghPopupTBar, %SW_HIDE   'hide it and..
            SendMessage ghTBar, %TB_CHECKBUTTON, %ID_TOOL, MakLng(0, 0) '.. pop up pressed button
         End If

      Case %WM_COMMAND
         Select Case LoWrd(CbWParam)
            Case %ID_NEW                                        'New clicked
               Beep : SendMessage CbHndl, %WM_LBUTTONDOWN, 0, 0 'pass on to %WM_LBUTTONDOWN

            Case %ID_OPEN                                       'Open clicked
               Beep : SendMessage CbHndl, %WM_LBUTTONDOWN, 0, 0 'pass on to %WM_LBUTTONDOWN

            Case %ID_TOOL
               If (GetKeyState(%VK_SPACE) And &H8000) Then      'trap and act on spacebar
                  SendMessage ghTBar, %TB_SETSTATE, %ID_TOOL, _
                              MakLng(%TBSTATE_CHECKED Or %TBSTATE_ENABLED, 0)
                  SetFocus ghPopupTBar
               End If

               If (SendMessage(ghTBar, %TB_GETSTATE, %ID_TOOL, 0) And %TBSTATE_CHECKED) Then
                  SendMessage ghTBar, %TB_GETITEMRECT, 3, VarPtr(rc)               'get button's position
                  SetWindowPos ghPopupTBar, 0, rc.nRight + 4, rc.nTop - 3, 0, 0, _ 'move popup there
                               %SWP_NOSIZE Or %SWP_NOZORDER
                  ShowWindow ghPopupTBar, %SW_SHOW                                 'and show it
               Else
                  SendMessage CbHndl, %WM_LBUTTONDOWN, 0, 0   'else, pass on to %WM_LBUTTONDOWN
               End If

            Case %IDCANCEL : Dialog End CbHndl
         End Select
   End Select
End Function

Ответить

  Ответы Всего ответов: 1  

Номер ответа: 1
Автор ответа:
 HACKER


 

Разработчик Offline Client

Вопросов: 236
Ответов: 8362
 Профиль | | #1 Добавлено: 30.11.06 22:25
  ghTBar = CreateToolbarEx(hDlg, %WS_CHILD Or %WS_VISIBLE Or %WS_THICKFRAME Or _
                                 %TBSTYLE_LIST Or %CCS_NORESIZE Or %CCS_NODIVIDER, _
                                 %ID_TOOLBAR, 26, %HINST_COMMCTRL, %IDB_STD_LARGE_COLOR, _
                                 tbb(0), 6, 0, 0, 0, 0, Len(TBBUTTON))

  Call SetWindowLong(ghTBar, %GWL_STYLE, _
                     GetWindowLong(ghTBar, %GWL_STYLE) Or %TBSTYLE_FLAT)     'set flat style


Ну где-то здесь какой-то флаг за это отвечает :) Шарить по мсдну в поисках нужной тебе константы что-то нет желания, попробуй сам :)

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам