[comp.windows.ms.programmer] Extra Bytes in Dialog Window

kevin@msa3b.UUCP (Kevin P. Kleinfelter) (05/29/91)

I need to store 2 bytes in a dialog window. In "normal" windows,
I set cbClsExtra = 2, and use SetWindowWord and GetWindowWord.

I can do similar stuff with a dialog box, but I have to use
CreateDialogIndirect, and do all the dialog stuff in my program, instead of
using a template created by the dialog editor.

Is there a way to create a dialog window, using a dialog-box template,
and get extra bytes?
-- 
Kevin Kleinfelter @ DBS, Inc (404) 239-2347   ...gatech!nanoVX!msa3b!kevin

"This product has an intuitive user interface" is equivalent to "We didn't
provide sh** for documentation."

cadsi@ccad.uiowa.edu (CADSI) (05/30/91)

From article <1663@msa3b.UUCP>, by kevin@msa3b.UUCP (Kevin P. Kleinfelter):
> I need to store 2 bytes in a dialog window. In "normal" windows,
> I set cbClsExtra = 2, and use SetWindowWord and GetWindowWord.
> 
> I can do similar stuff with a dialog box, but I have to use
> CreateDialogIndirect, and do all the dialog stuff in my program, instead of
> using a template created by the dialog editor.
> 
> Is there a way to create a dialog window, using a dialog-box template,
> and get extra bytes?

Indirectly.  I use the SetProp() function.  Matter of fact, this
is how I store the 'this' of my Dialog base class.  It works well for
me.  Just set the property during the WM_INITDIALOG message.  Then,
when you need those little bytees, call GetProp().  Also, you'll
probably call DialogBoxParam() instead of DialogBox so you can
pass the bytes you need to the WM_INITDIALOG message.

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|

lalli@casee.enet.dec.com () (05/30/91)

>I need to store 2 bytes in a dialog window. In "normal" windows,
>I set cbClsExtra = 2, and use SetWindowWord and GetWindowWord.

You could use SetProp/GetProp instead of SetWindowWord/GetWindowWord. You'll
need to RemoveProp as well. I think the size of a property is limited to an 
Handle, but you can use multiple ones.
 
Hope this helps


--
Didier Lalli				lalli@casee.enet.dec.com
Digital Equipment,
Centre Technique Europe S.A.R.L.        DTN 828-5423
B.P. 129 - Sophia Antipolis 	        Tel. +33 92 95 54 23
06561 Valbonne Cedex - France	        Fax  +33 93 65 41 58

cadsi@ccad.uiowa.edu (CADSI) (06/01/91)

From article <15781@adobe.UUCP>, by jciccare@adobe.COM (John Ciccarelli):
> 
> I never used the "extra bytes" technique; SetProp and GetProp work just
> fine regardless of window class.
> 

We must be carefull in general.  Speed is an issue, especially with Windows.
If all programs forego the ability to use the 'Extra Bytes', too much
time CPU will be used in the GetProp function.  The GetWindowWord and Long
routines are significantly faster than GetProp.  Some programs use
these capabilities to store object pointers.  In order to retrieve the
object during a Window Message, you gotta call one of them.  As the
number of programs in the desktop increase, so will the number of
messages and speed will become an issue.  This hasn't happened yet,
but programmers should think along this line.

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|

robertk@rkrajewski.lotus.com (Robert Krajewski) (06/03/91)

In article <1663@msa3b.UUCP> kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes:

   Is there a way to create a dialog window, using a dialog-box template,
   and get extra bytes?

It is possible to cleanly define your own dialog class, now that the
DefDlgProc procedure has been documented in Windows 3.0. After your
class is registered, you can specify the name of the dialog class in
its resource description. Perhaps the SDK Dialog Editor does not allow
you to do this through its user interface, but I know that there *is*
a place for the window class to be used for the dialog in the resource
format.