NTK and The NTK Project
are properties of Jn Dechereux
Home | Documentation | FAQ.

Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorPoke45
    • CommentTimeNov 19th 2021
     
    Hi.

    Please accept my apologies if the answer is obvious as I am not particularly adept when it comes to understanding the internal mechanics of Win32 messaging functions, but I have run into a problem where I do not know how to translate the following type of code (from an old Clipper / Clip4Win application) into NTK / XHARBOUR:

    ___
    [within a function which is the procedure passed to a NTK_SUBCLASSWINDOW command for the window receiving the event messages]
    case nMsg == WM_COMMAND
    if nwParam == ID_NEWCLOD
    cClodName := C4W_Peek(nlParam)
    if !Empty(oStock:oClod) .and. ValType(oStock:oClod) == "O"
    oStock:oClod:LoadDefault(cClodName)
    ___ [etc.]

    it is specifically / only this line that I am struggling with:

    ___
    cClodName := C4W_Peek(nlParam)
    ___

    "C4W_Peek" does not exist in NTK; according to my Clip4Win documentation it returns a string containing the bytes of memory, where the first parameter is a pointer to the start of the memory and the second optionally specifies the number of bytes


    The code which generates the message being intercepted is elsewhere within the application code itself:

    ___

    if !Empty(cClodName) .and. ValType(cClodName) == "C"
    NTK_SENDMESSAGE(oApp:hStkBrowse, WM_COMMAND, ID_NEWCLOD, cClodName)
    endif
    ___

    if anyone has any ideas this would be very helpful. "C4W_Peek" does also exist in one or two other areas of the application I am translating, again used in a similar way
    •  
      CommentAuthorPoke45
    • CommentTimeNov 20th 2021
     
    i bypassed the above "C4W_Peek" requirement in my code by using static / public variables to store the string values which were being passed via the NTK_SENDMESSAGE calls

    however it would be nice to know the answer here - i think my question boils down to this:

    if we use the "NTK_SENDMESSAGE" function to pass a string via its fourth "cnlParam" parameter (from the NTKPROJECT documentation: "An numeric or string value specifying an additional and specific information to be passed with the message. (a string value must be passed by reference)" - then how would our own window sub-classing code later read that string value 'back' again, when intercepting that message? i.e. surely not simply cString := STR(nlParam)
    •  
      CommentAuthorxbasefan
    • CommentTimeNov 22nd 2021
     
    hi poke45

    below a code snippet in C i found 10+ years ago when starting migrating to ntk but cannot remember where or in which tutorial. anyway works well as replacement for cw4_peek func - just paste it at the end of your prg.
    also this old post might help too... shows how to export extra vars to a subsclassed proc:
    https://www.ntkproject.com/forum_ntk/comments.php?DiscussionID=9&page=1#Item_0
    hth
    wilson

     
    #pragma BEGINDUMP
    
    #include <windows.h>
    #include "hbapi.h"
    #include "hbvm.h"
    #include "hbstack.h"
    #include "hbapiitm.h"
    
    
    // ---------------------------------------------------------
    // my_peek(<nPtr>,[<nCnt>]) --> cStr
    // ---------------------------------------------------------
    HB_FUNC( MY_PEEK )
    {
     if ( hb_pcount()==2 )
        hb_retclen( (char *) hb_parnl(1), hb_parni(2) );
     else
        hb_retc( (char *) hb_parnl(1) );
    }
    
    #pragma ENDDUMP
    
    •  
      CommentAuthorPoke45
    • CommentTimeNov 25th 2021
     
    thanks xbasefan: i had not considered this "peek" functionality might be more a HARBOUR/XHARBOUR thing (and to research within that) than a windows / NTK_PROJECT thing.

    i notice now there is also what appears to be a direct replacement within harbour itself:
    https://harbour.github.io/doc/clct3.html#peekstr