FreeBasic
Главная
Вход
Регистрация
Понедельник, 20.08.2018, 08:25Приветствую Вас Гость | RSS
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Форум » WinAPI » WinApi в freebasic » Использование ScrollBar в окне Static (Вопрос как заставить работать ScrollBar в панели на Static)
Использование ScrollBar в окне Static
miverДата: Среда, 12.12.2012, 18:23 | Сообщение # 1
Рядовой
Группа: Пользователи
Сообщений: 5
Репутация: 0
Статус: Offline
Изучаю Win Api. Пытаюсь сделать панель на основе статического элемента. Класс окна = "Static"
Включил для панели оба ScrollBar . Но они никак не реагируют на манипуляции мыши, похоже на неактивный ScrollBar
Если включить ScrollBar для Класс окна = "Edit", то все нормально
Можете рассказать почему так? И можно ли "активизировать" ScrollBar в окне с классом = "Static"
Внизу привел код программы для просмотра описанного
Code

'' Start
   #include once "windows.bi"

'' names of window classes.
   const WND_CLASS_NAME1 = "My_class1"

'' function prototypes.
   declare function message_loop as integer
   declare sub register_classes
   declare function WndProc1 (ByVal MainForm1 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   declare function WndProc4 (ByVal Panel4 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT

'' global data.
   Dim Shared hModule As HINSTANCE
   Dim Shared MainForm1 as HWND
   Dim shared Panel4 as HWND ' хэндл Panel
   Dim Shared OldWndProc_4 as Long
   Dim shared Label5 as HWND ' хэндл Label
   Dim shared Button6 as HWND ' хэндл Button
   Dim shared Edit7 as HWND ' хэндл Edit

'' main code.
   hModule=GetModuleHandle(NULL)
   register_classes
   MainForm1 = CreateWindowEx (NULL, WND_CLASS_NAME1, "Form", WS_VISIBLE Or WS_OVERLAPPEDWINDOW, 0, 0, 400, 419, NULL, NULL, hModule, NULL)
   ShowWindow(MainForm1, SW_SHOW)
   UpdateWindow(MainForm1)
  end message_loop
   
  ''message loop.
  Function message_loop as integer
   Dim wMsg as MSG
   Do 'цикл сообщений
    If PeekMessage( @wMsg, NULL, 0, 0, PM_REMOVE) <> 0 Then
     If wMsg.message = WM_QUIT Then Exit Do
     TranslateMessage( @wMsg )
     DispatchMessage( @wMsg )
    Else
     SleepEx(1,0)
    EndIf
   Loop
   return wMsg.wParam
  End Function
   
  ''' window procedure #1 ["Form"].
  Function WndProc1 (ByVal MainForm1 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   Function = 0
   Select case uMsg
    Case WM_CREATE
     'создаем Panel4
     Panel4 = CreateWindowEx (NULL, "Static", !"", WS_CHILD Or WS_VSCROLL Or WS_HSCROLL Or WS_DLGFRAME Or WS_VISIBLE, 30, 20, 331, 206, MainForm1, cptr(HMENU,4), hModule, NULL)
     SendMessage(Panel4 , WM_SETFONT, Cast(WPARAM, GetStockObject(ANSI_VAR_FONT)), 0)
     'Сабклассинг окна Panel4
     OldWndProc_4 = SetWindowLong(Panel4, GWL_WNDPROC, cPtr(Long, @WndProc4))
     WndProc4 (Panel4, uMsg, wParam, lParam)
     'создаем Edit7
     Edit7 = CreateWindowEx (WS_EX_CLIENTEDGE, "Edit", !"Edit", WS_CHILD Or WS_VSCROLL Or WS_HSCROLL Or WS_VISIBLE, 30, 240, 200, 90, MainForm1, cptr(HMENU,7), hModule, NULL)
     SendMessage(Edit7 , WM_SETFONT, Cast(WPARAM, GetStockObject(ANSI_VAR_FONT)), 0)
     
    Case WM_DESTROY
     PostQuitMessage(0)
     Exit function
   End select
   Function = DefWindowProc(MainForm1,uMsg,wParam,lParam) ' Дефултная функция обработки окна
  End Function
   
  ''' window procedure #4 [Panel4].
  Function WndProc4 (ByVal Panel4 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   Function = 0
   Select case uMsg
    Case WM_CREATE
     'создаем Label5
     Label5 = CreateWindowEx (NULL, "Static", !"Label", WS_CHILD Or WS_VISIBLE, 20, 20, 305, 20, Panel4, cptr(HMENU,5), hModule, NULL)
     SendMessage(Label5 , WM_SETFONT, Cast(WPARAM, GetStockObject(ANSI_VAR_FONT)), 0)
     'создаем Button6
     Button6 = CreateWindowEx (NULL, "Button", !"Push", WS_CHILD Or WS_VISIBLE, 15, 40, 55, 20, Panel4, cptr(HMENU,6), hModule, NULL)
     SendMessage(Button6 , WM_SETFONT, Cast(WPARAM, GetStockObject(ANSI_VAR_FONT)), 0)
     
    Case WM_COMMAND
     Select case loword(wParam)
      Case 6
       Select case hiword(wParam)
        Case BN_CLICKED
         'Событие onClick - Button6
         SetWindowText (Label5 , Str(25))
          
       End select
     End select
   End select
   Function = CallWindowproc (cPtr(WNDPROC, OldWndProc_4), Panel4, uMsg, wParam, lParam) ' Запускаем оригинальную процедуру окна
  End Function
   
  ''' register all the window classes.
  Sub register_classes  
   Dim wc as WNDCLASSEX
   with wc ' заполняем структуру wc
    .cbSize = SIZEOF( WNDCLASSEX ) ' размер структуры WNDCLASSEX
    .style = CS_BYTEALIGNCLIENT + CS_BYTEALIGNWINDOW + CS_DBLCLKS + CS_HREDRAW + CS_VREDRAW ' Стиль окна   
    .cbClsExtra = NULL ' резервирование дополнительных байт за концом структуры
    .cbWndExtra = NULL
    .hInstance = hModule ' хэндл модуля
    .hbrBackground = Cast(HBRUSH, COLOR_3DFACE + 1) ' Цвет фона
    .lpszMenuName = NULL ' Хэндл меню  
    .hIcon = LoadIcon( NULL,IDI_APPLICATION ) ' Хэндл иконки
    .hIconSm = .hIcon 'Хэндл маленькой иконки
    .hCursor = LoadCursor( NULL,IDC_ARROW) ' Хэндл курсора
   end with
   wc.lpfnWndProc   = @WndProc1
   wc.lpszClassName = strptr(WND_CLASS_NAME1)
   If(RegisterClassEx(@wc) = FALSE) then
    MessageBox(NULL,"Не могу зарегистрировать класс окна","Ошибка",MB_OK + MB_ICONSTOP + MB_TOPMOST)
    End 1
   End if
  End Sub
 
haavДата: Среда, 12.12.2012, 19:36 | Сообщение # 2
Генерал-полковник
Группа: Администраторы
Сообщений: 855
Репутация: 34
Статус: Offline
Для класса Edit реализовано разработчиками Microsoft. Для Static надо обработку делать самому. Вот пример от KetilO:

ScrollWin.bi:

Code

#Define IDD_DIALOG                        1000
#Define IDD_DLGCHILD                        1100

#Define IDM_MENU                    10000
#Define IDM_FILE_EXIT                10001
#Define IDM_HELP_ABOUT                10101

Dim Shared hInstance As HMODULE
Dim Shared CommandLine As ZString Ptr
Dim Shared hWnd As HWND
Dim Shared hCld As HWND

Const ClassName="DLGCLASS"
Const AppName="Dialog as main"
Const AboutMsg=!"FbEdit Dialog as main\13\10Copyright © FbEdit 2007"


ScrollWin.bas:

Code
#include once "windows.bi"
#Include Once "win/commctrl.bi"
#Include Once "win/commdlg.bi"
#Include Once "win/shellapi.bi"
#Include "ScrollWin.bi"

function ChildProc(byval hDlg as HWND,byval uMsg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as bool

    return FALSE

end function

Function WndProc(ByVal hWin As HWND,ByVal uMsg As UINT,ByVal wParam As WPARAM,ByVal lParam As LPARAM) As Integer
    Dim sinf As SCROLLINFO
    Dim nPos As Integer
    Dim fChanged As Boolean
    Dim rect As RECT
    Dim rect1 As RECT

    Select Case uMsg
       Case WM_INITDIALOG
          hWnd=hWin
          hCld=CreateDialogParam(hInstance,Cast(zstring ptr,IDD_DLGCHILD),hWin,@ChildProc,0)
          '
       Case WM_COMMAND
          Select Case HiWord(wParam)
             Case BN_CLICKED,1
                Select Case LoWord(wParam)
                   Case IDM_FILE_EXIT
                      SendMessage(hWin,WM_CLOSE,0,0)
                      '
                   Case IDM_HELP_ABOUT
                      ShellAbout(hWin,@AppName,@AboutMsg,NULL)
                      '
                End Select
                '
          End Select
          '
       Case WM_SIZE
          GetClientRect(hCld,@rect)
          sinf.cbSize=SizeOf(sinf)
          sinf.fMask=SIF_RANGE Or SIF_PAGE  
          sinf.nMin=0
          sinf.nMax=rect.bottom
          GetClientRect(hWin,@rect)
          sinf.nPage=rect.bottom
          SetScrollInfo(hWin,SB_VERT,@sinf,TRUE)
          GetClientRect(hCld,@rect)
          sinf.cbSize=SizeOf(sinf)
          sinf.fMask=SIF_RANGE Or SIF_PAGE
          sinf.nMin=0
          sinf.nMax=rect.right
          GetClientRect(hWin,@rect)
          sinf.nPage=rect.right
          SetScrollInfo(hWin,SB_HORZ,@sinf,TRUE)
          '
       Case WM_CLOSE
          DestroyWindow(hWin)
          '
       Case WM_DESTROY
          PostQuitMessage(NULL)
          '
       Case WM_VSCROLL
          sinf.cbSize=SizeOf(sinf)
          sinf.fMask=SIF_RANGE Or SIF_PAGE
          GetScrollInfo(hWin,SB_VERT,@sinf)
          Select Case LoWord(wParam)
             Case SB_THUMBPOSITION,SB_THUMBTRACK
                ' Get position
                nPos=HiWord(wParam)
                SetScrollPos(hWin,SB_VERT,nPos,TRUE)

                fChanged=TRUE
             Case SB_LINEDOWN
                nPos=GetScrollPos(hWin,SB_VERT)
                npos+=1
                SetScrollPos(hWin,SB_VERT,nPos,TRUE)
                fChanged=TRUE
             Case SB_LINEUP
                nPos=GetScrollPos(hWin,SB_VERT)
                npos-=1
                SetScrollPos(hWin,SB_VERT,nPos,TRUE)
                fChanged=TRUE
             Case SB_PAGEDOWN
                nPos=GetScrollPos(hWin,SB_VERT)
                npos+=sinf.nPage
                SetScrollPos(hWin,SB_VERT,nPos,TRUE)
                fChanged=TRUE
             Case SB_PAGEUP
                nPos=GetScrollPos(hWin,SB_VERT)
                npos-=sinf.nPage
                SetScrollPos(hWin,SB_VERT,nPos,TRUE)
                fChanged=TRUE
          End Select
          If fChanged Then
             GetWindowRect(hCld,@rect)
             ScreenToClient(hWin,Cast(Point Ptr,@rect.left))
             SetWindowPos(hCld,0,rect.left,-nPos,0,0,SWP_NOSIZE Or SWP_NOZORDER)
          EndIf
       Case WM_HSCROLL
          sinf.cbSize=SizeOf(sinf)
          sinf.fMask=SIF_RANGE Or SIF_PAGE
          GetScrollInfo(hWin,SB_HORZ,@sinf)
          Select Case LoWord(wParam)
             Case SB_THUMBPOSITION,SB_THUMBTRACK
                ' Get position
                nPos=HiWord(wParam)
                SetScrollPos(hWin,SB_HORZ,nPos,TRUE)
                fChanged=TRUE
             Case SB_LINEDOWN
                nPos=GetScrollPos(hWin,SB_HORZ)
                npos+=1
                SetScrollPos(hWin,SB_HORZ,nPos,TRUE)
                fChanged=TRUE
             Case SB_LINEUP
                nPos=GetScrollPos(hWin,SB_HORZ)
                npos-=1
                SetScrollPos(hWin,SB_HORZ,nPos,TRUE)
                fChanged=TRUE
             Case SB_PAGEDOWN
                nPos=GetScrollPos(hWin,SB_HORZ)
                npos+=sinf.nPage
                SetScrollPos(hWin,SB_HORZ,nPos,TRUE)
                fChanged=TRUE
             Case SB_PAGEUP
                nPos=GetScrollPos(hWin,SB_HORZ)
                npos-=sinf.nPage
                SetScrollPos(hWin,SB_HORZ,nPos,TRUE)
                fChanged=TRUE
          End Select
          If fChanged Then
             GetWindowRect(hCld,@rect)
             ScreenToClient(hWin,Cast(Point Ptr,@rect.left))
             SetWindowPos(hCld,0,-nPos,rect.top,0,0,SWP_NOSIZE Or SWP_NOZORDER)
          EndIf
       Case Else
          Return DefWindowProc(hWin,uMsg,wParam,lParam)
          '
    End Select
    Return 0

End Function

Function WinMain(ByVal hInst As HINSTANCE,ByVal hPrevInst As HINSTANCE,ByVal CmdLine As ZString ptr,ByVal CmdShow As Integer) As Integer
    Dim wc As WNDCLASSEX
    Dim msg As MSG

    ' Setup and register class for dialog
    wc.cbSize=SizeOf(WNDCLASSEX)
    wc.style=CS_HREDRAW or CS_VREDRAW
    wc.lpfnWndProc=@WndProc
    wc.cbClsExtra=0
    wc.cbWndExtra=DLGWINDOWEXTRA
    wc.hInstance=hInst
    wc.hbrBackground=Cast(HBRUSH,COLOR_BTNFACE+1)
    wc.lpszMenuName=Cast(ZString Ptr,IDM_MENU)
    wc.lpszClassName=@ClassName
    wc.hIcon=LoadIcon(NULL,IDI_APPLICATION)
    wc.hIconSm=wc.hIcon
    wc.hCursor=LoadCursor(NULL,IDC_ARROW)
    RegisterClassEx(@wc)
    ' Create and show the dialog
    CreateDialogParam(hInstance,Cast(ZString Ptr,IDD_DIALOG),NULL,@WndProc,NULL)
    ShowWindow(hWnd,SW_SHOWNORMAL)
    UpdateWindow(hWnd)
    ' Message loop
    Do While GetMessage(@msg,NULL,0,0)
       TranslateMessage(@msg)
       DispatchMessage(@msg)
    Loop
    Return msg.wParam

End Function

' Program start
hInstance=GetModuleHandle(NULL)
CommandLine=GetCommandLine
InitCommonControls
WinMain(hInstance,NULL,CommandLine,SW_SHOWDEFAULT)
ExitProcess(0)


ScrollWin.rc:

Code
#define IDD_DIALOG 1000
#define IDR_MENU 10000
#define IDM_FILE_EXIT 10001
#define IDM_HELP_ABOUT 10101
#define IDD_DLGCHILD 1100
#define IDC_EDT1 1001
#define IDC_STC1 1002
#define IDC_BTN1 1003
IDD_DIALOG DIALOGEX 6,5,192,88
CAPTION "Dialog As Main"
FONT 8,"MS Sans Serif",0,0
CLASS "DLGCLASS"
MENU IDR_MENU
STYLE 0x16FF0800
EXSTYLE 0x00000200
BEGIN
END
IDR_MENU MENU
BEGIN
   POPUP "&File"
   BEGIN
     MENUITEM "&Exit",IDM_FILE_EXIT
   END
   POPUP "&Help"
   BEGIN
     MENUITEM "&About",IDM_HELP_ABOUT
   END
END
IDD_DLGCHILD DIALOGEX 0,0,414,362
FONT 8,"MS Sans Serif",0,0
STYLE 0x50080000
BEGIN
   CONTROL "",IDC_EDT1,"Edit",0x50010000,22,33,134,15,0x00000200
   CONTROL "IDC_STC",IDC_STC1,"Static",0x50000000,22,131,148,11
   CONTROL "IDC_BTN",IDC_BTN1,"Button",0x50010000,54,216,80,15
END
  


Вы сохраняете власть над людьми покуда оставляете им что-то…Отберите у человека все, и этот человек уже будет неподвластен вам…
 
miverДата: Четверг, 13.12.2012, 14:30 | Сообщение # 3
Рядовой
Группа: Пользователи
Сообщений: 5
Репутация: 0
Статус: Offline
Супер. Большое спасибо thumb
Выложу, то что я хотел получить
ScrollWin_Edit.bas
Code

'' Start
   #include once "windows.bi"

'' names of window classes.
   const WND_CLASS_NAME1 = "My_class1"
   #Define IDD_DLGCHILD    1100

'' function prototypes.
   declare function message_loop as integer
   declare sub register_classes
   declare function WndProc1 (ByVal MainForm1 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   declare function WndProc4 (ByVal Panel4 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   declare Function ChildProc(byval hDlg as HWND,byval uMsg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as bool

'' global data.
   Dim Shared hModule As HINSTANCE
   Dim Shared MainForm1 as HWND
   Dim shared Panel4 as HWND ' хэндл Panel
   Dim Shared OldWndProc_4 as Long
   Dim Shared hCld As HWND
    
'' main code.
   hModule=GetModuleHandle(NULL)
   register_classes
   MainForm1 = CreateWindowEx (NULL, WND_CLASS_NAME1, "Form", WS_VISIBLE Or WS_OVERLAPPEDWINDOW, 0, 0, 400, 419, NULL, NULL, hModule, NULL)
   ShowWindow(MainForm1, SW_SHOW)
   UpdateWindow(MainForm1)
  end message_loop
   
  ''message loop.
  Function message_loop as integer
   Dim wMsg as MSG
   Do 'цикл сообщений
    If PeekMessage( @wMsg, NULL, 0, 0, PM_REMOVE) <> 0 Then
     If wMsg.message = WM_QUIT Then Exit Do
     TranslateMessage( @wMsg )
     DispatchMessage( @wMsg )
    Else
     SleepEx(1,0)
    EndIf
   Loop
   return wMsg.wParam
  End Function
   
  ''' window procedure #1 ["Form"].
  Function WndProc1 (ByVal MainForm1 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   Function = 0
   Select case uMsg
    Case WM_CREATE
     'создаем Panel4
     Panel4 = CreateWindowEx (NULL, "Static", !"", WS_CHILD Or WS_VSCROLL Or WS_HSCROLL Or WS_DLGFRAME Or WS_VISIBLE, 30, 20, 331, 206, MainForm1, cptr(HMENU,4), hModule, NULL)
     SendMessage(Panel4 , WM_SETFONT, Cast(WPARAM, GetStockObject(ANSI_VAR_FONT)), 0)
     'Сабклассинг окна Panel4
     OldWndProc_4 = SetWindowLong(Panel4, GWL_WNDPROC, cPtr(Long, @WndProc4))
     WndProc4 (Panel4, uMsg, wParam, lParam)
     
    Case WM_DESTROY
     PostQuitMessage(0)
     Exit function
   End select
   Function = DefWindowProc(MainForm1,uMsg,wParam,lParam) ' Дефултная функция обработки окна
  End Function
   
  ''' window procedure #4 [Panel4].
  Function WndProc4 (ByVal Panel4 as HWND, ByVal uMsg as UINT, ByVal wParam as WPARAM, ByVal lParam as LPARAM) as LRESULT
   Function = 0
   Dim sinf As SCROLLINFO  
   Dim rect As RECT
   Dim fChanged As Boolean
    
   Select case uMsg
    Case WM_CREATE
     hCld=CreateDialogParam(hModule,Cast(zstring ptr,IDD_DLGCHILD),Panel4,@ChildProc,0)
     GetClientRect(hCld,@rect)
     With sinf
      .cbSize=SizeOf(sinf)  
      .fMask=SIF_RANGE Or SIF_PAGE   
      .nMin=0  
      .nMax=rect.bottom
     End With
     GetClientRect(Panel4,@rect)
     sinf.nPage=rect.bottom
     SetScrollInfo(Panel4,SB_VERT,@sinf,TRUE)
     GetClientRect(hCld,@rect)
     With sinf
      .cbSize=SizeOf(sinf)  
      .fMask=SIF_RANGE Or SIF_PAGE   
      .nMin=0  
      .nMax=rect.right
     End With
     GetClientRect(Panel4,@rect)  
     sinf.nPage=rect.right  
     SetScrollInfo(Panel4,SB_HORZ,@sinf,TRUE)  
      
    Case WM_VSCROLL  
     sinf.cbSize=SizeOf(sinf)  
     sinf.fMask=SIF_RANGE Or SIF_PAGE  
     GetScrollInfo(Panel4,SB_VERT,@sinf)  
      
     Select Case LoWord(wParam)  
      Case SB_THUMBPOSITION,SB_THUMBTRACK   
       SetScrollPos(Panel4,SB_VERT,HiWord(wParam),TRUE)  
       fChanged=TRUE  
         
      Case SB_LINEDOWN
       SetScrollPos(Panel4,SB_VERT,GetScrollPos(Panel4,SB_VERT)+1,TRUE)  
       fChanged=TRUE
         
      Case SB_LINEUP  
       SetScrollPos(Panel4,SB_VERT,GetScrollPos(Panel4,SB_VERT)-1,TRUE)  
       fChanged=TRUE
           
      Case SB_PAGEDOWN
       SetScrollPos(Panel4,SB_VERT,GetScrollPos(Panel4,SB_VERT)+sinf.nPage,TRUE)  
       fChanged=TRUE
        
      Case SB_PAGEUP
       SetScrollPos(Panel4,SB_VERT,GetScrollPos(Panel4,SB_VERT)-sinf.nPage,TRUE)  
       fChanged=TRUE
           
     End Select
      
     If fChanged Then  
      GetWindowRect(hCld,@rect)  
      ScreenToClient(Panel4,Cast(Point Ptr,@rect.left))  
      SetWindowPos(hCld,0,rect.left,-GetScrollPos(Panel4,SB_VERT),0,0,SWP_NOSIZE Or SWP_NOZORDER)  
     EndIf
            
    Case WM_HSCROLL  
           sinf.cbSize=SizeOf(sinf)  
           sinf.fMask=SIF_RANGE Or SIF_PAGE  
           GetScrollInfo(Panel4,SB_HORZ,@sinf)  
            
           Select Case LoWord(wParam)  
            Case SB_THUMBPOSITION,SB_THUMBTRACK  
                 SetScrollPos(Panel4,SB_HORZ,HiWord(wParam),TRUE)  
                 fChanged=TRUE
                
            Case SB_LINEDOWN
                 SetScrollPos(Panel4,SB_HORZ,GetScrollPos(Panel4,SB_HORZ)+1,TRUE)  
                 fChanged=TRUE
                  
            Case SB_LINEUP
                 SetScrollPos(Panel4,SB_HORZ,GetScrollPos(Panel4,SB_HORZ)-1,TRUE)  
                 fChanged=TRUE
                   
            Case SB_PAGEDOWN
                 SetScrollPos(Panel4,SB_HORZ,GetScrollPos(Panel4,SB_HORZ)+sinf.nPage,TRUE)  
                 fChanged=TRUE
                  
            Case SB_PAGEUP
                 SetScrollPos(Panel4,SB_HORZ,GetScrollPos(Panel4,SB_HORZ)-sinf.nPage,TRUE)  
                 fChanged=TRUE
                  
           End Select  
            
           If fChanged Then  
              GetWindowRect(hCld,@rect)  
              ScreenToClient(Panel4,Cast(Point Ptr,@rect.left))  
              SetWindowPos(hCld,0,-GetScrollPos(Panel4,SB_HORZ),rect.top,0,0,SWP_NOSIZE Or SWP_NOZORDER)  
           EndIf
            
    Case Else  
           Return DefWindowProc(Panel4,uMsg,wParam,lParam)
           
   End select
   Function = CallWindowproc (cPtr(WNDPROC, OldWndProc_4), Panel4, uMsg, wParam, lParam) ' Запускаем оригинальную процедуру окна
  End Function
   
  Function ChildProc(byval hDlg as HWND,byval uMsg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as bool  
      return FALSE
   
  end Function  
   
  ''' register all the window classes.
  Sub register_classes  
   Dim wc as WNDCLASSEX
   with wc ' заполняем структуру wc
    .cbSize = SIZEOF( WNDCLASSEX ) ' размер структуры WNDCLASSEX
    .style = CS_BYTEALIGNCLIENT + CS_BYTEALIGNWINDOW + CS_DBLCLKS + CS_HREDRAW + CS_VREDRAW ' Стиль окна   
    .cbClsExtra = NULL ' резервирование дополнительных байт за концом структуры
    .cbWndExtra = NULL
    .hInstance = hModule ' хэндл модуля
    .hbrBackground = Cast(HBRUSH, COLOR_3DFACE + 1) ' Цвет фона
    .lpszMenuName = NULL ' Хэндл меню  
    .hIcon = LoadIcon( NULL,IDI_APPLICATION ) ' Хэндл иконки
    .hIconSm = .hIcon 'Хэндл маленькой иконки
    .hCursor = LoadCursor( NULL,IDC_ARROW) ' Хэндл курсора
   end with
   wc.lpfnWndProc   = @WndProc1
   wc.lpszClassName = strptr(WND_CLASS_NAME1)
   If(RegisterClassEx(@wc) = FALSE) then
    MessageBox(NULL,"Не могу зарегистрировать класс окна","Ошибка",MB_OK + MB_ICONSTOP + MB_TOPMOST)
    End 1
   End if
  End Sub


ScrollWin_Edit.rc
Code

#define IDD_DLGCHILD 1100
#define IDC_EDT1 1001
#define IDC_STC1 1002
#define IDC_BTN1 1003

IDD_DLGCHILD DIALOGEX 0,0,414,362
FONT 8,"MS Sans Serif",0,0,0
STYLE 0x50080000
BEGIN
   CONTROL "",IDC_EDT1,"Edit",0x50010000,22,33,134,15,0x00000200
   CONTROL "IDC_STC",IDC_STC1,"Static",0x50000000,22,131,148,11
   CONTROL "IDC_BTN",IDC_BTN1,"Button",0x50010000,21,216,80,15
END
 
Форум » WinAPI » WinApi в freebasic » Использование ScrollBar в окне Static (Вопрос как заставить работать ScrollBar в панели на Static)
  • Страница 1 из 1
  • 1
Поиск: