Strange effect on scrollbars

This is a discussion on Strange effect on scrollbars within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I have been trying to use scrollbars on my app, but I have seen that there's a strange effect ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287

    Strange effect on scrollbars

    Hello, I have been trying to use scrollbars on my app, but I have seen that there's a strange effect depending the size of the scrollbar. That is the sample:

    Code:
    #include <windows.h>
    #define BSX 1000
    
    LRESULT CALLBACK procedimentPrincipal (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    SCROLLINFO si;
    HINSTANCE hInstance=(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE);
    switch (msg)
        {
        case WM_CREATE:
            {
            CreateWindowEx(0,"SCROLLBAR","",WS_CHILD|WS_VISIBLE|SBS_HORZ,10,10,200,50,hwnd,(HMENU)BSX,hInstance,NULL);
            memset(&si,0,sizeof(si));
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_POS|SIF_RANGE|SIF_PAGE;
            si.nMin=0;
            si.nMax=100;
            si.nPage=0;
            si.nPos=50;
            si.nTrackPos=50;
            SetScrollInfo(GetDlgItem(hwnd,BSX),SB_HORZ,&si,TRUE);
            }
        break;
        case WM_LBUTTONDOWN:
            {
            memset(&si,0,sizeof(si));
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_POS;
            si.nPos=80;
            si.nTrackPos=80;
            SetScrollInfo(GetDlgItem(hwnd,BSX),SB_HORZ,&si,TRUE);
            }
        break;
    	case WM_DESTROY: {PostQuitMessage(0);} break;
        default: return DefWindowProc (hwnd, msg, wParam, lParam);
        }
    return 0;
    }
    
    int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int ncs)
    {
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wc;
    
    wc.hInstance = hInstance;
    wc.lpszClassName = "exbarrascroll";
    wc.lpfnWndProc = procedimentPrincipal;
    wc.style = CS_DBLCLKS;
    wc.cbSize = sizeof (WNDCLASSEX);
    wc.hIcon = LoadIcon(hInstance,"icona");
    wc.hIconSm = LoadIcon(hInstance,"icona");
    wc.hCursor = LoadCursor (NULL,IDC_ARROW);
    wc.lpszMenuName = NULL;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hbrBackground = CreateSolidBrush(RGB(255,255,255));
    
    if(!RegisterClassEx(&wc)) return 0;
    hwnd=CreateWindowEx(0,"exbarrascroll","",WS_OVERLAPPEDWINDOW,0,0,640,480,HWND_DESKTOP,NULL,hInstance,NULL);
    
    ShowWindow(hwnd,SW_SHOWDEFAULT);
    UpdateWindow(hwnd);
    
    while(TRUE==GetMessage(&msg,NULL,0,0))
        {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
        }
    return msg.wParam;
    }
    I'm using DevCpp with the default MingW compiler. The result is a strange scrollbar, with 2 sets of scrollbars (2 sets of arrows, thumbs, etc), one bigger than the other.
    but there's another strange effect, if I create the scrollbar width only 15px high, the second scroll set is not drawed but I cannot set the track position.

    How should I solve that?

    Thank's in advance
    Niara
    Last edited by Niara; 09-26-2006 at 01:47 AM.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Ok, the problem is partialy solved: I have created my own scrollbar window class, it's not fully working but for the moment is a good aproach.

    Niara

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 11:21 AM
  2. Very strange bug...
    By JaWiB in forum Tech Board
    Replies: 6
    Last Post: 04-27-2003, 02:56 PM
  3. Scrollbars
    By SOS in forum Windows Programming
    Replies: 2
    Last Post: 08-16-2002, 05:21 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. bcc32 compiling error (really strange!!)
    By jester in forum C++ Programming
    Replies: 14
    Last Post: 01-26-2002, 04:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21