Announcement

Collapse
No announcement yet.

Window in DLL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Window in DLL

    How does one go about creating a window in a DLL when the callback function also resides in the DLL?

    In this snippet the register class function returns an atom but the createwindow function fails.

    [code}
    Init = FN_InitClass(%CS_HREDRAW OR %CS_VREDRAW OR %CS_OWNDC, _
    CODEPTR(SpinCtl_CB), _
    4, _
    4, _
    Inst, _
    -1, _ %RGB_ORANGERED
    "SPIN_CTRL")


    tSpnr.BaseHndl = FN_InitWindow(%WS_EX_TOPMOST, _ or %ws_ex_transparent, _
    "SPIN_BASE", _
    "SPIN", _
    CtlStyle, _
    tPnt.X, _
    tPnt.Y, _
    64, _
    64, _
    Prnt, _
    0, _
    Inst)
    [/code]

    Works fine outside of the dll.
    Walt Decker

  • #2
    Insufficient code show. Probably you're missing the CS_GLOBALCLASS style.
    Last edited by José Roca; 22 Apr 2017, 05:44 PM.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Insufficient code show. Probably you're missing the CS_GLOBALCLASS style.
      If that was the case, why would the registerclassesx function return an atom? Other than a check for the class being registered and another for background brush, that's all that is in FN_InitClass.
      Walt Decker

      Comment


      • #4
        Check that you are using the right "Inst" value. The Instance handle of the DLL is different than that of the EXE.
        Paul Squires
        FireFly Visual Designer (for PowerBASIC Windows 10+)
        Version 3 now available.
        http://www.planetsquires.com

        Comment


        • #5
          Originally posted by Walt Decker View Post

          If that was the case, why would the registerclassesx function return an atom?
          And why not? The class is registered, but as it is not global, it can't be found when you call CreateWindowEx in your other code.


          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            I found an error in one of my API declarations.

            The CS_GLOBALCLASS is not necessary. When I found the error, the dll executed properly without it.

            Thanks for the help.
            Walt Decker

            Comment


            • #7
              Oh yeah! Error in code not shown where everybody can help find it. Now you know why that is said so often.

              Cheers,
              Dale

              Comment


              • #8
                Dale:

                Would not have mattered if I had displayed code. The error was in a PB include file, not my code.
                Walt Decker

                Comment


                • #9
                  How does one go about creating a window in a DLL when the callback function also resides in the DLL?
                  Uisng any SDK method (CreateWindowEx, DialogBox[indirect][param] or createDialog[indirect][param], the address of the window procedure ("callback function") is supplied as an argument in the call to create the window.

                  If your code happens to be in the same module as the creation, you can use CODEPTR. If the window procedure is in a different module, you can get it with LoadLibrary() (or GetModuleHandle()) plus GetProcAddress().

                  NOTE: using DDT the window procedure must be in the same code module in which the creation function (DIALOG NEW) exists; this is NOT a requirement of windows created using the native WinAPI calls.
                  Michael Mattias
                  Tal Systems Inc. (retired)
                  Racine WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Windows in a dll are not unusual. That's essentially what all the Windows Standard Controls (edit boxes, lables, etc.), Common Controls (Calendar Control, Listview Control, etc.), Custom Controls, and ActiveX Controls are.
                    Fred
                    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                    Comment


                    • #11
                      tSpnr.BaseHndl = FN_InitWindow(%WS_EX_TOPMOST, _ or %ws_ex_transparent, _
                      "SPIN_BASE", _
                      ....
                      I cannot see how that can be "working fine outside the DLL." I think you have an extra comma after WS_EX_TOPMOST and before OR. (actually 'or' in lowercase).


                      Michael Mattias
                      Tal Systems Inc. (retired)
                      Racine WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment

                      Working...
                      X