$PBExportHeader$uo_html_editor.sru
forward
global type uo_html_editor from userobject
end type
type pb_underline from picturebutton within uo_html_editor
end type
type pb_textcolor from picturebutton within uo_html_editor
end type
type pb_numbers from picturebutton within uo_html_editor
end type
type pb_bullets from picturebutton within uo_html_editor
end type
type pb_italic from picturebutton within uo_html_editor
end type
type pb_outdent from picturebutton within uo_html_editor
end type
type pb_bold from picturebutton within uo_html_editor
end type
type pb_indent from picturebutton within uo_html_editor
end type
type pb_left from picturebutton within uo_html_editor
end type
type pb_center from picturebutton within uo_html_editor
end type
type pb_right from picturebutton within uo_html_editor
end type
type pb_full from picturebutton within uo_html_editor
end type
type pb_line from picturebutton within uo_html_editor
end type
type pb_hyperlink from picturebutton within uo_html_editor
end type
type pb_picture from picturebutton within uo_html_editor
end type
type ddlb_fontsize from dropdownlistbox within uo_html_editor
end type
type ddlb_font from dropdownlistbox within uo_html_editor
end type
type ole_web from olecustomcontrol within uo_html_editor
end type
type bitmapinfoheader from structure within uo_html_editor
end type
type bitmapfileheader from structure within uo_html_editor
end type
type bitmapinfo from structure within uo_html_editor
end type
end forward

type bitmapinfoheader from structure
	long		bisize
	long		biwidth
	long		biheight
	integer		biplanes
	integer		bibitcount
	long		bicompression
	long		bisizeimage
	long		bixpelspermeter
	long		biypelspermeter
	long		biclrused
	long		biclrimportant
end type

type bitmapfileheader from structure
	integer		bftype
	long		bfsize
	integer		bfreserved1
	integer		bfreserved2
	long		bfoffbits
end type

type bitmapinfo from structure
	bitmapinfoheader		bmiheader 
	unsignedlong		bmicolors[]
end type

global type uo_html_editor from userobject
integer width = 3346
integer height = 1812
long backcolor = 16777215
string text = "none"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event size pbm_size
event ue_afterinit ( )
event getfocus pbm_bnsetfocus
event losefocus pbm_bnkillfocus
pb_underline pb_underline
pb_textcolor pb_textcolor
pb_numbers pb_numbers
pb_bullets pb_bullets
pb_italic pb_italic
pb_outdent pb_outdent
pb_bold pb_bold
pb_indent pb_indent
pb_left pb_left
pb_center pb_center
pb_right pb_right
pb_full pb_full
pb_line pb_line
pb_hyperlink pb_hyperlink
pb_picture pb_picture
ddlb_fontsize ddlb_fontsize
ddlb_font ddlb_font
ole_web ole_web
end type
global uo_html_editor uo_html_editor

type prototypes
function string getfontfaces() library "pbgdiex.dll" alias for "getfontfaces;Ansi"



Function ulong CameraSubArea() LIBRARY "CameraDll.dll" alias for "CameraSubArea;Ansi"
FUNCTION Boolean OpenClipboard(ULong hWndNewOwner) LIBRARY "user32.dll"   Alias For "OpenClipboard;Ansi"
FUNCTION Boolean CloseClipboard() LIBRARY "user32.dll"  Alias For "CloseClipboard;Ansi"
FUNCTION ULong GetClipboardData(ulong wFormat) LIBRARY "user32.dll"  Alias For "GetClipboardData;Ansi"
FUNCTION ulong IsClipboardFormatAvailable(ulong wFormat) LIBRARY "user32.dll"  Alias For "IsClipboardFormatAvailable;Ansi"
FUNCTION ULong GetDesktopWindow() LIBRARY "user32.dll"  Alias For "GetDesktopWindow;Ansi"
FUNCTION ULong GetDC(ULong hWnd) LIBRARY "user32.dll"  Alias For "GetDC;Ansi"
FUNCTION ULong CreateCompatibleDC(ULong hdc) LIBRARY "gdi32.dll"  Alias For "CreateCompatibleDC;Ansi"
FUNCTION ULong SelectObject(ULong hdc,ULong hgdiobj) LIBRARY "gdi32.dll"  Alias For "SelectObject;Ansi"
FUNCTION Int GetDIBits(ULong hdc,ULong hbmp,UInt uStartScan,UInt cScanLines,REF Blob lpvBits,REF bitmapinfo lpbi,UInt uUsage) LIBRARY "gdi32.dll" alias for "GetDIBits;Ansi"  
FUNCTION Int GetDIBits(ULong hdc,ULong hbmp,UInt uStartScan,UInt cScanLines, ULong lpvBits, REF bitmapinfo lpbi, UInt uUsage) LIBRARY "gdi32.dll" alias for "GetDIBits;Ansi"  
SUBROUTINE CopyBitmapFileHeader(REF Blob Destination, bitmapfileheader Source,Long Length) LIBRARY "kernel32.dll"  ALIAS FOR "RtlMoveMemory;Ansi"  
SUBROUTINE CopyBitmapInfo(REF Blob Destination, bitmapinfo Source,Long Length) LIBRARY "kernel32.dll"  ALIAS FOR "RtlMoveMemory" 
FUNCTION Boolean DeleteDC(ULong hdc) LIBRARY "gdi32.dll"   Alias For "DeleteDC;Ansi"
FUNCTION Int ReleaseDC(ULong hWnd,ULong hdc) LIBRARY "user32.dll"   Alias For "ReleaseDC;Ansi"
FUNCTION ULong CreateFile(String lpFileName, ULong dwDesiredAccess, ULong dwShareMode, ULong lpSecurityAttributes, ULong dwCreationDisposition, &  
ULong dwFlagsAndAttributes, ULong hTemplateFile ) LIBRARY "kernel32.dll" ALIAS FOR "CreateFileA;Ansi"  
FUNCTION Boolean WriteFile(ULong hFile,Blob lpBuffer,ULong nNumberOfBytesToWrite,REF ULong lpNumberOfBytesWritten, &  
ULong lpOverlapped) LIBRARY "kernel32.dll"  Alias For  "WriteFile;Ansi"
FUNCTION Boolean CloseHandle(ULong hObject) LIBRARY "kernel32.dll"  Alias For "CloseHandle;Ansi"

