Page 1 of 1

Macro / Resident file for RichEdit (EditorGadget)

Posted: Mon Apr 17, 2006 2:12 pm
by Flype
Code updated for 5.20+

richedit.zip -> richedit.zip
[ img]http://purebasic.myftp.org/files/44/ric ... _count.png[/img]


[EDIT]
richedit.pb updated
i removed the resident link - i made a consistent archive.

[EDIT]
richedit.pb updated : add unicode compatibility

richedit.pb

Code: Select all

;
; Operating System: Microsoft Windows
; Library: RichEdit.h ( From Win95 To WinXP SP1 )
;


;// windows.h

Macro LCID(lang, subLang) 
  ( ( #SORT_DEFAULT << 16 ) | ( ( subLang << 10 ) | lang ) )
EndMacro
Macro MAKELONG(loWord, hiWord) 
  ( hiWord << 16 | loWord )
EndMacro
Macro MAKEWPARAM(loWord, hiWord) 
  MAKELONG(loWord, hiWord)
EndMacro
Macro MAKELPARAM(loWord, hiWord) 
  MAKELONG(loWord, hiWord)
EndMacro
Macro MAKELRESULT(loWord, hiWord) 
  MAKELONG(loWord, hiWord)
EndMacro


;// Constants


Enumeration ; EM_
  #ECM_FIRST = $1500
  #EM_SETCUEBANNER   = #ECM_FIRST + 1
  #EM_GETCUEBANNER   = #ECM_FIRST + 2
  #EM_SHOWBALLOONTIP = #ECM_FIRST + 3
  #EM_HIDEBALLOONTIP = #ECM_FIRST + 4
EndEnumeration

Enumeration ; KHYPH_
  #khyphNil
  #khyphNormal
  #khyphAddBefore
  #khyphChangeBefore
  #khyphDeleteBefore
  #khyphChangeAfter
  #khyphDelAndChange
EndEnumeration
Enumeration ; TM_
  #TM_PLAINTEXT = 1
  #TM_RICHTEXT = 2
  #TM_SINGLELEVELUNDO = 4
  #TM_MULTILEVELUNDO = 8
  #TM_SINGLECODEPAGE = 16
  #TM_MULTICODEPAGE = 32
EndEnumeration
Enumeration ; UID_
  #UID_UNKNOWN
  #UID_TYPING
  #UID_DELETE
  #UID_DRAGDROP
  #UID_CUT
  #UID_PASTE
EndEnumeration
Enumeration ; TTI_
 #TTI_NONE
 #TTI_INFO
 #TTI_WARNING
 #TTI_ERROR
EndEnumeration


;// Structures, now predefined

; Structure BIDIOPTIONS
;   cbSize.l
;   wMask.w
;   wEffects.w
; EndStructure
; Structure CHARFORMAT
;   cbSize.l
;   dwMask.l
;   dwEffects.l
;   yHeight.l
;   yOffset.l
;   crTextColor.l
;   bCharSet.b
;   bPitchAndFamily.b
;   szFaceName.c[#LF_FACESIZE]
;   wAlignment.w
; EndStructure
; Structure CHARFORMAT2 Extends CHARFORMAT
;   wWeight.w
;   sSpacing.w
;   crBackColor.l
;   lcid.l
;   dwReserved.l
;   sStyle.w
;   wKerning.w
;   bUnderlineType.b
;   bAnimation.b
;   bRevAuthor.b
;   bReserved1.b
; EndStructure
; Structure EDITBALLOONTIP
;   cbStruct.l
;   pszTitle.l
;   pszText.l
;   ttiIcon.l
; EndStructure
; Structure ENLINK
;   nmhdr.NMHDR
;   msg.l
;   wParam.l
;   lParam.l
;   chrg.CHARRANGE
; EndStructure
; Structure ENLOWFIRTF
;   nmhdr.NMHDR
;   *szControl  
; EndStructure
; Structure GETTEXTEX
;   cb.l
;   flags.l
;   codepage.l
;   lpDefaultChar.l
;   lpUsedDefChar.l
; EndStructure
; Structure GETTEXTLENGTHEX
;   flags.l
;   codepage.l
; EndStructure
; Structure HYPHRESULT
;   khyph.l
;   ichHyph.l
;   chHyph.w
; EndStructure
; Structure HYPHENATEINFO
;   cbSize.w
;   dxHyphenateZone.w
;   pfnHyphenate.l
; EndStructure
; Structure IMECOMPTEXT
;   cb.l
;   flags.l
; EndStructure
; Structure OBJECTPOSITIONS
;   nmhdr.NMHDR
;   cObjectCount.l
;   *pcpPositions
; EndStructure
; Structure SETTEXTEX
;   flags.l
;   codepage.l
; EndStructure
; Structure PARAFORMAT
;   cbSize.l
;   dwMask.l
;   wNumbering.w
;   wEffects.w
;   dxStartIndent.l
;   dxRightIndent.l
;   dxOffset.l
;   wAlignment.w
;   cTabCount.w
;   rgxTabs.l[#MAX_TAB_STOPS]
; EndStructure
; Structure PARAFORMAT2 Extends PARAFORMAT
;   dySpaceBefore.l
;   dySpaceAfter.l
;   dyLineSpacing.l
;   sStyle.w
;   bLineSpacingRule.b
;   bOutlineLevel.b
;   wShadingWeight.w
;   wShadingStyle.w
;   wNumberingStart.w
;   wNumberingStyle.w
;   wNumberingTab.w
;   wBorderSpace.w
;   wBorderWidth.w
;   wBorders.w
; EndStructure


;// Macros

Macro EM_AutourLDetect(hWndControl, bool) 
  SendMessage_(hWndControl, #EM_AUTOURLDETECT, bool, #Null)
EndMacro
Macro EM_CanPaste(hWndControl, ClipboardFormat) 
  SendMessage_(hWndControl, #EM_CANPASTE, ClipboardFormat, #Null)
EndMacro
Macro EM_CanRedo(hWndControl) 
  SendMessage_(hWndControl, #EM_CANREDO, #Null, #Null)
EndMacro
Macro EM_CanUndo(hWndControl) 
  SendMessage_(hWndControl, #EM_CANUNDO, #Null, #Null)
EndMacro
Macro EM_CharFromPos(hWndControl, lpPointL) 
  SendMessage_(hWndControl, #EM_CHARFROMPOS, #Null, lpPointL)
EndMacro
Macro EM_DisplayBand(hWndControl, lpRect) 
  SendMessage_(hWndControl, #EM_DISPLAYBAND, #Null, lpRect)
EndMacro
Macro EM_EmptyUndoBuffer(hWndControl) 
  SendMessage_(hWndControl, #EM_EMPTYUNDOBUFFER, #Null, #Null)
EndMacro
Macro EM_FindText(hWndControl, param, lpFindText) 
  SendMessage_(hWndControl, #EM_FINDTEXT, param, lpFindText)
EndMacro
Macro EM_FindTextW(hWndControl, param, lpFindText) 
  SendMessage_(hWndControl, #EM_FINDTEXTEXW, param, lpFindText)
EndMacro
Macro EM_FindTextEx(hWndControl, param, lpFindTextEx) 
  SendMessage_(hWndControl, #EM_FINDTEXTEX, param, lpFindTextEx)
EndMacro
Macro EM_FindTextExW(hWndControl, param, lpFindTextEx) 
  SendMessage_(hWndControl, #EM_FINDTEXTW, param, lpFindTextEx)
EndMacro
Macro EM_FindWordBreak(hWndControl, type, CharPos) 
  SendMessage_(hWndControl, #EM_FINDWORDBREAK, type, CharPos)
EndMacro
Macro EM_FmtLines(hWndControl, bool) 
  SendMessage_(hWndControl, #EM_FMTLINES, bool, #Null)
EndMacro
Macro EM_FormatRange(hWndControl, render, lpFormatRange) 
  SendMessage_(hWndControl, #EM_FORMATRANGE, render, lpFormatRange)
EndMacro
Macro EM_HideBalloonTip(hWndControl) 
  SendMessage_(hWndControl, #EM_HIDEBALLOONTIP, #Null, #Null)
EndMacro
Macro EM_HideSelection(hWndControl, bool) 
  SendMessage_(hWndControl, #EM_HIDESELECTION, bool, #Null)
EndMacro
Macro EM_IsIME(hWndControl) 
  SendMessage_(hWndControl, #EM_ISIME, #Null, #Null)
EndMacro
Macro EM_LimitText(hWndControl, maximum) 
  SendMessage_(hWndControl, #EM_LIMITTEXT, maximum, #Null)
EndMacro
Macro EM_LimitTextEx(hWndControl, maximum) 
  SendMessage_(hWndControl, #EM_EXLIMITTEXT, #Null, maximum)
EndMacro
Macro EM_LineFromChar(hWndControl, CharPos) 
  SendMessage_(hWndControl, #EM_LINEFROMCHAR, CharPos, #Null)
EndMacro
Macro EM_LineFromCharEx(hWndControl, CharPos) 
  SendMessage_(hWndControl, #EM_EXLINEFROMCHAR, #Null, CharPos)
EndMacro
Macro EM_LineIndex(hWndControl, line) 
  SendMessage_(hWndControl, #EM_LINEINDEX, line, #Null)
EndMacro
Macro EM_LineLength(hWndControl, CharLinePos) 
  SendMessage_(hWndControl, #EM_LINELENGTH, CharLinePos, #Null)
EndMacro
Macro EM_LineScroll(hWndControl, number) 
  SendMessage_(hWndControl, #EM_LINESCROLL, #Null, number)
EndMacro
Macro EM_PasteSpecial(hWndControl, ClipboardFormat, lpRepasteSpecial) 
  SendMessage_(hWndControl, #EM_PASTESPECIAL, ClipboardFormat, lpRepasteSpecial)
EndMacro
Macro EM_PosFromChar(hWndControl, lpPointL, CharPos) 
  SendMessage_(hWndControl, #EM_POSFROMCHAR, lpPointL, CharPos)
EndMacro
Macro EM_Reconversion(hWndControl) 
  SendMessage_(hWndControl, #EM_RECONVERSION, #Null, #Null)
EndMacro
Macro EM_Redo(hWndControl) 
  SendMessage_(hWndControl, #EM_REDO, #Null, #Null)
EndMacro
Macro EM_ReplaceSel(hWndControl, undoable, lpszText) 
  SendMessage_(hWndControl, #EM_REPLACESEL, undoable, lpszText)
EndMacro
Macro EM_RequestResize(hWndControl) 
  SendMessage_(hWndControl, #EM_REQUESTRESIZE, #Null, #Null)
EndMacro
Macro EM_Scroll(hWndControl, type) 
  SendMessage_(hWndControl, #EM_SCROLL, type, #Null)
EndMacro
Macro EM_ScrollCaret() 
  SendMessage_(hWndControl, #EM_SCROLLCARET, #Null, #Null)
EndMacro
Macro EM_SelectionType(hWndControl) 
  SendMessage_(hWndControl, #EM_SELECTIONTYPE, #Null, #Null)
EndMacro
Macro EM_ShowBalloonTip(hWndControl, lpEditBalloonTip) 
  SendMessage_(hWndControl, #EM_SHOWBALLOONTIP, #Null, lpEditBalloonTip)
EndMacro
Macro EM_ShowScrollBar(hWndControl, type, bool) 
  SendMessage_(hWndControl, #EM_SHOWSCROLLBAR, type, bool)
EndMacro
Macro EM_StopGroupTyping(hWndControl) 
  SendMessage_(hWndControl, #EM_STOPGROUPTYPING, #Null, #Null)
EndMacro
Macro EM_StreamIn(hWndControl, format, lpEditStream) 
  SendMessage_(hWndControl, #EM_STREAMIN, format, lpEditStream)
EndMacro
Macro EM_StreamOut(hWndControl, format, lpEditStream) 
  SendMessage_(hWndControl, #EM_STREAMOUT, format, lpEditStream)
EndMacro
Macro EM_Undo(hWndControl) 
  SendMessage_(hWndControl, #EM_UNDO, #Null, #Null)
EndMacro


Macro EM_GetAutourLDetect(hWndControl) 
  SendMessage_(hWndControl, #EM_GETAUTOURLDETECT, #Null, #Null)
EndMacro
Macro EM_GetBIDIOptions(hWndControl, lpBIDIOptions) 
  SendMessage_(hWndControl, #EM_GETBIDIOPTIONS, #Null, lpBIDIOptions)
EndMacro
Macro EM_GetCharFormat(hWndControl, format, lpCharFormat) 
  SendMessage_(hWndControl, #EM_GETCHARFORMAT, format, lpCharFormat)
EndMacro
Macro EM_GetCTFModeBias(hWndControl) 
  SendMessage_(hWndControl, #EM_GETCTFMODEBIAS, #Null, #Null)
EndMacro
Macro EM_GetCTFOpenStatus(hWndControl) 
  SendMessage_(hWndControl, #EM_GETCTFOPENSTATUS, #Null, #Null)
EndMacro
Macro EM_GetCueBanner(hWndControl, lpszText) 
  SendMessage_(hWndControl, #EM_GETCUEBANNER, #Null, lpszText)
EndMacro
Macro EM_GetEditStyle(hWndControl) 
  SendMessage_(hWndControl, #EM_GETEDITSTYLE, #Null, #Null)
EndMacro
Macro EM_GetEventMask(hWndControl) 
  SendMessage_(hWndControl, #EM_GETEVENTMASK, #Null, #Null)
EndMacro
Macro EM_GetFirstVisibleLine(hWndControl) 
  SendMessage_(hWndControl, #EM_GETFIRSTVISIBLELINE, #Null, #Null)
EndMacro
Macro EM_GetHandle(hWndControl) 
  SendMessage_(hWndControl, #EM_GETHANDLE, #Null, #Null)
EndMacro
Macro EM_GetHyphenateInfo(hWndControl, lpHyphenateInfo) 
  SendMessage_(hWndControl, #EM_GETHYPHENATEINFO, lpHyphenateInfo, #Null)
EndMacro
Macro EM_GetIMEColor(hWndControl, lpCompColor) 
  SendMessage_(hWndControl, #EM_GETIMECOLOR, #Null, lpCompColor)
EndMacro
Macro EM_GetIMECompMode(hWndControl) 
  SendMessage_(hWndControl, #EM_GETIMECOMPMODE, #Null, #Null)
EndMacro
Macro EM_GetIMECompText(hWndControl, lpIMECompText, lpszText) 
  SendMessage_(hWndControl, #EM_GETIMECOMPTEXT, lpIMECompText, lpszText)
EndMacro
Macro EM_GetIMEModeBias(hWndControl) 
  SendMessage_(hWndControl, #EM_GETIMEMODEBIAS, #Null, #Null)
EndMacro
Macro EM_GetIMEOptions(hWndControl) 
  SendMessage_(hWndControl, #EM_GETIMEOPTIONS, #Null, #Null)
EndMacro
Macro EM_GetIMEProperty(hWndControl, type) 
  SendMessage_(hWndControl, #EM_GETIMEPROPERTY, type, #Null)
EndMacro
Macro EM_GetIMEStatus(hWndControl, type) 
  SendMessage_(hWndControl, #EM_GETIMESTATUS, type, #Null)
EndMacro
Macro EM_GetLangOptions(hWndControl) 
  SendMessage_(hWndControl, #EM_GETLANGOPTIONS, #Null, #Null)
EndMacro
Macro EM_GetLimitText(hWndControl) 
  SendMessage_(hWndControl, #EM_GETLIMITTEXT, #Null, #Null)
EndMacro
Macro EM_GetLine(hWndControl, line, lpszText) 
  SendMessage_(hWndControl, #EM_GETLINE, line, lpszText)
EndMacro
Macro EM_GetLineCount(hWndControl) 
  SendMessage_(hWndControl, #EM_GETLINECOUNT, #Null, #Null)
EndMacro
Macro EM_GetMargins(hWndControl) 
  SendMessage_(hWndControl, #EM_GETMARGINS, #Null, #Null)
EndMacro
Macro EM_GetModify(hWndControl) 
  SendMessage_(hWndControl, #EM_GETMODIFY, #Null, #Null)
EndMacro
Macro EM_GetPasswordChar(hWndControl) 
  SendMessage_(hWndControl, #EM_GETPASSWORDCHAR, #Null, #Null)
EndMacro
Macro EM_GetOLEInterface(hWndControl, lplpIRichEditOle) 
  SendMessage_(hWndControl, #EM_GETOLEINTERFACE, #Null, lplpIRichEditOle)
EndMacro
Macro EM_GetOptions(hWndControl) 
  SendMessage_(hWndControl, #EM_GETOPTIONS, #Null, #Null)
EndMacro
Macro EM_GetPageRotate(hWndControl) 
  SendMessage_(hWndControl, #EM_GETPAGEROTATE, #Null, #Null)
EndMacro
Macro EM_GetParaFormat(hWndControl, lpParaFormat) 
  SendMessage_(hWndControl, #EM_GETPARAFORMAT, #Null, lpParaFormat)
EndMacro
Macro EM_GetPunctuation(hWndControl, type, lpPunctuation) 
  SendMessage_(hWndControl, #EM_GETPUNCTUATION, type, lpPunctuation)
EndMacro
Macro EM_GetRect(hWndControl, lpRect) 
  SendMessage_(hWndControl, #EM_GETRECT, #Null, lpRect)
EndMacro
Macro EM_GetRedoName(hWndControl) 
  SendMessage_(hWndControl, #EM_GETREDONAME, #Null, #Null)
EndMacro
Macro EM_GetScrollPos(hWndControl, lpPoint) 
  SendMessage_(hWndControl, #EM_GETSCROLLPOS, #Null, lpPoint)
EndMacro
Macro EM_GetSel(hWndControl, lpCharPos1, lpCharPos2) 
  SendMessage_(hWndControl, #EM_GETSEL, lpCharPos1, lpCharPos2)
EndMacro
Macro EM_GetSelEx(hWndControl, lpCharRange) 
  SendMessage_(hWndControl, #EM_EXGETSEL, #Null, lpCharRange)
EndMacro
Macro EM_GetSelText(hWndControl, lpText) 
  SendMessage_(hWndControl, #EM_GETSELTEXT, #Null, lpText)
EndMacro
Macro EM_GetTextEx(hWndControl, lpGetTextEx, lpszText) 
  SendMessage_(hWndControl, #EM_GETTEXTEX, lpGetTextEx, lpszText)
EndMacro
Macro EM_GetTextLengthEx(hWndControl, lpGetTextLengthEx) 
  SendMessage_(hWndControl, #EM_GETTEXTLENGTHEX, lpGetTextLengthEx, #Null)
EndMacro
Macro EM_GetTextMode(hWndControl) 
  SendMessage_(hWndControl, #EM_GETTEXTMODE, #Null, #Null)
EndMacro
Macro EM_GetTextRange(hWndControl, lpTextRange) 
  SendMessage_(hWndControl, #EM_GETTEXTRANGE, #Null, lpTextRange)
EndMacro
Macro EM_GetThumb(hWndControl) 
  SendMessage_(hWndControl, #EM_GETTHUMB, #Null, #Null)
EndMacro
Macro EM_GetTypographyOptions(hWndControl) 
  SendMessage_(hWndControl, #EM_GETTYPOGRAPHYOPTIONS, #Null, #Null)
EndMacro
Macro EM_GetUndoName(hWndControl) 
  SendMessage_(hWndControl, #EM_GETUNDONAME, #Null, #Null)
EndMacro
Macro EM_GetWordBreakProc(hWndControl) 
  SendMessage_(hWndControl, #EM_GETWORDBREAKPROC, #Null, #Null)
EndMacro
Macro EM_GetWordBreakProcEx(hWndControl) 
  SendMessage_(hWndControl, #EM_GETWORDBREAKPROCEX, #Null, #Null)
EndMacro
Macro EM_GetWordWrapMode(hWndControl) 
  SendMessage_(hWndControl, #EM_GETWORDWRAPMODE, #Null, #Null)
EndMacro
Macro EM_GetZoom(hWndControl, lpNumerator, lpDenominator) 
  SendMessage_(hWndControl, #EM_GETZOOM, lpNumerator, lpDenominator)
EndMacro


Macro EM_SetBIDIOptions(hWndControl, lpBIDIOptions) 
  SendMessage_(hWndControl, #EM_SETCTFMODEBIAS, #Null, lpBIDIOptions)
EndMacro
Macro EM_SetBkgndColor(hWndControl, color) 
  SendMessage_(hWndControl, #EM_SETBKGNDCOLOR, #Null, color)
EndMacro
Macro EM_SetCharFormat(hWndControl, type, lpFormat) 
  SendMessage_(hWndControl, #EM_SETCHARFORMAT, type, lpFormat)
EndMacro
Macro EM_SetCTFModeBias(hWndControl, mode) 
  SendMessage_(hWndControl, #EM_SETCTFMODEBIAS, mode, #Null)
EndMacro
Macro EM_SetCTFOpenStatus(hWndControl, bool) 
  SendMessage_(hWndControl, #EM_SETCTFOPENSTATUS, bool, #Null)
EndMacro
Macro EM_SetCueBanner(hWndControl, lpszText) 
  SendMessage_(hWndControl, #EM_SETCUEBANNER, #Null, lpszText)
EndMacro
Macro EM_SetEditStyle(hWndControl, type, mask) 
  SendMessage_(hWndControl, #EM_SETEDITSTYLE, type, mask)
EndMacro
Macro EM_SetEventMask(hWndControl, mask) 
  SendMessage_(hWndControl, #EM_SETEVENTMASK, #Null, mask) 
EndMacro
Macro EM_SetFontSize(hWndControl, size) 
  SendMessage_(hWndControl, #EM_SETFONTSIZE, size, #Null)
EndMacro
Macro EM_SetHandle(hWndControl, lpBuffer) 
  SendMessage_(hWndControl, #EM_SETHANDLE, lpBuffer, #Null)
EndMacro
Macro EM_SetHyphenateInfo(hWndControl, lpHyphenateInfo) 
  SendMessage_(hWndControl, #EM_SETHYPHENATEINFO, lpHyphenateInfo, #Null)
EndMacro
Macro EM_SetIMEColor(hWndControl, lpCompColor) 
  SendMessage_(hWndControl, #EM_SETIMECOLOR, #Null, lpCompColor)
EndMacro
Macro EM_SetIMEModeBias(hWndControl, mode) 
  SendMessage_(hWndControl, #EM_SETIMEMODEBIAS, mode, mode)
EndMacro
Macro EM_SetIMEOptions(hWndControl, ecoop, imf) 
  SendMessage_(hWndControl, #EM_SETIMEOPTIONS, ecoop, imf)
EndMacro
Macro EM_SetIMEStatus(hWndControl, type, lpData) 
  SendMessage_(hWndControl, #EM_SETIMESTATUS, type, lpData)
EndMacro
Macro EM_SetLangOptions(hWndControl, option) 
  SendMessage_(hWndControl, #EM_SETLANGOPTIONS, #Null, option)
EndMacro
Macro EM_SetLimitText(hWndControl, maximum) 
  SendMessage_(hWndControl, #EM_SETLIMITTEXT, maximum, #Null)
EndMacro
Macro EM_SetMargins(hWndControl, types, width) 
  SendMessage_(hWndControl, #EM_SETMARGINS, types, width)
EndMacro
Macro EM_SetModify(hWndControl, bool) 
  SendMessage_(hWndControl, #EM_SETMODIFY, bool, #Null)
EndMacro
Macro EM_SetOLECallback(hWndControl, lpIRichEditOle) 
  SendMessage_(hWndControl, #EM_SETOLECALLBACK, #Null, lpIRichEditOle)
EndMacro
Macro EM_SetOptions(hWndControl, ecoop, eco) 
  SendMessage_(hWndControl, #EM_SETOPTIONS, ecoop, eco)
EndMacro
Macro EM_SetPageRotate(hWndControl, layout)
  SendMessage_(hWndControl, #EM_SETPAGEROTATE, layout, #Null)
EndMacro
Macro EM_SetPalette(hWndControl, lpPalette) 
  SendMessage_(hWndControl, #EM_SETPALETTE, lpPalette, #Null)
EndMacro
Macro EM_SetParaFormat(hWndControl, lpParaFormat) 
  SendMessage_(hWndControl, #EM_SETPARAFORMAT, #Null, lpParaFormat)
EndMacro
Macro EM_SetPasswordChar(hWndControl, char) 
  SendMessage_(hWndControl, #EM_SETPASSWORDCHAR, char, #Null)
EndMacro
Macro EM_SetPunctuation(hWndControl, type, lpPunctuation) 
  SendMessage_(hWndControl, #EM_SETPUNCTUATION, type, lpPunctuation)
EndMacro
Macro EM_SetReadOnly(hWndControl, bool) 
  SendMessage_(hWndControl, #EM_SETREADONLY, bool, #Null)
EndMacro
Macro EM_SetRect(hWndControl, bool, lpRect) 
  SendMessage_(hWndControl, #EM_SETRECT, bool, lpRect)
EndMacro
Macro EM_SetRectNP(hWndControl, bool, lpRect) 
  SendMessage_(hWndControl, #EM_SETRECTNP, bool, lpRect)
EndMacro
Macro EM_SetScrollPos(hWndControl, lpPoint) 
  SendMessage_(hWndControl, #EM_SETSCROLLPOS, #Null, lpPoint)
EndMacro
Macro EM_SetSel(hWndControl, CharPos1, CharPos2) 
  SendMessage_(hWndControl, #EM_SETSEL, CharPos1, CharPos2)
EndMacro
Macro EM_SetSelEx(hWndControl, lpCharRange) 
  SendMessage_(hWndControl, #EM_EXSETSEL, #Null, lpCharRange)
EndMacro
Macro EM_SetTabStops(hWndControl, number, lpArray) 
  SendMessage_(hWndControl, #EM_SETTABSTOPS, number, lpArray)
EndMacro
Macro EM_SetTargetDevice(hWndControl, hDC, lineWidth) 
  SendMessage_(hWndControl, #EM_SETTARGETDEVICE, hDC, lineWidth)
EndMacro
Macro EM_SetTextEx(hWndControl, lpSetTextEx, lpszText) 
  SendMessage_(hWndControl, #EM_SETTEXTEX, lpSetTextEx, lpszText)
EndMacro
Macro EM_SetTextMode(hWndControl, mode) 
  SendMessage_(hWndControl, #EM_SHOWSCROLLBAR, mode, #Null)
EndMacro
Macro EM_SetTypographyOptions(hWndControl, type, mask) 
  SendMessage_(hWndControl, #EM_SETTYPOGRAPHYOPTIONS, type, mask)
EndMacro
Macro EM_SetUndoLimit(hWndControl, maximum) 
  SendMessage_(hWndControl, #EM_SETUNDOLIMIT, maximum, #Null)
EndMacro
Macro EM_SetWordBreakProc(hWndControl, lpEditWordBreakProc) 
  SendMessage_(hWndControl, #EM_SETWORDBREAKPROC, #Null, lpEditWordBreakProc)
EndMacro
Macro EM_SetWordBreakProcEx(hWndControl, lpEditWordBreakProcEx) 
  SendMessage_(hWndControl, #EM_SETWORDBREAKPROCEX, #Null, lpEditWordBreakProcEx)
EndMacro
Macro EM_SetWordWrapMode(hWndControl, mode) 
  SendMessage_(hWndControl, #EM_SETWORDWRAPMODE, mode, #Null)
EndMacro
Macro EM_SetZoom(hWndControl, numerator, denominator) 
  SendMessage_(hWndControl, #EM_SETZOOM, numerator, denominator)
EndMacro


;// Functions

Procedure.l Ansi2Uni(ansi.s)
  
  Protected lAnsi.l, lUnicode.l, hUnicode.l
  
  lAnsi = MultiByteToWideChar_(#CP_ACP, 0, ansi, -1, 0, 0) 
  lUnicode = lAnsi * SizeOf(WORD)
  hUnicode = AllocateMemory(lUnicode)
  MultiByteToWideChar_(#CP_ACP, 0, @ansi, lAnsi, hUnicode, lUnicode)
  
  ProcedureReturn hUnicode
  
EndProcedure

Procedure.l Edit_SetCueBannerText(hWndControl, text.s)
  
  CompilerIf #PB_Compiler_Unicode
    
    ProcedureReturn EM_SetCueBanner(hWndControl, @text)
    
  CompilerElse
    
    Protected lResult.l, hText.l
    hText = Ansi2Uni(text)
    lResult = EM_SetCueBanner(hWndControl, hText)
    FreeMemory(hText)
    ProcedureReturn lResult
    
  CompilerEndIf
  
EndProcedure
Procedure.l Edit_ShowBalloonTip(hWndControl, title.s, text.s, ttiIcon.l)
  
  CompilerIf #PB_Compiler_Unicode
    
    Protected ebt.EDITBALLOONTIP
    ebt\cbStruct = SizeOf(ebt)
    ebt\ttiIcon  = ttiIcon
    ebt\pszText  = @text
    ebt\pszTitle = @title
    ProcedureReturn EM_ShowBalloonTip(hWndControl, @ebt)
    
  CompilerElse
    
    Protected lResult.l, ebt.EDITBALLOONTIP
    ebt\cbStruct = SizeOf(ebt)
    ebt\ttiIcon  = ttiIcon
    ebt\pszText  = Ansi2Uni(text)
    ebt\pszTitle = Ansi2Uni(title)
    lResult = EM_ShowBalloonTip(hWndControl, @ebt)
    FreeMemory(ebt\pszText)
    FreeMemory(ebt\pszTitle)
    ProcedureReturn lResult
    
  CompilerEndIf
  
EndProcedure

;// EOF

Posted: Mon Apr 17, 2006 4:52 pm
by Flype
Code updated for 5.20+

Two interessants - XP only - features for the EditorGadget
I discovered them while making the includefile.

[ img]http://purebasic.myftp.org/files/44/ric ... nshot1.PNG[/img]

Code: Select all

; Windows XP only
; XP Theme enabled in compiler options

XIncludeFile "richedit.pb"

If OpenWindow(0, 0, 0, 320, 240, "EditorGadgetXP", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  
  hGad1 = StringGadget(1, 5,  5, 310,  22, "")
  hGad2 = StringGadget(2, 5, 30, 310,  22, "")
  
  Edit_SetCueBannerText(hGad1, "Enter constant here")
  Edit_SetCueBannerText(hGad2, "Enter function here")
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
      Case #PB_Event_Gadget
        If EventType() = 14000
          Select EventGadget()
            Case 1: Edit_ShowBalloonTip(hGad1, "Find a constant", "Enter the constant here !", #TTI_INFO)
            Case 2: Edit_ShowBalloonTip(hGad2, "Find a function", "Enter the function here !", #TTI_INFO)
          EndSelect
        EndIf
    EndSelect
  ForEver
  
EndIf

Posted: Mon Apr 17, 2006 5:47 pm
by Rescator
The baloon tip example does not work properly if unicode is enabled!
Only the first letter is shown!

Posted: Mon Apr 17, 2006 8:45 pm
by Flype
You're right,
It was normal but now it works in both mode (first post edited).

Posted: Mon Apr 17, 2006 11:42 pm
by Flype
Code updated for 5.20+

another interessant use (xp only) :

[ img]http://purebasic.myftp.org/files/44/ric ... nshot2.PNG[/img]

Code: Select all

; Windows XP only
; XP Theme enabled in compiler options

EnableExplicit

XIncludeFile "richedit.pb"

Procedure.l EditorGadget_CheckAmount(gId.l)
  
  Static oldInput.s
  Protected hGadget.l, curPos1.l, curPos2.l, curInput.s, curChar.c
  
  If IsGadget(gId)
    hGadget = GadgetID(gId)
    curInput = GetGadgetText(gId)
    If curInput
      EM_GetSel(hGadget, @curPos1, @curPos2)
      curChar = Asc(Mid(curInput, curPos1, 1))
      If ((curChar>='0') And (curChar<='9')) Or (curChar='.')
        If CountString(curInput, ".") < 2
          If Len(curInput) = EM_GetLimitText(hGadget)
            Edit_ShowBalloonTip(hGadget, "Field `Amount`", "The maximum number of caracters for an amount is fixed to "+Str(EM_GetLimitText(hGadget))+" !", #TTI_INFO)
          ElseIf Len(StringField(curInput, 1, ".")) > 9
            Edit_ShowBalloonTip(hGadget, "Field `Amount`", "An amount is usually composed by a maximum of 9 digits before the point !", #TTI_WARNING)
          ElseIf Len(StringField(curInput, 2, ".")) > 2
            Edit_ShowBalloonTip(hGadget, "Field `Amount`", "An amount is usually composed by a maximum of 2 digits after the point !", #TTI_WARNING)
          EndIf
          oldInput = curInput
        Else
          Edit_ShowBalloonTip(hGadget, "Field `Amount`", "Only one point is allowed !", #TTI_ERROR)
          SetGadgetText(gId, oldInput)
          EM_SetSel(hGadget, curPos1-1, curPos2-1)
        EndIf
      Else
        Edit_ShowBalloonTip(hGadget, "Field `Amount`", "Allowed caracters : . 0 1 2 3 4 5 6 7 8 9", #TTI_ERROR)
        SetGadgetText(gId, oldInput)
        EM_SetSel(hGadget, curPos1-1, curPos2-1)
      EndIf
    EndIf
  EndIf
  
EndProcedure
Procedure.l EditorGadget_CheckFilename(gId.l)
  
  Static oldInput.s
  Protected hGadget.l, curPos1.l, curPos2.l, curInput.s
  
  If IsGadget(gId)
    hGadget = GadgetID(gId)
    curInput = GetGadgetText(gId)
    If curInput
      EM_GetSel(hGadget, @curPos1, @curPos2)
      If CheckFilename(curInput)
        If FindString(curInput, " ", curPos1)
          Edit_ShowBalloonTip(hGadget, "Field `Filename`", "Spaces are allowed but it might cause problem with some program !", #TTI_INFO)
        ElseIf Len(curInput) = EM_GetLimitText(hGadget)
          Edit_ShowBalloonTip(hGadget, "Field `Filename`", "The maximum number of caracters for a filename is fixed to "+Str(EM_GetLimitText(hGadget))+" !", #TTI_ERROR)
        EndIf
        oldInput = curInput
      Else
        Edit_ShowBalloonTip(hGadget, "Field `Filename`", "Forbidden caracters : / \ : * ? < > | "+Chr(34), #TTI_ERROR)
        SetGadgetText(gId, oldInput)
        EM_SetSel(hGadget, curPos1-1, curPos2-1)
      EndIf
    EndIf
  EndIf
  
EndProcedure

If OpenWindow(0, 0, 0, 200, 110, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  
  TextGadget  (1, 5,  5, 190,  18, "Amount :")
  StringGadget(2, 5, 25, 190,  22, "", #PB_Text_Right)
  TextGadget  (3, 5, 55, 190,  18, "Filename :")
  StringGadget(4, 5, 75, 190,  22, "")
  
  EM_SetLimitText(GadgetID(2), 12)
  EM_SetLimitText(GadgetID(4), #MAX_PATH)
  Edit_SetCueBannerText(GadgetID(2), "<Enter an amount>")
  Edit_SetCueBannerText(GadgetID(4), "<Enter a filename>")
  
  Repeat
    
    Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
        Break
        
      Case #PB_Event_Gadget
        If EventType() = #PB_EventType_Change
          Select EventGadget()
            Case 2: EditorGadget_CheckAmount(2)
            Case 4: EditorGadget_CheckFilename(4)
          EndSelect
        EndIf
        
    EndSelect
    
  ForEver
  
EndIf

Posted: Tue Apr 18, 2006 8:51 am
by Flype
archive has just been updated.

Posted: Tue Apr 18, 2006 8:16 pm
by Flype
Code updated for 5.20+

Another example.
This time it shows how to opening/formatting weblink inside an EditorGadget()
( zip archive updated )

Code: Select all

EnableExplicit

XIncludeFile "richedit.pb"

Procedure myWindowCallback(hWnd.l, uMsg.l, wParam.l, lParam.l)
  
  Protected *pnmh.NMHDR
  Protected *link.ENLINK
  Protected lResult.l = #PB_ProcessPureBasicEvents
  
  Select uMsg
    Case #WM_NOTIFY
      *pnmh = lParam
      Select *pnmh\code
        Case #EN_LINK
          *link = lParam
          Select *link\msg
            Case #WM_LBUTTONUP ; can be #WM_LBUTTONDBLCLK
              Define.TEXTRANGE tr
              tr\chrg\cpMin = *link\chrg\cpMin
              tr\chrg\cpMax = *link\chrg\cpMax
              tr\lpstrText = AllocateMemory(tr\chrg\cpMax-tr\chrg\cpMin+1)
              If tr\lpstrText
                If EM_GetTextRange(GadgetID(*pnmh\idFrom), @tr)
                  RunProgram(PeekS(tr\lpstrText))
                  Debug PeekS(tr\lpstrText)
                EndIf
                FreeMemory(tr\lpstrText)
              EndIf
          EndSelect
      EndSelect
  EndSelect
  
  ProcedureReturn lResult
  
EndProcedure

If OpenWindow(0, 0, 0, 300, 110, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  
  EditorGadget(1, 5, 5, 290, 100)
  
  EM_AutourLDetect(GadgetID(1), #True)
  EM_SetEventMask(GadgetID(1), EM_GetEventMask(GadgetID(1))|#ENM_LINK)
  
  Define.s txt
  
  txt = "Get PureBasic at http://www.purebasic.com." + #LF$ + #LF$
  txt + "For support, mailto:support@purebasic.com" + #LF$ + #LF$
  txt + "End."
  
  SetGadgetText(1, txt)
    
  SetWindowCallback(@myWindowCallback())
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow: Break
    EndSelect
  ForEver
  
EndIf

Posted: Sat Apr 22, 2006 7:00 am
by Fangbeast
Constant not found "#EN_LINK"

Posted: Sat Apr 22, 2006 12:21 pm
by Flype
hello fang,

1/ did you downloaded the richedit.zip on the first post ?
2/ did you downloaded purebasic 4 beta 11 ?

Posted: Sat Apr 22, 2006 12:38 pm
by Fangbeast
yes to both:):):)

Posted: Sat Apr 22, 2006 12:45 pm
by Flype
that's strange, fred has included EN_LINK since beta11.
so i do no need to declare it in the richedit.res.pb

anyway here is the stucture :

Code: Select all

Structure ENLINK
  nmhdr.NMHDR
  msg.l
  wParam.l
  lParam.l
  chrg.CHARRANGE
EndStructure

Posted: Sat Apr 22, 2006 1:41 pm
by Fangbeast
Stranger than me?? (grin).

By the way, still waiting for your email before I do any more with the MySql client.

Posted: Sun Apr 23, 2006 10:27 pm
by Flype
ok, it's ready fangbeast.

here is my mysql syntax parser which can be included in your project.

it was not easy to do but seems to works well enough.

http://www.penguinbyte.com/apps/pbwebst ... _mysql.zip

:wink:

Posted: Mon Apr 24, 2006 1:15 am
by Fangbeast
This should be fun. I just changed the query entry area to a multiline query adder just for this:):)

Posted: Mon Apr 24, 2006 1:21 am
by va!n
@Flype:
wow, seems someone cant sleep and is coding 24h/day ;) nice work!