Solved

Move a Window Without A Titlebar

Posted on 1997-08-30
18
457 Views
Last Modified: 2013-11-20
MSVC 1
How do I move a window without a title bar?
0
Comment
Question by:Adrian031197
  • 9
  • 6
  • 3
18 Comments
 
LVL 4

Accepted Solution

by:
mbhakta earned 30 total points
ID: 1305289
By default implementation of Windows API's moving a window without the title bar  is not possible. But there is a way of doing this. Firstly, you need to override the WM_NCPAINT or OnNCPaint() windows message. When the user clicks and drags determine the POINT location of the window and if the point position lies on the valid client area of the window ( and not on the border ) perform a MoveWindow().

This is a more professional approach and needs some bit of brain storming and smart coding. You might be able to find some information in the MSDN. If u are new to Visual C++/Windows programming I would suggest spending some time reading some Win32 SDK documentation and if you are in a real hurry , then rely on some freeware OCX /VBX tool available on the net.
0
 

Author Comment

by:Adrian031197
ID: 1305290
Well, I had that basic idea, but how do I convert where the mouse click is to a screen coord? I know how how to do the rest of it.

And I'm having another difficulty with this topic as well. Even though I turn off the title bar in the App Studio, I still get one!
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1305291
To convert mouse clicks to screen co-ordinates you have reliable API's like ClientToScreen(), GetCursorPos() etc.

If u want to remove the title bar of the application window. You can either disable it in the PreCreateWindow() method. Or also , run SetWindowLong() to disable the title bar. Surprisingly, App Wiz is not that exhaustive to disable the Window styles properly.



0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 4

Expert Comment

by:mbhakta
ID: 1305292
To convert mouse clicks to screen co-ordinates you have reliable API's like ClientToScreen(), GetCursorPos() etc.

If u want to remove the title bar of the application window. You can either disable it in the PreCreateWindow() method. Or also , run SetWindowLong() to disable the title bar. Surprisingly, App Wiz is not that exhaustive to disable the Window styles properly.



0
 

Author Comment

by:Adrian031197
ID: 1305293
I'm using a dialog as my main window. In the InitInstance() function I deleted the command to create a new window and inserted my dialog command.
In the App Studio, I unchecked title bar. When I test the dialog, there is no bar, but when I run the program, there is a bar, and everything is pushed down, some of it off the window. Very annoying.
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305294
First, you can move a window with no caption. You just have to write a handler for the WM_NCHITTEST message and reply HTCAPTION

For your dialog problem, how do you use a dialog as your main window ? Are you using a CFormView ? If you are just calling DoModal() in your InitInstance(), your dialog should be displayed  with no caption. Otherwise, the dialog is wrapped by a frame.
A frame with a caption...



0
 

Author Comment

by:Adrian031197
ID: 1305295
I use a CDialog as my main view.
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305296
You should create a new project and choose a dialog based one.
Unselect the "titlebar" style for the dialog and write a handler for WM_NCHITTEST :

UINT CDlgnotitleDlg::OnNcHitTest(CPoint point)
{
   return(HTCAPTION);
}

I have done it myself and it is working fine.
If you want it, send me a mail at nasarre@col.bsf.alcatel.fr and I'll send it to you

0
 

Author Comment

by:Adrian031197
ID: 1305297
There isn't such a thing as a dialog based program in MSVC 1. I have to do it myself, but when I compare what I've done to what the App Wizard does in future versions, it's the same.
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305298
So, implement your dialog class

Unselect the "
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305299
So, implement your dialog class

Unselect the "
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305300
Sorry but my comment seems to be always truncated :-(


So, implement your dialog class

Unselect t
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305301
Sorry but my comment seems to be always truncated :-((((

So, implement your dialog class, unselect the titlebar style for the
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305302
Arrrggg !!!!!!!

Impossible to answer :-(

(1) no titlebar style for the dialog
(2) handler for WM_NCHITTEST and return HTCAPTION
(3) change your InitInstance() : DoModal() and return FALSE


0
 

Author Comment

by:Adrian031197
ID: 1305303
I HAVE done 1 & 3. And I guess 2 is for moving it without a bar.
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305304
Right.
You have to add a handler for WM_NCHITTEST

BEGIN_MESSAGE_MAP(CDlgnotitleDlg, CDialog)
//{{AFX_MSG_MAP(CDlgnotitleDlg)
   ON_WM_NCHITTEST()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

with this implementation

UINT CDlgnotitleDlg::OnNcHitTest(CPoint point)
{
//      return CDialog::OnNcHitTest(point);
   return(HTCAPTION);
}

0
 

Author Comment

by:Adrian031197
ID: 1305305
Ok, but why do I still have a title bar?
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1305306
Take a look at your RC file and check that the dialog definition is done without WS_CAPTION style. Here is my own :

IDD_DLGNOTITLE_DIALOG DIALOGEX 0, 0, 185, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,128,7,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,128,23,50,14
    LTEXT           "TODO: Place dialog controls here.",IDC_STATIC,5,34,113,
                    8
END

0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference between String.subString() and String.subSequence() 6 196
no14 challenge 14 66
scoreUp challenge 14 62
Way to decrease size of apk file 9 67
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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