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.