Что-то я видимо не допонял
Получаем доступ к структуре SCROLL в процедуре FindDevice_Timer()
Я имел в виду получить доступ к существующей структуре (указатель на которую был передан функции CreateScroller()), а не создать новую в процедуре (она будет размещена по другому адресу в памяти, чем переданная в функцию CreateScroller()).
Enumeration #Window_0 #fon #Hide #Light_Button_Enable #Light_Button #Light_Button_On #Light_Auto #Light_Auto_On #Light_Help #Light_Help_On #Light_Down_Enable #Light_Pause #Light_Power #Light_Mode #Light_Tune #Light_Battery #Knob_pointer_White_Long #text #H_track #V_track #H_knob1 #H_knob2 #H_knob3 #H_knob4 #H_knob5 #H_knob6 #H_knob7 #H_knob8 #H_knob9 #H_knob10 #V_knob1 #V_knob2 #V_knob3 #V_knob4 #V_knob5 #V_knob6 #H_knob_Light1 #H_knob_Light2 #H_knob_Light3 #V_knob_Light1 #V_knob_Light2 #V_knob_Light3 #Skin_Image EndEnumeration Global Win1.s = "Подключено HID-устройство" Global Win2.s = "Устройство не обнаруженно" #USB_PID = $2012 ; Идентификаторы USB устройства. #USB_VID = $2004 UsePNGImageDecoder() Structure SCROLL_STRUCT scroll_hwnd.l ;handle of window where to draw scroll_text.s ;pointer scrolltext scroll_x.l ;x position scroll_y.l ;y position scroll_width.l ;width of scroller scroll_hFont.l ;Handle of Font scroll_textcolor.l ;example: 00F7DDCCh (00BBGGRR) scroll_alpha.b ;value for transparency (if using it on WS_EX_LAYERED window) scroll_wait.l ;wait time (milliseconds) before draw scrolltext scroll_pause.b ;dont modify this! Use PauseScroller function! scroll_speed.l ;скорость скроллинга (милисекунды) scroll_hThread.l ;дескриптор потока EndStructure Import "TextScroller.lib" CreateScroller(scr.l) PauseScroller (scr) EndImport UpdatePos.RECT HOLLOW_BRUSH=GetStockObject_(#HOLLOW_BRUSH) SCROLL.SCROLL_STRUCT Procedure FindDevice_Timer() Static Old_Test Shared W_DeviceHandle, SCROLL Test=HID_Lib_DeviceTest(#USB_PID, #USB_VID) If Test<>Old_Test Old_Test=Test If Test HID_Lib_CloseDevice(W_DeviceHandle) W_DeviceHandle=HID_Lib_OpenDevice(#USB_PID, #USB_VID) Win1.s = "Подключено HID устройство" SCROLL\scroll_text = Win1 Else HID_Lib_CloseDevice(W_DeviceHandle) W_DeviceHandle=0 Win2.s = "Устройство не обнаруженно" SCROLL\scroll_text = Win2 EndIf EndIf EndProcedure Procedure Draw_y(x, y, Gadget, ImageID, Active_ImID=0) GrabImage(#Skin_Image, #V_track, GadgetX(Gadget), GadgetY(Gadget), GadgetWidth(Gadget), GadgetHeight(Gadget)) StartDrawing(CanvasOutput(Gadget)) DrawImage(ImageID(#V_track), 0, 0) If Active_ImID DrawAlphaImage(Active_ImID, 0, 4) EndIf DrawAlphaImage(ImageID, x, y) StopDrawing() EndProcedure Procedure Draw_x(x, y, Gadget, ImageID, Active_ImID=0) GrabImage(#Skin_Image, #H_track, GadgetX(Gadget), GadgetY(Gadget), GadgetWidth(Gadget), GadgetHeight(Gadget)) StartDrawing(CanvasOutput(Gadget)) DrawImage(ImageID(#H_track), 0, 0) If Active_ImID DrawAlphaImage(Active_ImID, 4, 0) EndIf DrawAlphaImage(ImageID, x, y) StopDrawing() EndProcedure Procedure WindowCallback(hWnd, Msg, wParam, lParam) Shared HOLLOW_BRUSH Result = #PB_ProcessPureBasicEvents If Msg = #WM_CTLCOLORSTATIC And GetDlgCtrlID_(lParam)=19 SetTextColor_(wParam, $FFFFFF) SetBkMode_(wParam, #TRANSPARENT) ProcedureReturn HOLLOW_BRUSH EndIf ProcedureReturn Result EndProcedure CatchImage(#Skin_Image, ?Skin_Image) CatchImage(#H_track, ?H_track) CatchImage(#H_knob1, ?H_knob1) CatchImage(#H_knob2, ?H_knob2) CatchImage(#H_knob3, ?H_knob3) CatchImage(#H_knob4, ?H_knob4) CatchImage(#H_knob5, ?H_knob5) CatchImage(#H_knob6, ?H_knob6) CatchImage(#H_knob7, ?H_knob7) CatchImage(#H_knob8, ?H_knob8) CatchImage(#H_knob9, ?H_knob9) CatchImage(#H_knob10, ?H_knob10) CatchImage(#H_knob_Light1, ?H_knob_Light1) CatchImage(#H_knob_Light2, ?H_knob_Light2) CatchImage(#H_knob_Light3, ?H_knob_Light3) CatchImage(#V_knob_Light1, ?V_knob_Light1) CatchImage(#V_knob_Light2, ?V_knob_Light2) CatchImage(#V_knob_Light3, ?V_knob_Light3) CatchImage(#V_track, ?V_track) CatchImage(#V_knob1, ?V_knob1) CatchImage(#V_knob2, ?V_knob2) CatchImage(#V_knob3, ?V_knob3) CatchImage(#V_knob4, ?V_knob4) CatchImage(#V_knob5, ?V_knob5) CatchImage(#V_knob6, ?V_knob6) CatchImage(#Light_Button_Enable, ?Light_Button_Enable) x=OpenWindow(0, 0, 0, 200, 200, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) SetWindowCallback(@WindowCallback(), 0) SetClassLongPtr_(WindowID(#Window_0), #GCL_HBRBACKGROUND, CreatePatternBrush_(ImageID(#Skin_Image))) ContainerGadget(219, 5, 178, 190, 20) SetGadgetColor(219, #PB_Gadget_BackColor, $000000) SCROLL\scroll_hwnd = x SCROLL\scroll_text = Win2 SCROLL\scroll_x = 5 SCROLL\scroll_y = 178 SCROLL\scroll_width = 185 SCROLL\scroll_hFont = LoadFont(2, "Times New Roman", 13, #PB_Font_Bold) SCROLL\scroll_textcolor = RGB(0,128,255) SCROLL\scroll_alpha = 200 SCROLL\scroll_speed = 20 CreateScroller(SCROLL) CloseGadgetList() ; If HID_Lib_DeviceTest(#USB_PID, #USB_VID) ; If SCROLL\scroll_hThread ; TerminateThread_(SCROLL\scroll_hThread, 0) ; InvalidateRect_(WindowID(#Window_0), 0, #True) ; SCROLL\scroll_text = Win1 ; SCROLL\scroll_hFont = LoadFont(2, "Times New Roman", 13, #PB_Font_Bold) ; SCROLL\scroll_textcolor = RGB(0,128,255) ; CreateScroller(SCROLL) ; EndIf ; Else ; If SCROLL\scroll_hThread ; TerminateThread_(SCROLL\scroll_hThread, 0) ; InvalidateRect_(WindowID(#Window_0), 0, #True) ; SCROLL\scroll_text = Win2 ; SCROLL\scroll_hFont = LoadFont(2, "Times New Roman", 13, #PB_Font_Bold) ; SCROLL\scroll_textcolor = RGB(0,128,255) ; CreateScroller(SCROLL) ; EndIf ; EndIf CanvasGadget(20, 2, 5, 87, 15) Draw_x(0, 0, 20, ImageID(#H_knob1)) CanvasGadget(21, 2, 20, 87, 15) Draw_x(0, 0, 21, ImageID(#H_knob2)) CanvasGadget(22, 2, 35, 87, 15) Draw_x(0, 0, 22, ImageID(#H_knob3)) CanvasGadget(23, 2, 50, 87, 15) Draw_x(0, 0, 23, ImageID(#H_knob4)) CanvasGadget(24, 2, 65, 87, 15) Draw_x(0, 0, 24, ImageID(#H_knob5)) CanvasGadget(25, 89, 5, 87, 15) Draw_x(0, 0, 25, ImageID(#H_knob6)) CanvasGadget(26, 89, 20, 87, 15) Draw_x(0, 0, 26, ImageID(#H_knob7)) CanvasGadget(27, 89, 35, 87, 15) Draw_x(0, 0, 27, ImageID(#H_knob8)) CanvasGadget(28, 89, 50, 87, 15) Draw_x(0, 0, 28, ImageID(#H_knob9)) CanvasGadget(29, 89, 65, 87, 15) Draw_x(0, 0, 29, ImageID(#H_knob10)) CanvasGadget(30, 20, 80, 15, 87) Draw_y(0, 1, 30, ImageID(#V_knob1)) CanvasGadget(31, 35, 80, 15, 87) Draw_y(0, 1, 31, ImageID(#V_knob2)) CanvasGadget(32, 50, 80, 15, 87) Draw_y(0, 1, 32, ImageID(#V_knob3)) CanvasGadget(33, 65, 80, 15, 87) Draw_y(0, 1, 33, ImageID(#V_knob4)) CanvasGadget(34, 80, 80, 15, 87) Draw_y(0, 1, 34, ImageID(#V_knob5)) CanvasGadget(35, 95, 80, 15, 87) Draw_y(0, 1, 35, ImageID(#V_knob6)) For i=20 To 35 SetGadgetAttribute(i, #PB_Canvas_Cursor, #PB_Cursor_Hand) Next i TextGadget(19, 120, 120, 15, 15,"") SetTimer_(x, 2, 400, @FindDevice_Timer()) Repeat Event = WaitWindowEvent() Window = EventWindow() If Event = #PB_Event_Gadget Gadget=EventGadget() ;If Gadget>=30 And Gadget<=35 Type = EventType() If Gadget>=30 And Gadget<=35 If Gadget>=30 And Gadget<=31 Active_ImID=ImageID(#V_knob_Light1) ElseIf Gadget>=32 And Gadget<=33 Active_ImID=ImageID(#V_knob_Light2) ElseIf Gadget>=34 And Gadget<=35 Active_ImID=ImageID(#V_knob_Light3) EndIf Type = EventType() ; Перемещение вертикального бегунка. If Type = #PB_EventType_LeftClick Or Type = #PB_EventType_MouseWheel Or (Type = #PB_EventType_MouseMove And GetGadgetAttribute(Gadget, #PB_Canvas_Buttons) = #PB_Canvas_LeftButton) If Type = #PB_EventType_MouseWheel y=GetGadgetData(Gadget)-GetGadgetAttribute(Gadget, #PB_Canvas_WheelDelta)*2 Else y=GetGadgetAttribute(Gadget, #PB_Canvas_MouseY)-12 EndIf If y<1 : y=1 : EndIf If y>87-23 : y = 87-23 : EndIf Draw_y(0, y, Gadget, ImageID(Gadget), Active_ImID) SetGadgetData(Gadget, y) ; Мышка или вошла в пределы регулятора или вышла из него. ElseIf Type = #PB_EventType_MouseEnter Or Type = #PB_EventType_MouseLeave If Type = #PB_EventType_MouseLeave ; Мышь вышла с передлов регулятора. Active_ImID=0 EndIf y=GetGadgetData(Gadget) Draw_y(0, y+1, Gadget, ImageID(Gadget), Active_ImID) EndIf EndIf If Gadget>=20 And Gadget<=29 If Gadget>=20 And Gadget<=22 Active_ImID=ImageID(#H_knob_Light1) ElseIf Gadget>=23 And Gadget<=24 Active_ImID=ImageID(#H_knob_Light2) ElseIf Gadget>=25 And Gadget<=29 Active_ImID=ImageID(#H_knob_Light3) EndIf Type = EventType() ; Перемещение горизонтального бегунка. If Type = #PB_EventType_LeftClick Or Type = #PB_EventType_MouseWheel Or (Type = #PB_EventType_MouseMove And GetGadgetAttribute(Gadget, #PB_Canvas_Buttons) = #PB_Canvas_LeftButton) If Type = #PB_EventType_MouseWheel x=GetGadgetData(Gadget)-GetGadgetAttribute(Gadget, #PB_Canvas_WheelDelta)*2 Else x=GetGadgetAttribute(Gadget, #PB_Canvas_MouseX)-12 EndIf If x<0 : x=0 : EndIf If x>87-24 : x = 87-24 : EndIf Draw_x(x, 0, Gadget, ImageID(Gadget), Active_ImID) SetGadgetData(Gadget, x) SetGadgetText(19, Str(x)) SetRect_(@UpdatePos, 120, 120, 120+15, 120+15) InvalidateRect_(WindowID(0), @UpdatePos, 1) ; Мышка или вошла в пределы регулятора или вышла из него. ElseIf Type = #PB_EventType_MouseEnter Or Type = #PB_EventType_MouseLeave If Type = #PB_EventType_MouseLeave ; Мышь вышла с пределов регулятора. Active_ImID=0 EndIf x=GetGadgetData(Gadget) Draw_x(x, 0, Gadget, ImageID(Gadget), Active_ImID) EndIf EndIf EndIf If Window = 0 And Event = #WM_MOUSEWHEEL GetCursorPos_(@Cursor.POINT) hWnd = WindowFromPoint_(Cursor\X|(Cursor\Y<<32)) Gadget=GetDlgCtrlID_(hWnd) If Gadget>=20 And Gadget<=35 SendMessage_(hWnd, #WM_MOUSEWHEEL, EventwParam(), EventlParam()) EndIf EndIf Until Event = #PB_Event_CloseWindow DataSection ;{ ресурсы Skin_Image: IncludeBinary "Files\Skin_Image.png" H_track: IncludeBinary "Files\H.png" H_knob1: IncludeBinary "Files\H-knob1.png" H_knob2: IncludeBinary "Files\H-knob1.png" H_knob3: IncludeBinary "Files\H-knob1.png" H_knob4: IncludeBinary "Files\H-knob3.png" H_knob5: IncludeBinary "Files\H-knob3.png" H_knob6: IncludeBinary "Files\H-knob2.png" H_knob7: IncludeBinary "Files\H-knob2.png" H_knob8: IncludeBinary "Files\H-knob2.png" H_knob9: IncludeBinary "Files\H-knob2.png" H_knob10: IncludeBinary "Files\H-knob2.png" V_track: IncludeBinary "Files\V.png" V_knob1: IncludeBinary "Files\V-knob1.png" V_knob2: IncludeBinary "Files\V-knob2.png" V_knob3: IncludeBinary "Files\V-knob3.png" V_knob4: IncludeBinary "Files\V-knob4.png" V_knob5: IncludeBinary "Files\V-knob5.png" V_knob6: IncludeBinary "Files\V-knob6.png" H_knob_Light1: IncludeBinary "Files\H-knob1_Light.png" H_knob_Light2: IncludeBinary "Files\H-knob3_Light.png" H_knob_Light3: IncludeBinary "Files\H-knob2_Light.png" V_knob_Light1: IncludeBinary "Files\V-knob1_Light.png" V_knob_Light2: IncludeBinary "Files\V-knob2_Light.png" V_knob_Light3: IncludeBinary "Files\V-knob3_Light.png" Light_Button_Enable: IncludeBinary "Files\Knob_pointer_White_Long.png" ;} EndDataSection