maandag 1 juli 2013

Blend in your HTML Widget

Just a little trick to make an HTML widget blend in better with the rest of your application.


Two aspects:

  1. Get the background color that is used in your application
    I retrieve the color from the .ini file. You could also use $windowproperties to get the backcolor of the window.
  2. Set the background color of the HTML using JavaScript.
    The use of the eval function means that you do not have to include a JavaScript function in your HTML, meaning you can even use this for external websites.


; Set background color of the HTML widget to 
; the color specified in the backcolor property of 
; the window logical widget in 
; the [application] section of the .ini file
call lpGetSetting("application\window","backcolor",vColor)
if (vColor <> "")
   show
   $fieldhandle("TEXT.DUMMY")->$widgetoperation( "JS:eval(%%"document.body.style.backgroundColor = '%%vColor%%%';%%")")
endif
end


entry lpGetSetting
params
   string pSetting : IN
   string pTopic : IN
   string pValue : OUT
endparams
variables
   string vTopics
endvariables

   vTopics = $setting("", pSetting, "INIDATA")
   vTopics = vTopics[$scan(vTopics,"(")+1]
   vTopics = vTopics[1:$rscan(vTopics,")")-1]
   vTopics = $replace(vTopics, 1, ";", "·;", -1)
   getitem/id pValue, vTopics, pTopic

end

Geen opmerkingen:

Een reactie posten