FUNCTION Integer GlobalAddAtom(ref string lpString) LIBRARY "kernel32.dll" ALIAS FOR "GlobalAddAtomA" 
FUNCTION ulong RegisterHotKey(ulong hwnd,ulong id,ulong fsModifiers,ulong vk) LIBRARY "user32.dll"
FUNCTION ulong UnregisterHotKey( ulong hWnd, ulong id ) LIBRARY "user32.dll"
end prototypes

type variables
boolean ib_shown = false
long sys_atomid,sys_handle
constant integer MOD_ALT = 1 //ALT键
constant integer MOD_CONTROL = 2 //CTRL键
constant integer MOD_SHIFT = 4 //SHIFT键
string fjfilepathname = 'fjtemp'
end variables

forward prototypes
public subroutine uf_refreshtoolbar ()
public subroutine uf_addfonts ()
public function string uf_gethtml ()
public function string uf_gettext ()
public function integer uf_sethtml (string arg_html)
public subroutine uf_settext (string arg_text)
public function integer uf_test ()
public function integer uf_setbackground (string arg_path)
public function string uf_style_jianyue ()
public function string uf_style_shuangwu ()
public function string uf_style_zidingyi ()
public subroutine uf_setcontenteditable (string arg_set)
public subroutine uf_navigate (string arg_path)
public subroutine uf_setreadonly ()
public subroutine uf_getfont ()
public subroutine uf_setfont ()
public subroutine wf_picturetofile ()
end prototypes

event size;if this.width < 2500 then
	this.hscrollbar = true
	ole_web.width = 2500
else
	this.hscrollbar = false
	ole_web.width = this.width
end if

if this.height < 600 then
	this.vscrollbar = true
	ole_web.height = 600 - ole_web.y
else
	this.vscrollbar = false
	ole_web.height = this.height - ole_web.y
end if

end event

event losefocus;// unRegisterHotKey(Handle(this), atomid)
//messagebox("","eeew")
//IF  not IsNull(ClassName(GetFocus())) THEN
//	messagebox("",string(ClassName(GetFocus())))
//end if
//messagebox("","lose")
end event

public subroutine uf_refreshtoolbar ();string ls_fontname
long ll_fontsize
boolean lb_bold,lb_italic,lb_underline, lb_numbers, lb_bullets, lb_left, lb_center, lb_right, lb_full

ls_fontname = string(ole_web.object.document.queryCommandValue("FontName"))
long ll_index
ll_index = ddlb_font.finditem(ls_fontname, 1)
if ll_index > 0 then
	ddlb_font.selectitem(ll_index)
end if
ll_fontsize = long(ole_web.object.document.queryCommandValue("FontSize"))
ddlb_fontsize.selectitem(ll_fontsize)

lb_bold = ole_web.object.document.queryCommandState("Bold")
lb_italic = ole_web.object.document.queryCommandState("Italic")
lb_underline = ole_web.object.document.queryCommandState("Underline")

lb_numbers = ole_web.object.document.queryCommandState("InsertOrderedList")
lb_bullets = ole_web.object.document.queryCommandState("InsertUnorderedList")

lb_left = ole_web.object.document.queryCommandState("JustifyLeft")
lb_center = ole_web.object.document.queryCommandState("JustifyCenter")
lb_right = ole_web.object.document.queryCommandState("JustifyRight")
lb_full = ole_web.object.document.queryCommandState("JustifyFull")

if lb_bold then
	pb_bold.picturename = pb_bold.tag
else
	pb_bold.picturename = pb_bold.disabledname
end if

if lb_italic then
	pb_italic.picturename = pb_italic.tag
else
	pb_italic.picturename = pb_italic.disabledname
end if

if lb_underline then
	pb_underline.picturename = pb_underline.tag
else
	pb_underline.picturename = pb_underline.disabledname
end if

if lb_numbers then
	pb_numbers.picturename = pb_numbers.tag
else
	pb_numbers.picturename = pb_numbers.disabledname
end if

if lb_bullets then
	pb_bullets.picturename = pb_bullets.tag
else
	pb_bullets.picturename = pb_bullets.disabledname
end if

if lb_left then
	pb_left.picturename = pb_left.tag
else
	pb_left.picturename = pb_left.disabledname
end if

if lb_center then
	pb_center.picturename = pb_center.tag
else
	pb_center.picturename = pb_center.disabledname
end if

if lb_right then
	pb_right.picturename = pb_right.tag
else
	pb_right.picturename = pb_right.disabledname
end if

if lb_full then
	pb_full.picturename = pb_full.tag
else
	pb_full.picturename = pb_full.disabledname
end if

end subroutine

public subroutine uf_addfonts ();string ls_fonts
long ll_num1, ll_num2
ls_fonts = getfontfaces()
if isnull(ls_fonts) OR len(ls_fonts) <= 0 then return 
ll_num1 = 1
ll_num2 = pos(ls_fonts, '~t', ll_num1)
do while ll_num2 > 0
	ddlb_font.additem(trim(mid(ls_fonts, ll_num1, ll_num2 - ll_num1)))
	ll_num1 = ll_num2 + 1
	ll_num2 = pos(ls_fonts, '~t', ll_num1)
loop

end subroutine

public function string uf_gethtml ();string rslt
//if isnull(ole_web.object) then
//	rslt=''
//	goto ext
//end if 
//if isnull(ole_web.object.document) then
//	rslt=''
//	goto ext
//end if 
//if isnull(ole_web.object.document.body) then
//	rslt=''
//	goto ext
//end if 
do while isnull(ole_web.object.document.body)
//	yield()
	rslt=''
	goto ext
loop

rslt=ole_web.object.document.body.innerHtml

ext:
return rslt
end function

public function string uf_gettext ();string rslt
rslt=ole_web.object.document.body.innerText
//messagebox('',rslt)
return rslt
end function

public function integer uf_sethtml (string arg_html);//
//if isnull(ole_web.object) then
//	arg_html=''
//	goto ext
//end if 
//if isnull(ole_web.object.document) then
//	arg_html=''
//	goto ext
//end if 
//if isnull(ole_web.object.document.body) then
//	arg_html=''
//	goto ext
//end if 
//messagebox('','1'+arg_html)
do while isnull(ole_web.object.document.body)
	yield()
loop

//ext:

ole_web.object.document.body.innerhtml = arg_html
//messagebox('','2'+string(ole_web.object.document.body.innerhtml))
return 1
end function

public subroutine uf_settext (string arg_text);//
ole_web.object.document.body.innerText=arg_text
end subroutine

public function integer uf_test ();string body
//body='<BODY style="MARGIN: 0px" contentEditable=false><TABLE style="WIDTH: 100%; TABLE-LAYOUT: fixed; HEIGHT: 100%" border=0 cellSpacing=0 cellPadding=0 background="D:\Program Files\Foxmail 7.0\Data\MyStationery\002\5.jpg">'&
//+'<TBODY>'&
//+'<TR>'&
//+'<TD vAlign=top align=left><IMG src="file:///D:/Program%20Files/Foxmail%207.0/Data/MyStationery/002/头像.jpg"></TD></TR>'&
//+'<TR>'&
//+'<TD style="PADDING-BOTTOM: 10px; LINE-HEIGHT: 1.5; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-FAMILY: 微软雅黑; COLOR: #000000; FONT-SIZE: 10.5pt; PADDING-TOP: 10px" height="100%" vAlign=top width="100%">'&
//+'<DIV style="WIDTH: 100%; WHITE-SPACE: normal; WORD-BREAK: break-all" id=divFMContentBody contentEditable=true>'&
//+'<DIV>ghnvbnvb</DIV>'&
//+'<DIV>vbnvbn</DIV>'&
//+'<DIV>vbnvbnv</DIV>'&
//+'<DIV>vbnvbv</DIV>'&
//+'<DIV>vbvvnvbnvbn</DIV>'&
//+'<DIV>vbnbnvbnvbn</DIV>'&
//+'<DIV>vbnvbnbnvnvnv</DIV>'&
//+'<DIV>&nbsp;</DIV></DIV></TD></TR>'&
//+'<TR>'&
//+'<TD vAlign=bottom align=left><IMG src="file:///D:/Program%20Files/Foxmail%207.0/Data/MyStationery/002/feilvbin.jpg"></TD></TR></TBODY></TABLE></BODY>'
//
body=uf_style_jianyue()

