|
I don't have a "DRAW" sample. I have a "DRAWCLI" sample.
If these are the same then I know what you're talking about. However, the code isn't very portable and is way to complex for what I'm trying to do. The DRAWCLI sample uses OLE and ties the drawtool objects into the drawview cview so tightly that it becomes very difficult to pull just the drawtool object into a project and put it to use. Eventually I suppose I could trim the code down and disect it to where it fit my needs.
|
|
|
|
|
An easy solution is to use an XOR pen. When you draw your line it'll be XORed with whatever is already on the screen. When the mouse moves draw the previous line again using the XORed pen (this will remove the previous line) and then draw the new line, again using the XORed pen.
This works because XOR is it's own inverse.
To actually code this you'll need to use the api function SetROP2 before drawing. This determines how GDI merges pens (and some other drawing objects too) with what's already on the screen.
The only disadvantge is that an XOR pen isn't a solid colour, rather it appears as the inverse of the colour on the screen. Of course, this might actually be a good thing as it ensures your line is always visible no matter what you draw over.
Hope that helps.
|
|
|
|
|
hello,Please tell me what CALLBACK doing?thanks.
human
|
|
|
|
|
callback functions are static functions in your code that the operating system calls to notify you of some condition, such as a timer firing
"there is no spoon" biz stuff about me
|
|
|
|
|
l a u r e n wrote:
callback functions are static functions in your code
callback functions are not static functions... It is defined as follows
#define CALLBACK __stdcall
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Think twice, what about in C++?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Well i did do some RnD before posting tht , as long as it is VC++ i dont think its a static function unless i missed something.
or you could show me something that says its static.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Rickard Andersson19 wrote:
Think twice
surely in VC++ CALLBACK is not a static function at all.
and
Rickard Andersson19 wrote:
what about in C++?
Is VC++ not C++ ??
so really i dont know which C++ compiler you are talking about, but in VC++ callback is not a static function, its only a calling convention.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Mr.Prakash wrote:
Is VC++ not C++ ??
VC++ is a compiler. C++ is a language.
In C++ (the language) you must declare a method as static before you can use as a callback.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Rickard Andersson19 wrote:
VC++ is a compiler. C++ is a language.
VC++ compiles code writen in C++ so If you write something in C++ that VC++ cannot compile then its not a VC++ code.
what ever that meant.
using static functions as callback is one thing and in VC++
CALLBACK is different not callback but CALLBACK (something the original poster has asked the question about).
I hope now its clear.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Mr.Prakash wrote:
VC++ compiles code writen in C++ so If you write something in C++ that VC++ cannot compile then its not a VC++ code.
what ever that meant.
You can write C code. And LRESULT CALLBACK Name(...) is a callback declaration of a C function callback, not C++. lauren said it's a static function, and because this is a (V)C++ forum C++ is the first hand language so a callback function is a static function (member function actually).
Mr.Prakash wrote:
and in VC++ CALLBACK is different not callback but CALLBACK (something the original poster has asked the question about).
I hope now its clear.
if so, lauren explained what a callback was? not the defination of CALLBACK ...
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Rickard Andersson19 wrote:
if so, lauren explained what a callback was? not the defination of CALLBACK...
lauren said its a static function, which is wrong(it can be a static function but not neccessary).
lauren said what is callback function, that is correct.
no wonder the author of the post had given a low grade to that ans.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Mr.Prakash wrote:
lauren said its a static function, which is wrong
In C++ it's not.
Mr.Prakash wrote:
lauren said what is callback function, that is correct.
What do you mean?
Your English is almost impossible to understand sometimes.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
thanks,Would you give me CALLBACK example.
human
|
|
|
|
|
A CALLBACK function is a function in your code that Windows calls to tell you about an event or an item of interest.
Here is an example. The Windows API function EnumWindows enumerates the top-level windows. You pass it a pointer to a CALLBACK function. Windows calls that function once for each top-level window:
BOOL CALLBACK MyFunction(HWND hwnd,LPARAM lParam)
{
return TRUE;
}
EnumWindows(MyFunction,0); The function MyFunction is a callback function. When you call EnumWindows , Windows will call MyFunction for each top-level window in the system.
Software Zen: delete this;
|
|
|
|
|
thanks Gary R. Wheeler
human
|
|
|
|
|
i have just created a MDI application using CFormView. I have created 3 user interfaces - let's say Form A,B,and C. in form A i created a push button. i want to call form b by clicking form A's push button. and i want to call form C by clicking form B's push button. so how do i do it? plz i need the answer as fast as i can. i doing my final project using VC++.
NIMRODEL
|
|
|
|
|
Basically, in the class hiearchy, you have the main frame window. This owns the toolbar, the menu, and the child frame windows. Each child frame owns it's form view. So, if you need to issue a command that affects a form in the frames, you first need to obtain a pointer into the target view's class. Then use standard dialog commands to issue commands.
In order for this to work, you need pointers to the child frame windows. If you don't have them, you can enumerate through the childs of the main frame window by using GetTopWindow , then running a series of GetNextWindow calls along with a test to IsChild function. After you have all the pointers into the child frames, call GetActiveView through them to get the CView objects. Then cast down to CFormView, and voila, call the necessary functions.
You should also consider redesigning your application a bit if you don't have the pointers to the child windows. Enumerating through them is really troublesome. The easiest thing is to have pointers to the CFormView objects. You can always cast backwards or use GetParent to move back through the class hiearchy.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
well......i don't quite get it. b'coz i'm still new in this subject. i read somewhere that we can use OpenDocumentFile() func. if it's okay for u...can u include code sample for it.
NIMRODEL
|
|
|
|
|
I am trying to get this program to return a square-root value. The main function will call the Square_Root function that will use a do-while loop to calculated the SqRoot from the algorithm:
estimateSquareRoot = ((Number_Sent/estimateSquareRoot) +estimateSquareRoot)/2.0;
This statement will be placed in the loop that contunues to loop as long as
the square-root calculation is not within .00001 of the true value.
estimateSquareRoot*estimateSquareRoot-difference>=.00001
I can not get the loop to work. For example when I enter 9 it return 5, but
it should loop until it return the square-root of 3. If someone can point me
in the right direction please......Thank You
#include <iostream>
#include <math.h>
using namespace std;
double Square_Root (double); //declaring function returning double and passing a double
int main()
{
double Number_Enter, solution; //declaring two variables
cout<< "\n please enter a positive number."; //prompt
cin>>Number_Enter;
solution = Square_Root(Number_Enter);
cout<<"\n the square root of "<<number_enter<<"is" <<="" solution;
return="" 0;
="" }
=""
=""
double="" square_root(double="" number_sent)
{
="" double="" difference;
="" estimatesquareroot="1.0;
" do{
="" +="" estimatesquareroot)="" 2.0;
="" difference="estimateSquareRoot" *="" -="" number_sent;
="" }
while="" (estimatesquareroot*estimatesquareroot-difference="">=.00001);
return (estimateSquareRoot);
}
|
|
|
|
|
I don't know how the function was exiting with a value of 5.
Anyhoo, this line is causing the problem I think:
while (estimateSquareRoot*estimateSquareRoot-difference>=.00001);
Is always equal to the number sent in.
Change it to
while (difference >= .00001);
I'm assuming you know about the function sqrt()
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
|
You define difference as the current estimate squared minus the original square input by the user. The closer you get, the smaller the difference should be until it is less than the value .00001. In your while statement you are expecting the square of your estimated root minus the difference to get smaller. It won't converge.
For a start, change
while (estimateSquareRoot*estimateSquareRoot-difference>=.00001);
to
while(difference >= .00001);
Also, before you evaluate the difference, replace it by its absolute value. A difference of -.000009 satisfies the algorithm, but will not pass the test in the while statement.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
Hi,
How can I draw the following 2D curve with MSChart?
double X[]= {21.4, 76.56, 32.56, 98.55};
double Y[]= {1.4, 16.56, 22.56, 18.35};
Thanks.
|
|
|
|
|
Hi
I've been trying to find a way to create a basic text editor which saves what you've entered in the text box into a text file. I encountered a few errors and problems though....
Firstly, for the user to specify the name of the file it must be of type string to be used in the file name (ofstream file(variable.c_str());). This won't work with CStrings. How could I go about converting a CString to a string?
Secondly, I try to add the "using namespace std;" statement, but no matter where on the page I add it, I still get about 4 errors....
Here's my Pages code:
<code>
#include <fstream>
#include "stdafx.h"
#include "PyreSoft Text Editor.h"
#include "PyreSoft Text EditorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CPyreSoftTextEditorDlg::CPyreSoftTextEditorDlg(CWnd* pParent )
: CDialog(CPyreSoftTextEditorDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPyreSoftTextEditorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_FILENAME, m_FileName);
DDX_Control(pDX, IDC_EDIT_BOX, m_TextBoxString);
}
BEGIN_MESSAGE_MAP(CPyreSoftTextEditorDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnSave)
END_MESSAGE_MAP()
BOOL CPyreSoftTextEditorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
return TRUE;
}
void CPyreSoftTextEditorDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CPyreSoftTextEditorDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CPyreSoftTextEditorDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPyreSoftTextEditorDlg::OnSave()
{
CString FileName;
CString MainText;
m_TextBoxString.GetWindowText( MainText );
m_FileName.GetWindowText( FileName );
CString JustChecking = FileName + ".txt";
}
</code>
|
|
|
|
|