
Est il possible de prépositioner le curseur à un endroit précis par exemple dans un StringGadget qui possède déjà un texte.

Merci à vous
Salutations
Denis
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 400, 260, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Position curseur") And CreateGadgetList(WindowID())
CreateGadgetList(WindowID())
Font.l = LoadFont(30, "Arial", 15, #PB_Font_HighQuality | #PB_Font_Bold)
StringGadget(1, 10, 10, 300, 40, "essai1 pour position du curseur dans la chaine")
SetGadgetFont(1, Font)
ButtonGadget(1000, 10, 180, 350, 50, "Appuyer pour positionner le curseur après la 7 eme lettre")
Repeat
Select WaitWindowEvent()
Case #PB_EventGadget
Select EventGadgetID()
Case 1000
ActivateGadget(1)
UseFont(30)
SetCaretPos_(150,1)
EndSelect
Case #PB_EventCloseWindow
Quit + 1
EndSelect
Until Quit
EndIf
End
Code : Tout sélectionner
Enumeration
#Fentre
EndEnumeration
Enumeration
#Chaine
#N
#BPosition
#BDeplace
#BSDroite
#BSGauche
#BCentrage
#BDernier
EndEnumeration
#TOOLTIP_NO_ICON = 0
#TOOLTIP_INFO_ICON = 1
#TOOLTIP_WARNING_ICON = 2
#TOOLTIP_ERROR_ICON = 3
Procedure BalloonTip(WindowID, Gadget, Text$ , Title$, Icon)
ToolTip=CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,WindowID(WindowID),0,GetModuleHandle_(0),0)
SendMessage_(ToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
SendMessage_(ToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
SendMessage_(ToolTip,#TTM_SETMAXTIPWIDTH,0,180)
Balloon.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Balloon\uFlags=#TTF_IDISHWND | #TTF_SUBCLASS
Balloon\hWnd=GadgetID(Gadget)
Balloon\uId=GadgetID(Gadget)
Balloon\lpszText=@Text$
SendMessage_(ToolTip, #TTM_ADDTOOL, 0, Balloon)
If Title$ > ""
SendMessage_(ToolTip, #TTM_SETTITLE, Icon, @Title$)
EndIf
EndProcedure
Procedure Open_Fenetre()
If OpenWindow(#Fentre, 508, 124, 501, 200, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
If CreateGadgetList(WindowID())
StringGadget(#Chaine, 10, 55, 485, 20, "Les boutons ci dessous agissent sur cet exemple de chaine saisie dans un StringGadget. ")
StringGadget(#N, 235, 95, 40, 20, "10")
ButtonGadget(#BPosition, 15, 155, 75, 20, "Potision")
BalloonTip(WindowID(), #BPosition, "Positionnement du curseur à N caractères ", "", #TOOLTIP_NO_ICON)
ButtonGadget(#BDeplace, 95, 155, 75, 20, "Dépacelement")
BalloonTip(WindowID(), #BDeplace, "Dépalcement de N caractères", "", #TOOLTIP_NO_ICON)
ButtonGadget(#BSDroite, 175, 155, 75, 20, "Retour à Droite")
BalloonTip(WindowID(), #BSDroite, "Retour à droite de N caractères", "", #TOOLTIP_NO_ICON)
ButtonGadget(#BSGauche, 255, 155, 75, 20, "S à Gauche")
BalloonTip(WindowID(), #BSGauche, "Selection à gauche du N'ième caractère", "", #TOOLTIP_NO_ICON)
ButtonGadget(#BCentrage, 335, 155, 75, 20, "Centrage")
BalloonTip(WindowID(), #BCentrage, "Centrage dans le texte", "", #TOOLTIP_NO_ICON)
ButtonGadget(#BDernier, 415, 155, 75, 20, "Dernier")
BalloonTip(WindowID(), #BDernier, "Après le dernier Caractère", "", #TOOLTIP_NO_ICON)
EndIf
EndIf
EndProcedure
Procedure Cursor(Gadget.l,N.l,Sel.s)
ActivateGadget(gadget)
If Sel="S"
keybd_event_($23,0,0,0)
keybd_event_($23,0,2,0)
keybd_event_($10,0,0,0)
Key.b=$25
n=Len(GetGadgetText(Gadget))-n
ElseIf Sel="D"
keybd_event_($24,0,0,0)
keybd_event_($24,0,2,0)
Key.b=$27
ElseIf Sel="M"
Key.b=$27
ElseIf N < 0
Key.b=$25
N= -N
EndIf
For f=1 To N
keybd_event_(Key,0,0,0)
keybd_event_(Key,0,2,0)
Next
If Sel="S"
keybd_event_($10,0,2,0)
EndIf
EndProcedure
Open_Fenetre()
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = #Chaine
ElseIf GadgetID = #BPosition
Cursor(#Chaine,Val(GetGadgetText(#N)),"D")
ElseIf GadgetID = #BDeplace
Cursor(#Chaine,Val(GetGadgetText(#N)),"M")
ElseIf GadgetID = #BSDroite
Cursor(#Chaine,-Val(GetGadgetText(#N)),"")
ElseIf GadgetID = #BSGauche
Cursor(#Chaine,Val(GetGadgetText(#N)),"S")
ElseIf GadgetID = #BCentrage
Cursor(#Chaine,Len(GetGadgetText(#Chaine))/2,"D")
ElseIf GadgetID = #BDernier
Cursor(#Chaine,100,"D")
EndIf
EndIf
Until Event = #PB_EventCloseWindow
End