Menu

Windows application question

2003-01-15
2012-09-26
  • Nobody/Anonymous

    how can I make the "window" different shapes? i.e. circle pentagon, octagon, or even my own personalized shape?

     
    • Nobody/Anonymous

      Um, thats actually a very good question. I know it is possible because I have seen this done before. I would imagine that it has something to do with creating your own window class, registering, and a somewhat complex window procedure for the WM_PAINT and the WM_INITDIALOG / WM_CREATE. I would point you to the Petzold (the official win32 programming manual), but he does not get into such matters.

      I would first try google for hints on how people go abouts implementing this. Then I would check out M$DN for the details. Good luck and let us know what you did =)

      Kip

       
    • Lee G.

      Lee G. - 2003-01-15

      You certainly can just hop to http://www.subduck.com/pages/page.php?id=18 and there is a tutorial on window transparency

       
    • Nobody/Anonymous

      You won't believe this, but it takes only about 25 lines of code. Visit www.planetcpp.com and search for "shapeform" or "formshape" (I can't remember exactly). There is a zip there somewhere that has example code for VisualC++.. import the project in dev, in the .rc file comment out all references to afxres.h and comment out the "LANGUAGE LANG_ENGLISH.." line - and you're ready to go! Get back here if you can't find it. I can mail it to you.

      -Jay

       
    • Nobody/Anonymous

      i believe it is the use of regions
      void RegionMe()
      {
       
        /* We'll create an Elliptical region.
         We use a negative starting Y coordinate to make
         the ellipse cover a bit more of the caption. */
       
        HRGN hRegion1 = CreateEllipticRgn(20,-20,190,150);
        OffsetRgn(hRegion1, GetSystemMetrics(SM_CXBORDER)*4, GetSystemMetrics(SM_CYCAPTION));

        /* We'll create one more Elliptical region in another place */
        HRGN hRegion2 = CreateEllipticRgn(140,100,300,240);
        OffsetRgn(hRegion2, GetSystemMetrics(SM_CXBORDER)*4, GetSystemMetrics(SM_CYCAPTION));

        /* We'll combine the two regions to build a new region
         that will be the sum of the two.
         the resulting region will be stored in hRegion1,
         like if we were making something like this:
         hRegion1 = hRegion1 + hRegion2. */
       
        CombineRgn(hRegion1, hRegion1, hRegion2, RGN_OR);

        /* Assign the Region to the window */
        SetWindowRgn(hwnd, hRegion1, true);

        /* Now we'll delete the regions */
        DeleteObject(hRegion1);
        DeleteObject(hRegion2);

        /* We'll change the window style and get rid of the caption bar */
        DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
        dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
        SetWindowLong(hwnd, GWL_STYLE, dwStyle);

        /* Force the window to be repainted */
        InvalidateRect(hwnd, NULL, TRUE);
        SetWindowPos(hwnd, NULL, 0,0,320,242, SWP_NOMOVE|SWP_NOZORDER);

        /* Set the flag to true to make sure the application knows about it */
        bRegioned = true;
      }

      /* We'll remove the region from the window */
      void UnRegionMe()
      {
        /* Unassign the region */
        SetWindowRgn(hwnd, NULL, true);

        /* Change the window style and show the caption bar again */
        DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
        dwStyle |= WS_CAPTION|WS_SIZEBOX;
        SetWindowLong(hwnd, GWL_STYLE, dwStyle);

        /* Force the window to be repainted again */
        InvalidateRect(hwnd, NULL, TRUE);
        SetWindowPos(hwnd, NULL, 0,0,320,240, SWP_NOMOVE|SWP_NOZORDER);

        /* Set the flag to false, so the application knows about it */
        bRegioned = false;
      } /* End of UnRegionMe() function */

      Greggy

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.