ole_web.object.document.body.innerhtml=body
ole_web.object.document.body.contentEditable='false'

return 1
end function

public function integer uf_setbackground (string arg_path);
ole_web.object.document.body.background=arg_path
//messagebox('',a)
return 1
end function

public function string uf_style_jianyue ();string body

body=''&
+'<BODY style="MARGIN: 0px" contentEditable=false><TABLE style="PADDING-BOTTOM: 10px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 10px" border=0 cellSpacing=0 cellPadding=0 width="99.99%" background="D:\Program Files\Foxmail 7.0\Stationery\035\bg.jpg" height="100%">'&
+'<TBODY>'&
+'<TR>'&
+'<TD style="LINE-HEIGHT: 160%; WIDTH: 100%; HEIGHT: 100%; FONT-SIZE: 10.5pt" vAlign=top>'&
+'<DIV style="WIDTH: 100%; WHITE-SPACE: normal; WORD-BREAK: break-all" id=divFMContentBody contentEditable=true>'&
+'<DIV>&nbsp;</DIV>'&
+'<DIV>&nbsp;</DIV>'&
+'<HR style="WIDTH: 210px; HEIGHT: 1px" align=left color=#b5c4df SIZE=1>'&
+'<DIV><SPAN > </SPAN></DIV>'&
+'</DIV></TD></TR></TBODY></TABLE></BODY>'

return body
end function

public function string uf_style_shuangwu ();string body
body=''

return body
end function

public function string uf_style_zidingyi ();string body
body=''&
+'<BODY style="MARGIN: 0px" contentEditable=false><TABLE style="WIDTH: 100%; TABLE-LAYOUT: fixed; HEIGHT: 100%" border=0 cellSpacing=0 cellPadding=0 background="backPicPath">'&
+'<TBODY>'&
+'<TR>'&
+'<TD vAlign=top align=left><IMG src="file:///logoPicPath"></TD></TR>'&
+'<TR id=bodytext>'&
+'<TD style="PADDING-BOTTOM: 10px; LINE-HEIGHT: 1.5; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-FAMILY: 微软雅黑; COLOR: #000000; FONT-SIZE: 10.5pt; PADDING-TOP: 10px" height="100%" vAlign=top width="100%">'&
+'<DIV style="WIDTH: 100%; WHITE-SPACE: normal; WORD-BREAK: break-all" id=divLEContentBody contentEditable=true>'&
+'<DIV>&nbsp;</DIV>'&
+'<DIV>&nbsp;</DIV>'&
+'<HR style="WIDTH: 210px; HEIGHT: 1px" align=left color=#b5c4df SIZE=1>'&
+'<DIV><SPAN >  </SPAN></DIV>'&
+'<DIV><SPAN >  </SPAN></DIV>'&
+'<DIV id=divLEReplyBody></DIV></DIV></TD></TR>'&
+'<TR>'&
+'<TD vAlign=bottom align=left><IMG src="file:///bottomPicPath"></TD></TR></TBODY></TABLE></BODY>'

return body
end function

public subroutine uf_setcontenteditable (string arg_set);ole_web.object.document.body.contentEditable=arg_set
end subroutine

public subroutine uf_navigate (string arg_path);ole_web.object.document.ExecCommand("EditMode", true, 1)
ole_web.object.document.ExecCommand("LiveResize", true, 1)
//if ole_web.object.url='about:black' then
ole_web.object.Document.Write("<script>function showModalDialog{return;}</script>")
//end if
ole_web.object.Navigate(arg_path) 
ole_web.object.document.ExecCommand("EditMode", false, 0)
ole_web.object.document.ExecCommand("LiveResize", false, 0)
//string body
//body=ole_web.object.document.body.innerHtml
//
//messagebox('',body)


end subroutine

