Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VLC like seek bar

Featured Replies

Posted

Anyone know how to make a VLC like seek bar in plain Win32 C without using QT or MFC?

Or skinning a slider control to like it.

Edited by LulzCoder

What's wrong with the slider control?

Greetings

Without QT or MFC? That questions is pretty strange. Why wouldn't you use MFC as all normal people?! Try other window UI frameworks. There are planty of them for C.


Why wouldn't you use MFC as all normal people?!

Damn, I thought I was normal...

@dn5: I guess he is not using MFC because it's classes are pretty ugly to use[infact for me], needs more dependency.

@exodia: Using slider control as a seek bar is not a good idea, because slider control is not precise with clicks. As in a normal seek bar if we click then bar[thumb] directly jumps there, but in a standard slider control when we click the thumb goes only to the next tick.

I just played with a dialog app/ The dialog only contains a slider control, named IDC_SLIDER1.


 


The client are of the slider is 20 pixels wider than the horizontal track draw in it. As a consequence, the range of motion is the width of the slider - 20 pixels.


This also means that the smallest value of the slider will occur when the 10 pixels to the right of the control's left edge. That's why the hard-coded values of 10 and 20 have been chosen. Obviously, they shouldn't be hard-coded..


 


 




#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "resource.h"
HINSTANCE hInst;
int sliderWidth;
long oldProc;
LRESULT CALLBACK sliderWindowProc(HWND hwndSlider, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_LBUTTONDOWN:
            PostMessage(hwndSlider, TBM_SETPOS, true, LOWORD(lParam-10));
            return 0;
        case WM_MOUSEMOVE:
                if (wParam & MK_LBUTTON)
                {
                    PostMessage(hwndSlider, TBM_SETPOS, true, LOWORD(lParam-10));
                    return 0;
                }
    }
    return CallWindowProc( (WNDPROC)oldProc, hwndSlider, uMsg, wParam, lParam);
}
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    RECT mRect;
    HWND slider;
    switch(uMsg)
    {
    case WM_INITDIALOG:
    {
            slider = GetDlgItem(hwndDlg, IDC_SLIDER1);
            oldProc = GetWindowLong(slider, GWL_WNDPROC);
            SetWindowLong(slider, GWL_WNDPROC, (long)sliderWindowProc);
            GetClientRect( GetDlgItem(hwndDlg, IDC_SLIDER1), &mRect);
            sliderWidth = (mRect.right - mRect.left) - 20;
            printf("Slider Width (pixels): %d\n", sliderWidth);
            SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETRANGE, true, MAKELONG(0,sliderWidth));
  //          SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETPAGESIZE, 0, 1);
            SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETTICFREQ, 1, 0);
    }
    return TRUE;
    case WM_CLOSE:
    {
        EndDialog(hwndDlg, 0);
    }
    return TRUE;
    case WM_COMMAND:
    {
        switch(LOWORD(wParam))
        {
        }
    }
    return TRUE;
    }
    return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    hInst=hInstance;
    InitCommonControls();
    return DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DlgMain);
}


 


Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.