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
  1. Home
  2. General Programming
  3. Graphics
  4. UpdateLayeredWindow() fails, GetLastError() == 0

UpdateLayeredWindow() fails, GetLastError() == 0

Scheduled Pinned Locked Moved Graphics
helpgraphicstestingbeta-testingquestion
2 Posts 2 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    klorin
    wrote on last edited by
    #1

    Hi. I have (in my oppinion) a VERY annoying and wierd problem. I'm using UpdateLayeredWindow() according to the code below. I do the FillRect() just for testing. But when I do this UpdateLayeredWindow() returns 0 which, according to the msdn documentation, indicates that the function failed and more info should be in GetLastError(). However, if I call GetLastError() just after UpdateLayeredWindow() it simply returns 0, indicating that there was no last error. I have remembered to set WS_EX_LAYERED... Could it be that FillRect() doesn't set any alpha information? Any ideas? Thanks. HDC dcScreen = ::GetDC(NULL); HDC dcMemory = ::CreateCompatibleDC(dcScreen); HBITMAP bmpMemory = ::CreateCompatibleBitmap(dcScreen, 500, 500); ::SelectObject(dcMemory, bmpMemory); BITMAP bitmap; GetObject(bmpMemory, sizeof(BITMAP), &bitmap); RECT rc = {0, 0, 100, 100}; ::FillRect(dcMemory, &rc, ::GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; UpdateLayeredWindow(m_hWnd, dcScreen, NULL, NULL, dcMemory, NULL, 0, &bf, ULW_ALPHA);

    J 1 Reply Last reply
    0
    • K klorin

      Hi. I have (in my oppinion) a VERY annoying and wierd problem. I'm using UpdateLayeredWindow() according to the code below. I do the FillRect() just for testing. But when I do this UpdateLayeredWindow() returns 0 which, according to the msdn documentation, indicates that the function failed and more info should be in GetLastError(). However, if I call GetLastError() just after UpdateLayeredWindow() it simply returns 0, indicating that there was no last error. I have remembered to set WS_EX_LAYERED... Could it be that FillRect() doesn't set any alpha information? Any ideas? Thanks. HDC dcScreen = ::GetDC(NULL); HDC dcMemory = ::CreateCompatibleDC(dcScreen); HBITMAP bmpMemory = ::CreateCompatibleBitmap(dcScreen, 500, 500); ::SelectObject(dcMemory, bmpMemory); BITMAP bitmap; GetObject(bmpMemory, sizeof(BITMAP), &bitmap); RECT rc = {0, 0, 100, 100}; ::FillRect(dcMemory, &rc, ::GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; UpdateLayeredWindow(m_hWnd, dcScreen, NULL, NULL, dcMemory, NULL, 0, &bf, ULW_ALPHA);

      J Offline
      J Offline
      Jeff J Anderson
      wrote on last edited by
      #2

      Since you're specifying the source DC (dcMemory), I would try passing values for arguments 3,4 & 6 (i.e., the various size and positions). Argument 6 should just be the address of a POINT with value (0,0). I use this function all the time, and that's what I do (returns non zero - and it works of course:-))

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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