Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

SETWINDOWPOS and showing a form vbModal -CRASHING

Posted on 2006-03-31
8
Medium Priority
?
450 Views
Last Modified: 2008-03-10
Hello EE,

I have inherited a piece of software and it tends to crash intermittently but very annoyingly. On the off-chance that wsome of you would know about this, I will explain what I think might be crashing it -

Basically, is it a bad idea to call SetWindowPos before showing a form vbModal as per the following?

' ------------------------------------------------------------------------------------------------

320         Call SetWindowPos(Me.hWnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, _
                        SWP_NOMOVE Or SWP_NOSIZE Or SWP_FRAMECHANGED)
   
330         Me.Show modal:=1

' ------------------------------------------------------------------------------------------------

Cheers,

Charlie
0
Comment
Question by:butterhook
  • 5
  • 3
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16340869
what are you trying to achieve with that code?

usually, to put one of your forms in front of all the others in the same project (where MainForm is the Main project form), but allowing the focus to go to any of the forms:

330         Me.Show vbModeless, MainForm  

usually, to put one of your forms in front (of all the others in the same project)
but only allow focus to the form itself :

330         Me.Show vbModal, Parentform


you should not need the SetWindowPos at all, that is only useful to put the form in front of ALL windows of all applications, while then you don't need the Me.show vbModal at all (but only a me.visible = true, but that BEFORE The setwindowpos call...)
0
 
LVL 1

Author Comment

by:butterhook
ID: 16340920
This project is a Word Addin, so there is no 'Main project form'
0
 
LVL 1

Author Comment

by:butterhook
ID: 16340931
I am trying it with .Visible = True before the SetWindowPos
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 16340982
you don't need the setwindowpos at all then.
0
 
LVL 1

Author Comment

by:butterhook
ID: 16341092
I have taken the SETWINDOWPOS out, and shown the form Modal. Seems to work fine. Hasn't crashed yet
0
 
LVL 1

Author Comment

by:butterhook
ID: 16342873
I have found the place where my crash occurs - it's where I set the form to visible, but I need to set the focus to a richtextbox, but I can't do this in the code after I have set the form to Modal, and can't do it before. Any ideas? Thanks a lot
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16342988
>but I need to set the focus to a richtextbox,
usually, the tabindex = 0 defines the control that gets the focus when the form loads....
0
 
LVL 1

Author Comment

by:butterhook
ID: 16343047
I seem to have fixed it by doing the rtfBox.setFocus on the Form_Paint event. Here are your points - thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question