[quote="srod"]I must be missing something here because it all works fine for me. Nothing is debugged with the following which is correct.
...
Thank you for your attention, here is my code. It seems that my other code uses by calling 'Show_StrGdgBalloon' GadgetNr or the GadgetID,
and i couldnt find the problem, so I will solve this here and be sure that i use GadgetID and
if i dont use 'If Not GetDlgCtrlID_( GadgetID )' my balloon on LostFocus will not appear
Code: Select all
; This code is copy and paste, so i have to thank to all guys who find a fragment of their own work here
#StrGdg_User = 422 : #wMain = 400
Structure __Struct_StrGdgBalloon
StructSize.l
CompilerIf #PB_Compiler_Processor=#PB_Processor_x64 : _pad1.l : CompilerEndIf
pTitle.i
pText.i
Icon.l
CompilerIf #PB_Compiler_Processor=#PB_Processor_x64 : _pad2.l : CompilerEndIf
EndStructure
Procedure CreateGadget( GadgetTyp, GadgetNr, x, y, w, h, Text.s="", Flags=0, gTitle.s="" )
Define.l gTitleID, gTitleID_Width = 30, gTitleID_Height = 20
Define.i gadPosX
; First, create the Gadget
Select GadgetTyp
Case #PB_GadgetType_Button : ButtonGadget( GadgetNr, x, y, w, h, Text )
Case #PB_GadgetType_ComboBox : ComboBoxGadget( GadgetNr, x, y, w, h )
Case #PB_GadgetType_String : StringGadget( GadgetNr, x, y, w, h, Text, Flags )
EndSelect
; Produce the StringGadget and the related TextGadget in one process
If gTitle <> ""
gTitleID = 1000 + GadgetNr
TextGadget( gTitleID, gadPosX, y + ( h - 14 ) / 2, 130, 14, gTitle, #PB_Text_Right )
ResizeGadget( gTitleID, x - gTitleID_Width - 10, y+(h-14)/2, gTitleID_Width, 14)
EndIf
EndProcedure
Procedure Hide_StrGdgBalloon( GadgetID )
SendMessage_( GadgetID, #EM_HIDEBALLOONTIP, 0, 0 )
EndProcedure
Procedure Show_StrGdgBalloon( hWnd, GadgetID, Title.s, Text.s, IconFlag = #TTI_INFO, MilliSecs = 3000 )
Title = " " + Title
Text = #CRLF$ + Text + #CRLF$ + " "
Protected TitleBuffer.l = StringByteLength( Title, #PB_Unicode ) + 2
Protected TextBuffer.l = StringByteLength( Text , #PB_Unicode ) + 2
Protected *Buffer = AllocateMemory( TitleBuffer + TextBuffer )
Protected.i timerNr = 123
Protected Balloon.__Struct_StrGdgBalloon
; I use this Show_StrGdgBalloon for different Gadgets and sometimes is the GadgetNr or the GadgetID delivered so will be sure that:
If Not GetDlgCtrlID_( GadgetID ) ; If the reverse value of GadgetID is no GadgetNr the GadgetID-Value is no GadgetID
; Debug IsGadget( GadgetID ) in this situation IsGadget doesnt help
GadgetID = GadgetID( GadgetID )
EndIf
If OSVersion() < #PB_OS_Windows_Vista And IconFlag > #TTI_ERROR : IconFlag - 3 : EndIf
If *Buffer
Balloon\StructSize = SizeOf( __Struct_StrGdgBalloon )
PokeS( *Buffer, Title, Len( Title ), #PB_Unicode)
PokeS( *Buffer + TitleBuffer, Text, Len( Text ), #PB_Unicode )
Balloon\pTitle = *Buffer
Balloon\pText = *Buffer + TitleBuffer
Balloon\Icon = IconFlag
SendMessage_( GadgetID, #EM_SHOWBALLOONTIP, 0, @Balloon )
FreeMemory( *Buffer )
EndIf
AddWindowTimer( hWnd, timerNr, MilliSecs )
Repeat
If WaitWindowEvent() = #PB_Event_Timer And EventTimer() = timerNr
Hide_StrGdgBalloon( GadgetID )
RemoveWindowTimer( hWnd, timerNr )
Break
EndIf
ForEver
Hide_StrGdgBalloon( GadgetID )
EndProcedure
If OpenWindow( #wMain, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadget( #PB_GadgetType_String, #StrGdg_User, 70, 10, 100, 20, "", 0, "User" )
GadgetToolTip( #StrGdg_User, "Enter user (at least 6 characters)" )
ButtonGadget( 1, 70, 35, 100, 20, "Standard Button")
If Not IsGadget(422)
Debug "Not return #True!"
EndIf
Repeat
wwEvent = WaitWindowEvent()
If wwEvent = #PB_Event_Gadget And EventType() = #PB_EventType_LostFocus And EventGadget() = #StrGdg_User
If Len( GetGadgetText( #StrGdg_User ) ) < 6
Show_StrGdgBalloon( #wMain, #StrGdg_User, "Error...", "Must be 6 chars at minimum", #TTI_ERROR, 2000 )
EndIf
EndIf
Until wwEvent = #PB_Event_CloseWindow
EndIf