Internet Address Control?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Internet Address Control?

Udo Schneider
Hello,

does anybody has a working wrapper for the Internet Address Control from
the Common Control Library?

My first attempts allways caused (at least I assume this) resource
problems (Font in all windows switches back to default font).

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Bill Schwab-2
Udo,

> does anybody has a working wrapper for the Internet Address Control from
> the Common Control Library?
>
> My first attempts allways caused (at least I assume this) resource
> problems (Font in all windows switches back to default font).

Take a look at Ian's site, especially his D3 and D4 goodies.  I get the
impression that he has dropped support for some things (though he might have
moved them and I simply haven't rediscovered them).  In particular, look at

   http://www.idb.me.uk/goodies3/commoncontrols.html

If Ian's site doesn't solve your problems, then I would urge you to throw
together a composite persenter and be done with it.  You need something that
prompts the user for four numbers[*], and a little range validation.  You
can build that yourself much faster than you can wrap an external library,
particularly one that (perhaps through no fault of its own) is causing
unwanted side effects.

[*] IP addresses are "slowly getting bigger", but you can handle that too if
you have motivation or need.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Ian Bartholomew-19
Bill/Udo,

> Take a look at Ian's site, especially his D3 and D4 goodies.  I get
> the impression that he has dropped support for some things (though he
> might have moved them and I simply haven't rediscovered them).

Thanks Bill, I'd completely forgotten I had that as a goodie - just lost
too many brain cells I suppose :-(.  As you surmise I had dropped that
one and it doesn't appear in the D5 goodies.

FWIW, I updated the IPAddress wrapper for D5 and I get exactly the same
as Udo with the Dolphin environment reverting to a default font.    I've
no idea why.....

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Ian Bartholomew-19
I wrote:

> I've no idea why.....

but I discovered that if you specify a Font

ip := IPAddress show.
ip view font:(Font name: 'Arial' pointSize: 10)

(in my case) then that seems to prevent the default font reasserting
itself <shrug>

Udo, let me know if you want a copy of the D5 version of IPAddress.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Bill Schwab-2
Ian,

> > Take a look at Ian's site, especially his D3 and D4 goodies.  I get
> > the impression that he has dropped support for some things (though he
> > might have moved them and I simply haven't rediscovered them).
>
> Thanks Bill, I'd completely forgotten I had that as a goodie - just lost
> too many brain cells I suppose :-(.

My hunch is that they are simply engaged in more important work :)


> As you surmise I had dropped that
> one and it doesn't appear in the D5 goodies.

Just out of curiosity, why did you drop it?


> FWIW, I updated the IPAddress wrapper for D5 and I get exactly the same
> as Udo with the Dolphin environment reverting to a default font.    I've
> no idea why.....

It's either a bug in Dolphin, your wrapper (of course, you and Udo would
both have to have made the same mistake), or in the common controls.  It's
worth some experimenting just in case the flaw is in Dolphin.


> but I discovered that if you specify a Font
>
> ip := IPAddress show.
> ip view font:(Font name: 'Arial' pointSize: 10)
>
> (in my case) then that seems to prevent the default font reasserting
> itself <shrug>

That's interesting, but the fact that it is ok to set the font after #show
is _really_ spooky.  One thought: are you certain that the choice of font
(Arial 10) isn't masking the problem?  If you have doubts, you might try the
same test with a really unusual font to see if Dolphin follows it.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Udo Schneider
In reply to this post by Bill Schwab-2
Bill Schwab wrote:
> Take a look at Ian's site, especially his D3 and D4 goodies.  I get the
> impression that he has dropped support for some things (though he might have
> moved them and I simply haven't rediscovered them).  In particular, look at
>
>    http://www.idb.me.uk/goodies3/commoncontrols.html
Good pointer. I found Ian mentioning this goodies in a previous post but
didn't find it on the website.


> If Ian's site doesn't solve your problems, then I would urge you to throw
> together a composite persenter and be done with it.  You need something that
> prompts the user for four numbers[*], and a little range validation.  You
> can build that yourself much faster than you can wrap an external library,
I'll think I'll go this way if I have to deal with IPv6 stuff (which
might be pretty soon).

> particularly one that (perhaps through no fault of its own) is causing
> unwanted side effects.
Regarding unwanted side effects: After digging through MSDN I
reimplemented my control as subclass of ControlView instead of TextView.
I think the IP Address view is a subclassed view of TextView and
therefore understands the TextView messages as well. However according
to MSDN it has a different protocol ......

.... this only brought me several GPFs in the message dispatch. After
debugging with an external Tracer I discovered that some notifications
sent by the control are not neither understood by Dolphin nor assigned
anywhere else and that the default message proccessing fails.

The GPF comes from within the commctrl library ......


> [*] IP addresses are "slowly getting bigger", but you can handle that too if
> you have motivation or need.
Independent of which way I'll choose I have to add some more inteligence
anyway (regarding subnetmasks, broadcast addresses.....)

Thanks for your help,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Udo Schneider
In reply to this post by Ian Bartholomew-19
Ian Bartholomew wrote:

> FWIW, I updated the IPAddress wrapper for D5 and I get exactly the same
> as Udo with the Dolphin environment reverting to a default font.    I've
> no idea why.....

Don't take it personally .... but I'm happy you get the same error. I
though I was going crazy :-)

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Udo Schneider
In reply to this post by Ian Bartholomew-19
Ian Bartholomew wrote:

> but I discovered that if you specify a Font
>
> ip := IPAddress show.
> ip view font:(Font name: 'Arial' pointSize: 10)
>
> (in my case) then that seems to prevent the default font reasserting
> itself <shrug>
I'll try this. Thanks for the hint. Do you know whether it is possible
to assign the default font without setting the font property to nil?

> Udo, let me know if you want a copy of the D5 version of IPAddress.
Yes. This would be great. This way I can compare the versions because my
  version now (implemented "right" according to MSDN) throws GPFs :-(


Thanks,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Udo Schneider
In reply to this post by Bill Schwab-2
Bill Schwab wrote:

> It's either a bug in Dolphin, your wrapper (of course, you and Udo would
> both have to have made the same mistake), or in the common controls.  It's
> worth some experimenting just in case the flaw is in Dolphin.
Out of curiosity I'll try to create the control manually (without the
View Framework) and see what happens ..... GPFs from Dolphin are making
me nervous. This normally never happens (thanks to OA at this point!).


> That's interesting, but the fact that it is ok to set the font after #show
> is _really_ spooky.  One thought: are you certain that the choice of font
> (Arial 10) isn't masking the problem?  If you have doubts, you might try the
> same test with a really unusual font to see if Dolphin follows it.
The interesting thing I discoverd is that if you use the control for the
first time and don't close it everything is fine. Only if you close the
control (or install it in a Presenter) the Fonts get screwed up. I think
that the control has some problems releasing windows resources .... but
this is far my horizont/understanding of windows controls.

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Ian Bartholomew-19
In reply to this post by Bill Schwab-2
Bill,

> Just out of curiosity, why did you drop it?

I really can't remember.  I suspect I just got lost when I split the
CommonControls package up into individual packages - IPAddress never
really did much anyway, as you mentioned earlier it's probably quicker
to roll your own.

> It's either a bug in Dolphin, your wrapper (of course, you and Udo
> would both have to have made the same mistake), or in the common
> controls.  It's worth some experimenting just in case the flaw is in
> Dolphin.

I don't think it is a problem with Dolphin.  I've never seen anything
like it before and the wrapper is really _just_ that, there is very
little other than api interface.

> That's interesting, but the fact that it is ok to set the font after
> #show is _really_ spooky.

The actual sequence is that you if you open a control (without the font
change) and refresh the rest of the visible views then nothing changes.
If you then close the IPAddress view and refresh the other views the
font change is visible..

>          One thought: are you certain that the
> choice of font (Arial 10) isn't masking the problem?  If you have
> doubts, you might try the same test with a really unusual font to see
> if Dolphin follows it.

I tried reducing down to 6pt and going up to 16 with no difference in
the Dolphin views.

I've included the package should anyone want to try it for themselves.
It may be that I'm doing something silly (back to the disappearing brain
cells again :-) )

==== Package start, snip here

| package |

package := Package name: 'ipaddress'.

package paxVersion: 0;

basicComment: ''.

package basicScriptAt: #postinstall put: 'CommCtrlLibrary
initializeWithInternetClasses.

CommCtrlLibrary closeDefault; default.

'.

package basicScriptAt: #preinstall put: 'CommCtrlConstants

at: ''ICC_INTERNET_CLASSES'' put: 16r800;

at: ''IPM_CLEARADDRESS'' put: 1124;

at: ''IPM_SETADDRESS'' put: 1125;

at: ''IPM_GETADDRESS'' put: 1126;

at: ''IPM_SETRANGE'' put: 1127;

at: ''IPM_SETFOCUS'' put: 1128;

at: ''IPM_ISBLANK'' put: 1129;

at: ''IPN_FIRST'' put: -860;

at: ''IPN_FIELDCHANGED'' put: -860

'.

package classNames

add: #IPAddress;

add: #NMIPADDRESS;

yourself.

package methodNames

add: 'CommCtrlLibrary class' -> #initializeWithInternetClasses;

yourself.

package binaryGlobalNames: (Set new

yourself).

package globalAliases: (Set new

yourself).

package allResourceNames: (Set new

yourself).

package setPrerequisites: (IdentitySet new

add: 'Object Arts\Dolphin\Base\Dolphin';

add: 'Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';

yourself).

