Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Window with fixed position

Status
Not open for further replies.

maldini1010

Programmer
Jun 3, 2005
6
0
0
CA
Hello,

I would like to create a window which cannot be moved by the user. (By cliking and holding the top of the window).


CREATESTRUCT cs
Maximaze/Minimaze/Close button.
cs.lpszName = "My Window";
cs.style = WS_OVERLAPPED | WS_HSCROLL ;

Does anyone know how to do this.
Thanks
maldini
 
Hi,
In order to override the onmove function. I wrote a function afx_msg void onMove(int, int ); which basically does nothing in my class --> class CMainFrame : public CFrameWnd


Is that what you mean cause it does not seem to work.

Thanks
maldini
 
This might help? I just want my app to create a window fullscreen which it would be imposible to (move with a mouse, resize with a mouse or close with a mouse, even by double cliking on the bar where the caption of the window is written ). Baically, only the keyboard should be able to perform these actions.

I hope you can help
Thanks
 


Hi,

I have actually found a solution, Not a so nice one, but a it works, What I did is i removed the caption bar at the top. Therefore through a mouse no action can be takin on the window. I used the following.


DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
dwStyle &= ~( WS_CAPTION );
SetWindowLong(hWnd , GWL_STYLE, dwStyle );

hWndMain->ShowWindow(SW_SHOWMAXIMIZED);

It works fine, however NO CAPTION :(

Later
maldini
 
To keep the title bar for the window, override WM_SYSCOMMAND in MFC and change it like this:

Code:
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
	// TODO: Add your message handler code here and/or call default

	if((nID & 0xFFF0) == SC_MOVE)
	{
		//Prevent any moving of window
		return;
	}

	if((nID & 0xFFF0) == SC_MINIMIZE)
	{
		//Prevent minimizing
		return;
	}

	if((nID & 0xFFF0) == SC_MAXIMIZE)
	{
		//Prevent maximizing
		return;
	}

	if((nID & 0xFFF0) == SC_SIZE)
	{
		//Prevent sizing
		return;
	}

	if((nID & 0xFFF0) == SC_CLOSE)
	{
		//Prevent closing
		return;
	}

	//For other nID values see WM_SYSCOMMAND

	CFrameWnd::OnSysCommand(nID, lParam);
}
Remove those "if" blocks that you won't need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top