Advertisement
Guest User

Untitled

a guest
Apr 5th, 2012
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <dwmapi.h>
  4.  
  5. #include "resource.h"
  6.  
  7. #pragma comment (lib, "dwmapi.lib")
  8.  
  9.  
  10.  
  11.  
  12. /*  Declare Windows procedure  */
  13. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  14.  
  15. /*  Make the class name into a global variable  */
  16. char szClassName[ ] = "CodeBlocksWindowsApp";
  17.  
  18. int WINAPI WinMain (HINSTANCE hThisInstance,
  19.                      HINSTANCE hPrevInstance,
  20.                      LPSTR lpszArgument,
  21.                      int nCmdShow)
  22. {
  23.     HWND hwnd;               /* This is the handle for our window */
  24.     MSG messages;            /* Here messages to the application are saved */
  25.     WNDCLASSEX wincl;        /* Data structure for the windowclass */
  26.  
  27.             BLENDFUNCTION bfunc;
  28.             bfunc.AlphaFormat = 0;
  29.             bfunc.BlendFlags = 0;
  30.             bfunc.BlendOp = AC_SRC_OVER;
  31.             bfunc.SourceConstantAlpha = 0;
  32.  
  33.     /* The Window structure */
  34.     wincl.hInstance = hThisInstance;
  35.     wincl.lpszClassName = szClassName;
  36.     wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
  37.     wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
  38.     wincl.cbSize = sizeof (WNDCLASSEX);
  39.  
  40.     /* Use default icon and mouse-pointer */
  41.     wincl.hIcon = LoadIcon (GetModuleHandle(0), MAKEINTRESOURCE(IDI_MYAPP));
  42.     wincl.hIconSm = LoadIcon (GetModuleHandle(0), MAKEINTRESOURCE(IDI_MYAPP));
  43.     wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  44.     wincl.lpszMenuName = NULL;                 /* No menu */
  45.     wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  46.     wincl.cbWndExtra = 0;                      /* structure or the window instance */
  47.     /* Use Windows's default colour as the background of the window */
  48.     wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  49.  
  50.     /* Register the window class, and if it fails quit the program */
  51.     if (!RegisterClassEx (&wincl))
  52.         return 0;
  53.  
  54.     /* The class is registered, let's create the program*/
  55.     hwnd = CreateWindowEx (
  56.            0,                   /* Extended possibilites for variation */
  57.            szClassName,         /* Classname */
  58.            "My App",            /* Title Text */
  59.            WS_EX_LAYERED,       /* default window */
  60.            CW_USEDEFAULT,       /* Windows decides the position */
  61.            CW_USEDEFAULT,       /* where the window ends up on the screen */
  62.            640,                 /* The programs width */
  63.            480,                 /* and height in pixels */
  64.            HWND_DESKTOP,        /* The window is a child-window to desktop */
  65.            NULL,                /* No menu */
  66.            hThisInstance,       /* Program Instance handler */
  67.            NULL                 /* No Window Creation data */
  68.            );
  69.         MARGINS mar =  { -1, -1, -1, -1 };
  70.  
  71. SetLayeredWindowAttributes(hwnd,  RGB(0x0, 0x0, 0x0), 0, LWA_COLORKEY);
  72.  
  73.       DwmExtendFrameIntoClientArea(hwnd, &mar);
  74.  
  75.     /* Make the window visible on the screen */
  76.     ShowWindow (hwnd, nCmdShow);
  77.  
  78.     /* Run the message loop. It will run until GetMessage() returns 0 */
  79.     while (GetMessage (&messages, NULL, 0, 0))
  80.     {
  81.         /* Translate virtual-key messages into character messages */
  82.         TranslateMessage(&messages);
  83.         /* Send message to WindowProcedure */
  84.         DispatchMessage(&messages);
  85.     }
  86.  
  87.     //Start of my code...
  88.  
  89.  
  90.  
  91. //    UpdateLayeredWindow (hwnd, //window handle
  92. //                         NULL, //DC for screen (optional)
  93. //                         NULL, //window position (NULL = no change)
  94. //                         NULL, //New window size (NULL = same)
  95. //                         NULL, //used if you want to morph the window, otherwise NULL
  96. //                         NULL, //location of layer on Device context, if previous param is NULL, this should be too
  97. //                         RGB(0,0,0), //window color
  98. //                         &bfunc, //a BLENDFUNCTION variable, for setting alpha and stuff like that
  99. //                         0); //tells how to use the blending, make 0 if param 5 is NULL
  100.  
  101.  
  102.  
  103.     //End of my code...
  104.  
  105.  
  106.  
  107.     /* The program return-value is 0 - The value that PostQuitMessage() gave */
  108.     return messages.wParam;
  109. }
  110.  
  111.  
  112. /*  This function is called by the Windows function DispatchMessage()  */
  113.  
  114. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  115. {
  116.     switch (message)                  /* handle the messages */
  117.     {
  118.         case WM_DESTROY:
  119.             PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
  120.             break;
  121.         default:                      /* for messages that we don't deal with */
  122.             return DefWindowProc (hwnd, message, wParam, lParam);
  123.     }
  124.  
  125.     return 0;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement