private void timer_Tick( object sender, EventArgs e)
{
TimeSpan timeSpan = DateTime .Now.Date.AddDays(1) - DateTime .Now;
labelHours.Text = string .Format( "{0} of 24 hours left" , timeSpan.Hours);
labelMinutes.Text = string .Format( "{0} of 60 minutes left" , timeSpan.Minutes);
labelSeconds.Text = string .Format( "{0} of 60 seconds left" , timeSpan.Seconds);
labelTotalMinutes.Text = string .Format( "{0} of 1440 total minutes left" ,
timeSpan.TotalMinutes.ToString( "#.0" ));
labelTotalSeconds.Text = string .Format( "{0} of 86400 total seconds left" ,
timeSpan.TotalSeconds);
progressBarTotal.Value = 86400 - ( int ) timeSpan.TotalSeconds;
progressBarHours.Value = 24 - timeSpan.Hours;
progressBarMinutes.Value = 60 - timeSpan.Minutes;
progressBarSeconds.Value = 60 - timeSpan.Seconds;
progressBarTotalMinutes.Value = 1440 - ( int ) timeSpan.TotalMinutes;
progressBarTotalSeconds.Value = 86400 - ( int ) timeSpan.TotalSeconds;
}
* This source code was highlighted with Source Code Highlighter .
DialogBox (hInstance, (LPCSTR) IDD_MYDIALOG, NULL, MyDialogProc);
INT_PTR CALLBACK MyDialogProc(HWND hDlg,
UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
// this is similar to the Load event so we
// can perform dialog initialisation code here
break ;
case WM_CLOSE:
// this is similar to the Close event so we
// can perform dialog shutdown logic here
break ;
...
}
}
* This source code was highlighted with Source Code Highlighter .
// Get the window handle for the control
// with an ID of IDC_MESSAGE
HWND hwndCtrl = GetDlgItem(hWnd, IDC_MESSAGE);
* This source code was highlighted with Source Code Highlighter .
// Change the label to display "Hello World"
SetWindowText(hwndCtrl, L "Hello World" );
* This source code was highlighted with Source Code Highlighter .
// Set the progress bar referenced by 'hWndCtrl'
// to have the range 25 to 75
SendMessage(hWndCtrl, PBM_SETRANGE, 0, MAKELPARAM(25, 75));
* This source code was highlighted with Source Code Highlighter .
// Set the progress bar referenced by 'hWndCtrl'
// to the value 45
SendMessage(hwndCtrl, PBM_SETPOS, 45, 0);
* This source code was highlighted with Source Code Highlighter .
// Create a timer with ID 1234 and
// an interval of 1000 milliseconds (1 second)
SetTimer(hWnd, 1234, 1000, NULL);
* This source code was highlighted with Source Code Highlighter .
// Stop the timer with ID 1234
KillTimer(hWnd, 1234);
* This source code was highlighted with Source Code Highlighter .
case WM_TIMER:
if (wParam == 1234)
{
// timer 1234's interval has occurred so
// we can do something here...
}
break ;
* This source code was highlighted with Source Code Highlighter .
// Define a rectangle at x=40, y=10 with size 40x10
RECT rcBounds;
rcBounds.top = 10;
rcBounds.bottom = 20;
rcBounds.left = 40;
rcBounds.right = 80;
// Create a red brush and fill the
// area of the rectangle
HBRUSH hbrRed = CreateSolidBrush(RGB(255, 0, 0));
FillRect(hdc, &rcBounds, hbrRed);
DeleteObject(hbrRed);
* This source code was highlighted with Source Code Highlighter .
__int64 amount_of_today_past = current_time % ONE_DAY;
__int64 amount_of_today_left = ONE_DAY - amount_of_today_past;
* This source code was highlighted with Source Code Highlighter .
__int64 minutes = (amount_of_today_left / ONE_MINUTE) % 60
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/61248/