Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7669029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:30:14+00:00 2026-05-31T15:30:14+00:00

I attampted to draw a irregular window with the UpdateLayeredWindow(), in msvc2008, xp sp3.

  • 0

I attampted to draw a irregular window with the UpdateLayeredWindow(), in msvc2008, xp sp3.
Here is part of my code:

//Add something(CreateWindowEx()):
hwndCyauWnd = CreateWindowEx(
    /*WS_EX_TOOLWINDOW |*/ WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_LAYERED,
    lpwsCyauClassName,
    lpwsCyauWndName,
    WS_CLIPSIBLINGS | WS_POPUP,
    GetSystemMetrics(SM_CXSCREEN)-320,
    GetSystemMetrics(SM_CYSCREEN)-232,
    320, 200,
    NULL,
    NULL,
    hInstance,
    NULL);

//Skip Lines
HDC hdcCyauWnd = GetDC(hwndCyauWnd);
HDC hdcBuffer = CreateCompatibleDC(hdcCyauWnd);
//HBITMAP hbmCyau = CreateCompatibleBitmap(hdcBuffer,120, 93);
//SelectObject(hdcBuffer, hbmCyau);

POINT ptZero = {0, 0};
POINT ptDrawPos = {0, 0};
RECT rctCyauWnd;
GetWindowRect(hwndCyauWnd, &rctCyauWnd);
SIZE szCyauWnd={rctCyauWnd.right - rctCyauWnd.left, rctCyauWnd.bottom - rctCyauWnd.top};
BLENDFUNCTION blendPixelFunction = { AC_SRC_OVER, 0, 100, AC_SRC_ALPHA};

Graphics gphCyauWnd(hdcBuffer);
Image imgCyau(L"surface0000.png");
gphCyauWnd.DrawImage(&imgCyau, 0, 0, 125, 93);

UpdateLayeredWindow(hwndCyauWnd,
    hdcCyauWnd, &ptZero,
    &szCyauWnd,
    hdcBuffer, &ptZero,
    0, //RGB(255, 255, 255),
    &blendPixelFunction,
    ULW_ALPHA);

while (GetMessage(&msg, NULL, 0, 0))    
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
return msg.wParam;

I have tried several method to use this function, but all failed, NOTHING APPEAR on the screen.
Could anybody tell me what happens and how to slove it?

Add:
Whole source file have been upload to my skydrive, anyone can edit, much appreciation! (I have become a poor underdog now…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:30:16+00:00Added an answer on May 31, 2026 at 3:30 pm

    You mixed up GDI and GDI+, which is not a good idea. Here is a working example:

    hWnd = CreateWindowEx(WS_EX_LAYERED, szWindowClass, szTitle, 0,
         CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
    
    // Load PNG
    CImage img;
    img.Load("BACKGR.png");
    // Get image sizes
    int nWidth = img.GetWidth();
    int nHeight = img.GetHeight();
    // Create memory DC
    HDC hdcScreen = GetDC(NULL);
    HDC hDC = CreateCompatibleDC(hdcScreen);
    // Create memory bitmap
    HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, nWidth, nHeight);
    HBITMAP hBmpOld = (HBITMAP)SelectObject(hDC, hBmp);
    // Draw image to memory bitmap (currently selected in memory DC)
    img.Draw(hDC, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight);
    
    // Call UpdateLayeredWindow
    BLENDFUNCTION blend = {0};
    blend.BlendOp = AC_SRC_OVER;
    blend.SourceConstantAlpha = 128;// half transparent
    blend.AlphaFormat = AC_SRC_ALPHA;
    POINT ptLocation = {0, 0};
    SIZE szWnd = {nWidth, nHeight};
    POINT ptSrc = {0, 0};
    UpdateLayeredWindow(hWnd, hdcScreen, &ptLocation, &szWnd, hDC, &ptSrc, 0, &blend, ULW_ALPHA);
    ShowWindow(hWnd, SW_SHOW);
    
    SelectObject(hDC, hBmpOld);
    DeleteObject(hBmp);
    DeleteDC(hDC);
    ReleaseDC(NULL, hdcScreen);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I attampted to write a Message Map following a sample in a book. Here
I attempted to write the following code to draw a cylinder. The cylinder was
I attempted to answer this question (answer deleted, so here is my code). <?php
I've attempted to add the TopSongs parser and Core Data files into my application,
Based on the graphael documentation I am supposed to draw charts like this: var
I attempted to display adds using code below. I got the error AdView missing
I attempted to add a ADO.NET Entity Data Model to my Visual Web Developer
I'm running into a problem with the following Python 3.2.2 code. The code is
I'm trying to draw a couple of UIImage s in a UIView , and
i attempted to port the code in this answer to Java: PHP VIN number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.