public subroutine uf_setreadonly ();pb_underline.Visible = False
pb_textcolor.Visible = False
pb_numbers.Visible = False
pb_bullets.Visible = False
pb_italic.Visible = False
pb_outdent.Visible = False
pb_bold.Visible = False
pb_indent.Visible = False
pb_left.Visible = False
pb_center.Visible = False
pb_right.Visible = False
pb_full.Visible = False
pb_line.Visible = False
pb_hyperlink.Visible = False
pb_picture.Visible = False
ddlb_fontsize.Visible = False
ddlb_font.Visible = False
ole_web.y = 0
ole_web.Object.document.ExecCommand("BrowseMode", False, 0)
ole_web.Object.document.ExecCommand("LiveResize", False, 0)
TriggerEvent('size')


end subroutine

public subroutine uf_getfont ();// 在分销客户端环境下会产生字体变大的问题，因此屏蔽。ERP则正常

//string font
//long index
//ddlb_font.text=string(f_ProfileString(sys_empid,publ_userid+'_ddlb_font' ,"text",'宋体'))
//index=long(f_ProfileString(sys_empid,publ_userid+'_ddlb_font_size' ,"text_size",'12'))
//
//
//font = ddlb_font.text
//ole_web.object.Document.ExecCommand("FontName", false, font)
//ole_web.setfocus()
//uf_refreshtoolbar()
//
//long fontsize
//fontsize = index
//ole_web.object.Document.ExecCommand("FontSize", false, fontsize)
//ole_web.setfocus()
//uf_refreshtoolbar()

end subroutine

public subroutine uf_setfont ();f_SetProfileString (sys_empid,publ_userid+'_ddlb_font', "text",String(ddlb_font.text))
//f_SetProfileString (sys_empid,publ_userid+'_ddlb_font_size', "text_size",String(ddlb_fontsize.index))


end subroutine

public subroutine wf_picturetofile ();Long lul_hBitmap
Long lul_hdcmem, hdc
//判断剪贴板中的数据是否是BMP数据  
Constant Long CF_BITMAP = 2
Constant Long DIB_RGB_COLORS = 0
Constant Long BITMAPTYPE = 19778
TRY
	IF IsNull(ClassName(GetFocus())) THEN
		RegisterHotKey(sys_handle, sys_atomid, MOD_CONTROL , 86)
	END IF
Catch(runtimeerror err)
	unRegisterHotKey(sys_handle, sys_atomid)
	keybd_event ( 17, 0, 0 , 0 ) // 按下ctrl
	keybd_event ( 86, 0, 0 , 0 ) // 按下v
	
	keybd_event ( 17, 0, 2 , 0 ) // 按下ctrl
	keybd_event ( 86, 0, 2 , 0 ) // 按下v
	RETURN
END TRY
IF IsClipboardFormatAvailable(CF_BITMAP) <> 1 THEN
	
	ole_web.Object.Document.ExecCommand("Paste", True, 0)
	ole_web.SetFocus()
	uf_refreshtoolbar()
	RETURN
END IF
//（1）开始从剪贴板取数据  
OpenClipboard(GetDesktopWindow())
lul_hBitmap = GetClipBoardData(CF_BITMAP)
CloseClipboard()
Blob lb
hdc = GetDC(GetDesktopWindow())
lul_hdcmem = CreateCompatibleDC(hdc)
SelectObject(lul_hdcmem, lul_hBitmap)
//（2）将取得的内存图片转换位blob数据流  
Long lul_hdc, lul_pixels
Blob lblb_header, lblb_info, lblb_bitmap
BitmapInfo lstr_Info
BitmapFileHeader lstr_Header
IF lul_hBitmap = 0 THEN RETURN
lstr_Info.bmiHeader.biSize = 40
IF GetDIBits(lul_hdcmem, lul_hBitmap, 0, 0, 0, lstr_Info, DIB_RGB_COLORS) <= 0 THEN RETURN
lul_pixels = lstr_Info.bmiHeader.biBitCount
lstr_Info.bmiColors[lul_pixels] = 0
lblb_bitmap = Blob(Space(lstr_Info.bmiHeader.biSizeImage/2)) //原来------ Blob(Space(lstr_Info.bmiHeader.biSizeImage))
// 获取文件信息 
GetDIBits(lul_hdcmem, lul_hBitmap, 0, lstr_Info.bmiHeader.biheight, &
	lblb_bitmap, lstr_Info, DIB_RGB_COLORS)
// 创建BMP文件头 
lstr_Header.bfType = BITMAPTYPE
lstr_Header.bfSize = lstr_Info.bmiHeader.biSizeImage
lstr_Header.bfOffBits = 54 + (lul_pixels * 4)
// 将文件头转换成blob 
lblb_header = Blob(Space(7)) //原来------Blob(Space(14))
CopyBitmapFileHeader(lblb_header, lstr_Header, 14)
// 将文件内容转换为blob 
lblb_info = Blob(Space(20 + lul_pixels * 2)) //原来------Blob(Space(40 + lul_pixels * 4)) 
CopyBitmapInfo(lblb_info, lstr_Info, 40 + lul_pixels * 4)
// 整合文件信息 
lblb_bitmap = lblb_header + lblb_info + lblb_bitmap


//释放通过GetDC或GetWindowDC所检索出来的公用上下文设备  
ReleaseDC(GetDesktopWindow(),hdc)
//删除通过CreteDC或CreateCompatibleDC所创建的上下文设备  
DeleteDC(lul_hdcmem)

//（3）取到图片文件后，则开始保存到文件中  
IF Len(lblb_bitmap) <= 0 THEN  RETURN
Constant ULong INVALID_HANDLE_VALUE = -1
Constant ULong GENERIC_WRITE = 1073741824
Constant ULong FILE_SHARE_WRITE = 2
Constant ULong CREATE_ALWAYS = 2
ULong lul_file, lul_length, lul_written
Boolean lb_rtn
// (创建)打开文件  

String ls_path, ls_file,ls_filename
Int li_rc

//ls_filename = String(Today(), "yyyyMMddHHmmss") +"-"+ String(Hour(Now())) + String(Minute (Now()))+ String(Second(Now())) + ".bmp"
ls_filename=string(today(), "yyyyMMddHHmmss") + ".bmp"
ls_path = sys_cur_path+fjfilepathname+'\'+ls_filename
//ls_path ="C:\Documents and Settings\Administrator\桌面\" + ls_filename
//messagebox("",ls_path)
//ls_path="C:\Documents and Settings\Administrator\桌面\1123.bmp"
String arg_msg
IF f_blobtofile(ls_path, lblb_bitmap, arg_msg) <> 1 THEN
	RETURN
END IF
//
//lul_file = CreateFile(ls_path, GENERIC_WRITE, &
//	FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0)
//IF lul_file = INVALID_HANDLE_VALUE THEN  RETURN
//// 写文件  
//lul_length = Len(lblb_bitmap)
//lb_rtn = WriteFile(lul_file, lblb_bitmap, &
//	lul_length, lul_written, 0)
//// 关闭文件  
//CloseHandle(lul_file)
ole_web.Object.Document.ExecCommand("InsertImage", False, ls_path)





end subroutine

on uo_html_editor.create
this.pb_underline=create pb_underline
this.pb_textcolor=create pb_textcolor
this.pb_numbers=create pb_numbers
this.pb_bullets=create pb_bullets
this.pb_italic=create pb_italic
this.pb_outdent=create pb_outdent
this.pb_bold=create pb_bold
this.pb_indent=create pb_indent
this.pb_left=create pb_left
this.pb_center=create pb_center
this.pb_right=create pb_right
this.pb_full=create pb_full
this.pb_line=create pb_line
this.pb_hyperlink=create pb_hyperlink
this.pb_picture=create pb_picture
this.ddlb_fontsize=create ddlb_fontsize
this.ddlb_font=create ddlb_font
this.ole_web=create ole_web
this.Control[]={this.pb_underline,&
this.pb_textcolor,&
this.pb_numbers,&
this.pb_bullets,&
this.pb_italic,&
this.pb_outdent,&
this.pb_bold,&
this.pb_indent,&
this.pb_left,&
this.pb_center,&
this.pb_right,&
this.pb_full,&
this.pb_line,&
this.pb_hyperlink,&
this.pb_picture,&
this.ddlb_fontsize,&
this.ddlb_font,&
this.ole_web}
end on

on uo_html_editor.destroy
destroy(this.pb_underline)
destroy(this.pb_textcolor)
destroy(this.pb_numbers)
destroy(this.pb_bullets)
destroy(this.pb_italic)
destroy(this.pb_outdent)
destroy(this.pb_bold)
destroy(this.pb_indent)
destroy(this.pb_left)
destroy(this.pb_center)
destroy(this.pb_right)
destroy(this.pb_full)
destroy(this.pb_line)
destroy(this.pb_hyperlink)
destroy(this.pb_picture)
destroy(this.ddlb_fontsize)
destroy(this.ddlb_font)
destroy(this.ole_web)
end on

event constructor;do while ddlb_font.totalitems( ) > 0
	ddlb_font.deleteitem(1)
loop

uf_addfonts()

ole_web.object.Navigate('about:blank')
ole_web.object.document.ExecCommand("EditMode", false, 0)
ole_web.object.document.ExecCommand("LiveResize", false, 0)
ddlb_font.selectitem(1)
ddlb_fontsize.selectitem(1)
triggerevent('size')


end event

event other;//在窗口的other事件编写脚本：
//处理系统热键

IF wparam = sys_atomid And sys_atomid <> 0 THEN
	//处理
	wf_picturetofile()
END IF
end event

type pb_underline from picturebutton within uo_html_editor
string tag = "graphics\_Underline.bmp"
integer x = 1184
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Underline.bmp"
string disabledname = "graphics\Underline.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("Underline", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_textcolor from picturebutton within uo_html_editor
string tag = "graphics\_Color.bmp"
integer x = 1285
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Color.bmp"
string disabledname = "graphics\Color.bmp"
alignment htextalign = left!
end type

event clicked;string ls_color
long ll_color

ll_color = long(ole_web.object.Document.queryCommandValue("ForeColor"));

if ChooseColor(ll_color) = 1 then
	ls_color = tohex(ll_color, 6)
	ls_color = '#' + mid(ls_color, 5, len(ls_color)) + mid(ls_color, 3, 2) + mid(ls_color, 1, 2)
	ole_web.object.Document.ExecCommand("ForeColor", false, ls_color)
	ole_web.setfocus()
	uf_refreshtoolbar()
end if
end event

type pb_numbers from picturebutton within uo_html_editor
string tag = "graphics\_Numbers.bmp"
integer x = 1385
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Numbers.bmp"
string disabledname = "graphics\Numbers.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("InsertOrderedList", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_bullets from picturebutton within uo_html_editor
string tag = "graphics\_Bullets.bmp"
integer x = 1486
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Bullets.bmp"
string disabledname = "graphics\Bullets.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("InsertUnorderedList", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_italic from picturebutton within uo_html_editor
string tag = "graphics\_Italic.bmp"
integer x = 1083
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Italic.bmp"
string disabledname = "graphics\Italic.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("Italic", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_outdent from picturebutton within uo_html_editor
string tag = "graphics\_Outdent.bmp"
integer x = 1586
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Outdent.bmp"
string disabledname = "graphics\Outdent.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("Outdent", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_bold from picturebutton within uo_html_editor
string tag = "graphics\_Bold.bmp"
integer x = 983
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Bold.bmp"
string disabledname = "graphics\Bold.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("Bold", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_indent from picturebutton within uo_html_editor
string tag = "graphics\_Indent.bmp"
integer x = 1687
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Indent.bmp"
string disabledname = "graphics\Indent.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("Indent", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_left from picturebutton within uo_html_editor
string tag = "graphics\_Left.bmp"
integer x = 1787
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Left.bmp"
string disabledname = "graphics\Left.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("JustifyLeft", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_center from picturebutton within uo_html_editor
string tag = "graphics\_Center.bmp"
integer x = 1888
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Center.bmp"
string disabledname = "graphics\Center.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("JustifyCenter", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_right from picturebutton within uo_html_editor
string tag = "graphics\_Right.bmp"
integer x = 1989
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Right.bmp"
string disabledname = "graphics\Right.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("JustifyRight", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_full from picturebutton within uo_html_editor
string tag = "graphics\_Full.bmp"
integer x = 2089
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Full.bmp"
string disabledname = "graphics\Full.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("JustifyFull", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_line from picturebutton within uo_html_editor
string tag = "graphics\_Line.bmp"
integer x = 2190
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Line.bmp"
string disabledname = "graphics\Line.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("InsertHorizontalRule", false, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_hyperlink from picturebutton within uo_html_editor
string tag = "graphics\_Hyperlink.bmp"
integer x = 2290
integer width = 101
integer height = 88
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Hyperlink.bmp"
string disabledname = "graphics\Hyperlink.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("CreateLink", true, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type pb_picture from picturebutton within uo_html_editor
string tag = "graphics\_Picture.bmp"
integer x = 2391
integer width = 101
integer height = 88
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\Picture.bmp"
string disabledname = "graphics\Picture.bmp"
alignment htextalign = left!
end type

event clicked;ole_web.object.Document.ExecCommand("InsertImage", true, 0)
ole_web.setfocus()
uf_refreshtoolbar()
end event

type ddlb_fontsize from dropdownlistbox within uo_html_editor
integer x = 759
integer y = 4
integer width = 219
integer height = 576
integer taborder = 20
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
string item[] = {"8","10","12","14","18","24","36"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;int fontsize
fontsize = index
ole_web.object.Document.ExecCommand("FontSize", false, fontsize)
ole_web.setfocus()
uf_refreshtoolbar()

f_SetProfileString (sys_empid,publ_userid+'_ddlb_font_size', "text_size",String(index))
end event

type ddlb_font from dropdownlistbox within uo_html_editor
integer y = 4
integer width = 750
integer height = 576
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean vscrollbar = true
string item[] = {"宋体","黑体","@宋体","@黑体"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;string font
font = this.text
ole_web.object.Document.ExecCommand("FontName", false, font)
ole_web.setfocus()
uf_refreshtoolbar()

f_SetProfileString (sys_empid,publ_userid+'_ddlb_font', "text",String(ddlb_font.text))



end event

type ole_web from olecustomcontrol within uo_html_editor
event statustextchange ( string text1 )
event progresschange ( long progress,  long progressmax )
event commandstatechange ( long command,  boolean enable )
event downloadbegin ( )
event downloadcomplete ( )
event titlechange ( string text1 )
event propertychange ( string szproperty )
event beforenavigate2 ( oleobject pdisp,  any url,  any flags,  any targetframename,  any postdata,  any headers,  ref boolean cancel1 )
event newwindow2 ( ref oleobject ppdisp,  ref boolean cancel1 )
event navigatecomplete2 ( oleobject pdisp,  any url )
event documentcomplete ( oleobject pdisp,  any url )
event onquit ( )
event onvisible ( boolean ocx_visible )
event ontoolbar ( boolean toolbar )
event onmenubar ( boolean menubar )
event onstatusbar ( boolean statusbar )
event onfullscreen ( boolean fullscreen )
event ontheatermode ( boolean theatermode )
event windowsetresizable ( boolean resizable )
event windowsetleft ( long left )
event windowsettop ( long top )
event windowsetwidth ( long ocx_width )
event windowsetheight ( long ocx_height )
event windowclosing ( boolean ischildwindow,  ref boolean cancel1 )
event clienttohostwindow ( ref long cx,  ref long cy )
event setsecurelockicon ( long securelockicon )
event filedownload ( ref boolean cancel1 )
event navigateerror ( oleobject pdisp,  any url,  any frame,  any statuscode,  ref boolean cancel1 )
event printtemplateinstantiation ( oleobject pdisp )
event printtemplateteardown ( oleobject pdisp )
event updatepagestatus ( oleobject pdisp,  any npage,  any fdone )
event privacyimpactedstatechange ( boolean bimpacted )
event keyup pbm_keyup
event showwindow pbm_showwindow
integer y = 92
integer width = 2501
integer height = 600
integer taborder = 20
boolean border = false
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
string binarykey = "uo_html_editor.udo"
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
end type

event keyup;
uf_refreshtoolbar()


end event

event showwindow;if not ib_shown then
	parent.triggerevent('ue_afterinit')
end if
ib_shown = true
end event

event getfocus;uf_refreshtoolbar()

end event

event clicked;string font

uf_getfont()
//font = string(f_ProfileString(sys_empid,publ_userid+'_ddlb_font' ,"text",'宋体'))
//ole_web.object.Document.ExecCommand("FontName", false, font)
//ole_web.setfocus()
//uf_refreshtoolbar()

 RegisterHotKey(sys_handle, sys_atomid, MOD_CONTROL , 86) 
////
////注册热键
//long ll_RC
//string ls_atomid 
//ls_atomid = 'myatomid'
//atomid = GlobalAddAtom(ls_atomid) 
////得到惟一的ID，保证不和其他应用程序发生冲突 
//ll_RC = RegisterHotKey(Handle(this), atomid, MOD_CONTROL , 86) 
////注册的热键为Ctrl+F ，70为'F' 86 v 
////如果组合键，可用MOD_CONTROL + MOD_ALT等ctrl +v
//if ll_RC = 0 then messagebox("Error!","热键注册错误") 
////热键注册冲突


end event

event doubleclicked;string font

uf_getfont()
//font = ddlb_font.text
//ole_web.object.Document.ExecCommand("FontName", false, font)
//ole_web.setfocus()
//uf_refreshtoolbar()
//



end event

event constructor;//注册热键
long ll_RC
string ls_atomid 
ls_atomid = 'myatomid'
sys_atomid = GlobalAddAtom(ls_atomid) 
sys_handle=Handle(parent)
//得到惟一的ID，保证不和其他应用程序发生冲突 
ll_RC = RegisterHotKey(sys_handle, sys_atomid, MOD_CONTROL , 86) 
//注册的热键为Ctrl+F ，70为'F' 86 v 
//如果组合键，可用MOD_CONTROL + MOD_ALT等ctrl +v
//if ll_RC = 0 then messagebox("Error!","热键注册错误")  // 貌似注册失败都可以使用Ctrl+F热键 hjy161223
//热键注册冲突
end event


Start of PowerBuilder Binary Data Section : Do NOT Edit
05uo_html_editor.bin 
[encoded data, 7990 characters]
15uo_html_editor.bin 
End of PowerBuilder Binary Data Section : No Source Expected After This Point
