Click here to Skip to main content
12,951,823 members (65,085 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I import "htmlayout.dll", call "HTMLayoutLoadFile" function, and the winform come out, but it just display blank. can anybody tell me what is wrong?

here is the code:
(println "win32demo")
 
(define (import-list library flist)
    (dolist (fname flist) (import library (string fname))))
 
(define-macro (@setq %var %value)
    (set %var (eval %value))
    (println %var " " (eval %var)))
 
(import-list "kernel32" '(GetModuleHandleA GetConsoleWindow))
(import-list "user32" '(PostQuitMessage DefWindowProcA))
(import-list "user32" '(LoadCursorA RegisterClassA CreateWindowExA))
(import-list "user32" '(ShowWindow UpdateWindow))
(import-list "user32" '(GetMessageA TranslateMessage DispatchMessageA))
 
(import-list "htmlayout.dll" '(HTMLayoutLoadFile))
 
(setq WM_CREATE 1 WM_DESTROY 2 WM_ERASEBKGND 0x0014 WM_CHAR  0x102 WM_LBUTTONDOWN 0x201)
(setq IDC_ARROW 0x7F00 CS_VREDRAW 1 CS_HREDRAW 2 COLOR_WINDOW 5)
(setq WS_OVERLAPPEDWINDOW 0xCF0000 HWND_MESSAGE -3 SW_SHOWDEFAULT 10)
 
(@setq hinstance (GetModuleHandleA 0))
(@setq hconsole (GetConsoleWindow))
(@setq cursor (LoadCursorA 0 IDC_ARROW))
 
(define (window-callback-function hwnd message wparam lparam)
    (cond
        ((= message WM_CREATE) (println "created") (HTMLayoutLoadFile hwnd "default.htm") 0)
        ((= message WM_LBUTTONDOWN) (println "click!") 0)
        ((= message WM_CHAR) (println (format "char %c" wparam)) 0)
        ((= message WM_ERASEBKGND) (println "WM_ERASEBKGND!") true)
        ((= message WM_DESTROY) (println "destroyed") (PostQuitMessage 0) 0)
        (true (DefWindowProcA hwnd message wparam lparam))))
 
(setq wndproc (callback 0 'window-callback-function))
(setq classname (HTMLayoutClassNameA))
 
(println classname)
 
(setq wc (pack (dup "ld" 10)
            (| CS_HREDRAW CS_VREDRAW)   ; style
            wndproc                     ; lpfnWndProc
            0                           ; cbClsExtra
            0                           ; cbWndExtra
            hinstance                   ; hInstance
            0                           ; hIcon
            cursor                      ; hCursor
            (+ COLOR_WINDOW 1)          ; hbrBackground
            0                           ; lpszMenuName
            classname                   ; lpszClassName
         ))
 
(@setq hwc (RegisterClassA wc))
(@setq hwnd (CreateWindowExA
                0                       ; dwExStyle
                classname         ; lpClassName
                "newlisp window"        ; lpWindowName
                WS_OVERLAPPEDWINDOW     ; dwStyle
                80 60 640 480           ; x y w h
                0                       ; hwndParent
                0                       ; hMenu
                hinstance               ; hInstance
                0                       ; hParam
           ))
 
; hconsole and HWND_MESSAGE are other useful values for hwndParent
 
(ShowWindow hwnd SW_SHOWDEFAULT)
(UpdateWindow hwnd)
 

 
(setq msg (pack "n28"))
 
(until (member (GetMessageA msg hwnd 0 0) '(0 -1))
    (TranslateMessage msg)
    (DispatchMessageA msg))
 
(println "the end")
 
(exit)
Posted 18-Mar-13 1:24am
eshioin346

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,239
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100