| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 658 人关注过本帖
标题:关于VC++入门问题
取消只看楼主 加入收藏
lansd
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-6-5
收藏
 问题点数:0 回复次数:2 
关于VC++入门问题

请教各位大虾:
我刚刚学过C/C++
现在学用VC++
发现Windowns 编程对VC++很有帮助.所以现在也在学习.
等熟练掌握了以上2个方面的知识接下来打算做些实际性的东西,比如一些小工程项目的.
不知道大虾门有没更好的心得体会和建议,望不吝赐教,本人感激不尽~!

搜索更多相关主题的帖子: 入门 
2006-06-05 15:11
lansd
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-6-5
收藏
得分:0 
请高手指点,根据教程编写的程序怎么实现不了预期结果?????/
请高手帮忙看下,我利用教程中的程序编写要实现对光标与图标的调用,结果只出现Windows的一个框架而已
比如其中填充WNDCLASSEX 结构体内的相应域。使用API 函数LoadIcon( )LoadCursor( )
wcl.hIcon = LoadIcon(hThisInst,″MyIcon″);/*standard icon */
wcl.hIconSm = NULL;/*use small icon in MyIcon */
wcl.hCursor = LoadCursor(hThisInst,″MyCursor″);/*load cursor */
但并没有实现该结果.
另外:
HDC DC, memDC;
switch(message)
{
case WM_CREATE: /* load the bitmap */
hBit1 = LoadBitmap(hInst, "MyBP1"); /* load bitmap */
break;
case WM_LBUTTONDOWN:
DC = GetDC(hwnd); /* get device context */
memDC = CreateCompatibleDC(DC); /* create compatible DC */
SelectObject(memDC,hBit1);
BitBlt(DC,LOWORD(lParam),HIWORD(lParam),64,64,
memDC,0,0,SRCCOPY);/*display image */
ReleaseDC(hwnd,DC);/* free the device context */
DeleteDC(memDC);/* free the memory context */
break;
也并没有在我点击鼠标左键(WM_LBUTTONDOWN)的时候绘显示我的图片"MyBP1"
请问这是为什么啊?
恳盼哪位给以指点,不胜感激~~~~~~~

2006-06-14 15:49
lansd
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-6-5
收藏
得分:0 

源程序:
#include <windows.h>
#include <string.h>
#include <stdio.h>

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

char szWinName[ ] = "MyWin"; /* name of window class */
HBITMAP hBit1; /* handle of bitmap */
HINSTANCE hInst; /* handle to this instance */

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;

/* Define a window class. */
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.hInstance = hThisInst; /* handle to this instance*/
wcl.lpszClassName = szWinName; /* window class name */
wcl.lpfnWndProc = WindowFunc; /* window function */
wcl.style = 0; /* default style */
wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* standard icon */
wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); /* small icon */
wcl.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor style */
wcl.lpszMenuName = NULL; /* no menu */
wcl.cbClsExtra = 0; /* no extra */
wcl.cbWndExtra = 0; /* information needed */

/* Make the window white. */
wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

/* Register the window class. */
if(!RegisterClassEx(&wcl)) return 0;
hInst = hThisInst; /* save instance handle */

/* Now that a window class has been registered, a window
can be created. */
hwnd = CreateWindow(
szWinName, /* name of window class */
"Custom Bitmap", /* title */
WS_OVERLAPPEDWINDOW, /* window style - normal */
CW_USEDEFAULT, /* X coordinate - let Windows decide */
CW_USEDEFAULT, /* Y coordinate - let Windows decide */
CW_USEDEFAULT, /* width - let Windows decide */
CW_USEDEFAULT, /* height - let Windows decide */
HWND_DESKTOP, /* no parent window */
NULL, /* no override of class menu */
hThisInst, /* handle of this instance of the program */
NULL /* no additional arguments */
);

/* Display the window. */
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);

/* Create the message loop. */
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg); /* translate keyboard messages */
DispatchMessage(&msg); /* return control to Windows 98 */
}
return msg.wParam;
}

/* This function is called by Windows 98 and is passed
messages from the message queue.
*/
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC DC, memDC;
switch(message)
{
case WM_CREATE: /* load the bitmap */
hBit1 = LoadBitmap(hInst, "MyBP1"); /* load bitmap */
break;
case WM_LBUTTONDOWN:
DC = GetDC(hwnd); /* get device context */
memDC = CreateCompatibleDC(DC); /* create compatible DC */
SelectObject(memDC,hBit1);
BitBlt(DC,LOWORD(lParam),HIWORD(lParam),64,64,
memDC,0,0,SRCCOPY);/*display image */
ReleaseDC(hwnd,DC);/* free the device context */
DeleteDC(memDC);/* free the memory context */
break;
case WM_DESTROY:/*terminate the program */
DeleteObject(hBit1);/* remove the bitmap */
PostQuitMessage(0);
break;
default:
/* Let Windows 98 process any messages not specified in
the preceding switch statement. */
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}

2006-06-14 15:59
快速回复:关于VC++入门问题
数据加载中...
 
   



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

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