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

x
?
Solved

Move a Window Without A Titlebar

Posted on 1997-08-30
18
Medium Priority
?
474 Views
Last Modified: 2013-11-20
MSVC 1
How do I move a window without a title bar?
0
Comment
Question by:Adrian031197
[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
  • 9
  • 6
  • 3
18 Comments
 
LVL 4

Accepted Solution

by:
mbhakta earned 60 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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