MakeProcInstance und FreeProcInstance

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

Post Reply
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

MakeProcInstance und FreeProcInstance

Post 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?
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

MakeProcInstance und FreeProcInstance

Post 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.
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

MakeProcInstance und FreeProcInstance

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

MakeProcInstance und FreeProcInstance

Post 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?
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

MakeProcInstance und FreeProcInstance

Post by robert »

> Is GetFunctionPointerForDelegate X# or VO?
X# (or actually .Net)

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

MakeProcInstance und FreeProcInstance

Post by lagraf »

Why can I not debug the app, I get the mess "No active entity" instead of going into debugger?
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

MakeProcInstance und FreeProcInstance

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

MakeProcInstance und FreeProcInstance

Post 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
Post Reply