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.
    •  
      CommentAuthorsperling
    • CommentTimeSep 17th 2010
     
    Hi all:

    Well, I´m new to this forum, so I have my first question...
    I come from the C4W environment, where I was used to subclass my windows.
    Now, I started converting my app into NTK, and I ran into the following problem:

    I try to subclass the main window, and the app aborts without any warning at all...
    So far I can see, this source should work without any problems; if I remove the subclass, everything works fine.

    Here´s what I do:
    For simplicity, I used as basis the HELLO.EXE source, where already exists a registered window (the main window).
    So I reduced the source to the following:

    IF !NTK_RegisterClass( CS_HREDRAW + CS_VREDRAW,; // CS_OWNDC + CS_VREDRAW + CS_HREDRAW + CS_DBLCLKS,;
    hInst,;
    hIcon,;
    hCurs,;
    hBrush,;
    "NTKFEN",;
    { |hWnd, message, nwParam, nlParam|;
    HELLOWNDPROC(hWnd, message, nwParam, nlParam) })
    ENDIF
    hWndDemo = NTK_CreateWindowEX(WS_EX_WINDOWEDGE, "NTKFEN", cWinTitle,F_MIN+F_MAX+WS_SYSMENU,0,0,640,480)
    NTK_ShowWindow( hWndDemo, SW_SHOW )
    NTK_UpdateWindow( hWndDemo )

    nproc := NTK_SubClassWindow( hWndDemo, ;
    {|hWnd,nMsg,nwParam,nlParam| ;
    MyProcJan(nproc,hWnd,nMsg,nwParam,nlParam)},-1)

    DO WHILE NTK_GetMessage( NTK_aMSG, 0 )
    NTK_TranslateMessage( NTK_aMSG )
    NTK_DispatchMessage( NTK_aMSG )
    ENDDO

    NTK_DeleteObject( hDemoFont1 )
    NTK_SelectWindow( hWndDemo )
    NTK_DestroyWindow( hWndDemo )
    NTK_UnregisterClass( "NTKFEN", hInst )

    And here are my Subclass Wndproc's:

    FUNCTION HELLOWNDPROC( hWnd, message, nwParam, nlParam)
    RETURN( NTK_DEFWNDPROC(hWnd, message, nwParam, nlParam) )

    FUNCTION MyProcJan(nProc, hWnd, nMsg, nWparam, nLparam)
    RETURN (NTK_CallWindowProc(nProc, hWnd, nMsg, nWparam, nLparam))

    TIA, Jan
    •  
      CommentAuthorAbbougaga
    • CommentTimeSep 20th 2010
     
    Hi Jan,

    Welcome to NTK forum.

    As you I'm a former C4W's user. Nowadays, I'm still using to subclass Edit controls for maskedit purposes in apps using modeless-Dialogs. No pb at all. NTK_Subclass() works fine for me.

    However, I must admit I never tried to subclass a window I made using CreateWindowEx, and for which I'm responsible for handling messages in its windproc. Nor with C4W, nor using NTK framework.
    But I confirm, when I try the helloword you suggested, the program hangs a few seconds after it displays the main window. Sorry, I'm afraid to be a litlle bit stuck with this pb! Maybe JN would be able to point you the right direction?

    Cheers,
    Ab
    •  
      CommentAuthorsperling
    • CommentTimeSep 20th 2010
     
    Hi Ab:

    Tx for your answer!
    Well, I hope to contribute in the future with some knowledge in this forum.

    I´ve used subclassing for many, many things back in C4W, and as I´m trying to port a very big app (about 2.000.000 lines source), I really need this working... Will ask JN if he is able to shed some light on this...

    If you don´t mind, I have just another question:
    I need to incorporate the CREATEDIALOGINDIRECT API. Is this contained in the Pro version of NTK? Haven´t d
    Just for the background: For all dialogs (which are contained in a .RES), I first read from memory the Template, convert this template to an understandable array for the CREATEDIALOGINDIRECT, and then I create a modeless dialog with it. We use this to translate at runtime dialogs, and to combine dialogs into a new one...
    I have the source of all this, and it compiles fine with MSVC, but not in BCC :-((

    Thanks in advance, Jan.
    •  
      CommentAuthorsperling
    • CommentTimeSep 20th 2010
     
    Just adding a few comments to the last message:

    The CREATEDIALOGINDIRECT as stating from the NTK Help file has a different syntax from the API...
    This is the API's one:

    HWND CreateDialogIndirect(
    HINSTANCE hInstance,
    LPCDLGTEMPLATE lpTemplate,
    HWND hWndParent,
    DLGPROC lpDialogFunc);

    Well, I have this done so far, now I´m running into the following missing functions:
    FINDRESOURCE
    LOADRESOURCE
    LOCKRESOURCE
    FREERESOURCE

    Are they included in the PRO NTK version?

    BR, Jan
    •  
      CommentAuthorsperling
    • CommentTimeSep 20th 2010
     
    Hmmm, well, got FINDRESOURCE and so on working..
    Now I´m stuck with BIN2A...
    Will do some more research, before posting :-)))

    BR, Jan
    •  
      CommentAuthorAbbougaga
    • CommentTimeSep 20th 2010
     
    Hi Jan,

    You should find relevant information about
    NTK CreateDialog( <cDlgTitle>, <nStyle>, <nX>, <nY>, <nWidth>, <nHeight>,;
    [<nPointSize>], [<cFontName>]) –> aDlg
    Or
    NTK CreateDialogIndirect( <cDlgTitle>, <nStyle>, <nX>, <nY>, <nWidth>, <nHeight>,;
    [<nPointSize>], [<cFontName>]) –> aDlg

    at chapter 0.10.3 of your NTKCORE_PART1.pdf programer's guide. As far as I know, it is possible to download a quite recent version on NTK website.

    According to my own exeperience, I also remember pretty good tutorials in ..\NTKCORE directory:
    demomul.prg, bmdlgres.prg

    I also remember that when I was porting my C4W 16bit app to NTK Win32, I encountered some slight differences between 16Bit and 32bit RC dialogs. Unfortunately, I can't remember what they are. Nothing really significant, just pay attention, read the docs, and over all: do not hesitate to refer to MSDN2 or Win32 SDK (if you own a copy)

    Hope it helps.

    Cheers,
    Ab
    •  
      CommentAuthorAbbougaga
    • CommentTimeSep 20th 2010
     
    Jan,

    FINDRESOURCE
    LOADRESOURCE
    LOCKRESOURCE
    FREERESOURCE
    Are they included in the PRO NTK version?

    As far as I know, YES.

    Regarding BIN2A and A2BIN, when I asked JN (long time ago) about this topic, he adviced me to rather use xharbour modern way of managing C structure. So far, I did like that.
    Anyway you should be able to find source code of both function, and easily adapt it to NTK. It's just a matter of #include...

    Cheers,
    Ab
    •  
      CommentAuthorsperling
    • CommentTimeSep 21st 2010
     
    Tx Ab, will search the BIN2A and A2BIN in xHarbour.
    Related to the CREATEDIALOGINDIRECT, well, the NTK syntax is quite different from MSDN.
    But anyway, it is question of writing the HB_FUNC.

    So far, I´ve managed to include the HB_FUNC for the *RESOURCE, and will check out the BIN funcs.

    Thank U very much for your input.

    Jan.
    •  
      CommentAuthorAbbougaga
    • CommentTimeSep 21st 2010
     
    Jan,

    **Related to the CREATEDIALOGINDIRECT, well, the NTK syntax is quite different from MSDN.

    Indeed, but 100% similar to C4W CreateDialog() function. So, very easy to translate!

    **But anyway, it is question of writing the HB_FUNC.
    Ok, but using NTK_CreateDialog(), no need to deal with the LPCDLGTEMPLATE structure nor handle the callback procedure using a lpDialogFunc pointer... Personally I'm not a C guru.

    Cheers,
    Ab
    •  
      CommentAuthorsperling
    • CommentTimeSep 21st 2010
     
    Yep, I understand your point...
    But I never used CREATEDIALOG from C4W, I always used the WDIALOG class, with some MDI flag turned on, which caused to create the dialogs from some mysterious function called MDICREATEDIALOG.

    But for years I have developed my own core lib's, which are the very main structure of my app...
    It's all oop-based, all message-driven, and the only function is the MAIN function. I rely at 100% on the C4W class structure, and now I have translated the most of the C4W class sources to xHarbour.
    Back in the C4W world, you was able to create a MDI app, where each child window was a dialog. This was archived with the function MDICREATEDIALOG. The nearest approach I´ve found for that is the CREATEDIALOGINDIRECT, which allows me also to manipulate at runtime the dialog template... Sometimes we use this to translate certain words, etc. The source for managing this already exists in xHarbour (at least for the dialog and the callback. I wrote the source for reading from memory the .RES dialog, which relies precisly on BIN2A (which should not be a problem to solve).

    Now I have the pressure from my clients to have their app in 32bits. In fact, more and more are buying 64bit laptops, which come with 64 based Windows, unable to run any 16bit app...

    So, nobody said things are easy... :-)
    When I finish this step, I want to contribute this to the NTK team, maybe someone else will find this useful.

    Tx for sharing comments, I hope this will enrich this forum.

    Jan