我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

野猪



性别: 保密 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 796
威望: 0
浮云: 1335
在线等级:
注册时间: 2006-01-05
最后登陆: 2008-06-29

5come5帮你背单词 [ cord /ko:d/ n. 细绳,弦 ]


VC++的定时器

就做一个界面
要用定时器
正常状态是一个波形(一张图)
点击一个键就是波形慢慢动(其实就是几张图在换~)


怎么用定时器弄图片?




[ 此帖被野猪在2008-05-02 00:07重新编辑 ]
顶端 Posted: 2008-05-01 23:56 | [楼 主]
yy1213



性别: 美女 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 511
威望: 0
浮云: 1149
在线等级:
注册时间: 2005-12-28
最后登陆: 2008-06-29

5come5帮你背单词 [ antique /æn'ti:k/ a. 古代的,古式的,旧式的;n. 古物,古董 ]


// Timer Functions
    UINT SetTimer(UINT nIDEvent, UINT nElapse,
        void (CALLBACK* lpfnTimer)(HWND, UINT, UINT, DWORD));
    BOOL KillTimer(int nIDEvent);
顶端 Posted: 2008-05-02 00:05 | [1 楼]
yy1213



性别: 美女 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 511
威望: 0
浮云: 1149
在线等级:
注册时间: 2005-12-28
最后登陆: 2008-06-29

5come5帮你背单词 [ residential // a. 居住的 ]


SetTimer(1,3000);//打开定时器1,时间3000ms,输入是两个的话默认响应函数是通过消息WM_TIMER
KillTimer(1);//关闭定时器1
//相应WM_TIMER函数
void CDialog1::OnTimer(UINT nIDEvent)
{
    // TODO: Add your message handler code here and/or call default
    if(nIDEvent==1)
                    {
                    KillTimer(1);//关闭定时器1
                    //添加定时器1处理
          SetTimer(1,3000);//再打开定时器1
                    }
    CDialog::OnTimer(nIDEvent);
}
顶端 Posted: 2008-05-02 00:14 | [2 楼]
stephenwang



性别: 帅哥 状态: 该用户目前不在线
等级: 人见人爱
家族: 考研俱乐部
发贴: 3812
威望: 0
浮云: 1815
在线等级:
注册时间: 2006-11-15
最后登陆: 2009-06-10

5come5帮你背单词 [ compound /'kompaund, kəm'paund/ n. 化合物,混合物;a. 复合的,合成的 ]


Quote:
引用第2楼yy1213于2008-05-02 00:14发表的 :
SetTimer(1,3000);//打开定时器1,时间3000ms,输入是两个的话默认响应函数是通过消息WM_TIMER
KillTimer(1);//关闭定时器1
//相应WM_TIMER函数
void CDialog1::OnTimer(UINT nIDEvent)
{
.......

哦 酱汁啊
 有点乱 ··
顶端 Posted: 2008-05-02 00:17 | [3 楼]
yy1213



性别: 美女 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 511
威望: 0
浮云: 1149
在线等级:
注册时间: 2005-12-28
最后登陆: 2008-06-29

5come5帮你背单词 [ handicap /'hændikæp/ n. 伤残,障碍,不利条件;vt. 妨碍 ]


Quote:
引用第3楼stephenwang于2008-05-02 00:17发表的  :

哦 酱汁啊
 有点乱 ··

将就一下!
看函数原型就知道怎么回事了!
顶端 Posted: 2008-05-02 09:44 | [4 楼]
野猪



性别: 保密 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 796
威望: 0
浮云: 1335
在线等级:
注册时间: 2006-01-05
最后登陆: 2008-06-29

5come5帮你背单词 [ melody /'melədi/ n. 曲调,旋律 ]


Quote:
// Wave.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include<math.h>
#include<TCHAR.h>
#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                                // current instance
TCHAR szTitle[]=_T("asd");                    // The title bar text
TCHAR szWindowClass[]=_T("asd");            // the main window class name
HWND hWnd;
// Forward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

VOID CALLBACK TimerProc(HWND hwnd,
    UINT uMsg,
    UINT_PTR idEvent,
    DWORD dwTime)
{
    RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
}


int APIENTRY _tWinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPTSTR    lpCmdLine,
                    int      nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.
    MSG msg;
    HACCEL hAccelTable;

    // Initialize global strings
    MyRegisterClass(hInstance);

    // Perform application initialization:
    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    SetTimer(hWnd, NULL, 25, TimerProc);

    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, NULL, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}



//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage are only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style            = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra        = 0;
    wcex.cbWndExtra        = 0;
    wcex.hInstance        = hInstance;
    wcex.hIcon            = NULL;
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName    = NULL;
    wcex.lpszClassName    = szWindowClass;
    wcex.hIconSm        = NULL;

    return RegisterClassEx(&wcex);
}

//
//  FUNCTION: InitInstance(HINSTANCE, int)
//
//  PURPOSE: Saves instance handle and creates main window
//
//  COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{

  hInst = hInstance; // Store instance handle in our global variable

  hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

  if (!hWnd)
  {
      return FALSE;
  }

  ShowWindow(hWnd, nCmdShow);
  UpdateWindow(hWnd);

  return TRUE;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND    - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY    - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        {
        DWORD count = GetTickCount();
        hdc = BeginPaint(hWnd, &ps);
        MoveToEx(hdc, 0, 100, NULL);
        for(int i=0;i<500;i+=2) {
            int h = 100 + 100 * sin((count + i) / 50.0);
            LineTo(hdc, i, h);
        }
        EndPaint(hWnd, &ps);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);
    switch (message)
    {
    case WM_INITDIALOG:
        return (INT_PTR)TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
        {
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        }
        break;
    }
    return (INT_PTR)FALSE;
}




我写unsigned int它说要改成unsigned long。。
改了它又说要改回来。。

应该怎么办
顶端 Posted: 2008-05-02 19:36 | [5 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.015849(s) query 5, Time now is:05-03 01:09, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号