[vb_ro] Re: RightButton as LeftButton

Pai salutare. Nu mai cauta pe Internet inainte de a
cauta in MSDN. 

DECLARA 

Private Declare Function SetCaretPos Lib "user32"
(ByVal x As Long, ByVal y As Long) As Long

APOI O CHEMI IN RICHTEXTBOX_MOUSEUP. Ti-am dat un
exemplu si cum sa suprimi meniul default si sa-l
inlocuiesti cu un pop-up al tau

*****************************************

Private Sub Rtb_MouseUp(Button As Integer, shift As
Integer, x As Single, y As Single)
  ' Show right-click context menu
  If Button = vbRightButton Then
    'AICI ESTE FUNCTIA TA
     SetCaretPos x / Screen.TwipsPerPixelX, y /
Screen.TwipsPerPixelY


    SetEditMenuItemText True
    DoEvents
    ' Execution stops here until context menu is
hidden. (TrackPopupMenu() behaves identically!)
    PopupMenu mnuedit   ' Invokes mnuEdit_Click()
    SetEditMenuItemText False
  End If
End Sub


' To change menu command text, this proc must be
called BEFORE the Edit menu is displayed.
' Will fail miserably if executed when menu IS
displayed!! Called right before & right after context
menu
' is displayed  in Form_KeyDown() (Shift+F10) &
Rich1_MouseUp()
Private Sub SetEditMenuItemText(bIsContext As Boolean)
   mnucut1.Caption = "Taie" & IIf(bIsContext, "",
vbTab & "")
   mnucopy1.Caption = "Copiaza" & IIf(bIsContext, "",
vbTab & "")
   If rtb.SelText = "" Then SetareMeniuriCutPaste
False Else SetareMeniuriCutPaste True
   mnupaste1.Caption = "Scrie peste" & IIf(bIsContext,
"", vbTab & "")
   mnuundo1.Caption = "Inapoi" & IIf(bIsContext, "",
vbTab & "")
   mnuredo1.Caption = "Inainte" & IIf(bIsContext, "",
vbTab & "")
   
   mnufind1.Caption = "Cauta/Inlocuieste" &
IIf(bIsContext, "", vbTab & "")
   mnuinsertsimbol1.Caption = "Simbol" &
IIf(bIsContext, "", vbTab & "")
   mnuucase1.Caption = "Majuscule" & IIf(bIsContext,
"", vbTab & "")
   mnulcase1.Caption = "Litere mici" & IIf(bIsContext,
"", vbTab & "")
End Sub

' The Rich ctrl processes edit accelerator keys but
does not display a corresponding right-click edit
' context menu (?).  So NO shortcut keys are defined
for the following cmds:
' Undo, Cut, Copy, Paste, Delete & Select All.
' Allows their respective shortcut key strings to be
added & remove appropriately by mnuEdit_Click() above.
' Their corresponding click events below are called
only from their respective menu item cmds
'(not from accelerators). The Enabled property is the
menu's default property & is either True or False.
' Happens after menu is displayed!

Private Sub EnableEditMenuItems()
  Dim CR As CHARRANGE, dwTxtLen As Long
  ' Fill CR w/ current selection range
  SendMessage m_hwndEdit, EM_EXGETSEL, 0, CR
  ' Undo:
  mnuEditUndo = SendMessage(m_hwndEdit, EM_CANUNDO, 0,
0)
  
  ' Cut, Copy & Delete: enable if a selection, disable
if no selection
  mnuEditCut = (CR.cpMin < CR.cpMax)
  ' Paste: enable of clipboard text, disable if not
  
  ' Select All: disable if everything's already
selected, enable otherwise.
  ' The Rich ctrl ALWAYS has a CrLf at the end of it's
contents
  ' which is not seen by WM_GETTEXTLENGTH.
  dwTxtLen = SendMessage(m_hwndEdit, WM_GETTEXTLENGTH,
0, 0)
  mnuEditSelAll = Not (CR.cpMin = 0 And CR.cpMax =
dwTxtLen + 2&)
End Sub






--- MaTricks <matricks@xxxxxxxxxxxx> wrote:
> Salutare
> 
> Exista vreo posibilitate ca intr-un RichTexBox,
> atunci cand se face click
> dreapta pe un anumit cuvant, caret-ul (cursorul
> textului) sa se mute automat
> pe acel cuvant, ca si cand s-ar fi apasat click
> stanga, inainte de a aparea
> meniulpopup?
> Am cautat si pe net, dar nu am gasit absolut nimic.
> Sau nu se poate face asa
> ceva?
> Poate cu ceva api-uri?
> 
> MaTricks
> 
> 
> 
> Site: http://info.AdvanCode.com
> Dezabonare: vb_ro-request@xxxxxxxxxxxxx cu
> "unsubscribe" la subiect.


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

Site: http://info.AdvanCode.com
Dezabonare: vb_ro-request@xxxxxxxxxxxxx cu "unsubscribe" la subiect.

Other related posts: