I'm trying to make sure I get the handle to the Notepad window before 
attempting alterations by using:

hNotepad = FindWindow("Notepad",NULL);

but it's returning NULL and I'm not sure why. Any ideas?



--- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
> remarknibor wrote:
> > 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);
> 
> Actually, now that I think about it, your original assumption of 
using 
> GetSystemMenu() and EnableMenuItem() was probably correct.  
Disabling 
> the SC_CLOSE menu item has the side-effect of disabling the close 
button.
> 
> HMENU MyMenu = GetSystemMenu(SomeHwnd, FALSE);
> EnableMenuItem(MyMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED | 
MF_DISABLED);
> 
> 
> GetForegroundWindow() does not always return the window handle you 
> expect and may even return NULL.  Always check to make sure you 
have the 
> right window handle by matching it with its process ID.
> 
> NOTE:  Fiddling with other processes in this manner may not be 
allowed. 
>   A simpler approach might be to simply restart Notepad if it is 
closed 
> (i.e. the process handle becomes 'signaled') before the time is up.
> 
> -- 
> 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