使用Borland的C ++图形 [英] Graphics in C++ using Borland
问题描述
目前我正在使用Borland的C ++
( http://www.borland.com/products/down...cbuilder.html# )
我想要能够获取一系列点并在屏幕上绘制它们。
有办法做到这一点吗?例如。我希望能够绘制一个函数。在这个
点,我没有达到C ++的水平,我想开始学习Visual C ++
所以我不想走那条路。
谢谢
Pmb
Pmb< so*****@somewhere.com>这样说:
我希望能够获取一系列点并在屏幕上绘制它们。有没有办法做到这一点?例如。我希望能够绘制一个函数。在这个问题上,我没有达到C ++的水平,我想开始学习Visual C ++
所以我不想走那条路。
(newsgroups.borland.com很乐意提供帮助。)
您的帖子对于comp.lang.c ++来说是偏离主题的。请访问
http://www.slack .net / ~shiva / welcome.txt
http://www.parashift.com/c++-faq-lite/
用于发布指南和常见问题解答。谢谢。
-
Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我
ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。
嗨Pmb(皮特),
你提到过,
"我希望能够获得一系列积分
并在屏幕上绘制它们。
你需要创建一个窗口然后获得
该窗口的设备常量HDC。
你还需要一支笔,HPEN。
注意,这是一个Win32项目,而不是一个控制台项目。
下面是一些代码片段这可能会对你有所帮助。
长__stdcall
WinProc(HWND Wnd,uint WM,uint wp,long lp){
return DefWindowProc(Wnd,WM,wp,lp); }
int __stdcall WinMain(HINSTANCE inst,
HINSTANCE PID,LPSTR CmdLn,int x1){
HPEN Pen = CreatePen(PS_SOLID,0,RGB(255,0,0));
HBRUSH Black = CreateSolidBrush(RGB(0,0,0));
{WNDCLASS Class = {
0,WinProc,0,0,PID,0,0,Black,0," WinProc" };
RegisterClass(& Class); }
int Left_Scr,Top_Scr,W_Me,H_Me,Right_Scr,Bot_Scr;
{long R [4];
SystemParametersInfo (
SPI_GETWORKAREA,0,(RECT *)R,0);
Right_Scr = R [2]; Bot_Scr = R [3];
R [2] - = R [0]; R [3] - = R [1];
Left_Scr = R [0]; Top_Scr = R [1];
W_Me = R [2]; H_Me = R [3]; }
HWND Win = CreateWindow" WinProc"," Some Title",
WS_VISIBLE,Left_Scr,Top_Scr,
W_Me,H_Me,0,0,PID,0);
HDC DC = GetDC(Win);
int x,y;
MoveToEx(DC,x = 100,y = 200,0);
LineTo(DC,x = 200,y = 300);
ReleaseDC(Win,DC);
MSG Msg;
while(GetMessage(& Msg,0,0,0){
TranslateMessage(& Msg); DispatchMessage(& Msg);
unsigned int M = Msg.message,C = Msg.wParam;
if(M == WM_KEYDOWN&& C == 27)返回1;
}
}
Christopher Benson-Manica< at *** @ nospam.cyberspace.org>在留言中写道
news:c9 ********** @ chessie.cirr.com ...Pmb< so ***** @ somewhere.com>这样说:
我希望能够获取一系列点并在
屏幕上绘制它们。有没有办法做到这一点?例如。我希望能够绘制一个函数。在
这一点我不能达到C ++的水平,我想开始学习Visual
C ++所以我不想走这条路。
(newsgroups.borland.com很乐意提供帮助。)
你的帖子对于comp.lang.c ++来说是偏离主题的。
这不是主题,因为我想学习如何用C ++做这件事。
< snip unhelpful comments>
Pmb
At the moment I''m using Borland''s C++
(http://www.borland.com/products/down...cbuilder.html#)
I want to be able to take an array of points and plot them on the screen. Is
there a way to do this? E.g. I want to be able to graph a function. At this
point I''m not up to a level in C++ where I want to start learning Visual C++
so I don''t want to go that route.
Thanks
Pmb
Pmb <so*****@somewhere.com> spoke thus:
I want to be able to take an array of points and plot them on the screen. Is
there a way to do this? E.g. I want to be able to graph a function. At this
point I''m not up to a level in C++ where I want to start learning Visual C++
so I don''t want to go that route.
(newsgroups.borland.com would be glad to help.)
Your post is off-topic for comp.lang.c++. Please visit
http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/
for posting guidelines and frequently asked questions. Thank you.
--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.
Hi Pmb ( Pete ),
You mentioned,
" I want to be able to take an array of points
and plot them on the screen. "
You need to create a window and then get
the device constant, HDC, of that window.
You also need a pen, HPEN.
Note, this is a Win32 project, not a console project.
Below are a few code snippets that might help you.
long __stdcall
WinProc ( HWND Wnd, uint WM, uint wp, long lp ) {
return DefWindowProc( Wnd, WM, wp,lp ); }
int __stdcall WinMain ( HINSTANCE inst,
HINSTANCE PID, LPSTR CmdLn, int x1 ) {
HPEN Pen = CreatePen( PS_SOLID, 0, RGB( 255, 0, 0 ) );
HBRUSH Black = CreateSolidBrush ( RGB( 0, 0, 0 ) );
{ WNDCLASS Class = {
0, WinProc, 0, 0, PID, 0, 0, Black, 0, "WinProc" };
RegisterClass( & Class ); }
int Left_Scr, Top_Scr, W_Me, H_Me, Right_Scr, Bot_Scr ;
{ long R[ 4 ];
SystemParametersInfo(
SPI_GETWORKAREA, 0, ( RECT * ) R, 0 );
Right_Scr = R [ 2 ]; Bot_Scr = R [ 3 ];
R [ 2 ] -= R [ 0 ]; R[ 3 ] -= R [ 1 ];
Left_Scr = R [ 0 ]; Top_Scr = R [ 1 ];
W_Me = R [ 2 ]; H_Me = R [ 3 ]; }
HWND Win = CreateWindow "WinProc", "Some Title",
WS_VISIBLE, Left_Scr, Top_Scr,
W_Me, H_Me, 0, 0, PID, 0 );
HDC DC = GetDC( Win );
int x, y ;
MoveToEx ( DC , x = 100, y = 200, 0 );
LineTo ( DC, x = 200, y = 300 );
ReleaseDC( Win, DC);
MSG Msg;
while ( GetMessage( & Msg, 0,0,0) {
TranslateMessage( & Msg ); DispatchMessage( & Msg );
unsigned int M = Msg.message, C = Msg.wParam ;
if ( M == WM_KEYDOWN && C == 27) return 1;
}
}
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c9**********@chessie.cirr.com...Pmb <so*****@somewhere.com> spoke thus:I want to be able to take an array of points and plot them on the screen. Is there a way to do this? E.g. I want to be able to graph a function. At this point I''m not up to a level in C++ where I want to start learning Visual C++ so I don''t want to go that route.
(newsgroups.borland.com would be glad to help.)
Your post is off-topic for comp.lang.c++.
It''s not off topic since I want to learn how to do this in C++.
<snip unhelpful comments>
Pmb
这篇关于使用Borland的C ++图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!