Welcome, Guest
Username: Password: Remember me
Hier wird Deutsch gesprochen
  • Page:
  • 1

TOPIC:

MakeProcInstance und FreeProcInstance 14 Feb 2023 11:44 #25230

  • lagraf
  • lagraf's Avatar
  • Topic Author


  • Posts: 338
  • 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:
    pProc := MakeProcInstance(@getname(), _GetInst())
    DialogBox(_GetInst(),"HISCORE",hwnd,pProc)
    FreeProcInstance(pProc)
    Wie kann ich die Dialogbox HISCORE anstelle dessen aufrufen?

    Please Log in or Create an account to join the conversation.

    MakeProcInstance und FreeProcInstance 15 Feb 2023 10:17 #25239

    • lagraf
    • lagraf's Avatar
    • Topic Author


  • Posts: 338
  • Ich habs rausgefunden, man kanns anscheinend direkt angeben:
    //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:
        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.

    Please Log in or Create an account to join the conversation.

    Last edit: by lagraf.

    MakeProcInstance und FreeProcInstance 15 Feb 2023 10:37 #25240

    • robert
    • robert's Avatar


  • Posts: 3600
  • 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:
    System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate( (System.Delegate) getname)

    instead of
    @getname

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    MakeProcInstance und FreeProcInstance 15 Feb 2023 13:19 #25246

    • lagraf
    • lagraf's Avatar
    • Topic Author


  • Posts: 338
  • Hi Robert,
    functions GetName (and also About) are defined as
    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:
    //    pProc := MakeProcInstance(@About(), _GetInst())
    //    DialogBox(_GetInst(),"ABOUTBOX",hwnd,pProc)
    //    FreeProcInstance(pProc)
          DialogBox(_GetInst(),"ABOUTBOX",hWnd,@About())

    Is GetFunctionPointerForDelegate X# or VO?

    Please Log in or Create an account to join the conversation.

    MakeProcInstance und FreeProcInstance 15 Feb 2023 13:35 #25247

    • robert
    • robert's Avatar


  • Posts: 3600
  • > Is GetFunctionPointerForDelegate X# or VO?
    X# (or actually .Net)

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    MakeProcInstance und FreeProcInstance 16 Feb 2023 18:16 #25273

    • lagraf
    • lagraf's Avatar
    • Topic Author


  • Posts: 338
  • Why can I not debug the app, I get the mess "No active entity" instead of going into debugger?

    Please Log in or Create an account to join the conversation.

    MakeProcInstance und FreeProcInstance 16 Feb 2023 20:20 #25274

    • robert
    • robert's Avatar


  • Posts: 3600
  • 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

    Please Log in or Create an account to join the conversation.

    MakeProcInstance und FreeProcInstance 17 Feb 2023 05:49 #25276

    • lagraf
    • lagraf's Avatar
    • Topic Author


  • Posts: 338
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    Moderators: wriedmann