;############################################## ;Pruefen ob sich sich die Maus über einem Static-Control ;befindet, und dann darauf reagieren ;############################################## ;Andreas Miethe * Januar 2003 ;############################################## ;ab PB 4.x ;############################################## Global Static1.l Global ReUsableBrush,a.l Procedure IsMouseOver(wnd) GetWindowRect_(wnd,re.RECT) GetCursorPos_(pt.POINT) Result = PtInRect_(re,pt\x,pt\y) ProcedureReturn Result EndProcedure Procedure SetColor(TxtColor,BkColor,wParam ,lParam ) Shared ReUsableBrush DeleteObject_(ReUsableBrush) ReUsableBrush = GetStockObject_(#HOLLOW_BRUSH) SetBkColor_(wParam,BkColor) SetTextColor_(wParam,TxtColor) SetBkMode_(wParam,#TRANSPARENT) Result = ReUsableBrush ProcedureReturn Result EndProcedure Procedure WindowCallback(WindowID, Message, wParam, lParam) Result = #PB_ProcessPureBasicEvents Select Message Case #WM_LBUTTONUP If IsMouseOver(Static1) CreateFile(0,"~~1.url") WriteStringN(0,"[InternetShortCut]") WriteStringN(0,"URL=http://www.ampsoft.eu") CloseFile(0) ShellExecute_(0,"open","~~1.url",0,0,#SW_SHOWNORMAL) DeleteFile("~~1.url") EndIf Case #WM_MOUSEMOVE GetCursorPos_(pt.Point) GetWindowRect_(Static1,re.Rect) If PtInRect_(re,pt\x,pt\y) a = 1 SetWindowText_(Static1,"www.ampsoft.eu") SetCursor_(LoadCursor_(0,32649)) Else a = 0 SetWindowText_(Static1,"www.ampsoft.eu") SetCursor_(LoadCursor_(0,#IDC_ARROW)) EndIf InvalidateRect_(WindowID(0),0,0) Case #WM_CTLCOLORSTATIC If lParam = Static1 If a Result = SetColor(RGB(0,0,255),RGB(255,255,255),wParam,lParam) Else Result = SetColor(RGB(0,0,0),RGB(255,255,255),wParam,lParam) EndIf EndIf EndSelect ProcedureReturn Result EndProcedure If OpenWindow(0, 10, 10, 640,180,"MouseOver",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget) If CreateGadgetList(WindowID(0)) Static1 = TextGadget(0, 10,10,220,24,"") EndIf SetWindowCallback(@WindowCallback()) SendMessage_(WindowID(0),#WM_MOUSEMOVE,0,0) Repeat EventID.l = WaitWindowEvent() If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button Quit = 1 EndIf Until Quit = 1 EndIf End ; IDE Options = PureBasic v4.01 (Windows - x86) ; CursorPosition = 38 ; FirstLine = 25 ; Folding = - ; DisableDebugger