Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Alex Gibbs

@Alex Gibbs
About
Posts
4
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Sub-Forums
    A Alex Gibbs

    Some of the forums are too large, especially the Visual C++ forum. There are so many posts per day that new posts are lost very fast, which makes getting answers unlikely. There are many good categories set up for articles and it would be great to have similar sub-forums. This would also make it easier to find more relevant posts. Alex Gibbs

    Site Bugs / Suggestions c++

  • Change style of window owned by another app in 98? Works in XP.
    A Alex Gibbs

    Here is an update. I can modify another window's style under XP using any of the calls below, if the priveleges are set as mentioned in the first post: SetWindowLongPtr (hWnd, GWL_STYLE, dwStyle); CWnd::ModifyStyle (hWnd, dwRemove, dwAdd, 0); pCWnd->ModifyStyle (dwRemove, dwAdd); However, none of them change the visible appearance of a window under 98. Remember I am trying to change the window of another process. I think the problem is one of priveleges/permissions in 98. I found something else that might be relevant at MSDN, but I don't think it is the problem. MSDN Article, 5th paragraph: "Windows 95/98/Me automatically adds and removes the WS_EX_WINDOWEDGE style for windows in all applications. ..." Anyone able to help with priveleges/permissions in 98? Alex Gibbs

    C / C++ / MFC help question

  • Change style of window owned by another app in 98? Works in XP.
    A Alex Gibbs

    I too saw that only the one you mentioned is documented. I found the other when Dev Studio showed two forms to choose from when I was typing it in. Going to the declaration takes you to afxwin.h in the CWnd declaration: static BOOL PASCAL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd, UINT nFlags); which of course also has: BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0); I tried both forms under 98 and neither worked. Both now work in XP though. At least it was another thing to try. :) Alex Gibbs

    C / C++ / MFC help question

  • Change style of window owned by another app in 98? Works in XP.
    A Alex Gibbs

    I need to modify the style of a window owned by another application under Windows 98/ME and XP/2000. I can get it to work under XP, but not 98. Windows XP In XP (and hopefully 2000) the following code works:

    DWORD dwStyle, dwError;

    // Get and modify a window's style.
    if (dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE))
    {
    dwStyle &= ~(WS_TILEDWINDOW | WS_CHILD | WS_POPUP);
    dwStyle |= WS_BORDER | WS_OVERLAPPED;
    SetLastError (0);
    if (0 == SetWindowLongPtr (hWnd, GWL_STYLE, dwStyle) && 0 != (dwError = GetLastError ()))
    {
    CString csMess;

    csMess.Format ("SetWindowLongPtr Failed: %lX", dwError);
    AfxMessageBox (csMess, MB\_ICONSTOP);
    

    }
    }

    To make this work in XP I first have to set some privileges as below:

    bool CTools::SetPrivileges ()
    {
    bool bRet = false;
    HANDLE hToken;

    if (OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES, &hToken))
    {
    TOKEN_PRIVILEGES tPriv;

    tPriv.PrivilegeCount = 1;
    if (LookupPrivilegeValue ("", SE\_DEBUG\_NAME, &tPriv.Privileges\[0\].Luid))
    {
      tPriv.Privileges\[0\].Attributes = SE\_PRIVILEGE\_ENABLED;
      if (AdjustTokenPrivileges (hToken, FALSE, &tPriv, NULL, NULL, NULL) &&
          GetLastError() == ERROR\_SUCCESS)
        bRet = true;
    }
    CloseHandle (hToken);
    

    }
    return bRet;
    }

    Windows 98 Under Windows 98 these don't work. SetWindowLongPtr returns 0 (usually non-zero when it works) but GetLastError returns 0 too. More importantly, the style doesn't change. GetWindowLongPtr does work though. There may be a permissions problem in 98 like there was in XP but SetPrivileges is not relevant to 98. Documentation does say: "Windows 95/98/Me: The SetWindowLong function may fail if the window specified by the hWnd parameter does not belong to the same process as the calling thread." I also tried this, without success in 98 or XP (even with priveleges set):

    CWnd::ModifyStyle (hWnd, WS_TILEDWINDOW | WS_CHILD | WS_POPUP, WS_BORDER | WS_OVERLAPPED, 0);

    In XP it indicates failure with it's return value. In 98 it pretends to work but the style doesn't change. Does anyone know another way to change a windows style? I don't know what to do to set the style of a window my application doesn't own under Win 98. Any ideas? Thanks in advance! Alex Gibbs

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups