Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

API for Window creation

Posted on 1999-07-08
8
Medium Priority
?
407 Views
Last Modified: 2008-01-16
Can anyone tell me the correct way to display a MODAL window using the API SetWindowPos, or possibly another API call?
0
Comment
Question by:NickHeitz3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Accepted Solution

by:
stewfidgeon earned 360 total points
ID: 1522788
If you are using a 32 bit version of VB, you cant. It doesnt allow for system modal windows. If you are using VB4 16bit version then it is done like this:

private declare function setsysmodalwindow lib "user" (ByVal hwnd as Integer) as integer

private sub form1_load()
result = Setsysmodalwindow (form1.hwnd)
end sub

It sets form1 to the topmost window, and keeps it there until you close the form. No other applications or forms can be used until you close the modal form.

If you need to display a form to simulate a system modal window, you can work on the lostfocus event, and use that to set focus back to your form.

If you need code examples, just add a comment saying so, and I'll write some for you.

Hope this answers your question.

0
 
LVL 1

Expert Comment

by:alex1234
ID: 1522789
stewfidgeon,

doesn't NickHeitz3 want to fiaplay a modal form similar to what in WIN32 API called "Modal Dialog Box"? I think he does. And wouldn't it be simplier to do something like this:

Dim frmMyForm As New Form2

frmMyForm.Show 1



0
 
LVL 1

Expert Comment

by:stewfidgeon
ID: 1522790
Hmm, it is enterily possible that I have got the wrong end of a whole bunch of sticks. Oooops.....


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 3

Expert Comment

by:HATCHET
ID: 1522791
NickHeitz3,

The only reason you should be using the Windows API to do this is if you want to manipulate external windows/programs.  Otherwise, use the code given above to do it :

Form1.Show vbModal

I believe that stewfidgeon was right when he said that you can NOT display a form SystemModally.  Though you CAN display a dialog box SystemModally.

If you're more specific on what you want, maybe we could help more.

HATCHET
0
 

Author Comment

by:NickHeitz3
ID: 1522792
Sorry guys, I was actually trying to mimic the vbmodal aspect of vb windows using api calls.  I will be within a vb environment, but I want ot have more control ovr how the window behaves, namely, how the background is refreshed, and wanted to see if there was a way to display a form modally.  
If there still isn't a way, then I will givethe points to stewfidgeon.
0
 
LVL 3

Expert Comment

by:HATCHET
ID: 1522793
NickHeitz3,

To refresh the form, or any object on it, simply use the REFRESH property :

Form1.Refresh
Text1.Refresh
ComboBox1.Refresh

To bring up a form modally, simply Show it using "vbModal"  :

Form2.Show vbModal


HATCHET
0
 

Author Comment

by:NickHeitz3
ID: 1522794
Please, would somebody just tell me how to bring up a show a form modally using API calls.  I a man experienced programmer, I know how to refresh a form and how to use vb for modality, but my situation os more complex than that.  I am working inside an environment whose environment I only have bits of control over, nad I am looking for other option in terms of showing a form.  I acknowledge that what I want may not be possible.
0
 

Author Comment

by:NickHeitz3
ID: 1522795
Actually, it looks like your answer may be the one I want...sorry it took so long.  If you could post me some examples, I would appreciate it.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

721 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