| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 347 人关注过本帖
标题:我写的滚动列怎么跳回来了。
只看楼主 加入收藏
々NARUTO
Rank: 2
等 级:论坛游民
帖 子:80
专家分:85
注 册:2011-6-19
结帖率:77.78%
收藏
 问题点数:0 回复次数:1 
我写的滚动列怎么跳回来了。
#include <WINDOWS.H>
#define NUMILNES 1000
LRESULT CALLBACK myproc(
                        HWND hwnd,      // handle to window
                        UINT uMsg,      // message identifier
                        WPARAM wParam,  // first message parameter
                        LPARAM lParam   // second message parameter
                        );
int WINAPI WinMain(
                   HINSTANCE hInstance,      // handle to current instance
                   HINSTANCE hPrevInstance,  // handle to previous instance
                   LPSTR lpCmdLine,          // command line
                   int nCmdShow              // show state
                   ){
    WNDCLASS wndclass;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hbrBackground=HBRUSH(COLOR_WINDOWTEXT);
    wndclass.hCursor=LoadCursor(hInstance,IDC_CROSS);
    wndclass.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndclass.hInstance=hInstance;
    wndclass.lpfnWndProc=myproc;
    wndclass.lpszClassName="winclass";
    wndclass.lpszMenuName="NULL";
    wndclass.style=CS_VREDRAW|CS_HREDRAW;
    RegisterClass(&wndclass);
    HWND hwnd=CreateWindow("winclass","myfirst",WS_OVERLAPPEDWINDOW|WS_VSCROLL,0,0,500,500,NULL,NULL,hInstance,NULL);
    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);
    MSG msg;
    while (GetMessage(&msg,NULL,NULL,NULL))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
LRESULT CALLBACK myproc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){
    HDC hdc,hDC;
    PAINTSTRUCT ps;
    int ipos;
    switch(uMsg){
    case WM_PAINT:
        int i;
        int x,y;
        CHAR xyz[40];
        TEXTMETRIC tx;
        hdc=BeginPaint(hwnd,&ps);
        TextOut(hdc,0,0,"hello.",strlen("hello."));
        i=GetTextMetrics(hdc,&tx);
        x=tx.tmAveCharWidth ;
        y=tx.tmHeight + tx.tmExternalLeading ;
        TextOut(hdc,0,17,xyz,wsprintf(xyz,"字体的宽是:%d,字体的高是:%d",x,y));
        EndPaint(hwnd,&ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    case WM_SIZE:
        int xi,yi;
        char xyi[40];
        hDC=GetDC(hwnd);
        xi=LOWORD(lParam);
        yi=HIWORD(lParam);        
        ReleaseDC(hwnd,hDC);
        break;
    case WM_CREATE:
        SetScrollRange(hwnd,SB_VERT,0,NUMILNES-1,FALSE);
        SetScrollPos(hwnd,SB_VERT,ipos,TRUE);
        break;        
    case WM_VSCROLL:
        switch(LOWORD(wParam)){
        case SB_LINEUP:
            ipos=-1;
            break;
        case SB_LINEDOWN:
            ipos=+1;
            break;
        case SB_PAGEUP:
            ipos -= yi / y ;
            break ;
            
        case SB_PAGEDOWN:
            ipos += yi/ y ;
            break ;
        case SB_THUMBTRACK:
            ipos=HIWORD(wParam);
            break;
        default:
            break;
        }
        default:
            return DefWindowProc(hwnd,uMsg,wParam,lParam);}
    return 0;}
我处理了SB_THUMBTRACK:消息啊。

[ 本帖最后由 々NARUTO 于 2011-12-27 15:34 编辑 ]
搜索更多相关主题的帖子: message current include window second 
2011-12-27 15:29
々NARUTO
Rank: 2
等 级:论坛游民
帖 子:80
专家分:85
注 册:2011-6-19
收藏
得分:0 
怎么一个人都没有
2011-12-27 17:46
快速回复:我写的滚动列怎么跳回来了。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032051 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved