| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 667 人关注过本帖
标题:win32API中如何更改光标设置
只看楼主 加入收藏
洪溪
Rank: 2
等 级:论坛游民
帖 子:42
专家分:34
注 册:2010-9-7
结帖率:100%
收藏
 问题点数:0 回复次数:2 
win32API中如何更改光标设置
在win32API 中如何设置更改光标呀!我的头真的要炸了,,烦好心人帮帮忙啊!感激不尽!!

下面程序想要达到:当按下改变光标按钮时,光标改变;
#include <windows.h>
#include <stdio.h>
//HINSTANCE hInstance;

LRESULT CALLBACK WndProc(HWND ,UINT,WPARAM,LPARAM);
   
    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
        LPSTR lpCmdLine,int nCmdShow)
    {
        HWND hwnd;
        MSG msg;
        WNDCLASS wndclass;
        wndclass.style=CS_HREDRAW |CS_VREDRAW;
        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.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        wndclass.lpszMenuName = NULL;
        wndclass.lpszClassName ="六一";
        if(!RegisterClass(&wndclass))
        {
            MessageBox(NULL,"窗口注册失败","六一",MB_ABORTRETRYIGNORE);
            return 0;
        }
        
        hwnd = CreateWindow("六一",
            "有意思",
            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 lParam)
{
    HDC hdc;   
    PAINTSTRUCT ps;
    static HWND hButton,hwndEdit,hButton1;
    HCURSOR hcousor;
    char strEdit[80];
    int x,y;
    switch (message)
    {
    case WM_CREATE:
        hButton = CreateWindow("button","读取",WS_CHILD | WS_VISIBLE|BS_PUSHBUTTON,
            420,200,80,25,hwnd,NULL,NULL,NULL);
        hwndEdit = CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,
            100,100,150,80,hwnd,NULL,NULL,NULL);
        hButton1 = CreateWindow("button","改变光标",WS_CHILD | WS_VISIBLE|BS_PUSHBUTTON,
            300,200,80,25,hwnd,NULL,NULL,NULL);        
        return 0;
    case WM_COMMAND:
        if (((HWND)lParam==hButton)&&(HIWORD(wParam)==BN_CLICKED))
        {
            GetWindowText(hwndEdit,strEdit,20);
            MessageBox(NULL,strEdit,"攻取",MB_COMPOSITE);            
        }
        return 0;
        
    case WM_PAINT:
        hdc = BeginPaint(hwnd,&ps);
        TextOut(hdc,320,110,"请输入",9);TextOut(hdc,x,y,"jfeof",10);
        EndPaint(hwnd,&ps);
        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
        
    }
    return DefWindowProc(hwnd,message,wParam,lParam);
}

[ 本帖最后由 洪溪 于 2011-3-27 21:29 编辑 ]
搜索更多相关主题的帖子: include 如何 
2011-03-27 21:21
洪溪
Rank: 2
等 级:论坛游民
帖 子:42
专家分:34
注 册:2010-9-7
收藏
得分:0 
大仙们在哪啊??

case WM_LBUTTONDBLCLK:
        x = LOWORD(lParam);
        y =HIWORD(lParam);
        hdc = GetDC(hwnd);
        TextOut(hdc,x,y,"fiewo",10);
        return 0;

加上的这个消息为什么没有响应呢?郁闷啦!!

[ 本帖最后由 洪溪 于 2011-3-28 11:02 编辑 ]
2011-03-28 10:49
洪溪
Rank: 2
等 级:论坛游民
帖 子:42
专家分:34
注 册:2010-9-7
收藏
得分:0 
12
2011-03-29 16:17
快速回复:win32API中如何更改光标设置
数据加载中...
 
   



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

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