Advertisement
rhouland

Text Out custom Color Font Size & Transparent

May 15th, 2018
1,851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <sstream>
  3. #include <windows.h>
  4.  
  5.  
  6. HFONT hFont = CreateFont (43, 0, 0, 0, 700, FALSE, FALSE, FALSE, BALTIC_CHARSET,
  7. OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  8. DEFAULT_PITCH | FF_DONTCARE, TEXT("Comic Sans MS"));
  9.  
  10. // HFONT CreateFont(
  11.   //_In_ int     nHeight, AUKÐTIS
  12.   //_In_ int     nWidth,   PLOTIS
  13.   //_In_ int     nEscapement, PASVIRIMAS
  14.   //_In_ int     nOrientation,
  15.   //_In_ int     fnWeight, STORIS FW_BOLD, = 700 NUO 1 IKI  900
  16.   //_In_ DWORD   fdwItalic,
  17.   //_In_ DWORD   fdwUnderline,
  18.   //_In_ DWORD   fdwStrikeOut,
  19.   //_In_ DWORD   fdwCharSet,
  20.   //_In_ DWORD   fdwOutputPrecision,
  21.   //_In_ DWORD   fdwClipPrecision,
  22.   //_In_ DWORD   fdwQuality,
  23.   //_In_ DWORD   fdwPitchAndFamily,
  24.   //_In_ LPCTSTR lpszFace
  25.  
  26. LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
  27.     static HBITMAP hImageBitmap;
  28.     static HBITMAP hImageOldBitmap;
  29.     static HDC hImageDC;
  30.     static BITMAP bm;
  31.     static HWND HWNDStatic;
  32.          
  33.     switch(Message) {
  34.        
  35.         case WM_DESTROY: {
  36.             if (hImageBitmap)
  37.             {
  38.                 DeleteObject (SelectObject (hImageDC, hImageOldBitmap));
  39.                 DeleteDC (hImageDC);
  40.             }
  41.             PostQuitMessage(0);
  42.             break;
  43.         }
  44.        
  45.         case WM_CREATE: {
  46.  
  47.     HWNDStatic = CreateWindow(TEXT("STATIC"),TEXT(" ÐEÐKAS Á JÛRÀ ÞIÛRËJO "),
  48.     WS_VISIBLE | WS_CHILD | SS_CENTER | SS_CENTERIMAGE,
  49.     50,70,460,75,hwnd,(HMENU)1,NULL,NULL);
  50.     SendMessage (HWNDStatic, WM_SETFONT, WPARAM (hFont), TRUE);
  51.    
  52. hImageBitmap = (HBITMAP) LoadImage (NULL, "1.bmp", 0, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
  53.             if (hImageBitmap)
  54.             {
  55. GetObject (hImageBitmap, sizeof (BITMAP), &bm);
  56. HDC hDC = GetDC (hwnd);
  57. hImageDC = CreateCompatibleDC (hDC);
  58. hImageOldBitmap = (HBITMAP) SelectObject (hImageDC, hImageBitmap);
  59. ReleaseDC (hwnd, hDC);
  60.             }
  61.             break;
  62.         }
  63.        
  64.     case WM_CTLCOLORSTATIC:
  65.     {  
  66.     if((HWND)lParam == HWNDStatic)
  67.     {  
  68.     //SetBkColor((HDC)wParam, RGB(255,0,255));
  69.     SetTextColor((HDC)wParam, RGB(0, 255, 0));    
  70.     SetBkMode((HDC)wParam, TRANSPARENT);
  71.     return (INT_PTR)GetStockObject(NULL_BRUSH);
  72.     }
  73.     break;
  74. }
  75.        
  76.        
  77.         case WM_PAINT: {
  78.             PAINTSTRUCT ps;
  79.             HDC hDC = BeginPaint (hwnd, &ps);
  80.            
  81.             if (hImageBitmap)
  82. BitBlt (hDC, 0, 0, bm.bmWidth, bm.bmHeight, hImageDC, 0, 0, SRCCOPY);
  83.             EndPaint (hwnd, &ps);
  84.             break;
  85.         }
  86.        
  87.     default:
  88.             return DefWindowProc(hwnd, Message, wParam, lParam);
  89.     }
  90.     return 0;
  91. }
  92.  
  93. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  94.     WNDCLASSEX wc;
  95.     HWND hwnd;
  96.     MSG msg;
  97. setlocale(LC_ALL, "Lithuanian");
  98.  
  99.     memset(&wc,0,sizeof(wc));
  100.     wc.cbSize        = sizeof(WNDCLASSEX);
  101.     wc.lpfnWndProc   = WndProc;
  102.     wc.hInstance     = hInstance;
  103.     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  104.    
  105.     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  106.     wc.lpszClassName = "WindowClass";
  107.     wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
  108.     wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
  109.  
  110.     if(!RegisterClassEx(&wc)) {
  111.         MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
  112.         return 0;
  113.     }
  114.  
  115.     hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass",
  116.     "Tekstas, permatomas, spalva. ðriftas",
  117.     WS_VISIBLE | WS_SYSMENU,
  118.     GetSystemMetrics(SM_CXSCREEN)/2-335,
  119.     GetSystemMetrics(SM_CYSCREEN)/2-233,
  120.     669,466,NULL,NULL,hInstance,NULL);
  121.  
  122.     if(hwnd == NULL) {
  123.         MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
  124.         return 0;
  125.     }
  126.  
  127.     while(GetMessage(&msg, NULL, 0, 0) > 0) {
  128.         TranslateMessage(&msg);
  129.         DispatchMessage(&msg);
  130.     }
  131.     return msg.wParam;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement