PB11 WebForm方式下messagebox的本地化处理

    技术2022-05-11  17

    PB11 在 web form 下毕竟工作方式有很大区别,使用过程中发现很多的对话框窗口已经不再调用操作系统的底层函数来实现了,其中最有影响的当属messagebox函数,虽然屏幕上显示这样的提示:   按钮文字是英文的看起来也不是非常难受,但给用户使用时,总感觉美中不足。为次,多次上到sybase newsgroup寻求解决方案,但最后还是否定了从PB版本上的直接解决方法。以下是我从新闻组上交流到的信息(后者前先者后):   Jim O'Neil: You're going to use a binary editor on a DLL shipped with PowerBuilder???  I don't even think .NET would let you do that as it would be a security breach if the assembly were tampered with - assuming you could even figure out WHAT to change. DJ posted a quite viable workaround for you, I would recommend that. In terms of the other 'system dialogs' that are also not culture-aware, I supposed the job would be bigger/harder.   DJ Huang: No I am not suggesting to change the DLL or implementation internal to PB11. I do ask you to write a modal PB window with OK/Cancel button or other command buttons, to mimic MessageBox look-and-feel On 1 Mar 2007 03:44:14 -0800, qland <qland@vip.sina.com> wrote: >Hi "Jim O'Neil > >In which DLL file is the function of implementation messagebox ? > >I can change text to chinese if I know the DLL file. > >>probably obvious given the context) and the implementation is > >On 28 Feb 2007 06:50:11 -0800, "Jim O'Neil [Sybase]" >< joneil_@_sybase_dot_com> wrote: >   DJ Huang: qland/Jim, If the Engineering team has no quick solution, then you can try this work around: Create your own POwerBuilder window, type = response window, with a few buttons to simulate the messagebox. Then call your own MessageBox() function. A meesageBox function in your class will hide the system build-in messagebox when you call within that class >>The Web Forms generation is not using the underlying MessageBox (as is >>probably obvious given the context) and the implementation is >>currently such that you will only see English text.    My >>recommendation would be to submit a case under the beta program so >>that it gets into our system.  If you think this is fundamental to >>being able to use the product to build applications, you might include >>a note to that effect in your case notes, so the appropriate priority >>can be given. >> >>On 27 Feb 2007 21:21:28 -0800, qland < qland@vip.sina.com> wrote: >> >>> >>>Thank Jim O'Neil >>> >>>Some diaglogs like GetFileOpenDialog, GetFolder, etc. have this same >>>problem, texts of displaying  is english. >>> >>>my environment is: >>> >>>Windows XP sp2 chinese version >>>IIS 5.0 >>>my machine is Server and Client >>> >>>but it's ok if running smart client app by calling : >>> >>>#IF Defined PBDOTNET Then >>>    System.Windows.Forms.MessageBox.Show ("This message is from .net") >>>#END IF >>> >>>The text of "OK" button is chinese >>> >>> >>>Thanks >>> >>> >>>On 27 Feb 2007 05:01:53 -0800, "Jim O'Neil [Sybase]" >>>< joneil_@_sybase_dot_com> wrote: >>> >>>>The MessageBox function will use the machine's OS in order to >>>>determine the text of the buttons NOT the culture info.  There are >>>>several posts you can find in Google on this.  The underlying cause is >>>>that the .NET MessageBox.Show calls the Win32 MessageBox and the >>>>latter is not culture-aware. >>>> >>>>With that said though, if you see Chinese text for the buttons in PB >>>>Native Mode on the same machine that hosts IIS, then I would conclude >>>>that machine IS running Chinese Windows.  In that case, I  the >>>>MessageBox you see generated for WebForms should reflect the same >>>>behavior, and what you are reporting should be considered a bug. >>>> >>>>I had sent a note into engineering about your question earlier, and >>>>will follow up with them.  I'd be curious if other system dialogs - >>>>like the GetFileOpenDialog, GetFolder, etc. have this same problem? >>>> >>>> >>>>On 27 Feb 2007 04:07:37 -0800, qland < qland@vip.sina.com> wrote: >>>> >>>>> >>>>>Thanks. >>>>> >>>>>I change PBCultureSource property on the configuration tab to "client" >>>>>or to "server", the result is the same as shown in figure >>>>> >>>>>but it's work fine under PB app native mode. >>>>> >>>>>On 26 Feb 2007 08:43:04 -0800, "Dave Fish [Team Sybase]" >>>>>< dfish@_no_spam_sybase.com> wrote: >>>>> >>>>>>Actually that is available in the latest engineering drop (build >>>>>>6056). It is the PBCultureSource property on the configuration tab. By >>>>>>default it is set to Server. I'm not sure that it would change >>>>>>anything in this situation though. I believe message boxes get >>>>>>converted to Javascript alerts so there may be a way to modify the >>>>>>generated Javascript for the application if the PBCultureSource >>>>>>property doesn't handle this. >>>>>> >>>>>>Regards, >>>>>>Dave Fish >>>>>>Sybase >>>>>> >>>>>>On 26 Feb 2007 08:34:21 -0800, "Jim O'Neil [Sybase]" >>>>>>< joneil_@_sybase_dot_com> wrote: >>>>>> >>>>>>>Does the language of that button not reflect the server language?  I'd >>>>>>>suggest that is a bug, or at the very least a limitation that needs to >>>>>>>be documented. >>>>>>> >>>>>>>The next beta drop will have a 'culture' property that *may* address >>>>>>>this. >>>>>>> >>>>>>> On 26 Feb 2007 07:47:08 -0800, qland < qland@vip.sina.com> wrote: >>>>>>> >>>>>>>> >>>>>>>>Hi all >>>>>>>> >>>>>>>>In webform app, >>>>>>>> >>>>>>>>Is there any way to change the button's text language(i.e. chinese ) >>>>>>>>in the messagebox >>>>>>>> >>>>>>>>Thank >>>>>>>> >>>>>   所以,最后我按DJ Huang的建议,自己使用PB对象来解决了,下图就是新的结果,基本上实现了原来messagebox函数的所有功能,但无法做到后面3个参数的缺省调用。   调用方式还是与原来的messagebox函数类似: calling this function like this: messageboxx('prompt','information', icontype, buttonname, default) fox example: messageboxx('error?,'aaaa~r~nbbbbbbbb',Exclamation!,AbortRetryIgnore!,2) 》》》》 messageboxx function There is no heavily overrided messagebox in order to keep the original messagebox function. --------------------------------------------------- global type messageboxx from function_object end type forward prototypes global function integer messageboxx (string as_title, string as_info, icon aic_type, button abt_type, integer ai_default) end prototypes global function integer messageboxx (string as_title, string as_info, icon aic_type, button abt_type, integer ai_default);s_messagebox str_recv integer li_rtn str_recv.as_title = as_title str_recv.as_info = as_info str_recv.aic_type = aic_type str_recv.abt_type = abt_type str_recv.ai_default = ai_default openwithparm(w_messagebox, str_recv) li_rtn = message.DoubleParm return li_rtn end function 越来越喜欢PB11的WebForm了,现正在将原来OA中的某些业务逻辑比较复杂的功能采用PB11实现。  2007-3-12 附加一副PB11做的简单程序的界面:   ============================================================== 鉴于多位网友咨询本文的有关内容较多,特对本文进行续作,补充有关内容:   1. s_messagebox 结构  global type s_messagebox from structure string  as_title string  as_info icon  aic_type button  abt_type integer  ai_defaultend type   2. w_messageboxx 窗口源代码 forward global type w_messagebox from window end type type mle_info from multilineedit within w_messagebox end type type cb_ignore from commandbutton within w_messagebox end type type cb_abort from commandbutton within w_messagebox end type type cb_retry from commandbutton within w_messagebox end type type cb_no from commandbutton within w_messagebox end type type cb_cancel from commandbutton within w_messagebox end type type cb_yes from commandbutton within w_messagebox end type type cb_ok from commandbutton within w_messagebox end type type p_stopsign from picture within w_messagebox end type type p_question from picture within w_messagebox end type type p_information from picture within w_messagebox end type type p_exclamation from picture within w_messagebox end type end forward global type w_messagebox from window integer width = 2208 integer height = 528 boolean titlebar = true boolean controlmenu = true windowtype windowtype = response! long backcolor = 67108864 string icon = "AppIcon!" mle_info mle_info cb_ignore cb_ignore cb_abort cb_abort cb_retry cb_retry cb_no cb_no cb_cancel cb_cancel cb_yes cb_yes cb_ok cb_ok p_stopsign p_stopsign p_question p_question p_information p_information p_exclamation p_exclamation end type global w_messagebox w_messagebox type variables string as_title string as_info integer li_rtn = 0 end variables on w_messagebox.create this.mle_info=create mle_info this.cb_ignore=create cb_ignore this.cb_abort=create cb_abort this.cb_retry=create cb_retry this.cb_no=create cb_no this.cb_cancel=create cb_cancel this.cb_yes=create cb_yes this.cb_ok=create cb_ok this.p_stopsign=create p_stopsign this.p_question=create p_question this.p_information=create p_information this.p_exclamation=create p_exclamation this.Control[]={this.mle_info,& this.cb_ignore,& this.cb_abort,& this.cb_retry,& this.cb_no,& this.cb_cancel,& this.cb_yes,& this.cb_ok,& this.p_stopsign,& this.p_question,& this.p_information,& this.p_exclamation} end on on w_messagebox.destroy destroy(this.mle_info) destroy(this.cb_ignore) destroy(this.cb_abort) destroy(this.cb_retry) destroy(this.cb_no) destroy(this.cb_cancel) destroy(this.cb_yes) destroy(this.cb_ok) destroy(this.p_stopsign) destroy(this.p_question) destroy(this.p_information) destroy(this.p_exclamation) end on event open; s_messagebox str_recv integer visible_btns = 0 long ll_cwidth, ll_left, ll_temp long ll_lspace=100, ll_rspace=100, ll_btnwidth=261, ll_btnspace=36 str_recv = message.PowerObjectParm ll_cwidth = lenA(str_recv.as_info)*UnitsToPixels(40, XUnitsToPixels!) this.width = ll_lspace + PixelsToUnits ( ll_cwidth, XPixelsToUnits!) + ll_rspace if this.width>2200 then this.width = 2200 this.title = str_recv.as_title this.mle_info.text = str_recv.as_info if str_recv.aic_type = stopsign! then p_stopsign.visible = true if str_recv.aic_type = question! then p_question.visible = true if str_recv.aic_type = information! then p_information.visible = true if str_recv.aic_type = exclamation! then p_exclamation.visible = true if str_recv.aic_type = none! then end if //确定按钮数目 if str_recv.abt_type = OK! then    visible_btns=1 end if if str_recv.abt_type = OKCancel! or &    str_recv.abt_type = YesNo! or &    str_recv.abt_type = RetryCancel! then    visible_btns=2 end if if str_recv.abt_type = YesNoCancel! or &    str_recv.abt_type = AbortRetryIgnore! then    visible_btns=3 end if ll_temp = cb_ok.width*visible_btns+(visible_btns -1)*ll_btnspace ll_left = (this.width - ll_temp)/2 if ll_left<0 then    this.width = ll_lspace + ll_temp + ll_rspace    ll_left = ll_lspace end if if str_recv.ai_default<1 or str_recv.ai_default > visible_btns then str_recv.ai_default = 1 //确定按钮位置并确定: 焦点按钮 if str_recv.abt_type = OK! then    cb_ok.visible = true    cb_ok.x = ll_left    cb_ok.setfocus() end if if str_recv.abt_type = OKCancel! then    cb_ok.visible = true    cb_cancel.visible = true    cb_ok.x = ll_left    cb_cancel.x = cb_ok.x + ll_btnwidth + ll_btnspace    if str_recv.ai_default = 1 then cb_ok.setfocus()    if str_recv.ai_default = 2 then cb_cancel.setfocus() end if if str_recv.abt_type = YesNo! then    cb_yes.visible = true    cb_no.visible = true    cb_yes.x = ll_left    cb_no.x = cb_yes.x + ll_btnwidth + ll_btnspace    if str_recv.ai_default = 1 then cb_yes.setfocus()    if str_recv.ai_default = 2 then cb_no.setfocus() end if if str_recv.abt_type = YesNoCancel! then    cb_yes.visible = true    cb_no.visible = true    cb_cancel.visible = true    cb_yes.x = ll_left    cb_no.x = cb_yes.x + ll_btnwidth + ll_btnspace    cb_cancel.x = cb_no.x + ll_btnwidth + ll_btnspace    if str_recv.ai_default = 1 then cb_yes.setfocus()    if str_recv.ai_default = 2 then cb_no.setfocus()    if str_recv.ai_default = 3 then cb_cancel.setfocus() end if if str_recv.abt_type = RetryCancel! then    cb_retry.visible = true    cb_cancel.visible = true    cb_retry.x = ll_left    cb_cancel.x = cb_retry.x + ll_btnwidth + ll_btnspace    if str_recv.ai_default = 1 then cb_retry.setfocus()    if str_recv.ai_default = 2 then cb_cancel.setfocus() end if if str_recv.abt_type = AbortRetryIgnore! then    cb_abort.visible = true    cb_retry.visible = true    cb_ignore.visible = true    cb_abort.x = ll_left    cb_retry.x = cb_abort.x + ll_btnwidth + ll_btnspace    cb_ignore.x = cb_retry.x + ll_btnwidth + ll_btnspace    if str_recv.ai_default = 1 then cb_abort.setfocus()    if str_recv.ai_default = 2 then cb_retry.setfocus()    if str_recv.ai_default = 3 then cb_ignore.setfocus() end if #IF DEFINED PBNATIVE  then  //窗口位置设置为center时,实际的位置还是偏上,需要重新设置  this.center = false  Environment envir  GetEnvironment(envir) // 获得屏幕分辨率的大小  this.move((PixelsToUnits(envir.ScreenWidth, XPixelsToUnits!) - this.Width)/2,(PixelsToUnits(envir.ScreenHeight,YPixelsToUnits!)-this.Height)/2 ) // 把窗口移动到屏幕中央 #ELSE  this.center = true #END IF end event type mle_info from multilineedit within w_messagebox integer x = 270 integer y = 80 integer width = 1792 integer height = 184 integer taborder = 30 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 67108864 boolean border = false boolean autovscroll = true boolean displayonly = true end type type cb_ignore from commandbutton within w_messagebox boolean visible = false integer x = 1851 integer y = 296 integer width = 261 integer height = 100 integer taborder = 40 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "忽略" end type event clicked; closewithreturn(parent, 3) end event type cb_abort from commandbutton within w_messagebox boolean visible = false integer x = 1554 integer y = 296 integer width = 261 integer height = 100 integer taborder = 30 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "终止" end type event clicked; closewithreturn(parent, 1) end event type cb_retry from commandbutton within w_messagebox boolean visible = false integer x = 1257 integer y = 296 integer width = 261 integer height = 100 integer taborder = 10 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "重试" end type event clicked; if cb_abort.visible then // AortRetryIgnore!    closewithreturn(parent, 2) else    closewithreturn(parent, 1)   //RetryCancel! end if end event type cb_no from commandbutton within w_messagebox boolean visible = false integer x = 960 integer y = 296 integer width = 261 integer height = 100 integer taborder = 30 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "否" end type event clicked; closewithreturn(parent, 2) end event type cb_cancel from commandbutton within w_messagebox boolean visible = false integer x = 366 integer y = 296 integer width = 261 integer height = 100 integer taborder = 20 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "取消" end type event clicked; if cb_yes.visible and cb_no.visible then     // YesNoCancel!    closewithreturn(parent, 3) else    closewithreturn(parent, 2)   //  OKCancel! or RetryCancel! end if end event type cb_yes from commandbutton within w_messagebox boolean visible = false integer x = 663 integer y = 296 integer width = 261 integer height = 100 integer taborder = 20 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "是" end type event clicked; closewithreturn(parent, 1) end event type cb_ok from commandbutton within w_messagebox boolean visible = false integer x = 69 integer y = 296 integer width = 261 integer height = 100 integer taborder = 10 integer textsize = -9 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! string facename = "宋体" string text = "确定" end type event clicked; closewithreturn(parent, 1) end event type p_stopsign from picture within w_messagebox boolean visible = false integer x = 55 integer y = 56 integer width = 146 integer height = 128 boolean originalsize = true string picturename = "images/stop.GIF" boolean focusrectangle = false end type type p_question from picture within w_messagebox boolean visible = false integer x = 55 integer y = 56 integer width = 146 integer height = 128 boolean originalsize = true string picturename = "images/quest.GIF" boolean focusrectangle = false end type type p_information from picture within w_messagebox boolean visible = false integer x = 55 integer y = 56 integer width = 146 integer height = 128 boolean originalsize = true string picturename = "images/info.GIF" boolean focusrectangle = false end type type p_exclamation from picture within w_messagebox boolean visible = false integer x = 55 integer y = 56 integer width = 146 integer height = 128 boolean originalsize = true string picturename = "images/excl.GIF" boolean focusrectangle = false end type  

    最新回复(0)