package!

"Class Definitions"!

NMHDR subclass: #NMIPADDRESS

instanceVariableNames: ''

classVariableNames: ''

poolDictionaries: ''

classInstanceVariableNames: ''!

ValueConvertingControlView subclass: #IPAddress

instanceVariableNames: ''

classVariableNames: 'IpnMap'

poolDictionaries: ''

classInstanceVariableNames: ''!

"Global Aliases"!



"Loose Methods"!

!CommCtrlLibrary class methodsFor!

initializeWithInternetClasses

InitFlags := InitFlags | ICC_INTERNET_CLASSES! !

!CommCtrlLibrary class categoriesFor:
#initializeWithInternetClasses!public! !

"End of package definition"!

"Source Globals"!

"Classes"!

NMIPADDRESS guid: (GUID fromString:
'{425D0EA6-542E-11D3-998B-D5CA2C3C1D61}')!

NMIPADDRESS comment: ''!

!NMIPADDRESS categoriesForClass!Unclassified! !

!NMIPADDRESS class methodsFor!

defineFields

"Define the fields of the Win32 NMIPADDRESS structure.

NMIPADDRESS compileDefinition

"

super

defineFields;

defineField: #iField type: SDWORDField new;

defineField: #iValue type: SDWORDField new! !

!NMIPADDRESS class categoriesFor: #defineFields!initializing!public! !

IPAddress guid: (GUID fromString:
'{425D0EAA-542E-11D3-998B-D5CA2C3C1D61}')!

IPAddress comment: 'NumberPresenter addView: IPAddress asResource:
''IPAddress''.'!

!IPAddress categoriesForClass!Unclassified! !

!IPAddress methodsFor!

defaultExtent

"Private - Answer the default size of the receiver. This is used only to

set the size of a view when it is created. Thereafter preferredExtent is

used when the desired size of a view is requested."

^##(160@25)!

displayValue

"Answer the displayable contents of the receiver"

^self ipmGetAddress!

displayValue: anInteger

"Set the displayable contents of the receiver"

self ipmSetAddress: anInteger!

initialize

"Initialize the receiver"

super initialize.

self setModel: 0 asValue!

ipmClearAddress

"Clear all the fields"

self sendMessage: IPM_CLEARADDRESS!

ipmGetAddress

"Answer the full address from the control"

| addr |

addr := DWORD new.

self sendMessage: IPM_GETADDRESS wParam: 0 lpParam: addr.

^addr asInteger!

ipmIsBlank

"Answers true if all the fields are blank"

^(self sendMessage: IPM_ISBLANK) ~= 0!

ipmSetAddress: anInteger

"Set the full address from the control"

self sendMessage: IPM_SETADDRESS wParam: 0 lParam: anInteger!

ipmSetFocus: anInteger

"Sets focus ob the zero based fields anInteger OR the first non blank
field

if anInteger > the number of fields OR the first field"

^self sendMessage: IPM_SETFOCUS wParam: anInteger!

ipmSetRange: aFieldInteger to: anIntegerInterval

"Sets the range for zero based field number"

^self

sendMessage: IPM_SETRANGE

wParam: aFieldInteger

lParam: ((anIntegerInterval stop bitAnd: 16rFF) bitShift: 4) bitOr:
(anIntegerInterval start bitAnd: 16rFF)!

ipnFieldChanged: pNMHDR

