| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 422 人关注过本帖
标题:我所描绘的图像为什么会抖
只看楼主 加入收藏
q345918550q
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2010-3-28
结帖率:30%
收藏
 问题点数:0 回复次数:0 
我所描绘的图像为什么会抖
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
TCHAR lpszTitle[]=TEXT("MyDemo3");
wndclass.style =CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TEXT("MyClass");
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
if(!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("RegisterClass fail!"), TEXT("error"), MB_ICONERROR);
return 0;
}  
hwnd=CreateWindow(
TEXT("MyClass"),
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
  
while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}

LRESULT CALLBACK WndProc(HWND Hwnd, UINT message, WPARAM wParam, LPARAM iParam)
{
    HDC hdc;
    hdc=GetDC(Hwnd);
    HPEN  hPen,hhPen,hhhPen;
    hPen = CreatePen(PS_SOLID ,10,RGB(124,252,0));
    hhPen=CreatePen(PS_SOLID ,10,RGB(250,128,114));
    hhhPen=CreatePen(PS_SOLID ,5,RGB(0,0,0));
    HBRUSH hBrush=CreateSolidBrush(RGB(34,139,34));
    HBRUSH hhBrush=CreateSolidBrush(RGB(255,69,0));
   
switch(message)
{
   
case WM_PAINT:
    hBrush=(HBRUSH)SelectObject(hdc,hBrush);
    hPen=(HPEN)SelectObject(hdc,hPen);
    RoundRect(hdc,1,1,100,600,1,20);
   

    hhBrush=(HBRUSH)SelectObject(hdc, hhBrush);
    hhPen=(HPEN)SelectObject(hdc,hhPen);
    RoundRect(hdc,800,1,300,600,1,20);
   
    hhhPen=(HPEN)SelectObject(hdc,hhhPen);
    MoveToEx(hdc,300,0,NULL);
    LineTo(hdc,800,0);

    MoveToEx(hdc,300,100,NULL);
    LineTo(hdc,800,100);

    MoveToEx(hdc,300,200,NULL);
    LineTo(hdc,800,200);

    MoveToEx(hdc,300,300,NULL);
    LineTo(hdc,800,300);

    MoveToEx(hdc,300,400,NULL);
    LineTo(hdc,800,400);

    MoveToEx(hdc,300,500,NULL);
    LineTo(hdc,800,500);

    MoveToEx(hdc,300,600,NULL);
    LineTo(hdc,800,600);


    MoveToEx(hdc,300,0,NULL);
    LineTo(hdc,300,600);

    MoveToEx(hdc,400,0,NULL);
    LineTo(hdc,400,600);

    MoveToEx(hdc,500,0,NULL);
    LineTo(hdc,500,600);

    MoveToEx(hdc,600,0,NULL);
    LineTo(hdc,600,600);

    MoveToEx(hdc,700,0,NULL);
    LineTo(hdc,700,600);

    MoveToEx(hdc,800,0,NULL);
    LineTo(hdc,800,600);

    SelectObject(hdc,hPen);
    DeleteObject(hPen);
    SelectObject(hdc,hhPen);
    DeleteObject(hhPen);
    SelectObject(hdc,hhhPen);
    DeleteObject(hhhPen);

    SelectObject(hdc,hBrush);
    DeleteObject(hBrush);
    SelectObject(hdc,hhBrush);
    DeleteObject(hhBrush);
    ReleaseDC(Hwnd,hdc);
return 0;


case WM_LBUTTONDOWN:               
        PostQuitMessage(0);         
        return 0;
}

return DefWindowProc(Hwnd, message, wParam, iParam);
}


请问什么会抖,而且最后有些图像会消失?(还有:那个让最大化会失效的代码wndclass.style =xxxx,那xxxx怎么写)
搜索更多相关主题的帖子: 图像 描绘 
2010-05-19 19:50
快速回复:我所描绘的图像为什么会抖
数据加载中...
 
   



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

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