xsharp.eu • MakeProcInstance und FreeProcInstance
Page 1 of 1

MakeProcInstance und FreeProcInstance

Posted: Tue Feb 14, 2023 10:44 am
by lagraf
Hallo,
da ich grad keine Arbeit habe, wollte ich versuchen das Beispiel Sokoban auf VO 2.8 zu bringen. Das Meiste habe ich ausgebessert, es bleiben mir nur die inzwischen obsoleten Aufrufe MakeProcInstance und FreeProcInstance übrig:

Code: Select all

pProc := MakeProcInstance(@getname(), _GetInst())
DialogBox(_GetInst(),"HISCORE",hwnd,pProc)
FreeProcInstance(pProc)
Wie kann ich die Dialogbox HISCORE anstelle dessen aufrufen?

MakeProcInstance und FreeProcInstance

Posted: Wed Feb 15, 2023 9:17 am
by lagraf
Ich habs rausgefunden, man kanns anscheinend direkt angeben:

Code: Select all

//pProc := MakeProcInstance(@getname(), _GetInst())
DialogBox(_GetInst(),"HISCORE",hwnd,@getname())
//FreeProcInstance(pProc)
Das Prog compiliert nun zwar ohne Fehler, AboutBox wird angezeigt, Lev kann ich auswählen, hier schmiert das Prog dann ab:

Code: Select all

    WHILE GetMessage(@msg2, 0, 0, 0)
      IF  TranslateAccelerator(hWnd,hAcc,@msg2)=0
        TranslateMessage(@msg2)
        DispatchMessage(@msg2)
      END
    END
Interessanterweise kann ich das Prog auch nicht debuggen, bekomme immer die Meldung "No active entity" im Debugfenster.

MakeProcInstance und FreeProcInstance

Posted: Wed Feb 15, 2023 9:37 am
by robert
France,
You cannot send the address of a managed function (I am assuming getname is managed) to an unmanaged Win32 function like DialogBox.
You need to write something like this:

Code: Select all

System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate( (System.Delegate) getname)
instead of

Code: Select all

 @getname
Robert

MakeProcInstance und FreeProcInstance

Posted: Wed Feb 15, 2023 12:19 pm
by lagraf
Hi Robert,
functions GetName (and also About) are defined as

Code: Select all

FUNCTION getname(hDlg AS WORD, message AS WORD, wParam AS WORD, lParam AS LONG) AS LOGIC _WINCALL
FUNCTION About(hDlg AS WORD, message AS WORD, wParam AS WORD, lParam AS LONG) AS LOGIC _WINCALL
In Internet I found following text:
The MakeProcInstance function is obsolete. Win32 functions can be called directly.

So I changed this for function About and it does well, Hiscore should be the same:

Code: Select all

//    pProc := MakeProcInstance(@About(), _GetInst())
//    DialogBox(_GetInst(),"ABOUTBOX",hwnd,pProc)
//    FreeProcInstance(pProc)
      DialogBox(_GetInst(),"ABOUTBOX",hWnd,@About())
Is GetFunctionPointerForDelegate X# or VO?

MakeProcInstance und FreeProcInstance

Posted: Wed Feb 15, 2023 12:35 pm
by robert
> Is GetFunctionPointerForDelegate X# or VO?
X# (or actually .Net)

Robert

MakeProcInstance und FreeProcInstance

Posted: Thu Feb 16, 2023 5:16 pm
by lagraf
Why can I not debug the app, I get the mess "No active entity" instead of going into debugger?

MakeProcInstance und FreeProcInstance

Posted: Thu Feb 16, 2023 7:20 pm
by robert
lagraf post=25273 userid=4521 wrote:Why can I not debug the app, I get the mess "No active entity" instead of going into debugger?
Difficult to say without example

Robert

MakeProcInstance und FreeProcInstance

Posted: Fri Feb 17, 2023 4:49 am
by lagraf
Oh no - I got it, debug wasn't enabled!
This is a switch I always used with default on and so I didn't think of it!
Thanks for help!
Franz