Incorporate HTML in your program...

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Well maybe somebody else with Win2000 can check this out?
It would be highly appreciated.
Thanks in advance.


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Well maybe somebody else with Win2000 can check this out?
> It would be highly appreciated.

Sorry Franco, I didn't realise that it was important to you... is there anything
else I can do to test it, though? Aside from what I posted above, I can't think
of anything else...


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by michaelj.
Well maybe somebody else with Win2000 can check this out?
It would be highly appreciated.
Hi Franco,

Well I couldn't get it working as you posted it in win2k, but I have modified it, and got it working now.... I basically added in using the hInstance, as documented in their API, which seemed to do the trick.

Code: Select all

; (c) 2002 - Franco's template - absolutely free
; Simple HTML viewer example file
; This Version uses Mr.Skunk DLL library.
; QHTML Light is a free Win32 DLL (184KB) by Russ Freeman that
; Allows you to easily incorporate HTML in your program.
; Uses WinAPI but I don't know if IE must be installed or not... sorry.
; Homepage: [/url]
; This piece of code works on WinXP and on Win98SE
;
; Modified by Michael Kearns to run on win2k *and* hopefully still on the others.
;


#QHTM_LOAD_FROM_FILE = #WM_USER + 2
Dll_hWnd=OpenDLL(0,"qhtmlight.dll")
HtmlFile$=OpenFileRequester("Open an HTML file",".\","HTML file |*.htm;*.html",0)


If HtmlFile$
  MainForm=OpenWindow(0, 200, 200, 320, 240, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "HTML Test")
  If DLLFunction(0,0,"QHTM_Initialize")
     hinst.l = GetModuleHandle_(0)
     If CallDLL1(0, hinst) = #NULL
      MessageRequester("Oops", "QHTM Intialize() failed !", 0)
    EndIf
  Else
    MessageRequester("Sorry","No DLL Function",0)
  EndIf ; Register function
  QhtmCtrl = CreateWindowEx_(0,"QHTM_Window_Class_001","",#WS_CHILD | #WS_VISIBLE, 0, 0, 310, 208, MainForm,0,hinst,#NULL)


  If QhtmCtrl  #NULL


    SendMessage_(QhtmCtrl,#QHTM_LOAD_FROM_FILE, 0, HtmlFile$ )


    Repeat
      Event=WaitWindowEvent()
    Until Event=#PB_EventCloseWindow
  Else
    MessageRequester("Sorry", "QHTML window failed", 0)
  EndIf


EndIf
End
This now works fine on my Win2k SP2 (IE5).

By the way, does anyone know if PureBasic provides easy access to the app hInstance ??? Fred ???



Michael.
(Registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Don.

OK, here's a possible reason why it doesn't work ....

I couldn't get it to work with Windows ME, despite trying to call the initialisation function etc. etc. The problem seemed to be that the CreateWindowEx call was failing & returning zero - seems like it doesn't recognise the window class for some reason, even though this gets registered by the QHTM_Initialize function.

Anyway I finally tracked it down the the DLL itself. The version of QHTMLight.dll at http://www.gipsysoft.com/qhtm/qhtmlight.zip is 0.1.5.3 whereas the one in Franco's zip file on the resources site is 0.1.5.2. When I tried version 0.1.5.2 it worked! (I have no idea why this should be!)

btw, Franco, in your call to CreateWindowEx you use ID_QhtmCtrl which is uninitialised ... but it does no harm as #NULL is OK. Also, the #WS_EX_CLIENTEDGE extended style makes it look a bit better:

Code: Select all

QhtmCtrl = CreateWindowEx_(#WS_EX_CLIENTEDGE,"QHTM_Window_Class_001","",#WS_CHILD | WS_VISIBLE,0,0,WindowWidth()-5,WindowHeight()-32,Main_hWnd,#NULL,Dll_hWnd,#NULL)
Hope this might help ... it worked for me

Don
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
... The version of QHTMLight.dll at http://www.gipsysoft.com/qhtm/qhtmlight.zip is 0.1.5.3 whereas the one in Franco's zip file on the resources site is 0.1.5.2. When I tried version 0.1.5.2 it worked! (I have no idea why this should be!)
Don and PB, I have to apologize!!!

The second source code that I posted had an old DLL call (from an earlier code that I had...).

The name was "qhtmlite.dll" instead of "qhtmlight.dll" (they changed it grr...)
And I had both DLL in the same directory, that's why it worked for me...

Michael,
your changes work well on Win98SE (not tested yet on WinXP - I have to go home for this.)
As soon I tested it on WinXP I will update this file on Paul's resource site!
But I suppose it will...
Thanks a lot

-----------------------

The result of this:

Under WinXP at the 'CreateWindowEx' call the 'hInst' was not needed at all. It worked!!!
I tryed every way to handle this and it worked every time... strange isn't it

Under Win98SE I had to use 'Dll_hWnd' from 'LoadLibrary' and put it instead of the real Instance and it worked.
I assumed that is correct but it was false. ...well that's me

And now under Win2000 it works only if all has the correct setting:
Instance instead of Handle.

Conclusion:
it seems that for a programmer Win2000 is the 'best' WinOS to test the code.
WinXP allows too much false settings... and it runs anyway.
That's really bad!

Sometimes I don't like my OS very much


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Edited by - franco on 30 January 2002 00:18:16
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.
OK, here's a possible reason why it doesn't work ....

I couldn't get it to work with Windows ME, despite trying to call the initialisation function etc. etc. The problem seemed to be that the CreateWindowEx call was failing & returning zero - seems like it doesn't recognise the window class for some reason, even though this gets registered by the QHTM_Initialize function.

Anyway I finally tracked it down the the DLL itself. The version of QHTMLight.dll at http://www.gipsysoft.com/qhtm/qhtmlight.zip is 0.1.5.3 whereas the one in Franco's zip file on the resources site is 0.1.5.2. When I tried version 0.1.5.2 it worked! (I have no idea why this should be!)

btw, Franco, in your call to CreateWindowEx you use ID_QhtmCtrl which is uninitialised ... but it does no harm as #NULL is OK. Also, the #WS_EX_CLIENTEDGE extended style makes it look a bit better:

Code: Select all

QhtmCtrl = CreateWindowEx_(#WS_EX_CLIENTEDGE,"QHTM_Window_Class_001","",#WS_CHILD | WS_VISIBLE,0,0,WindowWidth()-5,WindowHeight()-32,Main_hWnd,#NULL,Dll_hWnd,#NULL)
Hope this might help ... it worked for me

Don
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.

Hi

Franco / Michael - with Michaels amendment everything works fine now, thanks very much. Great tool - makes on screen report writing very easy now.

Shame theres no support, though. It would be really useful to be able to access form elements from Purebasic - it would be a really neat way of building User Interfaces. Beyond my ability, though (not a C / ASM coder).

Ta - N
Post Reply