Advertisement
Guest User

Untitled

a guest
Dec 9th, 2013
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 37.37 KB | None | 0 0
  1. #include "resource.h"
  2. #include <windows.h>
  3. #include <windowsx.h> // for TransparentBlt()
  4. #include <commctrl.h>
  5. #include <gdiplus.h>
  6.  
  7. #pragma comment( linker, "/manifestdependency:\"type='win32' \
  8.                          name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
  9.                          processorArchitecture='*' publicKeyToken='6595b64144ccf1df' \
  10.                          language='*'\"")
  11.  
  12. #pragma comment( lib, "comctl32.lib")
  13. #pragma comment( lib, "Msimg32.lib" ) // for TransparentBlt()
  14. #pragma comment( lib, "Gdiplus.lib" )
  15.  
  16. using namespace Gdiplus;
  17.  
  18. // variable for storing the instance
  19.  
  20. static HINSTANCE hInst;
  21.  
  22. // icons
  23.  
  24. static HICON hIcon, // main window's icon
  25.             hiAdmin; // icon in the left corner of the status bar
  26.  
  27. // Images for logos
  28.  
  29. Image *image, // left logo on main window's top banner
  30.         *image1, // right logo on main window's top banner
  31.         *btn5; // map for the orange static control
  32.  
  33. // variables for painting the window
  34.  
  35. static HBRUSH hbPozadina, // gray background brush for grid on the top
  36.             BlueFrame, // needed to frame blue static controls
  37.             hbr; // orange brush for orange panel
  38.  
  39. static HBITMAP bmpBTN1, // image for top left blue static control
  40.                 bmpBTN2, // image for top right blue static control
  41.  
  42.                 //============ these two make one image =========== //
  43.  
  44.                 bmpBTN3, // left image for bottom left blue static control
  45.                 bmpBTN3a, // right image for bottom left blue static control
  46.  
  47.                 //==================================================//
  48.  
  49.                 bmpBTN4, // image for bottom right blue static control
  50.                 bmpSimbol, // middle logo on the main window's top banner
  51.                 bmpInfo, // top left image for child window of the 1st orange static control
  52.                 bmpLink, // top left image for child window of the 3rd orange static control
  53.                 bmpHelp; // top left image for child window of the 2nd orange static control
  54.  
  55. /****************************** helper functions for WM_PAINT **************************/
  56.  
  57. // Fills triangle with gradient brush
  58.  
  59. void GradientTriangle( HDC MemDC, LONG x1, LONG y1, LONG x2, LONG y2, LONG x3, LONG y3,
  60.                       COLORREF top, COLORREF bottom )
  61. {
  62.     TRIVERTEX vertex[3];
  63.  
  64.     vertex[0].x     = x1;
  65.     vertex[0].y     = y1;
  66.     vertex[0].Red   = GetRValue(bottom) << 8;
  67.     vertex[0].Green = GetGValue(bottom) << 8;
  68.     vertex[0].Blue  = GetBValue(bottom) << 8;
  69.     vertex[0].Alpha = 0x0000;
  70.  
  71.     vertex[1].x     = x2;
  72.     vertex[1].y     = y2;
  73.     vertex[1].Red   = GetRValue(top) << 8;
  74.     vertex[1].Green = GetGValue(top) << 8;
  75.     vertex[1].Blue  = GetBValue(top) << 8;
  76.     vertex[1].Alpha = 0x0000;
  77.  
  78.     vertex[2].x     = x3;
  79.     vertex[2].y     = y3;
  80.     vertex[2].Red   = GetRValue(bottom) << 8;
  81.     vertex[2].Green = GetGValue(bottom) << 8;
  82.     vertex[2].Blue  = GetBValue(bottom) << 8;
  83.     vertex[2].Alpha = 0x0000;
  84.  
  85.     // Create a GRADIENT_TRIANGLE structure that
  86.     // references the TRIVERTEX vertices.
  87.            
  88.     GRADIENT_TRIANGLE gTriangle;
  89.  
  90.     gTriangle.Vertex1 = 0;
  91.     gTriangle.Vertex2 = 1;
  92.     gTriangle.Vertex3 = 2;
  93.  
  94.     // Draw a shaded triangle.
  95.            
  96.     GradientFill( MemDC, vertex, 3, &gTriangle, 1, GRADIENT_FILL_TRIANGLE);
  97. }
  98.  
  99. // draws the background for the part of the window between header and footer
  100.  
  101. void drawBackground( HDC MemDC, RECT r )
  102. {
  103.     /******************** main window's gradient background ***************/
  104.  
  105.     GradientTriangle( MemDC, r.right, r.bottom - r.top - 30, r.left, r.bottom - r.top - 30,
  106.         r.left, r.top + 120, RGB( 0x95, 0xB3, 0xD7 ), RGB( 0xDB, 0xE5, 0xF1 ) );
  107.  
  108.     GradientTriangle( MemDC, r.right, r.bottom - r.top - 30, r.right, r.top + 120,
  109.         r.left, r.top + 120, RGB( 0x95, 0xB3, 0xD7 ), RGB( 0xDB, 0xE5, 0xF1 ) );
  110.  
  111. }
  112.  
  113. // draws the header of the main window
  114.  
  115. void drawHeader( HDC MemDC, RECT rect, HBRUSH hbPozadina )
  116. {
  117.     FillRect( MemDC, &rect, hbPozadina );
  118.  
  119.     // draw grid on the banner background
  120.  
  121.     LOGBRUSH lbPozadina;
  122.            
  123.     HGDIOBJ hPenPozadina = NULL, hOldPenPozadina;
  124.  
  125.     lbPozadina.lbColor = RGB( 216, 216, 216 );
  126.     lbPozadina.lbHatch = 0;
  127.     lbPozadina.lbStyle = BS_SOLID;
  128.  
  129.     hPenPozadina = ExtCreatePen( PS_COSMETIC | PS_SOLID, 1, &lbPozadina, 0, NULL);
  130.  
  131.     hOldPenPozadina = SelectObject( MemDC, hPenPozadina); // needed for cleanup
  132.  
  133.     for( int i = rect.left + 12; i< rect.right; i += 12)
  134.     {
  135.         MoveToEx( MemDC, i, rect.top, NULL );
  136.  
  137.         LineTo( MemDC, i, rect.bottom - rect.top + 1 );
  138.     }
  139.  
  140.     for( int i = rect.top + 12; i< rect.bottom; i += 12)
  141.     {
  142.         MoveToEx( MemDC, rect.left, i, NULL );
  143.  
  144.         LineTo( MemDC, rect.right - rect.left + 1, i );
  145.     }
  146.  
  147.     // perform proper cleanup
  148.  
  149.     SelectObject( MemDC, hOldPenPozadina);
  150.  
  151.     DeleteObject(hPenPozadina);
  152.  
  153.     /********* draw a line at the bottom of the top banner ******/
  154.  
  155.     LOGBRUSH lb;
  156.  
  157.     HGDIOBJ hPen = NULL, hOldPen;
  158.  
  159.     lb.lbColor = RGB( 0, 0, 0 );
  160.     lb.lbHatch = 0;
  161.     lb.lbStyle = BS_SOLID;
  162.  
  163.     hPen = ExtCreatePen( PS_COSMETIC | PS_SOLID, 1, &lb, 0, NULL);
  164.  
  165.     hOldPen = SelectObject( MemDC, hPen ); // needed for proper cleanup
  166.  
  167.     MoveToEx( MemDC, rect.left, rect.top + 120, NULL );
  168.  
  169.     LineTo( MemDC, rect.right - rect.left + 1, rect.top + 120 );
  170.  
  171.     // perform proper cleanup
  172.  
  173.     SelectObject( MemDC, hOldPen );
  174.  
  175.     DeleteObject(hPen);
  176. }
  177.  
  178. // fills rectangle with gradient brush
  179.  
  180. void GradientRectangle( HDC MemDC, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF top,
  181.                        COLORREF bottom )
  182. {
  183.     // vertexes for static's gradient color
  184.  
  185.     TRIVERTEX vertexS[2];
  186.  
  187.     vertexS[0].x     = x1;
  188.     vertexS[0].y     = y1;
  189.     vertexS[0].Red   = GetRValue(top) << 8;
  190.     vertexS[0].Green = GetGValue(top) << 8;
  191.     vertexS[0].Blue  = GetBValue(top) << 8;
  192.     vertexS[0].Alpha = 0x0000;
  193.  
  194.     vertexS[1].x     = x2;
  195.     vertexS[1].y     = y2;
  196.     vertexS[1].Red   = GetRValue(bottom) << 8;
  197.     vertexS[1].Green = GetGValue(bottom) << 8;
  198.     vertexS[1].Blue  = GetBValue(bottom) << 8;
  199.     vertexS[1].Alpha = 0x0000;
  200.  
  201.     // Create a GRADIENT_RECT structure that
  202.     // references the TRIVERTEX vertices.
  203.  
  204.     GRADIENT_RECT gRect;
  205.  
  206.     gRect.UpperLeft  = 0;
  207.     gRect.LowerRight = 1;
  208.  
  209.     // Draw a shaded rectangle.
  210.  
  211.     GradientFill( MemDC, vertexS, 2, &gRect, 1, GRADIENT_FILL_RECT_V );
  212. }
  213.  
  214. // fills the "button" with blue gradient and frames it with blue brush
  215.  
  216. void FillButton( HDC MemDC, RECT rect, HBRUSH BlueFrame )
  217. {
  218.     // fill upper half of the rectangle
  219.  
  220.     GradientRectangle( MemDC, rect.left, rect.top, rect.right,
  221.         rect.top + ( rect.bottom - rect.top ) / 2,
  222.         RGB( 0x95, 0xB3, 0xD7 ), RGB( 0x4F, 0x8B, 0xBD ) );
  223.  
  224.     // fill bottom half of the rectangle
  225.  
  226.     GradientRectangle( MemDC, rect.left, rect.top + ( rect.bottom - rect.top ) / 2,
  227.         rect.right, rect.bottom, RGB( 0x4F, 0x8B, 0xBD ), RGB( 0x95, 0xB3, 0xD7 ) );
  228.  
  229.     FrameRect( MemDC, &rect, BlueFrame );
  230. }
  231.  
  232. // draws the "status bar" at the bottom of the main window
  233.  
  234. void drawFooter( HDC MemDC, RECT r, COLORREF top, COLORREF bottom )
  235. {
  236.     // down triangle
  237.  
  238.     GradientTriangle( MemDC,
  239.         r.right, r.bottom,
  240.         ( r.right - r.left ) / 2,
  241.         r.bottom - r.top - 15,
  242.         r.left, r.bottom,
  243.         top, bottom );
  244.  
  245.     // upper triangle
  246.  
  247.     GradientTriangle( MemDC,
  248.         r.right, r.bottom - r.top - 30,
  249.         ( r.right - r.left ) / 2, r.bottom - r.top - 15,
  250.         r.left, r.bottom - r.top - 30,
  251.         top, bottom );
  252.  
  253.     // left triangle
  254.  
  255.     GradientTriangle( MemDC,
  256.         r.left, r.bottom,
  257.         ( r.right - r.left ) / 2, r.bottom - r.top - 15,
  258.         r.left, r.bottom - r.top - 30,
  259.         top, bottom );
  260.  
  261.     // right triangle
  262.  
  263.     GradientTriangle( MemDC,
  264.         r.right, r.bottom - r.top - 30,
  265.         ( r.right - r.left ) / 2, r.bottom - r.top - 15,
  266.         r.right, r.bottom,
  267.         top, bottom );
  268.  
  269.     // draw icon
  270.  
  271.     DrawIconEx( MemDC, r.left, r.bottom - r.top - 30, hiAdmin, 30, 30, NULL, NULL, DI_NORMAL );
  272. }
  273.  
  274. // draw orange panel on which map and 3 static controls will be drawn
  275.  
  276. void drawOrangePanel( HDC MemDC, RECT r, COLORREF top, COLORREF bottom )
  277. {
  278.     // down triangle
  279.  
  280.     GradientTriangle( MemDC,
  281.         r.right, r.bottom,
  282.         r.left + ( r.right - r.left ) / 2,
  283.         r.top + ( r.bottom - r.top ) / 2,
  284.         r.left, r.bottom,
  285.         top, bottom );
  286.  
  287.     // upper triangle
  288.  
  289.     GradientTriangle( MemDC,
  290.         r.right, r.top,
  291.         r.left + ( r.right - r.left ) / 2,
  292.         r.top + ( r.bottom - r.top ) / 2,
  293.         r.left, r.top,
  294.         top, bottom );
  295.  
  296.     // left triangle
  297.  
  298.     GradientTriangle( MemDC,
  299.         r.left, r.bottom,
  300.         r.left + ( r.right - r.left ) / 2,
  301.         r.top + ( r.bottom - r.top ) / 2,
  302.         r.left, r.top,
  303.         top, bottom );
  304.  
  305.     // right triangle
  306.  
  307.     GradientTriangle( MemDC,
  308.         r.right, r.top,
  309.         r.left + ( r.right - r.left ) / 2, r.top + ( r.bottom - r.top ) / 2,
  310.         r.right, r.bottom,
  311.         top, bottom );
  312. }
  313.  
  314. void drawStrings( HDC MemDC, RECT r )
  315. {
  316.     // rectangle for header
  317.  
  318.     RECT rect, baner; // needed for proper positioning
  319.    
  320.     SIZE sBaner; // needed for proper positioning
  321.  
  322.     HFONT hf, hfOld;
  323.            
  324.     long lfHeight;
  325.  
  326.     rect.left = r.left;
  327.     rect.top = r.top;
  328.     rect.right = r.right;
  329.     rect.bottom = 120;
  330.  
  331.     /************************ middle orange text ************************/
  332.  
  333.     // set font size below via function's first argument
  334.  
  335.     lfHeight = -MulDiv( 14, GetDeviceCaps( MemDC, LOGPIXELSY), 72 );
  336.            
  337.     hf = CreateFont( lfHeight, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, L"Arial Black" );
  338.  
  339.     SetBkMode( MemDC, TRANSPARENT );
  340.  
  341.     SetTextColor( MemDC, RGB( 255, 163, 94 ) ); // orange
  342.                
  343.     hfOld = (HFONT)SelectObject( MemDC, hf ); // needed for cleanup
  344.  
  345.     GetTextExtentPoint32( MemDC, L"ГЕОТЕРМАЛНИ ИНФОРМАЦИОНИ СИСТЕМ ГРАДА БЕОГРАДА-ГЕОТЕРМИСТ",
  346.         wcslen(L"ГЕОТЕРМАЛНИ ИНФОРМАЦИОНИ СИСТЕМ ГРАДА БЕОГРАДА-ГЕОТЕРМИСТ"), &sBaner );
  347.  
  348.     // proper positioning
  349.  
  350.     baner.left = r.left + 60;
  351.     baner.right = r.right - r.left - 60;
  352.     baner.top = r.top + 15;
  353.     baner.bottom = r.top + sBaner.cy;
  354.  
  355.     DrawTextEx( MemDC, L"ГЕОТЕРМАЛНИ ИНФОРМАЦИОНИ СИСТЕМ ГРАДА БЕОГРАДА-ГЕОТЕРМИСТ",
  356.         wcslen(L"ГЕОТЕРМАЛНИ ИНФОРМАЦИОНИ СИСТЕМ ГРАДА БЕОГРАДА-ГЕОТЕРМИСТ"), &baner,
  357.         DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_WORDBREAK, 0 );
  358.  
  359.     SelectObject( MemDC, hfOld ); // proper cleanup
  360.  
  361.     DeleteObject( hf );
  362.  
  363.     /******************************* top left text ************************/
  364.  
  365.     //position it properly
  366.  
  367.     baner.left = r.left + 90;
  368.     baner.top = r.top + sBaner.cy + 28;
  369.     baner.right = 460;
  370.     baner.bottom = r.bottom;
  371.  
  372.     lfHeight = -MulDiv( 8, GetDeviceCaps( MemDC, LOGPIXELSY), 72 );
  373.            
  374.     hf = CreateFont( lfHeight, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, L"Arial Black" );
  375.  
  376.     SetTextColor( MemDC, RGB( 0, 0, 0 ) );
  377.                
  378.     hfOld = (HFONT)SelectObject( MemDC, hf ); // needed for proper cleanup
  379.  
  380.     DrawTextEx( MemDC, L"УПРАВА ГРАДА БЕОГРАДА\nСЕКРЕТАРИЈАТ ЗА КОМУНАЛНЕ И СТАМБЕНЕ ПОСЛОВЕ\nУПРАВА ЗА ЕНЕРГЕТИКУ",
  381.         wcslen(L"УПРАВА ГРАДА БЕОГРАДА\nСЕКРЕТАРИЈАТ ЗА КОМУНАЛНЕ И СТАМБЕНЕ ПОСЛОВЕ\nУПРАВА ЗА ЕНЕРГЕТИКУ"),
  382.         &baner, DT_CENTER | DT_NOCLIP | DT_WORDBREAK, 0 );
  383.  
  384.     /*************************** top right text *************************/
  385.  
  386.     // position it properly
  387.  
  388.     baner.top = r.top + sBaner.cy + 28;
  389.     baner.left = r.right - 350;
  390.     baner.right = r.right - 100;
  391.     baner.bottom = r.bottom;
  392.  
  393.     DrawTextEx( MemDC, L"УНИВЕРЗИТЕТ У БЕОГРАДУ\nРУДАРСКО ГЕОЛОШКИ ФАКУЛТЕТ\nДЕПАРТМАН ЗА ХИДРОГЕОЛОГИЈУ",
  394.         wcslen(L"УНИВЕРЗИТЕТ У БЕОГРАДУ\nРУДАРСКО ГЕОЛОШКИ ФАКУЛТЕТ\nДЕПАРТМАН ЗА ХИДРОГЕОЛОГИЈУ"),
  395.         &baner, DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_WORDBREAK, 0 );
  396.  
  397.     SelectObject( MemDC, hfOld ); // proper cleanup
  398.  
  399.     DeleteObject( hf );
  400.  
  401.     //========= draw right text in status bar =============//
  402.  
  403.     lfHeight = -MulDiv( 8, GetDeviceCaps( MemDC, LOGPIXELSY), 72 );
  404.            
  405.     hf = CreateFont( lfHeight, 0, 0, 0, FW_BOLD, TRUE, 0, 0, 0, 0, 0, 0, 0, L"Arial Black" );
  406.                
  407.     hfOld = (HFONT)SelectObject( MemDC, hf ); // needed for proper cleanup
  408.  
  409.     GetTextExtentPoint32( MemDC, L"ЦЕНТАР ЗА ОБНОВЉИВЕ ВОДНЕ ЕНЕРГЕТСКЕ РЕСУРСЕ",
  410.         wcslen(L"ЦЕНТАР ЗА ОБНОВЉИВЕ ВОДНЕ ЕНЕРГЕТСКЕ РЕСУРСЕ"), &sBaner );
  411.  
  412.     // position it properly
  413.  
  414.     rect.bottom = r.bottom;
  415.     rect.right = r.left + sBaner.cx + 30;
  416.     rect.left = r.left + 30;
  417.     rect.top = r.bottom - r.top - 30;
  418.  
  419.     // draw it to the back buffer
  420.  
  421.     DrawTextEx( MemDC, L"РУДАРСКО ГЕОЛОШКИ ФАКУЛТЕТ\nЦЕНТАР ЗА ОБНОВЉИВЕ ВОДНЕ ЕНЕРГЕТСКЕ РЕСУРСЕ",
  422.         wcslen(L"РУДАРСКО ГЕОЛОШКИ ФАКУЛТЕТ\nЦЕНТАР ЗА ОБНОВЉИВЕ ВОДНЕ ЕНЕРГЕТСКЕ РЕСУРСЕ"),
  423.         &rect, DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_WORDBREAK, 0 );
  424.  
  425.     SelectObject( MemDC, hfOld ); // proper cleanup
  426.  
  427.     DeleteObject( hf );
  428.  
  429.     //============== right text in the status bar ==================//
  430.  
  431.     lfHeight = -MulDiv( 10, GetDeviceCaps( MemDC, LOGPIXELSY), 72 );
  432.            
  433.     hf = CreateFont( lfHeight, 0, 0, 0, FW_BOLD, TRUE, 0, 0, 0, 0, 0, 0, 0, L"Arial" );
  434.                
  435.     hfOld = (HFONT)SelectObject( MemDC, hf ); // needed for proper cleanup
  436.  
  437.     GetTextExtentPoint32( MemDC, L" Дејан Миленић & Ана Врањеш © 2013 сва права задржана",
  438.         wcslen(L" Дејан Миленић & Ана Врањеш © 2013 сва права задржана"), &sBaner );
  439.  
  440.     // position it properly
  441.  
  442.     rect.bottom = r.bottom;
  443.     rect.right = r.right - 10;
  444.     rect.left = r.right - r.left - sBaner.cx - 10;
  445.     rect.top = r.bottom - r.top - sBaner.cy;
  446.  
  447.     // draw it to the back buffer
  448.  
  449.     DrawTextEx( MemDC, L" Дејан Миленић & Ана Врањеш © 2013 сва права задржана",
  450.         wcslen(L" Дејан Миленић & Ана Врањеш © 2013 сва права задржана"),
  451.         &rect, DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_WORDBREAK | DT_NOPREFIX, 0 );
  452.  
  453.     // perform proper cleanup
  454.  
  455.     SelectObject( MemDC, hfOld );
  456.  
  457.     DeleteObject(hf);
  458.  
  459.     /****************** draw static control's background ******************/
  460.  
  461.     //=============== top left blue static control ================//
  462.  
  463.     //position it properly
  464.  
  465.     rect.left = ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  466.     rect.top = 230 + ( r.bottom - r.top - 450 ) / 3;
  467.     rect.right = 150 + ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  468.     rect.bottom = 270 + ( r.bottom - r.top - 450 ) / 3;
  469.  
  470.     // draw text
  471.  
  472.     // set font size below via function's first argument
  473.  
  474.     lfHeight = -MulDiv( 8, GetDeviceCaps( MemDC, LOGPIXELSY ), 72);
  475.            
  476.     hf = CreateFont( lfHeight, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, L"Arial Black");
  477.  
  478.     hfOld = (HFONT)SelectObject( MemDC, hf );
  479.  
  480.     DrawTextEx( MemDC, L"УНОС ПОДАТАКА", wcslen(L"УНОС ПОДАТАКА"),
  481.         &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_WORDBREAK, 0 );
  482.  
  483.     //================= top right blue static control =====================//
  484.  
  485.     //position it properly
  486.  
  487.     rect.left = 150 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  488.     rect.top = 230 + ( r.bottom - r.top - 450 ) / 3;
  489.     rect.right = 300 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  490.     rect.bottom = 270 + ( r.bottom - r.top - 450 ) / 3;
  491.  
  492.     // draw text
  493.  
  494.     DrawTextEx( MemDC, L"ПРЕГЛЕД ПОДАТАКА", wcslen(L"ПРЕГЛЕД ПОДАТАКА"),
  495.         &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_WORDBREAK, 0 );
  496.  
  497.     //================= bottom left blue static control =====================//
  498.  
  499.     //position it properly
  500.  
  501.     rect.left = ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  502.     rect.top = 380 + 2 * ( r.bottom - r.top - 450 ) / 3;
  503.     rect.right = 150 + ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  504.     rect.bottom = 420 + 2 * ( r.bottom - r.top - 450 ) / 3;
  505.  
  506.     // draw text
  507.  
  508.     DrawTextEx( MemDC, L"ИЗВЕШТАЈ", wcslen(L"ИЗВЕШТАЈ"),
  509.         &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_WORDBREAK, 0 );
  510.  
  511.     //================= bottom right blue static control =====================//
  512.  
  513.     //position it properly
  514.  
  515.     rect.left = 150 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  516.     rect.top = 380 + 2 * ( r.bottom - r.top - 450 ) / 3;
  517.     rect.right = 300 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  518.     rect.bottom = 420 + 2 * ( r.bottom - r.top - 450 ) / 3;
  519.  
  520.     // draw text
  521.  
  522.     DrawTextEx( MemDC, L"ПРЕТРАГА", wcslen(L"ПРЕТРАГА"),
  523.         &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_WORDBREAK, 0 );
  524.  
  525.     SelectObject( MemDC, hfOld );
  526.  
  527.     DeleteObject(hf);
  528.  
  529.     //================ text for orange static controls =============//
  530.    
  531.     // first one
  532.  
  533.     rect.left = 3 * ( r.right - r.left ) / 4 + 10;
  534.     rect.top = r.top + 160;
  535.     rect.right = r.right - r.top - 50;
  536.     rect.bottom = r.top + 180;
  537.  
  538.     //============= draw text ======//
  539.  
  540.     lfHeight = -MulDiv( 10, GetDeviceCaps( MemDC, LOGPIXELSY ), 72);
  541.            
  542.     hf = CreateFont(lfHeight, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0,L"Arial Unicode MS");
  543.  
  544.     hfOld = (HFONT)SelectObject( MemDC, hf );
  545.  
  546.     DrawTextEx( MemDC, L"ИНФОРМАЦИЈЕ", wcslen(L"ИНФОРМАЦИЈЕ"), &rect,
  547.         DT_VCENTER | DT_LEFT | DT_SINGLELINE, 0 );
  548.  
  549.     // second one
  550.  
  551.     rect.left = 3 * ( r.right - r.left ) / 4 + 10;
  552.     rect.top = r.top + 200;
  553.     rect.bottom = r.top + 220;
  554.  
  555.     //====== draw text ======//
  556.  
  557.     DrawTextEx( MemDC, L"ПОМОЋ", wcslen(L"ПОМОЋ"), &rect,
  558.         DT_VCENTER | DT_LEFT | DT_SINGLELINE, 0 );
  559.  
  560.     // third one
  561.  
  562.     rect.left = 3 * ( r.right - r.left ) / 4 + 10;
  563.     rect.top = r.top + 240;
  564.     rect.bottom = r.top + 260;
  565.  
  566.     //====== draw text ======//
  567.  
  568.     DrawTextEx( MemDC, L"КОРИСНИ ЛИНКОВИ", wcslen(L"КОРИСНИ ЛИНКОВИ"), &rect,
  569.         DT_VCENTER | DT_LEFT | DT_SINGLELINE, 0 );
  570.  
  571.     // font is no longer needed, so do cleanup
  572.  
  573.     SelectObject( MemDC, hfOld );
  574.  
  575.     DeleteObject(hf);
  576.  
  577. }
  578.  
  579. void drawImages( HDC hdc, HDC MemDC, RECT r )
  580. {
  581.     HDC hdcMemImg = CreateCompatibleDC(hdc); // back buffer for bitmaps
  582.    
  583.     RECT rect = { 0, 0, 0, 0 }; // needed for proper positioning
  584.    
  585.     /******************* top middle logo ********************/
  586.  
  587.     BITMAP b;
  588.  
  589.     memset( &b, 0 , sizeof(BITMAP) );
  590.  
  591.     GetObject( bmpSimbol, sizeof(BITMAP), &b );
  592.  
  593.     // needed for proper cleanup
  594.     // ( we select a bitmap from resource file )
  595.  
  596.     HBITMAP oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpSimbol );
  597.  
  598.     // draw bitmap to the back buffer
  599.  
  600.     TransparentBlt( MemDC, ( r.right - r.left - 64 ) / 2, r.top + 45, 64, 64,
  601.         hdcMemImg, 0, 0, b.bmWidth, b.bmHeight, RGB( 0, 0, 0) );
  602.  
  603.     SelectObject( hdcMemImg, oldBmp ); // proper cleanup
  604.  
  605.     //=============== top left blue static control ================//
  606.  
  607.     //position it properly
  608.  
  609.     rect.left = ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  610.     rect.top = 120 + ( r.bottom - r.top - 450 ) / 3;
  611.     rect.right = 150 + ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  612.     rect.bottom = 270 + ( r.bottom - r.top - 450 ) / 3;
  613.  
  614.     memset( &b, 0, sizeof(BITMAP) );
  615.  
  616.     GetObject( bmpBTN1, sizeof(BITMAP), &b );
  617.  
  618.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpBTN1 );
  619.  
  620.     // draw bitmap on back buffer
  621.  
  622.     TransparentBlt( MemDC, rect.left + 20, rect.top + 10, rect.right - rect.left - 30,
  623.         rect.bottom - rect.top - 40,
  624.         hdcMemImg, 0, 0, b.bmWidth, b.bmHeight, RGB( 0, 0, 0 ) );
  625.  
  626.     SelectObject( hdcMemImg, oldBmp );
  627.  
  628.     //================= top right blue static control =====================//
  629.  
  630.     //position it properly
  631.  
  632.     rect.left = 150 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  633.     rect.top = 120 + ( r.bottom - r.top - 450 ) / 3;
  634.     rect.right = 300 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  635.     rect.bottom = 270 + ( r.bottom - r.top - 450 ) / 3;
  636.  
  637.     memset( &b, 0, sizeof(BITMAP) );
  638.  
  639.     GetObject( bmpBTN2, sizeof(BITMAP), &b );
  640.  
  641.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpBTN2 );
  642.  
  643.     // draw bitmap on back buffer
  644.  
  645.     TransparentBlt( MemDC, rect.left + 15, rect.top + 10, rect.right - rect.left - 30,
  646.         rect.bottom - rect.top - 40, hdcMemImg, 0, 0, b.bmWidth, b.bmHeight, RGB( 255, 0, 255 ) );
  647.  
  648.     SelectObject( hdcMemImg, oldBmp );
  649.  
  650.     //================= bottom left blue static control =====================//
  651.  
  652.     //position it properly
  653.  
  654.     rect.left = ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  655.     rect.top = 270 + 2 * ( r.bottom - r.top - 450 ) / 3;
  656.     rect.right = 150 + ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  657.     rect.bottom = 420 + 2 * ( r.bottom - r.top - 450 ) / 3;
  658.  
  659.     memset( &b, 0, sizeof(BITMAP) );
  660.  
  661.     GetObject( bmpBTN3, sizeof(BITMAP), &b );
  662.  
  663.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpBTN3 );
  664.  
  665.     // draw left bitmap on back buffer
  666.  
  667.     TransparentBlt( MemDC, rect.left + 5, rect.top + 20, ( rect.right - rect.left) / 2,
  668.         rect.bottom - rect.top - 60, hdcMemImg, 0, 0, b.bmWidth, b.bmHeight, RGB( 0, 0, 0 ) );
  669.  
  670.     SelectObject( hdcMemImg, oldBmp );
  671.  
  672.     // draw right bitmap on back buffer
  673.  
  674.     memset( &b, 0 , sizeof(BITMAP) );
  675.  
  676.     GetObject( bmpBTN3a, sizeof(BITMAP), &b );
  677.  
  678.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpBTN3a );
  679.  
  680.     TransparentBlt( MemDC, rect.left + ( rect.right - rect.left) / 2 + 5, rect.top + 20,
  681.         ( rect.right - rect.left) / 2 - 5, rect.bottom - rect.top - 60,
  682.         hdcMemImg, 0, 0, b.bmWidth, b.bmHeight, RGB( 0, 0, 0 ) );
  683.  
  684.     SelectObject( hdcMemImg, oldBmp );
  685.  
  686.     //================= bottom right blue static control =====================//
  687.  
  688.     //position it properly
  689.  
  690.     rect.left = 150 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  691.     rect.top = 270 + 2 * ( r.bottom - r.top - 450 ) / 3;
  692.     rect.right = 300 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  693.     rect.bottom = 420 + 2 * ( r.bottom - r.top - 450 ) / 3;
  694.  
  695.     memset( &b, 0, sizeof(BITMAP) );
  696.  
  697.     GetObject( bmpBTN4, sizeof(BITMAP), &b );
  698.  
  699.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpBTN4 );
  700.  
  701.     // draw bitmap on back buffer
  702.  
  703.     TransparentBlt( MemDC, rect.left + 25, rect.top + 10, rect.right - rect.left - 50,
  704.         rect.bottom - rect.top - 40, hdcMemImg, 0, 0, b.bmWidth, b.bmHeight, RGB( 0, 0, 0 ) );
  705.  
  706.     SelectObject( hdcMemImg, oldBmp );
  707.  
  708.     //================= static controls on orange panel ==================//
  709.  
  710.     // first one
  711.  
  712.     rect.left = 3 * ( r.right - r.left ) / 4 - 30;
  713.     rect.top = r.top + 150;
  714.     rect.right = r.right - r.top - 50;
  715.     rect.bottom = r.top + 180;
  716.  
  717.     //=============== draw bitmap =============//
  718.  
  719.     memset( &b, 0, sizeof(BITMAP) );
  720.  
  721.     GetObject( bmpInfo, sizeof(BITMAP), &b );
  722.  
  723.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpInfo );
  724.  
  725.     // draw bitmap on back buffer
  726.  
  727.     TransparentBlt( MemDC, rect.left, rect.top, 30, 30, hdcMemImg, 0, 0,
  728.         b.bmWidth, b.bmHeight, RGB( 255, 163, 94 ) );
  729.  
  730.     SelectObject( hdcMemImg, oldBmp );
  731.  
  732.     // second one
  733.  
  734.     rect.left = 3 * ( r.right - r.left ) / 4 - 30;
  735.     rect.top = r.top + 190;
  736.     rect.bottom = r.top + 220;
  737.  
  738.     //=============== draw bitmap =============//
  739.  
  740.     memset( &b, 0, sizeof(BITMAP) );
  741.  
  742.     GetObject( bmpHelp, sizeof(BITMAP), &b );
  743.  
  744.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpHelp );
  745.  
  746.     // draw bitmap on back buffer
  747.  
  748.     TransparentBlt( MemDC, rect.left, rect.top, 30, 30, hdcMemImg, 0, 0,
  749.         b.bmWidth, b.bmHeight, RGB( 255, 163, 94 ) );
  750.  
  751.     SelectObject( hdcMemImg, oldBmp );
  752.  
  753.     // third one
  754.  
  755.     rect.left = 3 * ( r.right - r.left ) / 4 - 30;
  756.     rect.top = r.top + 230;
  757.     rect.bottom = r.top + 260;
  758.  
  759.     //=============== draw bitmap =============//
  760.  
  761.     memset( &b, 0, sizeof(BITMAP) );
  762.  
  763.     GetObject( bmpLink, sizeof(BITMAP), &b );
  764.  
  765.     oldBmp = (HBITMAP)SelectObject( hdcMemImg, bmpLink );
  766.  
  767.     // draw bitmap on back buffer
  768.  
  769.     TransparentBlt( MemDC, rect.left, rect.top, 30, 30, hdcMemImg, 0, 0,
  770.         b.bmWidth, b.bmHeight, RGB( 255, 163, 94 ) );
  771.  
  772.     SelectObject( hdcMemImg, oldBmp );
  773.  
  774.     //========= draw EMF and PNG files =========//
  775.  
  776.     {
  777.         Graphics graphics( MemDC );
  778.        
  779.         /******* fourth orange static control with the map ( EMF file ) ********/
  780.  
  781.         // proper positioning
  782.  
  783.         rect.top = r.top + 270;
  784.         rect.bottom = r.bottom - 60;
  785.         rect.left = 3 * ( r.right - r.left ) / 4 - 30;
  786.  
  787.         //============= aspect ratio ================//
  788.              
  789.         UINT o_height = btn5->GetHeight(), o_width =  btn5->GetWidth();
  790.  
  791.         float scale = 0.5;
  792.         int mapPosX, mapPosY;
  793.  
  794.         scale = (float)( rect.right - rect.left ) / o_width;
  795.  
  796.         if( (float)( rect.bottom - rect.top ) / o_height  <  scale )
  797.             scale = (float)( rect.bottom - rect.top ) / o_height;
  798.  
  799.         int marginX = ( rect.right - rect.left ) - (int)( o_width * scale );
  800.         int marginY = ( rect.bottom - rect.top ) - (int)( o_height * scale );
  801.  
  802.         marginX /= 2;
  803.         marginY /= 2;
  804.  
  805.         mapPosX = rect.left + marginX;
  806.         mapPosY = rect.top + marginY;
  807.  
  808.         graphics.DrawImage( btn5, mapPosX, mapPosY, (int)( o_width * scale ),
  809.             (int)( o_height * scale ) );
  810.  
  811.         /******************** top left logo ( PNG file ) *******************/
  812.  
  813.         o_height = image->GetHeight();
  814.         o_width = image->GetWidth();
  815.    
  816.         graphics.DrawImage( image, r.left + 5, r.top + 10, o_width, o_height );
  817.    
  818.         /******************** top right logo ( PNG file ) *******************/
  819.  
  820.         o_height = image1->GetHeight();
  821.         o_width = image1->GetWidth();
  822.    
  823.         graphics.DrawImage( image1, r.right - r.left - 90, r.top + 10, o_width, o_height );
  824.     }
  825.  
  826.     DeleteDC(hdcMemImg); // release memory DC
  827. }
  828.  
  829. void onPaint( HWND hwnd, WPARAM wParam, LPARAM lParam )
  830. {
  831.     PAINTSTRUCT ps;
  832.  
  833.     HDC hdc = BeginPaint( hwnd, &ps);
  834.  
  835.     RECT r; // rectangle for main window's client area
  836.            
  837.     GetClientRect( hwnd, &r);
  838.  
  839.     HDC MemDC = CreateCompatibleDC(hdc); // back buffer
  840.  
  841.     // compatible bitmap for MemDC
  842.  
  843.     HBITMAP bmp = CreateCompatibleBitmap( hdc, r.right - r.left, r.bottom - r.top ),
  844.         oldBmp = (HBITMAP)SelectObject( MemDC, bmp ); // needed for cleanup
  845.  
  846.     /*************** draw banner ******************/
  847.  
  848.     // position it properly at the top
  849.  
  850.     RECT rect;
  851.  
  852.     rect.left = r.left;
  853.     rect.top = r.top;
  854.     rect.right = r.right;
  855.     rect.bottom = 120;
  856.  
  857.     // draw background for middle part of the window
  858.  
  859.     drawBackground( MemDC, r );
  860.  
  861.     // draw header with grid lines
  862.  
  863.     drawHeader( MemDC, rect, hbPozadina );
  864.  
  865.     // draw "status bar"
  866.  
  867.     drawFooter( MemDC, r, RGB( 0x48, 0xAC, 0xC6), RGB( 0x31, 0x83, 0x99 ) );
  868.  
  869.     /****************** draw static control's background ******************/
  870.  
  871.     //=============== top left static control ================//
  872.  
  873.     //position it properly
  874.  
  875.     rect.left = ( 3 * ( r.right - r.left ) / 4 - 340 ) / 3;
  876.     rect.top = 120 + ( r.bottom - r.top - 450 ) / 3;
  877.     rect.right = 150 + ( 3 * ( r.right - r.left ) / 4 - 340 ) / 3;
  878.     rect.bottom = 270 + ( r.bottom - r.top - 450 ) / 3;
  879.  
  880.     // draw gradient button
  881.  
  882.     FillButton( MemDC, rect, BlueFrame );
  883.  
  884.     //================= top right static control =====================//
  885.  
  886.     //position it properly
  887.  
  888.     rect.left = 150 + 2 * ( 3 * ( r.right - r.left ) / 4 - 340 ) / 3;
  889.     rect.top = 120 + ( r.bottom - r.top - 450 ) / 3;
  890.     rect.right = 300 + 2 * ( 3 * ( r.right - r.left ) / 4 - 340 ) / 3;
  891.     rect.bottom = 270 + ( r.bottom - r.top - 450 ) / 3;
  892.  
  893.     // draw gradient button
  894.  
  895.     FillButton( MemDC, rect, BlueFrame );
  896.  
  897.     //================= bottom left static control =====================//
  898.  
  899.     //position it properly
  900.  
  901.     rect.left = ( 3 * ( r.right - r.left ) / 4 - 340 ) / 3;
  902.     rect.top = 270 + 2 * ( r.bottom - r.top - 450 ) / 3;
  903.     rect.right = 150 + ( 3 * ( r.right - r.left ) / 4 - 340 ) / 3;
  904.     rect.bottom = 420 + 2 * ( r.bottom - r.top - 450 ) / 3;
  905.  
  906.     // draw gradient button
  907.  
  908.     FillButton( MemDC, rect, BlueFrame );
  909.  
  910.     //================= bottom right static control =====================//
  911.  
  912.     //position it properly
  913.  
  914.     rect.left = 150 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  915.     rect.top = 270 + 2 * ( r.bottom - r.top - 450 ) / 3;
  916.     rect.right = 300 + 2 * ( 3  * ( r.right - r.left ) / 4 - 340 ) / 3;
  917.     rect.bottom = 420 + 2 * ( r.bottom - r.top - 450 ) / 3;
  918.  
  919.     // draw gradient button
  920.  
  921.     FillButton( MemDC, rect, BlueFrame );
  922.  
  923.     //======================== draw orange panel =================//
  924.        
  925.     //position it properly
  926.  
  927.     rect.left = 3 * ( r.right - r.left ) / 4 - 40;
  928.     rect.top = r.top + 140;
  929.     rect.right = rect.left + ( r.right - r.left ) / 4;
  930.     rect.bottom = rect.top + ( r.bottom - r.top - 190 );
  931.  
  932.     drawOrangePanel( MemDC, rect, RGB( 0xFF, 0xC8, 0xAA ), RGB( 0xFF, 0x96, 0x48 ) );
  933.  
  934.     // draw all the text
  935.  
  936.     drawStrings( MemDC, r );
  937.  
  938.     // draw all the bitmaps and EMF files
  939.  
  940.     drawImages( hdc, MemDC, r );
  941.  
  942.     /****************** draw back buffer on the screen DC *****************/
  943.  
  944.     BitBlt( hdc, 0, 0, r.right - r.left, r.bottom - r.top, MemDC, 0, 0, SRCCOPY );
  945.  
  946.     /************** cleanup *******************/
  947.  
  948.     SelectObject( MemDC, oldBmp );
  949.  
  950.     DeleteObject(bmp); // compatible bitmap for MemDC
  951.  
  952.     DeleteDC(MemDC);
  953.  
  954.     EndPaint( hwnd, &ps);
  955. }
  956.  
  957. // WinMain's procedure
  958.  
  959. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  960. {
  961.     switch(msg)
  962.     {
  963.     case WM_CREATE:
  964.         {
  965.             image = Image::FromFile(L".\\resources\\BG.png"), // upper left logo
  966.             image1 = Image::FromFile(L".\\resources\\RGF.png"); // upper right logo
  967.             btn5 = Image::FromFile(L".\\resources\\BTN5.emf"); // map in the bottom of the orange button
  968.  
  969.             // load gray background brush for the top banner
  970.  
  971.             hbPozadina = CreateSolidBrush( RGB( 230, 230, 230 ) );
  972.  
  973.             // load left icon in the status bar
  974.  
  975.             hiAdmin = LoadIcon( hInst, MAKEINTRESOURCE(IDI_ICON2) );
  976.  
  977.             // bitmaps for static controls
  978.  
  979.             bmpBTN1 = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP1) );
  980.  
  981.             bmpBTN2 = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP10) );
  982.  
  983.             /** these two bitmaps make one image for the bottom right blue static control **/
  984.  
  985.             bmpBTN3 = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP3) );
  986.  
  987.             bmpBTN3a = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP5) );
  988.  
  989.             //**********************************************************************//
  990.  
  991.             bmpBTN4 = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP4) );
  992.  
  993.             bmpSimbol = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP16) );
  994.  
  995.             bmpInfo = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP6) );
  996.  
  997.             bmpLink = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP7) );
  998.  
  999.             bmpHelp = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_BITMAP8) );
  1000.  
  1001.             //******** brushes ***********//
  1002.  
  1003.             // brush for orange panel that holds 3 static controls and a map
  1004.  
  1005.             hbr = CreateSolidBrush( RGB( 255, 163, 94 ) );
  1006.  
  1007.             // blue frame for blue static controls
  1008.  
  1009.             BlueFrame = CreateSolidBrush( RGB(79, 129, 189) );
  1010.  
  1011.             /*******************************************/
  1012.            
  1013.             // get rectangle dimensions of the main window
  1014.  
  1015.             RECT rec;
  1016.  
  1017.             GetClientRect( hwnd, &rec );
  1018.  
  1019.             /******* main window's static controls ******/
  1020.  
  1021.             // top left
  1022.  
  1023.             HWND hsUnosPodataka = CreateWindowEx( 0, L"Static",
  1024.                 L"", WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1025.                 ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1026.                 120 + ( rec.bottom - rec.top - 450 ) / 3,
  1027.                 150, 150, hwnd, (HMENU)4000, hInst, 0);
  1028.  
  1029.             // top right
  1030.  
  1031.             HWND hsPregledPodataka = CreateWindowEx( 0, L"Static", L"",
  1032.                 WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1033.                 150 + 2 * ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1034.                 120 + ( rec.bottom - rec.top - 450 ) / 3,
  1035.                 150, 150, hwnd, (HMENU)4001, hInst, 0);
  1036.  
  1037.             // bottom left
  1038.  
  1039.             HWND hsIzvestaj = CreateWindowEx(0, L"Static", L"",
  1040.                 WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1041.                 ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1042.                 270 + 2 * ( rec.bottom - rec.top - 450 ) / 3,
  1043.                 150, 150, hwnd, (HMENU)4002, hInst, 0);
  1044.  
  1045.             // bottom right
  1046.  
  1047.             HWND hsPretraga = CreateWindowEx(0, L"Static", L"",
  1048.                 WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1049.                 150 + 2 * ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1050.                 270 + 2 * ( rec.bottom - rec.top - 450 ) / 3,
  1051.                 150, 150, hwnd, (HMENU)4003, hInst, 0);
  1052.            
  1053.             //============= static controls on the orange panel ==============//
  1054.  
  1055.             // first one from the top
  1056.  
  1057.             HWND hsInfoInfo = CreateWindowEx(0, L"Static",
  1058.                 L"", WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1059.                 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 150,
  1060.                 ( rec.right - rec.left ) / 4 - 20, 30, hwnd, (HMENU)4007, hInst, 0);
  1061.  
  1062.             // second one from the top
  1063.  
  1064.             HWND hsInfoHelp = CreateWindowEx(0, L"Static",
  1065.                 L"", WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1066.                 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 190,
  1067.                 ( rec.right - rec.left ) / 4 - 20, 30, hwnd, (HMENU)4009, hInst, 0);
  1068.            
  1069.             // third one from the top
  1070.  
  1071.             HWND hsInfoLink = CreateWindowEx(0, L"Static",
  1072.                 L"", WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1073.                 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 230,
  1074.                 ( rec.right - rec.left ) / 4 - 20, 30, hwnd, (HMENU)4008, hInst, 0);
  1075.  
  1076.             // fourth one-it will contain a map
  1077.  
  1078.             HWND hsInfoKarta = CreateWindowEx(0, L"Static",
  1079.                 L"", WS_VISIBLE | WS_CHILD | SS_NOTIFY,
  1080.                 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 270,
  1081.                 ( rec.right - rec.left ) / 4 - 20, rec.bottom - rec.top - 330,
  1082.                 hwnd, (HMENU)4010, hInst, 0);
  1083.  
  1084.         }
  1085.         return (LRESULT)0;
  1086.  
  1087.     case WM_COMMAND:
  1088.  
  1089.         // just beep when user clicks on static control
  1090.  
  1091.         switch( LOWORD(wParam) )
  1092.         {
  1093.         case 4000:
  1094.         case 4001:
  1095.         case 4002:
  1096.         case 4003:
  1097.         case 4007:
  1098.         case 4008:
  1099.         case 4009:
  1100.         case 4010:
  1101.             MessageBeep(MB_ICONEXCLAMATION);
  1102.             break;
  1103.  
  1104.         default:
  1105.             return DefWindowProc(hwnd, msg, wParam, lParam);
  1106.         }
  1107.         break;
  1108.  
  1109.     case WM_ERASEBKGND:
  1110.         return (LRESULT)1; // so we avoid flicker ( all painting is in WM_PAINT )
  1111.  
  1112.     case WM_PAINT:
  1113.         {
  1114.             // paint the picture
  1115.  
  1116.             onPaint( hwnd, wParam, lParam );
  1117.         }
  1118.         return (LRESULT)0;
  1119.  
  1120.     case WM_SIZE:
  1121.         {
  1122.             RECT rec;
  1123.  
  1124.             GetClientRect( hwnd, &rec );
  1125.  
  1126.             SetWindowPos( GetDlgItem( hwnd, 4000 ), NULL, ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1127.                 120 + ( rec.bottom - rec.top - 450 ) / 3, 150, 150,
  1128.                 SWP_NOZORDER | SWP_NOCOPYBITS );
  1129.  
  1130.             SetWindowPos( GetDlgItem( hwnd, 4001 ), NULL, 150 + 2 * ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1131.                 120 + ( rec.bottom - rec.top - 450 ) / 3,
  1132.                 150, 150, SWP_NOZORDER | SWP_NOCOPYBITS);
  1133.  
  1134.             SetWindowPos( GetDlgItem( hwnd, 4002 ), NULL, ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1135.                 270 + 2 * ( rec.bottom - rec.top - 450 ) / 3,
  1136.                 150, 150, SWP_NOZORDER | SWP_NOCOPYBITS );
  1137.  
  1138.             SetWindowPos( GetDlgItem( hwnd, 4003 ), NULL, 150 + 2 * ( 3  * ( rec.right - rec.left ) / 4 - 340 ) / 3,
  1139.                 270 + 2 * ( rec.bottom - rec.top - 450 ) / 3,
  1140.                 150, 150, SWP_NOZORDER | SWP_NOCOPYBITS );
  1141.  
  1142.             SetWindowPos( GetDlgItem( hwnd, 4007 ), NULL, 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 150,
  1143.                 ( rec.right - rec.left ) / 4 - 20, 30, SWP_NOZORDER | SWP_NOCOPYBITS );
  1144.  
  1145.             SetWindowPos( GetDlgItem( hwnd, 4008 ), NULL, 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 190,
  1146.                 ( rec.right - rec.left ) / 4 - 20, 30, SWP_NOZORDER | SWP_NOCOPYBITS );
  1147.  
  1148.             SetWindowPos( GetDlgItem( hwnd, 4009 ), NULL, 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 230,
  1149.                 ( rec.right - rec.left ) / 4 - 20, 30, SWP_NOZORDER | SWP_NOCOPYBITS );
  1150.  
  1151.             SetWindowPos( GetDlgItem( hwnd, 4010 ), NULL, 3 * ( rec.right - rec.left ) / 4 - 30, rec.top + 270,
  1152.                 ( rec.right - rec.left ) / 4 - 20, rec.bottom - rec.top - 330,
  1153.                 SWP_NOZORDER | SWP_NOCOPYBITS );
  1154.  
  1155.             InvalidateRect( hwnd, NULL, FALSE );
  1156.         }
  1157.         return (LRESULT)0;
  1158.  
  1159.     case WM_CTLCOLORSTATIC:
  1160.         return (LRESULT)( (HBRUSH)GetStockObject(NULL_BRUSH) );
  1161.  
  1162.     case WM_CLOSE:
  1163.  
  1164.         // destroy bitmaps
  1165.  
  1166.         DeleteObject(bmpSimbol);
  1167.         DeleteObject(bmpBTN1);
  1168.         DeleteObject(bmpBTN2);
  1169.         DeleteObject(bmpBTN3);
  1170.         DeleteObject(bmpBTN4);
  1171.         DeleteObject(bmpInfo);
  1172.         DeleteObject(bmpLink);
  1173.         DeleteObject(bmpHelp);
  1174.  
  1175.         // destroy icons
  1176.  
  1177.         DestroyIcon(hIcon);
  1178.         DestroyIcon(hiAdmin);
  1179.  
  1180.         // destroy brushes
  1181.        
  1182.         DeleteObject(hbPozadina);
  1183.         DeleteObject(hbr);
  1184.         DeleteObject(BlueFrame);
  1185.  
  1186.         // delete Image objects
  1187.  
  1188.         delete image;
  1189.         delete image1;
  1190.         delete btn5;
  1191.  
  1192.         DestroyWindow(hwnd);
  1193.  
  1194.         return (LRESULT)0;
  1195.  
  1196.     case WM_DESTROY:
  1197.  
  1198.         PostQuitMessage(0);
  1199.  
  1200.         return (LRESULT)0;
  1201.  
  1202.     default:
  1203.         return DefWindowProc(hwnd, msg, wParam, lParam);
  1204.     }
  1205.     return 0;
  1206. }
  1207.  
  1208. // WinMain
  1209.  
  1210. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
  1211.                    int nCmdShow)
  1212. {
  1213.     // store hInstance in global variable for later use
  1214.  
  1215.     hInst = hInstance;
  1216.    
  1217.     // load main icon
  1218.  
  1219.     hIcon = LoadIcon( hInst, MAKEINTRESOURCE(IDI_ICON1));
  1220.  
  1221.     WNDCLASSEX wc;
  1222.     HWND hwnd;
  1223.     MSG Msg;
  1224.  
  1225.     /*********** variables for GDI+ initialization *****************/
  1226.  
  1227.     GdiplusStartupInput gdiplusStartupInput;
  1228.     ULONG_PTR           gdiplusToken;
  1229.  
  1230.     /************** Initialize GDI+. *************************/
  1231.  
  1232.     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
  1233.  
  1234.     /*************** finished GDI+ initialisation ********************/
  1235.  
  1236.     // initialize common controls
  1237.  
  1238.     INITCOMMONCONTROLSEX iccex;
  1239.     iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  1240.     iccex.dwICC = ICC_STANDARD_CLASSES ;
  1241.     InitCommonControlsEx(&iccex);
  1242.    
  1243.     // register main window class
  1244.  
  1245.     wc.cbSize = sizeof(WNDCLASSEX);
  1246.     wc.style = 0;
  1247.     wc.lpfnWndProc = WndProc;
  1248.     wc.cbClsExtra = 0;
  1249.     wc.cbWndExtra = 0;
  1250.     wc.hInstance = hInst;
  1251.     wc.hIcon = hIcon;
  1252.     wc.hCursor = LoadCursor( NULL, IDC_ARROW );
  1253.     wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
  1254.     wc.lpszMenuName = NULL;
  1255.     wc.lpszClassName = L"Main_Window";
  1256.     wc.hIconSm = hIcon;
  1257.  
  1258.     if(!RegisterClassEx(&wc))
  1259.     {
  1260.         MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION |
  1261.             MB_OK);
  1262.  
  1263.         return 0;
  1264.     }
  1265.  
  1266.     // create main window
  1267.  
  1268.     hwnd = CreateWindowEx( 0, // WS_EX_COMPOSITED "improved" drawing of the edges
  1269.         L"Main_Window",
  1270.         L"Геотермист",
  1271.         WS_OVERLAPPEDWINDOW,
  1272.         ( GetSystemMetrics(SM_CXMAXIMIZED) - 1020 ) / 2,
  1273.         ( GetSystemMetrics(SM_CYMAXIMIZED) - 600 ) / 2,
  1274.         1020, 600, NULL, NULL, hInstance, 0 );
  1275.  
  1276.     if(hwnd == NULL)
  1277.     {
  1278.         MessageBox(NULL, L"Window creation failed!", L"Error!", MB_ICONEXCLAMATION |
  1279.             MB_OK);
  1280.  
  1281.         return 0;
  1282.     }
  1283.  
  1284.     ShowWindow(hwnd, nCmdShow);
  1285.     UpdateWindow(hwnd);
  1286.  
  1287.     while(GetMessage(&Msg, NULL, 0, 0) > 0)
  1288.     {
  1289.         TranslateMessage(&Msg);
  1290.         DispatchMessage(&Msg);
  1291.     }
  1292.  
  1293.     // shutdownd GDI+
  1294.  
  1295.     GdiplusShutdown(gdiplusToken);
  1296.  
  1297.     return Msg.wParam;
  1298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement