Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Original window shape

Hello!

Does anyone Know how to make a window which doesn't look like a rectangle?
Indeed I want to make a window which has an original shape such as window media player 9 has.

Thanks

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Hello!
    :
    : Does anyone Know how to make a window which doesn't look like a rectangle?
    : Indeed I want to make a window which has an original shape such as window media player 9 has.
    :
    : Thanks
    :
    [blue]Try that:
    1. When registering a window class, specify NULL for background brush inside WNDCLASS structure.

    2. Respond to WM_ERASEBKGND message and return 1.

    3. When creating a window by CreateWindow() - specify only styles: WS_POPUP | WS_VISIBLE. No borders, titles or min/max buttons. Try these two first.

    4. In WM_PAINT handler draw all your custom window stuff, including for example ellipsoid borders or whatever you need.

    One thing: since the window will not have a caption - how to move it? You should implement mouse clicks and moves yourself to provide that functionality.[/blue]
  • dev48dev48 Posts: 7Member
    Thanks a lot.

    Another thing.

    Do you thing it works with qt???
  • pingpongpingpong Posts: 937Member
    : [blue]Try that:
    : One thing: since the window will not have a caption - how to move it? You should implement mouse clicks and moves yourself to provide that functionality.[/blue]
    :

    You can always trick Windows to move it like this:
    [code]
    // in your window proc
    switch(message)
    case WM_NCHITTEST:
    // get Windows to do its hittest first
    longVal = DefWindowProc(hWnd, message, wParam, lParam);
    // if the mouse is on client area, trick Windows to think its on the caption
    if(longVal == HTCLIENT)
    longVal = HTCAPTION;
    return longVal;
    [/code]
    If you put the code above in any window, clicking on the client area and dragging will move the while window around (like Winamp and WMP).
    In real world app, you probably need to check if the cursor location is not on any of your buttons and other controls first otherwise nothing will work.
  • bikibiki Posts: 492Member
    [green]
    Try using CreateEllipticRgn() and its cousins
    [/green]
    [hr][red]~Bikram[/red]

Sign In or Register to comment.