Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scroll bar and text displaying

Status
Not open for further replies.

DeCoDeR

Programmer
Jun 4, 2002
37
0
0
US
hi,
i try to display the content of a text file in my application ( mo mfc, just win32 apis)
first i read all the contents of a file to a char array.
when it is time to display it, i failed.
i can display only the contents that fits the window.
can anyone show me an example how to handle WM_PAINT message and display the rest ?
i do the scroll messages by looking at examples like below :
---------
case WM_SIZE:
cxClient = LOWORD(wParam);
cyClient = HIWORD(wParam);
//vertical
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE|SIF_RANGE;
si.nPage = cyClient / icyChar;
si.nMin = 0;
si.nMax = ilen-1;
SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
//next is horizantal
si.nPage = cxClient / icxChar;
si.nMin =0;
si.nMax = 50 * icxChar;
SetScrollInfo(hwnd,SB_HORZ,&si,TRUE);
return 0;

case WM_VSCROLL:
//get old vpos
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
GetScrollInfo(hwnd,SB_VERT,&si);
ivPos = si.nPos ;

switch(LOWORD(wParam))
{
case SB_TOP :
si.nPos = si.nMin ;
break;
case SB_BOTTOM:
si.nPos = si.nMax ;
break;
case SB_LINEUP:
si.nPos --;
break;
case SB_LINEDOWN:
si.nPos ++;
break;
case SB_PAGEDOWN:
si.nPos += si.nPage ;
break;
case SB_PAGEUP:
si.nPos -= si.nPage ;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos ;
break;
default:
break;
}
si.fMask = SIF_POS;
SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
GetScrollInfo(hwnd,SB_VERT,&si);

if(si.nPos != ivPos)
{
ScrollWindow(hwnd,0,(ivPos-si.nPos )*icyChar,NULL,NULL);
UpdateWindow(hwnd);
}

return 0;

case WM_HSCROLL:
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
GetScrollInfo(hwnd,SB_HORZ,&si);
ihPos = si.nPos ;

switch(LOWORD(wParam))
{
case SB_LINELEFT:
si.nPos --;
break;
case SB_LINERIGHT:
si.nPos ++;
break;
case SB_PAGELEFT:
si.nPos -= si.nPage ;
break;
case SB_PAGERIGHT:
si.nPos += si.nPage;
break;
case SB_THUMBPOSITION:
si.nPos = si.nTrackPos ;
break;
default:
break;
}
SetScrollInfo(hwnd,SB_HORZ,&si,TRUE);
GetScrollInfo(hwnd,SB_HORZ,&si);

if(si.nPos != ihPos)
{
ScrollWindow(hwnd,(ihPos-si.nPos)*icxChar,0,NULL,NULL);
UpdateWindow(hwnd);
}
return 0;

Read between the lines
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top