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.

Code: Select all

; (c) 2002 - Franco's template - absolutely free
; Simple HTML viewer example file
; 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.
; Download the free version from [url]http://www.gipsysoft.com/qhtm/index.shtml[/url]
; This piece of code works on WinXP and on Win98SE
 
#QHTM_LOAD_FROM_FILE = #WM_USER + 2
 
HtmlFile$=OpenFileRequester("Open an HTML file",".\","HTML file |*.htm;*.html",0)
 
If HtmlFile$
  Main_hWnd=OpenWindow(0, 200, 200, 320, 240, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "HTML DLL")
  Dll_hWnd=LoadLibrary_("qhtmlight.dll")
  QhtmCtrl = CreateWindowEx_(0,"QHTM_Window_Class_001","",#WS_CHILD | #WS_VISIBLE,0,0,WindowWidth()-5,WindowHeight()-32,Main_hWnd,ID_QhtmCtrl,Dll_hWnd,#NULL)
  SendMessage_(QhtmCtrl,#QHTM_LOAD_FROM_FILE, 0, HtmlFile$ )
  Repeat
    Event=WaitWindowEvent()
  Until Event=#PB_EventCloseWindow
EndIf
 
End


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.

> Download the free version from http://www.gipsysoft.com/qhtm/index.shtml

The web page wants a valid E-Mail address before you can download it, so here's
the direct link for you all:

http://www.gipsysoft.com/qhtm/qhtmlight.zip


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 PB.

> This piece of code works on WinXP and on Win98SE

Hmm, it may not work on Win 2000 -- I tried your example after putting the DLL
in System32 but nothing happens when I select a HTM file...


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 Franco.

Update: Uploaded a zip file to Paul's resource site containing the dll.

PB: I have Win98SE at work and WinXP at home so I can't test it on Win2000, sorry.
I had a strange thing also, because I coded at home and it worked fine.
Here at work it doesn't. Found out that I scrambled the CreateWindowEx_ call.
But after put the correct 'Dll_hWnd' ID it worked fine also under Win98SE.
For me it was really strange because it worked on WinXP without error messages...

Just saw that you put the dll in the system32 directory.
I have it in the prog dir, try this too.
If this don't work out, force to initialize the dll with the function "QHTM_Initialize".

Please keep me updated.


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.

> But after put the correct 'Dll_hWnd' ID it worked fine also under Win98SE.

So what did you do? I'm still using your code from above...

> Just saw that you put the dll in the system32 directory.
> I have it in the prog dir, try this too.

Didn't help...

> If this don't work out, force to initialize the dll with the
> function "QHTM_Initialize".

Can you please show me how? I'm a newbie when it comes to DLLs.

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 naw.
> But after put the correct 'Dll_hWnd' ID it worked fine also under Win98SE.

So what did you do? I'm still using your code from above...

> Just saw that you put the dll in the system32 directory.
> I have it in the prog dir, try this too.

Didn't help...

> If this don't work out, force to initialize the dll with the
> function "QHTM_Initialize".

Can you please show me how? I'm a newbie when it comes to DLLs.

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 naw.
> But after put the correct 'Dll_hWnd' ID it worked fine also under Win98SE.

So what did you do? I'm still using your code from above...

> Just saw that you put the dll in the system32 directory.
> I have it in the prog dir, try this too.

Didn't help...

> If this don't work out, force to initialize the dll with the
> function "QHTM_Initialize".

Can you please show me how? I'm a newbie when it comes to DLLs.

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 naw.

I think I have the same problem as PB...

I put the DLL in C:/windows/system & system32, the C:/Program Files/purebasic & the same directory as your code Franco.

But all I get is a blank window. I'm a DLL newbie too, so dont understand how to use the 'Dll_hWnd'.

Any suggestions?

PS sorry about the 2 previous duplicate posts - oops!
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 Paul.

It works fine here.. I have the DLL in the same folder as the PB app.
Pretty cool Franco!!

Do you other guys have the latest IE installed??
Maybe it depends on Internet Explorer?
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.

Hi PB,
well I moved the QHTMlight.dll in the system32 dir of WinXP and it worked fine.
So I have no clue why Win2000 - the former WinXp - isn't willing to work.

I can only test it on WinXP and Win98SE so I can't search what causes the problem.
I feel extremly sorry for this.

Will try to code a version with Mr.Skunks DLL load library but I have to figure out how to get the handle 'Dll_hWnd'. If The OpenDLL(0,"qhtmlite.dll") command will return the handle (instead of 0 or 1) it should work.

I'm glad that the code works at Paul's computer.


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 Franco.
Do you other guys have the latest IE installed??
Maybe it depends on Internet Explorer?
Like it says in the header of the template:
; Uses WinAPI but I don't know if IE must be installed or not... sorry.
I don't know how much HTML functionality is in Windows - without IE...



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 Rings.

Oh guys, I thik franco missed something.
I studied the PowerBasic-Sourcecode and found that something is missing.
There is no call to the DLL.


Getting better with a little help from my friends....thx Siggi
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.
Oh guys, I thik franco missed something.
I studied the PowerBasic-Sourcecode and found that something is missing.
There is no call to the DLL.
Normally THIS library works without any calls. Well it does under Win98SE and WinXP!
THIS library reacts with the SendMessage command. That's why there is:

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

But there are some calls in the library like:

"QHTM_Initialize"
"QHTM_EnableCooltips"
"QHTM_MessageBox"
"QHTM_PrintCreateContext"
"QHTM_PrintDestroyContext"
"QHTM_PrintGetHTMLHeight"
"QHTM_PrintLayout"
"QHTM_PrintPage"
"QHTM_PrintSetText"
"QHTM_PrintSetTextFile"
"QHTM_PrintSetTextResource"

I have also the Cooltips WITHOUT calling "QHTM_EnableCooltips".

Siggi, you didn't tell if the code works for you.
At Paul's resource site you will find a zip file with the dll and PureB source.


PB, try this, it uses the DLL library of Mr.Skunk and I call the "QHTM_Initialize" command.
Maybe this works for you.
I can't really test your problem because both versions work fine for me!!!

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]http://www.gipsysoft.com/qhtm/index.shtml[/url]
; This piece of code works on WinXP and on Win98SE

#QHTM_LOAD_FROM_FILE = #WM_USER + 2

Dll_hWnd=OpenDLL(0,"qhtmlite.dll")

If DLLFunction(0,0,"QHTM_Initialize") : CallDLL0(0) : Else : MessageRequester("Sorry","No DLL Function",0) : End : EndIf ; Register function

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 DLL")
  QhtmCtrl = CreateWindowEx_(0,"QHTM_Window_Class_001","",#WS_CHILD | #WS_VISIBLE, 0, 0, 310, 208, MainForm,ID_QhtmCtrl,Dll_hWnd,#NULL)
  SendMessage_(QhtmCtrl,#QHTM_LOAD_FROM_FILE, 0, HtmlFile$ )
  Repeat
    Event=WaitWindowEvent()
  Until Event=#PB_EventCloseWindow
EndIf

End


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 Franco.

PB, try different HTML files.
Just found out, that some HTML files don't show up properly, like:

PureBasic - Guide.html

I get only a white blank window! That's strange.

Remember: this DLL is not a replacement for IE!

And there are some restrictions in the freeware version like: only BMP files are supported.
But if you look at the sample HTML files you can display nice things with it. Also hyperlinks are possible.



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.

Still no go, sorry!

I have Internet Explorer 6 installed (did it the other day, by co-incidence).
I have tried many different HTML files, including the most basic of pages.
I have put the DLL in System32 and the program folder.
I have tried registering the DLL with RegSvr32.

After all that, all I get is a blank window after selecting an HTML file.

Thanks anyway -- it's not something I intend to use at this time, so it
doesn't really bother me. I was just curious to see how it looked.

PB - Registered PureBasic Coder
Post Reply