Announcement

Collapse
No announcement yet.

Extra window memory

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

  • Michael Mattias
    replied
    If you are worried about getting a parameter to a DIALOG rather than a "standard window" you can use DialogBoxParam or CreateDialogParam.

    Which reminds me...

    Using DDT, I can't find a way to pass a parameter to a dialog.

    A new feature might be the addition of a parameter option to DIALOG NEW or DIALOG SHOW, as in:

    Code:
    DIALOG NEW hParent&, title$, [x&], [y&], xx&, yy& [, style& [, exstyle&] [,Param&] TO hDlg&
    OR...
    Code:
    DIALOG NEW   yadda, yadda
    DIALOG PARAM hDlg, X&
    CONTROL ADD  xxxxx
    ....
    DIALOG SHOW ...
    Param would be available on the WM_INITDIALOG message of the dialogproc, maybe as CBUPARAM or something like that.

    (I'm not sure when the dialog is created, on DIALOG NEW or DIALOG SHOW).

    MCM

    Leave a comment:


  • Aldo Cavini
    replied
    James,

    thanks for the idea. I didn't think about directly calling the window proc. No way this method will fail.

    Michael,

    yes, I'm more or less conveinced getting the values I need via the CRATESTRUCT does the job. The problem is the remark I found inside the Win32api.hlp file - if it were true, all the programs using this method couldn't work under Win NT!

    ------------------

    Leave a comment:


  • Michael Mattias
    replied
    Sure, I use CreateStruct in one of my apps. works good. (That's an MDI application, so it uses MDICreateStruct, but I have to believe the "regular" one works just fine.

    Here's the code I use on WM_cREATE of the MDI child window to pass an ASCIIZ string:

    Code:
      LOCAL pMdiC AS MDICreateStruct PTR
      LOCAL pCC   AS CreateStruct    PTR
       .....
          CASE %WM_CREATE
               pCC = lparam                 ' lparam = point to createstruct
               pMDIC = @pcc.lpcreateparams  ' createstuct.lpcreateparms is pointer to mdicreatestuct
               pZText = @pMDIC.lparam
    MCM
    (This would be a cool place for "C" type "casting", no?)


    Leave a comment:


  • jcfuller
    replied
    Aldo,
    One method is to call your Window Proc directly with a window handle of
    zero (before you create your window) passing your data pointer. Save it
    in a static var and use that until you receive your WM_CREATE message. Then you
    can store the pointer.

    James


    ------------------

    Leave a comment:


  • Aldo Cavini
    replied
    Michael,

    it isn't what I want. I'd like to use GetWindowLong inside the WM_CREATE message. Of course I can't use it, since the data isn't still stored. This is the reason I need to use some other method to pass the data. At the moment, to get the data pointer via the CREATESTRUCT type seems to work - I'd like to be confirmed this is not a wrong/dangerous method. Thanks anyway.

    ------------------

    Leave a comment:


  • Michael Mattias
    replied
    You can do SetWindowLong in WM_CREATE
    MCM

    Leave a comment:


  • Aldo Cavini
    replied
    Florent, thanks for the reply.

    I already use SetWindowLong and GetWindowLong. But they can be used only after the window was created. Are there other systems to pass a value you want to use during the window creation (i.e. inside the WM_CREATE message)?

    ------------------

    Leave a comment:


  • Florent Heyworth
    replied
    If in doubt why not just use SetWindowLong( hWnd, %GWL_USERDATA, lDataPtr )
    and then GetWindowLong( hWnd, %GWL_USERDATA ) to retrieve the
    data?

    Cheers

    Florent

    ------------------

    Leave a comment:


  • Aldo Cavini
    replied
    Found an article on MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/hh/winui/windows_06lu.asp)
    Windows NT/2000 or later: If the window is being created from a dialog template, this member is the address of a SHORT value that specifies the size, in bytes, of the window creation data. The value is immediately followed by the creation data.
    This quote is slightly different with respect what I quoted inside my first post (it was from Win32api.hlp). If the MSDN one is correct, hand created window behave all the same way, and all this forum is null (I tried it on Wn NT, and didn't find that SHORT value!). Please post a reply if is there something wrong.

    Thanks

    ------------------

    Leave a comment:


  • Aldo Cavini
    started a topic Extra window memory

    Extra window memory

    Hello. I started using the extra window memory to store some window-related values, instead of using static/globals. The problem is, how to initialize the extra memory values on the window creation? I know the following:
    • The number of required extra bytes must be declared on the window class registration
    • On the window creation I must pass a pointer to the init values (lpParam)
    • On the %WM_CREATE message I must assign the lParam value to a CREATESTRUCT pointer
    • I must use the lpCreateParams item of CREATESTRUCT as a pointer to the init values. But...

    Windows NT: This member is the address of a SHORT (16_bit) value that specifies the size, in bytes, of the window creation data. The value is immediately followed by the creation data.
    The question is, how to use this lpCreateParams value? Must be used two ways, depending on the O.S. version?

    Thanks

    ------------------

    [This message has been edited by Aldo Cavini (edited September 10, 2001).]
Working...
X