"Default handler for the IPN_FIELDCHANGED notification message.

An NMIPADDRESSis available from the header to inspect the proposed
change.

Any changes made here to the NMIPADDRESS structure will be passed back"

| nmIPAddress |

nmIPAddress := NMIPADDRESS fromAddress: pNMHDR.

self trigger: #valueChanged: with: nmIPAddress!

nmNotify: pNMHDR

"Private - Handler for a redirected IPAddress WM_NOTIFY message.

Implementation Note: Rather than create the appropriate header structure

object here, we delay that until the handler, because most of the time

we don't need to look at the notification at all."

| action |

action := IpnMap at: (pNMHDR sdwordAtOffset: 8) ifAbsent: [^super
nmNotify: pNMHDR].

^self perform: action with: pNMHDR! !

!IPAddress categoriesFor: #defaultExtent!constants!private! !

!IPAddress categoriesFor: #displayValue!private!updating! !

!IPAddress categoriesFor: #displayValue:!private!updating! !

!IPAddress categoriesFor: #initialize!initializing!private! !

!IPAddress categoriesFor: #ipmClearAddress!accessing!private! !

!IPAddress categoriesFor: #ipmGetAddress!accessing!private! !

!IPAddress categoriesFor: #ipmIsBlank!accessing!private! !

!IPAddress categoriesFor: #ipmSetAddress:!accessing!private! !

!IPAddress categoriesFor: #ipmSetFocus:!accessing!private! !

!IPAddress categoriesFor: #ipmSetRange:to:!accessing!private! !

!IPAddress categoriesFor: #ipnFieldChanged:!event handling!private! !

!IPAddress categoriesFor: #nmNotify:!event handling-win32!private! !

!IPAddress class methodsFor!

initialize

"Private - Initialise the map of IPAddress notification codes to
selector/parameter-class pairs.

IPAddress initialize

"

IpnMap := (LookupTable new)

at: IPN_FIELDCHANGED put: #ipnFieldChanged:;

shrink;

yourself!

winClassName

"Answer the name of the Windows window class to use when realizing the
receiver."

^'SysIPAddress32'

! !

!IPAddress class categoriesFor: #initialize!initializing!private! !

!IPAddress class categoriesFor: #winClassName!constants!private! !

"Binary Globals"!

"Resources"!


==== Package end, snip here

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Internet Address Control?

Blair McGlashan
In reply to this post by Udo Schneider
"Udo Schneider" <[hidden email]> wrote in message
news:[hidden email]...
> Bill Schwab wrote:
>
> > It's either a bug in Dolphin, your wrapper (of course, you and Udo would
> > both have to have made the same mistake), or in the common controls.
It's
> > worth some experimenting just in case the flaw is in Dolphin.
> Out of curiosity I'll try to create the control manually (without the
> View Framework) and see what happens ..... GPFs from Dolphin are making
> me nervous. This normally never happens (thanks to OA at this point!).
>
>
> > That's interesting, but the fact that it is ok to set the font after
#show
> > is _really_ spooky.  One thought: are you certain that the choice of
font
> > (Arial 10) isn't masking the problem?  If you have doubts, you might try
the
> > same test with a really unusual font to see if Dolphin follows it.
> The interesting thing I discoverd is that if you use the control for the
> first time and don't close it everything is fine. Only if you close the
> control (or install it in a Presenter) the Fonts get screwed up. I think
> that the control has some problems releasing windows resources .... but
> this is far my horizont/understanding of windows controls.

It sounds like the control is deleting the font.  To see the same effect try
opening a class browser, and then evaluating the following in any workspace:

    View desktop font free

You should feel a sense of being transported back to Windows 3.0 :-(

You need to make sure you give it a font that it owns exclusively. This is
essentially what Ian has done in his workaround where he specifies a font.
Of course this will only last as long as the control is not recreated -
changing some styles will cause the view to be recreated, at which point the
control will delete the font. Since most controls don't delete the font they
are given, Dolphin's framework assumes they will not. In order to cater for
this it will be necessary to give the control its own copy of the font
handle. A reasonable way to do this might be to override #setFont: like
this:

    setFont: aFont
        super setFont: aFont copy

I'll leave you to test that it doesn't leak and that the font "sticks". You
may find that the control deletes the font in other circumstances too. I
haven't tested it myself.

Regards

Blair