Home Log In or Register Forums

VB6 query

Home > Forums > It And Computing > 'VB6 query'
'VB6 query'
Page: [1] [2] [3]
deathjester's user image
deathjester
16.07.2003 - 13:29
forum administrator
ugly, UGLY language, but very rapid i suppose.

we got a zillion projects that have been written in it, and so i am forced to deal with it from time to time.

the latest problem is rather odd- i can't figure out when the [hidden] event handler crap code goes off relative to my code that i contain within the *_Click()

depending on the code, it seems to go either way...

?!?!!?

thought id ask for your experience on this, esp as the MSDN says nothing (which raises alarm bells in itself- cos stuff that aint documented by microsoft is usually in for significant & regular change :/ )

forwards compatibility with documentation for programming languages? erm.... be nice if they paired the buzz words up with the correct contexts really wouldnt it.

(vb7 is actually rather nice btw. C# gives me orgasms though, and im trying to steer the boss in that direction. u?)
nelson's user image
nelson
16.07.2003 - 18:29
forum administrator
I'm not sure exactly what you mean... want to post the code here (you can use the [ CODE ] tags to make it readable)...
richard's user image
richard
17.07.2003 - 07:51
forum administrator
First instinct: need more information, what hidden event handler?

Second: use breakpoints / msgbox's!

Send some code snippets
deathjester's user image
deathjester
17.07.2003 - 11:14
forum administrator
at work now will do. gimme till lunch u vultures.
nelson's user image
nelson
17.07.2003 - 12:11
forum administrator
hurry up!
deathjester's user image
deathjester
18.07.2003 - 11:34
forum administrator
Right. This is contrived so bear with me.

Imagine a situation where u have a textbox that exists to accept an argument from the user.

However, this textbox is to be greyed out if a tickbox isnt checked.

eg. its a cfg form for an FTP connection which takes the following arguments


IP: (textbox)
Directory: (textbox)
Username: (textbox)
Password: (textbox)
Proxy: (TICKBOX) <- uiFtpUseProxy
Proxy IP: (textbox) <- uiFtpProxyIp



Lets say i want the last textbox to be greyed out if the tickbox gets checked.
Easy peasy.



Private Sub uiFtpUseProxy_Click()
If uiFtpUseProxy = False Then
uiFtpProxyIp.Locked = True
Else
uiFtpProxyIp.Locked = False
End If
End Sub



uiFtpUseProxy_Click() is the block that vb6 will move to when the control uiFtpUseProxy is clicked on.

The problem is that the tickbox control itself will be registering its interest in a click event so that it can change its value appropriately.

In a decent language like Java/C#/vb7 the event handler code is actually visible, but vb6 doesnt let it grace you with its prescence.

This raises the question of WHEN the tickbox contol (which registers interest with the _click event inherited by the form) gets ITS code crunched (to render the tick state, set its .Value value to true/false etc).becasue without actually seeing the stuff, I can never really know if my "If uiFtpUseProxy = False Then" test...
deathjester's user image
deathjester
18.07.2003 - 11:39
forum administrator
...will test the value before or after the .Value of the tickbox changes based on the _Click().

Now, u can play with it to experiment and find out. The wierd thing is that the results aren't consistant!

!!?!?!?!?!?

My colleagues reckon

1) its an event list problem
2) it aint documented 'when' and so MS prolyl want liscense to change it at will or its its very badly done
3)event handling done properly in vb6? PFFFT
4)ditto
5) go make a coffee pls Andy.



bastards.
richard's user image
richard
18.07.2003 - 12:57
forum administrator
I haven't got a bleedin' clue what you're talking about, but I would try changing the code to this as it's a bit more robust:


Private Sub uiFtpUseProxy_Click()
uiFtpProxyIp.Locked = Not uiFtpUseProxy.Value
End Sub


Give it a try and let me know how you get on.
nelson's user image
nelson
18.07.2003 - 15:03
forum administrator
Ok, I read what you wrote 4 times until it dawned on me what is the problem.

I have a kind of workaround but I'm not sure if it will work...

Firstly though, for reference, here is the sequence of events on the order they are executed, with the ones that might interest you highlighted:

1) onmouseover (entering new element but not actually getting focus)

2) onmousedown (Left/Right mouse button depressed)

3) onblur(on previous control!) (loose focus of the last element that had focus)

4) onfocus (gain focus of the current element positioned over)

5) onmouseup

6) onclick (finally!)


Ok, try this workaround...

On the OnClick event of uiFtpUseProxy, add this:


uiFtpProxyIp.Locked = Not uiFtpProxyIp.Locked

if uiFtpProxyIp.Locked then
    uiFtpUseProxy.Value = 0
else
    uiFtpUseProxy.Value = 1

You might want to know that the value of a checkbox is not true/false, but a 0, 1, or 2 - see the reference...

If this still doesn't work, try moving the code into the OnMouseUp event instead...

Hope it works...
richard's user image
richard
18.07.2003 - 15:17
forum administrator
I think you're being overcomplicated.

Do this:


Private Sub uiFtpUseProxy_Click()
uiFtpProxyIp.Enabled = uiFtpUseProxy.Value
End Sub


This works fine, plus you can see that the control has been disabled. (Don't forget to set the checkbox value to ticked and the textbox to enabled by default [or vice versa]).
Page: [1] [2] [3]

You must log in to post messages on this board. If you don't have a username and password, you can register quickly to get them!

contact us © 2003, 2004 BurningHorizons.net