windows程序设计源代码(windows开源代码)
admin 发布:2022-12-19 21:59 98
本篇文章给大家谈谈windows程序设计源代码,以及windows开源代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
求个用c/c++编写windows程序源代码
下面是完整程序,MS VC++ 6.0 编译器。
主要用途,用鼠标点击调节 RGB 数值,椭圆里显示 对应的颜色。
程序里有多余的码,你可以删去。(一个多余是试验鼠标移动时连续显示坐标数值,还有一个多余部分是调用Vfw32.lib播放一个avi视频。)
// cl show_color.cpp
#include Afxwin.h
#include math.h
// #include Vfw.h
// #pragma comment (lib, "Vfw32.lib")
#define DEBUG 1
HWND hWndMain;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
char one_line[80];
int len,NN;
LPTSTR argv;
RECT RectR, RectG, RectB, RectX;
int RectDy,RectW,RectH;
int x_r=495,x_g=495,x_b=495,x_shift=100;
long int v_r,v_g,v_b;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
MSG Msg;
int i;
RectDy = 50; RectW = 400; RectH = 30;
RectR.left = 0; RectR.right=RectW; RectR.bottom=200; RectR.top = RectR.bottom + RectH;
RectG.left = 0; RectB.left = 0;
RectG.right=RectW; RectB.right=RectW;
RectG.bottom=RectR.bottom + RectDy; RectB.bottom=RectG.bottom + RectDy;
RectG.top = RectG.bottom + RectH;
RectB.top = RectB.bottom + RectH;
v_r = (x_r - x_shift) * 255 / RectW;
v_g = (x_g - x_shift) * 255 / RectW;
v_b = (x_b - x_shift) * 255 / RectW;
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
ShowWindow(hWndMain,nCmdShow);
UpdateWindow(hWndMain);
while(GetMessage(Msg,NULL,0,0))
{
TranslateMessage(Msg);
DispatchMessage(Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
static long nXChar,nYChar,xInc,yInc;
static int xClient, yClient; // width height of client area
static int xClientMax; // maximum width of client area
static int xChar, yChar; // horizontal vertical scrolling unit
static int xPos,yPos; // current horizontal vertical scrolling position
static int xMax,yMax; // maximum horizontal scrolling position
SCROLLINFO si;
HDC hdc;
short x;
TEXTMETRIC tm;
PAINTSTRUCT ps;
COLORREF color;
HFONT font;
HPEN hP1; // pen
HBRUSH hBr,hBrR,hBrG,hBrB;
CPoint aP,mousePos;
HWND h_wnd2;
int i;
char szlocation[100]; //temp
CPoint pt,pt2; // temp
RECT rect,rect2;
switch(message)
{
case WM_LBUTTONDOWN: case WM_LBUTTONUP:
mousePos.x = LOWORD( lParam );
mousePos.y = HIWORD( lParam );
if (mousePos.x = RectR.left+x_shift mousePos.x = RectR.right+x_shift){
if (mousePos.y RectR.bottom mousePos.y RectR.top) x_r = mousePos.x;
if (mousePos.y RectG.bottom mousePos.y RectG.top) x_g = mousePos.x;
if (mousePos.y RectB.bottom mousePos.y RectB.top) x_b = mousePos.x;
v_r = (x_r - x_shift) * 255 / RectW;
v_g = (x_g - x_shift) * 255 / RectW;
v_b = (x_b - x_shift) * 255 / RectW;
ShowWindow(hwnd, SW_HIDE);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
};
return 0;
case WM_CREATE:
hdc=GetDC(hwnd);
GetTextMetrics(hdc,tm);
nXChar=tm.tmAveCharWidth;
nYChar=tm.tmHeight;
xInc=1;yInc=1; xChar=nXChar; yChar=nYChar; // for scroll window
ReleaseDC(hwnd,hdc);
xClientMax = 800;
// h_wnd2 = MCIWndCreate(hwnd,NULL,0,"sylvtwt.avi"); //Play
// MCIWndPlay(h_wnd2); // Play
return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,ps); // begin paint
SetGraphicsMode(hdc,GM_ADVANCED);
SetWindowExtEx(hdc,700,400,NULL); // cx=700,cy=400 logical unit
SetViewportExtEx(hdc,600,400,NULL);
SetViewportOrgEx(hdc,x_shift,10,NULL);
SetMapMode(hdc,MM_ANISOTROPIC);
color=RGB(0,128,128);
hP1=CreatePen(PS_SOLID,0,color);
SelectObject(hdc,hP1);
hBrR = CreateSolidBrush( RGB(255,0,0));
hBrG = CreateSolidBrush( RGB(0,255,0));
hBrB = CreateSolidBrush( RGB(0,0,255));
hBr = CreateSolidBrush( RGB(200,200,200));
SelectObject(hdc,hBrR);
FillRect(hdc, RectR, hBrR);
RectX=RectR; RectX.left=x_r-x_shift; SelectObject(hdc,hBr); FillRect(hdc, RectX, hBr);
SelectObject(hdc,hBrG);
FillRect(hdc, RectG, hBrG);
RectX=RectG; RectX.left=x_g-x_shift; SelectObject(hdc,hBr); FillRect(hdc, RectX, hBr);
SelectObject(hdc,hBrB);
FillRect(hdc, RectB, hBrB);
RectX=RectB; RectX.left=x_b-x_shift; SelectObject(hdc,hBr); FillRect(hdc, RectX, hBr);
font=CreateFont(
24,10,0,0, FW_NORMAL,0,0,0, ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,NULL,"myfont"
);
SelectObject(hdc,font);
GetTextMetrics(hdc,tm);
nYChar=tm.tmHeight;
color=RGB(0,0,0);
sprintf(one_line,"R=%3d",v_r);
TextOut(hdc,RectR.right+10,RectR.bottom,one_line,strlen(one_line));
sprintf(one_line,"G=%3d",v_g);
TextOut(hdc,RectG.right+10,RectG.bottom,one_line,strlen(one_line));
sprintf(one_line,"B=%3d",v_b);
TextOut(hdc,RectB.right+10,RectB.bottom,one_line,strlen(one_line));
color = RGB(v_r,v_g,v_b);
hBr = CreateSolidBrush(color);
SelectObject(hdc,hBr);
Ellipse(hdc, 100, 30, 326, 144);
EndPaint(hwnd,ps); // end paint
return 0L;
case WM_SIZE:
yClient = HIWORD (lParam);
xClient = LOWORD (lParam);
yMax = max (0, 600 - yClient/yChar); // need to calculate
yPos = min (yPos, yMax); // current position not exceed the maximum
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMin = 0; si.nMax = yMax; si.nPage = yClient / yChar;
si.nPos = yPos;
SetScrollInfo(hwnd, SB_VERT, si, TRUE);
xMax = max (0, 2 + (1600 - xClient)/xChar);
xPos = min (xPos, xMax);
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMin = 0;
si.nMax = xMax;
si.nPage = xClient / xChar;
si.nPos = xPos;
SetScrollInfo(hwnd, SB_HORZ, si, TRUE);
UpdateWindow (hwnd);
return 0;
case WM_VSCROLL:
switch(LOWORD (wParam))
{
case SB_PAGEUP: // User clicked shaft left of the scroll box.
yInc = -4; break;
case SB_PAGEDOWN: // User clicked shaft right of the scroll box.
yInc = 4; break;
case SB_LINEUP: // User clicked the left arrow.
yInc = -1; break;
case SB_LINEDOWN: // User clicked the right arrow.
yInc = 1; break;
case SB_THUMBTRACK: // User dragged the scroll box.
yInc = HIWORD(wParam) - yPos; break;
default:
yInc = 0; break;
}
if (yInc = max(-yPos, min(yInc, yMax - yPos)))
{
yPos += yInc;
ScrollWindowEx(hwnd, 0, -yChar * yInc,
(CONST RECT *) NULL, (CONST RECT *) NULL,
(HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE);
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = yPos;
SetScrollInfo(hwnd, SB_VERT, si, TRUE);
UpdateWindow (hwnd);
};
return 0;
case WM_HSCROLL:
switch(LOWORD (wParam))
{
case SB_PAGEUP: // User clicked shaft left of the scroll box.
xInc = -4; break;
case SB_PAGEDOWN: // User clicked shaft right of the scroll box.
xInc = 4; break;
case SB_LINEUP: // User clicked the left arrow.
xInc = -1; break;
case SB_LINEDOWN: // User clicked the right arrow.
xInc = 1; break;
case SB_THUMBTRACK: // User dragged the scroll box.
xInc = HIWORD(wParam) - xPos; break;
default:
xInc = 0; break;
}
if (xInc = max(-xPos, min(xInc, xMax - xPos)))
{
xPos += xInc;
ScrollWindowEx(hwnd, -xChar * xInc, 0,
(CONST RECT *) NULL, (CONST RECT *) NULL,
(HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE);
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = xPos;
SetScrollInfo(hwnd, SB_HORZ, si, TRUE);
UpdateWindow (hwnd);
};
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,"END");
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName="Windows Fill";
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
return(RegisterClass(wndclass));
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd=CreateWindow(
"Windows Fill",
"Show_color",
WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_BORDER | WS_HSCROLL | WS_VSCROLL,
100,100,800,400,
NULL,
NULL,
hInstance,
NULL
);
if(!hWnd)
return FALSE;
hWndMain=hWnd;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
求小甲鱼Windows程序设计课件 源代码
源代码是“Windows程序设计第5版”这本书里的,小甲鱼以这本书为教材的。
python windows系统 源代码
一、python如何运行程序
首先说一下python解释器,它是一种让其他程序运行起来的程序。当你编写了一段python程序,python解释器将读取程序,并按照其中的命令执行,得出结果,实际上,解释器是代码与机器的计算机硬件之间的软件逻辑层。
通俗来说,我们的计算机是基于二进制进行运算的,无论你用什么语言来写程序,无论你的程序写的多么简单或多么复杂,最终交给计算机运行的一定是 0或1,因为计算机只能识别0和1。
我们目前使用的大多数编程语言都是高级程序语言,也就是利于我们人类阅读的语言,要使我们编写的程序能够在计算机上跑起来,要经过一定的转换才可以,python程序大致的过程应该是这样:
源代码--字节码--pvm(虚拟机)--机器码
可以到Python的官方网站下载python(),通常包括解释器、库文件及简单的编码环境(IDLE)。把源代码编译成字节码其实是为了程序更节省时间,如果源代码没有变动,那么运行程序时会直接从字节码读取,加快速度,把字节码放到虚拟机去解释,可以更好的跨平台运行,最后转换成机器码。
二、Windows系统下搭建python编程环境。
1、进入Python官网,在“Downloads”下拉菜单中选择相应的操作系统,我们选择windows。
2、这里有32位和64位版本,要和自己的电脑系统相对应。
3、安装刚才已经下载下来的安装包, 安装过程下图所示,使用默认配置,选择“Install Now”,勾选下面的Add Python3.5 to PATH,然后就是一直next,直到完成。
三、认识编程环境
1、在开始运行处运行命令cmd,进行dos模式,输入python,即可进行python的交互式环境。
2、进行到IDLE界面
3、交互式界面可以用于简单的学习,编写较大程序时应到具体的python文件中,python文件默认的后缀为.py,我们可以新建文本文件,然后把后缀扩展名改为.py,然后
最后选择菜单中的Run下的run module即可运行,快捷键为F5。
什么是Windows系列操作系统源代码
Windows系列操作系统源代码就是微软公司开发系统的程序代码
那是微软公司的机密,不可能让人知道的!^^
打个比方把,系统是墙,代码就是砖拉,没砖哪来的墙!让人知道不是泄了机密,微软还赚什么呢!
关于windows程序设计源代码和windows开源代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-09网页代码,网页代码快捷键
- 05-07pb超级报表源代码(pb报表工具)[20240507更新]
- 05-07简历源代码可以上传照片的简单介绍[20240507更新]
- 05-07广告切换源代码免费下载(广告切换源代码免费下载安装)[20240507更新]
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06阁楼网源代码(阁楼是什么网站)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接