Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Stop Window with caption bar moving

Posted on 1997-05-21
3
Medium Priority
?
177 Views
Last Modified: 2011-09-20
I am writing CBT software and want a MDI child form with a caption bar and title (no system menu, minimize or maximize) but I dont want the user to be able to move the window, is
this possible if so how do you do it?
0
Comment
Question by:mark.H
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
tward earned 210 total points
ID: 1426452
I haven't tried this but the SWP_NOMOVE sounds like it would do what you want.

Knowledge Base

How to Create a Topmost or Floating Window in Visual Basic

Article ID: Q84251
Creation Date: 06-MAY-1992
Revision Date: 08-AUG-1996

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for
  Windows, versions 2.0 and 3.0

- Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

You can create a "floating" window such as that used for the Microsoft Windows version 3.1 Clock by using the SetWindowPos Windows API call.

MORE INFORMATION

A floating (or Topmost) window is a window that remains constantly above all other windows, even when it is not active. Examples of floating windows are the Find dialog box in WRITE.EXE, and CLOCK.EXE (when Always on Top is selected from the Control menu).

For more information on this topic, please see the following article in the Microsoft Knowledge Base:

ARTICLE-ID: Q81137

TITLE     : INF: How to Create a Topmost Window

NOTE: Visual Basic forms that are TopMost Windows when they are in either Normal or Maximized positions will lose the Topmost setting when the Visual Basic program is Minimized. Visual Basic destroys the old window and creates a new one with the Icon in the Window. Therefore, in order for TopMost to stay in effect, the user needs to reset TopMost in the Resize event.

There are two methods to produce windows that "hover" or "float," one of which is possible in Visual Basic for Windows. This method is described below:

Use the following declarations:

Declare Function SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer ' The above Declare statement must appear on one line.

Global Const SWP_NOMOVE = 2 Global Const SWP_NOSIZE = 1 Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE Global Const HWND_TOPMOST = -1 Global Const HWND_NOTOPMOST = -2 'Put global constants in bas module.

To set the form XXXX to TOPMOST, use the following code:

success% = SetWindowPos (XXXX.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) REM success% <> 0 When Successful

To reset the form XXXX to NON-TOPMOST, use the following code:

success% = SetWindowPos (XXXX.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS) REM success% <> 0 When Successful

NOTE: This attribute was introduced in Windows, version 3.1, so remember to make a GetVersion() API call to determine whether the application is running under Windows, version 3.1.

REFERENCES

"Page 892 of Microsoft Windows 3.1 Programmer's Reference, Volume 2,  Functions,"
------------------------------------------------------------------------
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

©1996 Microsoft Corporation

Additional reference words: top most Win31 Float Topmost Notopmost
Setwindowpos
KBCategory: kbui kbprg kbcode
KBSubcategory: APrgWindow
0
 

Author Comment

by:mark.H
ID: 1426453
This does not work.  All it does is to stop the window moving when you are changing the window properties using the setWindowPos API call.
0
 

Author Comment

by:mark.H
ID: 1426454
This does not work.  All it does is to stop the window moving when you are changing the window properties using the setWindowPos API call.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

886 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