Je suis retourné en amerique ou j'y ai rencontré un americain (Folie des grandeurs)
Et le grand SPARKIE hitself m'a mijoté ce joli code, qui fait tout ce que je veux et meme plus
Je le pose ici pour que les copains puisse en profiter et l'etudier.
Il peut surement etre utile un jour.
Ne serait ce pour connaitre la taille des caracteres dans un WebGadget, j'ai trouvé ça géant
Je remercie encore tout ceux qui se sont interessé à mon probleme.
Et vous souhaite une excelente journée
Code : Tout sélectionner
; Mal commencé par KCC et bien fini par Maitre SPARKIE
#Form = 1
#WebGadget = 2
Dim Html.s(1000)
Global Stop
Global TotalHtml.s
Procedure WinCallback(hwnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_CLOSE
End
Case #WM_KEYDOWN
If wParam = #VK_ESCAPE
Stop = #True
EndIf
Case #WM_SIZING
ResizeGadget(#WebGadget, #PB_Ignore, #PB_Ignore, WindowWidth(#Form) - 10, WindowHeight(#Form) - 10)
SetGadgetAttribute(#WebGadget, #PB_Web_ScrollY, 1000000)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(#Form, 0, 0, 800, 500, "", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
;- set your font and line size here
fontSize.f = 18
lineHeight.f = fontSize / 0.85
;- Convert font pt size to pixels
hdc = StartDrawing(WindowOutput(#Form))
logPixY = GetDeviceCaps_(hdc, #LOGPIXELSY)
StopDrawing()
;-72pt = 1 inch
fontheight.f = fontSize / (72 / logPixY)
linePixels = lineHeight / (72 / logPixY)
WebGadget(#WebGadget, 0, 0, WindowWidth(#Form) - 10, WindowHeight(#Form) - 10, "")
divHeight.f = GadgetHeight(#WebGadget) - (lineHeight * 2)
Entete$ = "<html><head><title></title>"
Entete$ + "<body scroll='no'><div class='page' style='overflow-y: hidden; align: bottom; height: " + Str(divHeight) + "px; font-Size: " + Str(fontSize) + " pt; line-height: " + Str(lineHeight) + " pt'>"+#CRLF$
Fin$ + "</div></body></html>"
SetWindowCallback(@WinCallback())
For i = 1 To 100
NBreLignes = divHeight / linePixels
Html(i) = "La ligne " + Str(i) + " de KCC est ecrite<br>" + #CRLF$
TotalHtml + Html(i)
If i < NBreLignes
For w = 1 To NBreLignes
html$ + Html(w)
Next
Else
For w = i - NBreLignes To i
html$ + Html(w)
Next
EndIf
SetGadgetItemText(#WebGadget, #PB_Web_HtmlCode, Entete$ + html$ + Fin$)
While WindowEvent():Wend
Delay(70)
html$ = ""
If Stop
Break
EndIf
Next
divHeight.f = GadgetHeight(#WebGadget) - (lineHeight * 2)
Entete$ = "<html><head><title></title>"
Entete$ + "<body><div class='page' style='font-Size: " + Str(fontSize) + " pt; line-height: " + Str(lineHeight) + " pt'>"+#CRLF$
SetGadgetItemText(#WebGadget, #PB_Web_HtmlCode, Entete$ + TotalHtml + Fin$)
While WindowEvent():Wend
SetGadgetAttribute(#WebGadget, #PB_Web_ScrollY, 1000000)
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
End