|
Hi,
I have two points(CPoint), m_pStart, m_pEnd
I like to get all the points between these two points.
anyone knows how to do this?
thanks
Ehsan Behboudi
|
|
|
|
|
Do yourself a favor and buy some good book about graphic programming. In the meantime, play with LineDDA function.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
hi,
Do you know any usefull graphic programming book??
Ehsan Behboudi
|
|
|
|
|
Computer Graphics: Principles & Practice.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Check out Bresenham's alogrithm for finding points on a line. Its simple and fast and works well for discrete space(like the pixels on the screen). Any graphics book worth the paper its written on will address this topic.
Or you could find the midpoint of the line segment, then find the midpoint of each of those line segments, then find the mid point of each of those line segments.........
Josh
josh@schroff.com
|
|
|
|
|
Try this:
CPoint m_ptStart(10, 10);
CPoint m_ptEnd(600, 200);
int nY = 0;
double dLineSlope = ((double)(m_ptStart.y - m_ptEnd.y)) / (double)(m_ptEnd.x - m_ptStart.x);
for(int nX = m_ptStart.x; nX < m_ptEnd.x; nX++)
{
nY = m_ptStart.y - (int)(dLineSlope * nX);
pDC->SetPixel(nX, nY, RGB(255, 0, 0));
}
Hope this works.
|
|
|
|
|
Go and take som beginners course in linear algebra.
|
|
|
|
|
Hello guys
I am new in VC++ and I need help please
1- I want to add some MFC code to my C++ project, do I have to include any *.dll files with my program when I want to run the program in any other PC ?
2- I want to run 2 functions in the same time ,can I ?how?
(note: I saw http://www.codeproject.com/threads/ but it did not help me because its talk about GUI and MFC)
foe example I am working in FTP console and I want to get a file from the ftp server and answer any command from the user (e.g. if he like to ABORT the transfer)
Thank You for your great answer
--------------
http://www.SaudiABM.com
|
|
|
|
|
hey,
> 1- I want to add some MFC code to my C++ project, do I have to include any *.dll files with my program when I want
> to run the program in any other PC ?
You can link staticaly with MFC, this will allow you to ship you application with no extra DLL's (MFC ones anyway) -- though your finall exe will be a whole lot bigger.
> 2- I want to run 2 functions in the same time ,can I ?how? (note: I saw http://www.codeproject.com/threads/ but
> it did not help me because its talk about GUI and MFC) foe example I am working in FTP console and I want to get
> a file from the ftp server and answer any command from the user (e.g. if he like to ABORT the transfer)
If your planing on using MFC, then check you docs for CWinThread. If your not using MFC, take a look at CreateThread ().
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Hi,
In my application, I can display Bitmaps.. but i like to get a blank document when i click on
the sub-menu "New".
Does anyone know how?
Thanks
Ehsan Behboudi
|
|
|
|
|
You can Send a Message "ID_FILE_NEW" to the main Frame
In the "new" handler.
Regards,
histimes
|
|
|
|
|
I am grabbing some Bitmaps from an external source and need to and them to the current module to build a menu.
I can add perfectly okay if the Bitmap / Icon in addedd to the current project using LoadBitmap(IDB_MYBITMAP);
but I have a CBitmap object and can't get it to display.
The Bitmap that I am recieving from the external source is a HBITMAP, example:
HBITMAP bm = res2.LoadResourceBitmap(....); /this returns a HBITMAP
The code below is how I set my Menu Bitmaps
SetIcon(1, IDB_EXIT); // the first parameter being the Menu Id Command.
SetIcon(35789, IDB_ABOUT); // the second being the ResourceID for the Icon/Bitmap
Whats the easiest, or should I say, what is any way of being about to add this loaded Bitmap e.i.
SetIcon(ResourceID, CBitmap);
regards,
pgudge
|
|
|
|
|
Programming would be a good way to make a living if it were not for these pesky users.
I work on an application that draws some graphs of data obtained from test instruments. The graphing is done by our own MFC based graph class. It draws onto a CDC object in response to a windows draw message in the normal MFC way. We can render our graphs on the screen or the printer with no problems. There's a lot of code in the class, but it's very standard MFC drawing, nothing unusual.
Just when I thought I was safe to take off early on Friday, management comes up with this: "Hey Jim, our big important customers love our graphs, but they want to be able to save them as jpegs so they can embed them in their word processing documents. Can you hack something up? They are visiting next week and we'd like a demo."
Great.
I have one little problem with this request. I have no idea how to even start!
I'm sure that saving it as a regular uncompressed bitmap would be fine, I have a graphics class that lets me display, save, and print bitmaps in both jpeg and windows bitmap formats.
But how do I get the bitmap in the first place? Is there anyway to have a "bitmap device context"? I'm trying to think, but nothing is happening. I know there are programs that do this, so it must be possible.
Your suggestions and pointers are very welcome.
Jim
|
|
|
|
|
"Bitmap device context" is called "memory device context" in Windows. Check the docs for CreateCompatibleDC.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I have included a c program (driver.lib) which is used as a library for my c++ program (myProgram.exe).
from my c++ program I need to call C functions from driver.lib. I keep getting this compiler error:
LNK2001: unresolved external symbol
I read from the MSDN that I have to use 'extern' to call C functions from a C++ program.
My question is how and where to use it.
A sample code would be wonderful.
thanks in advance
|
|
|
|
|
In your header file containing the C functions
#ifdef __cplusplus
extern "C"
{
#endif
void cFunction(int arg1)
{
...
}
#ifdef __cplusplus
}
#endif
Stephen Kellett
--
C++/Java/Win NT/Unix variants
Memory leaks/corruptions/performance/system problems. UK based.
Problems with RSI/WRULD? Contact me for advice.
|
|
|
|
|
To use a 'C' libary in a 'C++' program, in the header file for the c program, you prefix function declarations with "extern C" preprocessor commands.
For example, if you are using only C++, just do this in driver.h:
extern "C" void ExportedFunction(void* pBlah);
This tells the C++ complier that this function is to be treated as a plain ole 'C' function.
If you have several exported functions in the header file, you don't have write "extern C" for each one, you can use braces:
extern "C"
{
char ShowChar( char ch );
char GetChar( void );
}
If driver.h might also be used by a 'C' compiler, you use the processor to make sure that only the C++ compiler sees the "extern" command:
#ifdef __cplusplus
extern "C"
{
#endif
void ExportedCfunction1(void *pBlah);
void ExportedCfunction2(void *pBlah);
void ExportedCfunction3(void *pBlah);
#ifdef __cplusplus
}
#endif
If you don't want to change driver.h, you can surround the include statement in the cpp file for the driver with the extern command:
// Cause everything in the header file "cinclude.h"
// to have C linkage.
extern "C"
{
#include <cinclude.h> //from MSDN
}
See "Linkage to Non-C++ Functions" in MSDN for more fun with "extern".
Of course you want to be sure that the linker knows where to find driver.lib. In Visual Studio you do this with the project settings->linker.
Jim
|
|
|
|
|
Hello,
I have a CDialog derived dialog box, for which the default behavaior is to close when the user presses the ESCape key. Can anyone tell me how to catch the message (command) that is sent when the user presses ESCape? (I think I should be overriding CWnd::OnCommand(), but I'm not sure which command to catch.)
Thanks!
|
|
|
|
|
You can override CDialog::OnCancel()
|
|
|
|
|
Hi all, I'm stuck and was hoping someone might be able to help. I just put a combobox into a toolbar (Stingray Toolbar) And now I'm trying to think of a way to trap the enter message... Normally I would just make another class, derive it from CComboBox and in the pretranslate handle the WM_KEYDOWN and VK_ENTER... but if I'm putting it in the toolbar I have to use the standard CComboBox.
Anyone know a way I can trigger a method when the enterkey is hit inside a CComboBox?
--Dave
|
|
|
|
|
If you *absolutely* need CComboBox in the toolbar, revert to classic API tricks. Having combo's HWND, subclass it.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello,
I have a problem with distributing cab file. I put two OCX files and INF file in my test.cab file but my control does not appear on other machines. I check folder winnt/downloaded program files adn i do not see my OCXs being installed.
I do not know how to solve it.
The control apperas correctly on my machine where its is registered.
I give you the steps i go over and maybe anyone knows where i am making a mistake
1) in my release directory with control i build cab file:
cabarc n testCtrl1.cab testCtrl1.ocx pvdt80.ocx testCtrl1.inf
2) my inf file is very simple:
[Add.Code]
testCtrl1.ocx=testCtrl1.ocx
PVDT80.ocx=PVDT80.ocx
[testCtr1.ocx]
file-win32-x86=thiscab
clsid={C54F7CA2-6405-43BD-A189-2471A491142E}
FileVersion=1,0,0,1
[PVDT80.ocx]
file-win32-x86=thiscab
clsid={e9c9692e-f93c-11D1-abb0-0040054fc6fb}
FileVersion=8,0,3,3
3) My html file
<title>New Page
<object classid="CLSID:C54F7CA2-6405-43BD-A189-2471A491142E"
codebase="http://soft2/testCtrl1.cab">
<param name="_Version" value="65536" />
<param name="_ExtentX" value="14970" />
<param name="_ExtentY" value="9440" />
<param name="_StockProps" value="0" />
what is wrong ? Please help
|
|
|
|
|
All of our source is currently written in Borland C which allows the use of #pragma startup 'function_name' which ensures that a function is run when a program is started. Is there an equivilent method in Visual C++?
|
|
|
|
|
Hmmmm.... no - I don't think there is. You can alter the apps entry point, but if I read you correctly I think what you want is a function that gets called before main/WinMain or whatever during runtime init. Best substitute I could think of would be a global static class that performs 'function_name' code in its ctor.
|
|
|
|
|
Create some dummy class with startup code in constructor. Make a global variable of the class - the constructor will be called before main or WinMain.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|