I've been trying to alter the Notepad window like this:

hwnd = GetForegroundWindow();
LONG nOldStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
LONG nNewStyle = nOldStyle & ~WS_CAPTION;
SetWindowLongPtr(hwnd, GWL_STYLE, nNewStyle);
InvalidateRect(hwnd, NULL, FALSE);
//SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, 
SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DRAWFRAME);

I read somewhere about SetWindowPos() so I was playing with that too. 
But either way, I can't seem to get any effect on Notepad. Shouldn't 
I just be able to change "~WS_CAPTION" to whatever I want and get the 
desired alteration?

Thanks.


--- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
> remarknibor wrote:
> > I'm using Windows on a PC, and Visual C++ 2005.
> > I open Notepad as part of my program and I was wondering if I 
could 
> > alter its menus and things in order to limit what participants 
might 
> > (annoyingly) play around with. Ideally, I'd at the very least 
like to 
> > disable their ability to close it using the 'X' button or 'Close' 
in 
> > the menus.
> > I can get its handle using:
> > HWND hwnd = GetForegroundWindow();
> > What do I do next? Do I use things like GetSystemMenu() and 
> > EnableMenuItem()? If so how?
> > 
> > Thanks in advance.
> 
> The 'Close'/'X' button is a window style.  You have to change the 
window 
> style (the menu usually follows suit).
> 
> GetWindowLongPtr();
> (Remove the style that enables the close button).
> SetWindowLongPtr();
> 
> And then for good measure, call InvalidateRect() on the HWND.
> 
> -- 
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
> 
> *NEW* MyTaskFocus 1.1
> Get on task.  Stay on task.
> 
> http://www.CubicleSoft.com/MyTaskFocus/
>


Reply via email to