DLL Classes

Windows specific questions.
Post Reply
nastasa eodor
Posts: 182
Joined: Dec 18, 2018 16:37
Location: Germany, Hessdorf
Contact:

DLL Classes

Post by nastasa eodor »

try

Code: Select all

#include once "windows.bi"

common shared Main as hwnd

type PPropertyInfo as TPropertyInfo ptr
type TPropertyInfo  field = 1 ' is importand field align
    PropertyName  as zstring ptr
    PropertyValue as zstring ptr
end type

dim shared as TPropertyInfo PIF

sub click stdcall(sender as any ptr) export
    messagebox(main,"ok","ok",0)
end sub

function WndProc(Dlg as hwnd, Msg as uint, wParam as wParam, lParam as lparam) as uint
    static P as function(class as zstring ptr, Parent as hwnd, x as integer, y as integer, cx as integer, cy as integer, byref o as any ptr) as hwnd
    static DP as function stdcall(Dlg as hwnd) as boolean
    static LC as function stdcall() as zstring ptr
    static mC as function stdcall(Dlg as hwnd) as zstring ptr
    static ex as function stdcall() as integer
    static gh as function stdcall() as hwnd
    static mp as function stdcall (file as zstring ptr) as any ptr 
    static da as sub stdcall()
    static PH as function stdcall() as Hwnd
    static as hmodule M, EM
    static as hwnd h, hclass, hDLL
    dim as zstring ptr s
    dim as string u
    dim as integer count
    dim as COPYDATASTRUCT WC
    static as any ptr ob, oc, oe, of, off
    select case msg
    case WM_CREATE
        M = dylibload("RapidQ.DLL")
        if M <> 0 then
           P = dylibsymbol(M, "Create")
           if P <> 0 then
               hclass = P(@"QButton", Dlg, 0, 0, 450, 250,ob)
               print "obj = ";ob
               hclass = P(@"QMemo", Dlg, 0, 255, 450, 250,oc )
               print "obj = ";oc 
               hclass = P(@"QEdit", Dlg, 455, 0, 450, 250,oe)
               print "obj = ";oe
               hclass = P(@"QForm", Dlg, 455, 350, 250, 150,of)
               print "obj = ";of
               if IsWindow(hClass) then ShowWindow(hClass, SW_SHOW)
               hclass = P(@"QForm", 0, 40, 35, 250, 150,off)
               print "obj = ";off
               if IsWindow(hClass) then ShowWindow(hClass, SW_SHOW)

               DP = dylibsymbol(M, "Destroy")
               DA = dylibsymbol(M, "DestroyAll")
               LC = dylibsymbol(M, "GetClassName")
               mc = dylibsymbol(M, "ListDialogProperties")
               ex = dylibsymbol(M, "Execute")
               PH = dylibsymbol(M, "DLLHandle")
               if PH then hDLL = PH()
               if LC <> 0 then
                  s = LC()
                  print "length is = ";len(*s)
                  print *s
               end if
               if mc <> 0 then
                  s = mC(hclass)
                  print "addr ";s
                  print "length is = ";len(*s)
                  'copymemory(s, @u,len(*s))
                  print *s
               end if
               
           end if    
        end if
        return 0
    case WM_DESTROY
        
        return 0
    case WM_LBUTTONDOWN
        PIF.PropertyName = @"Text"
        PIF.PropertyValue = @"myEdit1"
        SendMessage(hDLL, WM_APP +1, cast(integer,oe), cast(integer, @PIF))
        PIF.PropertyName = @"Font.Name"
        PIF.PropertyValue = @"Lucida Console"
        SendMessage(hDLL, WM_APP +1, cast(integer,oe), cast(integer, @PIF))
        PIF.PropertyName = @"Font.Size"
        PIF.PropertyValue = @"12"
        SendMessage(hDLL, WM_APP +1, cast(integer,oe), cast(integer, @PIF))
        PIF.PropertyName = @"Lines"
        PIF.PropertyValue = @("Line 1"&chr(10)&"Line 2"&chr(10)&"Line 3"&chr(10)&"Last Line")
        SendMessage(hDLL, WM_APP +1, cast(integer,oc), cast(integer, @PIF))
        PIF.PropertyName = @"onclick"
        dim as string s = str(@click)
        PIF.PropertyValue = strptr(s)
        SendMessage(hDLL, WM_APP +1, cast(integer,ob), cast(integer, @PIF))
        PIF.PropertyName = @"Align"
        PIF.PropertyValue = @"alClient"
        SendMessage(hDLL, WM_APP +1, cast(integer,ob), cast(integer, @PIF))

        return 0
    case WM_RBUTTONDOWN
        
        return 0    
    case WM_CLOSE
        if Da <> 0 then DA()
        dylibfree(M)
        ExitProcess(0)
    end select
    
    return DefWindowProc(Dlg, Msg, wParam, lParam)
end function

function Register as integer
     dim as wndclassex wc
     wc.cbsize = sizeof(wc)
     wc.style = cs_owndc or cs_globalclass
     wc.hinstance = 0
     wc.lpszClassName = @"myCLASS"
     wc.lpfnWndProc = @WndProc
     wc.cbWndExtra += 4
     wc.hCursor = LoadCursor(0, IDC_ARROW)
     wc.hbrBackground = cast(HBRUSH, 16)
     return RegisterClassEx(@wc)
end function

function Create as hwnd
    Main = CreateWindowEx(0,@"myCLASS",@"myCLASS",WS_CLIPCHILDREN or WS_CLIPSIBLINGS or WS_OVERLAPPEDWINDOW or WS_VISIBLE, 0, 0, cw_usedefault, cw_usedefault,0,  cast(HMENU,0),GetModuleHandle(0), 0)

    return Main
end function

sub ApplicationRun
    DIM m as msg
    print Register
    print Create
    print getlasterror
    while GetMessage(@m, 0,0,0) > 0
        TranslateMessage(@m)
        DispatchMessage(@m)
    wend    
end sub

ApplicationRun
and dll here
https://drive.google.com/open?id=1qOagJ ... WiPt5H3Qsr
Post Reply