Someone know?
How to connect two forms - I want to connect one to second - because then it possible the moving a first Form together with a second Form. Similarly like in the Swedish Gimp
I have something like this
in Module
Code:
Option Explicit
Public NewWidth As Long
Public Sub CentreForm(F As Form)
NewWidth = FrmMAIN.Width + Form2.Width
F.Move (Screen.Width - NewWidth) \ 2, (Screen.Height - F.Height) \ 2
End Sub
Public Sub ReturnCentreForm(F As Form)
F.Move (Screen.Width - F.Width) \ 2, (Screen.Height - F.Height) \ 2
End Sub
In FormMAIN for Picture1 and Picture4 (arrows)
Code:
Private Sub Picture1_Click()
Form2.Hide
ReturnCentreForm FrmMAIN
Picture3.Visible = True
Picture2.Visible = False
End Sub
Private Sub Picture4_Click()
CentreForm FrmMAIN
Form2.Show
Picture2.Visible = True
Picture3.Visible = False
End Sub
For Form2
Code:
Private Sub Form_Load()
CentreForm FrmMAIN
Form2.Left = FrmMAIN.Left + FrmMAIN.Width
Form2.Top = FrmMAIN.Top
Form2.Height = FrmMAIN.Height
End Sub
Private Sub Form_Unload(Cancel As Integer)
ReturnCentreForm FrmMAIN
With FrmMAIN
.Picture3.Visible = True
.Picture2.Visible = False
End With
End Sub
The problem is that in VB6 form object doesn't respond to move event (it only has built-in Move method) so it needs to be subclassed.
Take a look at the attachments.
If you are making something like Winamp-style attached form, then I may have an easy solution for you. If your forms will ALWAYS move together when the 2nd one is shown, you can get by with only one form.
Make the first form as big as the two would have been together, add the controls to it, and resize the form back to its original size.
to "show the 2nd form", have a command button resize the form again and the 2nd group of controls will become visible again.
Timer isn't best solution by far. One of the problems that you may experience is the flickering effect.
Subclassing WM_MOVING message is best way all arround - see attached sample project (it's in my previous post).
Rhino is correct. But it is always dangerous to subclass in the IDE. Be sure to save each and every time before you run your project. One wrong code line will crash vb.
As for flickering, Perhaps it would if you were refreshing the form display, like in the example given. For just moving, it doesn't do it.
Depends on how much code is in the timer event. For window updating alone i would say no. Just don't go nuts with timers. If you have a bunch of stuff that needs to run in the background put it all in the same timer.
...But it is always dangerous to subclass in the IDE...
Why is it dangerous? Hit the SAVE button before you run it or set that ("save before run") in your options.
Subclassing is often the only option to overcome language limitation(s).
I think it is like a version history of your code changes ala the way msword tracks document changes. I have never understood it though. I have no idea how to get code back out of it if i put it in there. And i don't know how to put code in it after i say "no" the first time.
it is always dangerous to subclass in the IDE. Be sure to save each and every time before you run your project. One wrong code line will crash vb.
In Form_Load, debug.print a divide by 0. Trap the error (Error 11) and set a public variable to true. If the variable is true, don't subclass, and don't unhook the subclassing. That way, in the IDE there's no subclassing unless you're aware that you're commenting out that debug print, but in the compiled code you get subclassing.
Code:
Private Sub Form_Load()
bDebug is false at this point
On Error GoTo Error_Handler
Debug.Print 1 / 0 'if this executes, we'll throw an error 11, so bDebug will be true
If Not bDebug Then 'then we're not in the IDE or we commented out the above error
'set up subclassing for scrolling the grid with the mousewheel
'(set up whatever subclassing you need here)
OldProcGrid = GetWindowLong(Me.hWnd, GWL_WNDPROC)
SetWindowLong Me.hWnd, GWL_WNDPROC, AddressOf TWndProcMouseWheel
End If
'The rest of your code here
On Error GoTo 0
Exit Sub
Error_Handler:
If Err.Number = 11 Then
bDebug = True 'bDebug is declared Public in a module
Resume Next
End If
'The rest of your error handler here
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not bDebug Then
SetWindowLong Me.hWnd, GWL_WNDPROC, OldProcGrid
End If
End Sub
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
In Form_Load, debug.print a divide by 0. Trap the error (Error 11) and set a public variable to true. If the variable is true, don't subclass, and don't unhook the subclassing. That way, in the IDE there's no subclassing unless you're aware that you're commenting out that debug print, but in the compiled code you get subclassing...
How in world are you going to test your app? Compile and run?
How about checking whether or not you're passing correct values right when it actually happend?
I'm afraid I cannot accept that as a reasonable solution.
i agree wholeheartedly rhinobull. It is however a neat way to test if you are in the development environment. I would use getmodulefilename (perhaps) but of course if for some inane reason someone were to take it in their head to name all their applications vb6.exe then trial version .ocx would work. Hmm.