Moving a userform with the mouse within the word 2000 application

C

constance

Hi everybody, I noticed something weird.
Sometimes I can't move my userform in my word window when I ope
several word documents. When I call my form, ican't move it with th
mouse sometimes. Is it because I do a userfom.hide ??
Tell me if you need more information.

Thanx for any help
Constanc
 
W

Word Heretic

G'day constance <[email protected]>,

maybe its because you are using magic forms. Do you just do

UserForm1.Show

or do you do a

Dim MyForm as UserForm1
Set MyForm = New UserForm1

blah

Set MyForm = Nothing


Hi everybody, I noticed something weird.
Sometimes I can't move my userform in my word window when I open
several word documents. When I call my form, ican't move it with the
mouse sometimes. Is it because I do a userfom.hide ??
Tell me if you need more information.

Thanx for any help
Constance

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
C

constance

Hi Steve,
That is true, I use magic forms as you call them
I do UserForm1.Show
what should i do to avid that ?
do you need more info about my code ?
Thanx
Lyn
 
C

constance

Hi Steve,
That is true, I use magic forms as you call them
I do UserForm1.Show
instead of doing that :
Dim MyForm as UserForm1
Set MyForm = New UserForm1

blah

Set MyForm = Nothing

The practical thing with magical forms is that i can keep the values o
the textboxes that can be edited again in he formfiels when I do
cancel action on my buttons, if you know that I mean
If I do a new Userform, I loose my values
what should i do to avoid that ?
Hope this is clear
Thanx
Lyn
 
C

constance

Hi Steve,
That is true, I use magic forms as you call them
I do UserForm1.Show
instead of doing that :
Dim MyForm as UserForm1
Set MyForm = New UserForm1

blah

Set MyForm = Nothing

The practical thing with magical forms is that i can keep the values o
the textboxes that can be edited again in he formfields in memory whe
I do a cancel action on my buttons, if you know that I mean
If I do a new Userform, I loose my values
what should i do to avoid that ?
Hope this is clear
--------------------------------------------------------------------
It seems that I found the problem but I'm not sure
let me try to explain
I have two userforms : the first one is called by a macro and th
second one is called by a button on the first userform, hope you'r
still with me (lol). On the second form, I have a cancel button tha
recalls the first userform by a userform2.hide and a userform1.show
I had this code below to prevent the user to close the userforms by th
cross and to force him to use the buttons of my forms :

Private Declare Function _
GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function _
GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long

Private Declare Function _
DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function _
RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long

Private Declare Function _
GetActiveWindow Lib _
"user32" () As Long

Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&

and in the Activate method, I put the code below :
'Gestion de la croix
Dim hSysMenu As Long
Dim nCnt As Long
Dim lWin

lWin = GetActiveWindow()
hSysMenu = GetSystemMenu(lWin, False)
'Stop
If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
RemoveMenu hSysMenu, nCnt - 1, _
MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, _
MF_BYPOSITION Or MF_REMOVE
DrawMenuBar lWin
End If
End If


When I was clicking on the cancel button of the userform2 to recall th
userform1, I couldn't move the userform1 with the mouse
I erased from the userform1, the code I put below and it seems to work
but I'm not sure

do you have an explanation about that?

Thanx
Lyn
 
W

Word Heretic

G'day constance <[email protected]>,

1) Use the registry to hold old values to re-use them

2) The problem below reproduces the same sort of problem with magic
forms that I have already described to Jonathan West some moons ago
that was instantly dismissed as heresy. As he carries a lot of weight
in MVPville, it means my explanation has been buried.

Your problem goes away when you declare your forms properly.

If you need some hand-holding I offer an e-tutoring service and am
quite experienced in this sort of thing.


Hi Steve,
That is true, I use magic forms as you call them
I do UserForm1.Show
instead of doing that :
Dim MyForm as UserForm1
Set MyForm = New UserForm1

blah

Set MyForm = Nothing

The practical thing with magical forms is that i can keep the values of
the textboxes that can be edited again in he formfields in memory when
I do a cancel action on my buttons, if you know that I mean
If I do a new Userform, I loose my values
what should i do to avoid that ?
Hope this is clear
--------------------------------------------------------------------
It seems that I found the problem but I'm not sure
let me try to explain
I have two userforms : the first one is called by a macro and the
second one is called by a button on the first userform, hope you're
still with me (lol). On the second form, I have a cancel button that
recalls the first userform by a userform2.hide and a userform1.show
I had this code below to prevent the user to close the userforms by the
cross and to force him to use the buttons of my forms :

Private Declare Function _
GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function _
GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long

Private Declare Function _
DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function _
RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long

Private Declare Function _
GetActiveWindow Lib _
"user32" () As Long

Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&

and in the Activate method, I put the code below :
'Gestion de la croix
Dim hSysMenu As Long
Dim nCnt As Long
Dim lWin

lWin = GetActiveWindow()
hSysMenu = GetSystemMenu(lWin, False)
'Stop
If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
RemoveMenu hSysMenu, nCnt - 1, _
MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, _
MF_BYPOSITION Or MF_REMOVE
DrawMenuBar lWin
End If
End If


When I was clicking on the cancel button of the userform2 to recall the
userform1, I couldn't move the userform1 with the mouse
I erased from the userform1, the code I put below and it seems to work
but I'm not sure

do you have an explanation about that?

Thanx
Lyne

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
C

constance

Hi Steve,
thank you for your help
what you means is that there in no connection between the code I add t
disable a part of my userformq and my problem to move my userforms wit
the mouse ?
How do I use the registry to do what I need ?
I put in attachment the code of my userforms in order you to see how
use my variables.
Thanx for your help

Lyn

+----------------------------------------------------------------
| Attachment filename: mycode.txt
|Download attachment: http://www.WordForums.com.com/forums/attachment.php?postid=47905
+----------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top