|
if you dont need to this item you can delete it from listbox
|
|
|
|
|
I Just Need to make it Disable and After that I will Enable it , This is my need
|
|
|
|
|
It seems the CListBox class does not support "enabled/disabled" state of items.
I think instead of CListBox you have to try another class -- CCheckListBox -- and deal with the state of checkboxes.
I hope it helps.
|
|
|
|
|
Hello friends,
I have insert a active-x control in my dialog based application.
Through which i got the class caapi aapi.cpp and aapi.h
And i am able to call all the function which are in aapi.cpp thruogh wDlg.cpp by declare a object of aapi.
When i right click in active-x button it display all the events of function which are present in aapi.h/.cpp.
I dont know how to make use of that events or how to make connection between these events and my application.
Can u help me or any link .Thanks
|
|
|
|
|
Hi!!
I have a doubt regarding SendMessage() function. According to MSDN SendMessage syntax is as follow;
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
But I am not getting what wparam and lparam are erally used for. Its given in MSDN that they are jst for additional information about the msg.
Thx,
|
|
|
|
|
SendMessage(..) is mainly for user messages.
Say in one class you have two numbers and you have addition method in another class, now you can use the SendMessage as
SendMessage(AddtionMethodHWND, User_Msg, 5, 10)
you can send a structure or class as the Param values, but those have to be as pointers and the destination methos have to take care of deleting the allocated memory
PostMessage(..) also act as SendMessage(..),
PostMessage just send the message and continue executing the next line but SendMessage will wait untill the methos returns
Do your Duty and Don't expect the Result
|
|
|
|
|
Hi!
Thx for the reply.
Actually I am facing a problem where I am trying to port a VC6 code to VC8. In My VC6 code I was passing an iterator to the SendMessage just by typecasting it to WPARAM. But VC8 compiler is allowing to do this and giving me error saying..
error C2440: 'type cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'WPARAM'<br />
with<br />
[<br />
_Ty=KPUnprotectedFileCmd_s,<br />
_Alloc=std::allocator<KPUnprotectedFileCmd_s><br />
]<br />
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
can u suggest me solution tio this peoblem.
Thx again!
|
|
|
|
|
Hi...
Windows have message driven architecture basically. Messages are nothing but events (in VB). For every action a window will get a message like, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL etc., The above said messages are mouse click events that will be sent to a window if user clicks on it. Say, if a user clicks on a window... that window will get WM_LBUTTONDOWN message first and WM_LBUTTONUP when he release it. With this message additional information like X,Y positions where the user clicked also will be sent to that window.
Ok... now come to SendMessage() function. SendMessage function is having as u said four parameters,
LRESULT SendMessage(HWND hWnd,UINT Msg,WPARAM wParam, LPARAM lParam);
here hWnd is the handle to the window where you want to send the message
Msg is the Message as above said WM_LBUTTONDOWN or WM_LBUTTONUP (see msdn for all messages starting with WM_XXXXXXX)
wParam additional information
lParam additional information
for example, let us send a message to a window like user ctrl+clicks on it...
::SendMessage(hWnd,WM_LBUTTONDOWN,MK_CONTROL,MAKELPARAM(x,y));
::SendMessage(hWnd,WM_LBUTTONUP,MK_CONTROL,MAKELPARAM(x,y));
wParam and lParam will vary depends on the message you send. For WM_CLOSE, no need for wParam and lParam, so ::SendMessage(hWnd,WM_CLOSE,0,0); will close the window.
As our Friend Parthi said, difference between SendMessage and PostMessage is, SendMessage will send message and wait till the window process the message. PostMessage will post the message in the message queue and wont wait anymore.
I think the reply is pretty long, but clear enough.
with regards,
Naren Neelamegam
|
|
|
|
|
hi Naren!!
Thx a lot. That was really very helpful.
I am newbie in VC++. Ur reply erally helped me clear some basic things.
Thx again!!
|
|
|
|
|
hi!!
Iterator has a member called _MyPtr. Can I use that to get a pointer and then convert it to wparam??
thx
|
|
|
|
|
What iterator that was.. I mean map, list, vector..
anyway i hope the below approach will help you and i sorry 4 the delay..
Allocate memory of your type using new and copy the content from the iterator to the allocated memory and typecaste it...
say, the iterator has string valur then..
char *pStr = new char[..];
strcpy(pStr, (*it).c_str());
SendMessage(hWnd, USER_MSG, NULL, (LPARAM)(LPVOID)pStr);
the pStr memory should be freed in the handler of the message
Do your Duty and Don't expect the Result
|
|
|
|
|
|
Thx Whitesky!!
I already gone throught this article. I am clear now with the usage of SendMessage. My actual problem is how to convert an Iterator to WPARAM.
Typecasting was working in VC6. But it is not supported in VC8. can u suggest something. Also can i use _MyPtr member of iterator to get the pointer??
Thx again!
|
|
|
|
|
hi all,
I have Created a an Ellipse/Circle in mouse move, But after creating the Circle/Ellipse in the View i am trying to Drag the Circle what i have created.
But before Dragging the Circle what i have created. I am not able to see the dragged circle from the point what i am dragging. the Dragging is starting from the slight different position.
here is the Code.
void CPaintingView::OnLButtonDown(UINT nFlags, CPoint point)
{
Anchor = point;
OldPoint = Anchor;
int nTime = GetDoubleClickTime();
SetTimer(1,nTime,0);
if((nFlags && MK_LBUTTON) && circleDrawn == false) // For First Time
{
CString strReadBuffer,strTokenizer;
int index = -1,ind=0;
for(int i =0; i < strCollect.GetSize(); i++)
{
strReadBuffer = strCollect.GetAt(i);
index = strReadBuffer.Find(",");
do
{
strTokenizer = strReadBuffer.Left(index);
strReadBuffer = strReadBuffer.Mid(index+1);
index = strReadBuffer.Find(",");
array[ind++]= atoi(strTokenizer.GetBuffer(0));
}while(index != -1);
if(index == -1) array[ind++] = atoi(strReadBuffer.GetBuffer(0));
array[ind++] = '\0';
ind =0;
CRgn rgn;
rgn.CreateEllipticRgn(array[0],array[1],array[2],array[3]);
if(rgn.PtInRegion(point)== TRUE) insidepoint = true;
}
}
CScrollView::OnLButtonDown(nFlags, point);
}
void CPaintingView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(this);
DrawTo = point;
CPen one,*old;
if(bEllipseFlag && insidepoint == true)
{
dc.SetROP2(R2_NOT);
dc.SelectStockObject(NULL_BRUSH);
dc.SetBkMode(TRANSPARENT);
dc.Ellipse(array[0],array[1],array[2],array[3]);
}
else if(bEllipseFlag && insidepoint == false)
{
CRect rect;
GetClientRect(&rect);
ScreenToClient(&rect);
one.CreatePen(PS_DASH,1,RGB(200,100,50));
old = dc.SelectObject(&one);
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(Anchor.x, Anchor.y, point.x, point.y);
dc.SelectObject(old);
CString strCordinates;
strCordinates.Format("%d,%d,%d,%d",Anchor.x,Anchor.y,point.x,point.y);
strCollect.Add(strCordinates);
}
CScrollView::OnLButtonUp(nFlags, point);
}
void CPaintingView::OnMouseMove(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen one,*old;
if((insidepoint == true ) && (nFlags & MK_LBUTTON))
{
CRect rect;
GetClientRect(&rect);
ScreenToClient(&rect);
dc.SetROP2(R2_NOT);
one.CreatePen(PS_DASH,1,RGB(200,100,50));
old = dc.SelectObject(&one);
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(OldPoint.x+ array[0],OldPoint.y+array[1],(point.x + array[2]),(point.y + array[3])); // Here the Position is not getting Correctly
dc.Ellipse(OldPoint.x+ array[0],OldPoint.y+array[1],(point.x + array[2]),(point.y + array[3])); //A slight Difference in Position I cant Understand why this happens. please help me out.
OldPoint = point;
dc.SelectObject(old);
showCordinates(point);
}
if((nFlags && MK_LBUTTON) && bEllipseFlag && circleDrawn == true)
{
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SetROP2(R2_NOT);
dc.SelectStockObject(NULL_BRUSH);
one.CreatePen(PS_DASH,1,RGB(200,100,50));
old = dc.SelectObject(&one);
dc.Ellipse(OldPoint.x, OldPoint.y, Anchor.x, Anchor.y);
dc.Ellipse(Anchor.x, Anchor.y, point.x, point.y);
OldPoint= point;
dc.SelectObject(old);
showCordinates(point);
}
CScrollView::OnMouseMove(nFlags, point);
}
// what shall i do for getting the Circle Dragged exacltly and at the Point where i have dragged.
please help me out.
Uday kiran
-- modified at 2:09 Tuesday 8th August, 2006
|
|
|
|
|
whats problem in this code?you show your code but can you show declare variables (array,...)
|
|
|
|
|
Hi whitesky,
My intention is that.
1) when you first see the View. The moment you Mouse Down i created a Cirlce, and Added the Points into CStringArray. After drawing all circles with LButton Down Click.
2) when i Click RButton Down i set the Flags circleDrawn as false, It mean we can no more draw any Circles.
3) When the flag CircleDrawn is set to False and the Mouse is Pressed LButtonDown, I am Checking if this point lies between any of the Circles i have drawn before the CircleDrawn Flag set to False.
4) if the CircleDrawn Flag is False and if the LButton Lies in between the Circle then I Have to Draw a Circle When Mouse is Moving.
5) In The Mouse Move i calculated the Exact Circle Area by Calculating the Point of the Mouse Co-Oridinates + Points of the Circle.
//===============================================
dc.Ellipse(point.x+ array[0],point.y+array[1],(point.x + array[2]),(point.y + array[3]));
//================================================
The Step i have used because to Draw the Exact Circle what i have drawn previously.
This is Because when the Mouse is being moved we have to shift the new location this is done by CPoint point.
so i have added point.x + (X1 co-ordinate of the Circle which is previously drawn.)
please let me know if you get any doubts
Uday kiran
|
|
|
|
|
I want to run your code but i need to declares from variables and if they has initialize
|
|
|
|
|
Hi whitsky,
i am giving all the variables initialized. please see it. and also the View Class
//==========================================================
class CPaintingView : public CScrollView
{
protected: // create from serialization only
CPaintingView();
DECLARE_DYNCREATE(CPaintingView)
// Attributes
public:
CPaintingDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPaintingView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
CPoint Anchor;
CPoint DrawTo;
CPoint OldPoint;
bool bEllipseFlag;
bool insidepoint;
int array[60];
CStringArray strCollect;
public:
void showCordinates(CPoint point);
void DrawPixel();
void DrawCircles();
public:
UINT m_Circle,m_SolidCircle,m_Rectangle,m_SolidRectangle,m_Line;
CString szPosx,szPosy,Res;
bool circleDrawn;
virtual ~CPaintingView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CPaintingView)
afx_msg void OnFiguresCircle();
afx_msg void OnUpdateFiguresCircle(CCmdUI* pCmdUI);
afx_msg void OnButton32773();
afx_msg void OnUpdateButton32773(CCmdUI* pCmdUI);
afx_msg void OnButton32774();
afx_msg void OnFiguresExit();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnButton32775();
afx_msg void OnUpdateButton32775(CCmdUI* pCmdUI);
afx_msg void OnFiguresSolidcircle();
afx_msg void OnUpdateFiguresSolidcircle(CCmdUI* pCmdUI);
afx_msg void OnFiguresRectangle();
afx_msg void OnUpdateFiguresRectangle(CCmdUI* pCmdUI);
afx_msg void OnFiguresSolidrectangle();
afx_msg void OnUpdateFiguresSolidrectangle(CCmdUI* pCmdUI);
afx_msg void OnFiguresLine();
afx_msg void OnUpdateFiguresLine(CCmdUI* pCmdUI);
afx_msg void OnButton32780();
afx_msg void OnUpdateButton32780(CCmdUI* pCmdUI);
afx_msg void OnButton32782();
afx_msg void OnUpdateButton32782(CCmdUI* pCmdUI);
afx_msg void OnButton32781();
afx_msg void OnUpdateButton32781(CCmdUI* pCmdUI);
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//==============================================================
View Class
#include "stdafx.h"
#include "painting.h"
#include "colorattr.h"
#include "paintingDoc.h"
#include "paintingView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CPaintingView, CScrollView)
BEGIN_MESSAGE_MAP(CPaintingView, CScrollView)
//{{AFX_MSG_MAP(CPaintingView)
ON_COMMAND(ID_FIGURES_CIRCLE, OnFiguresCircle)
ON_UPDATE_COMMAND_UI(ID_FIGURES_CIRCLE, OnUpdateFiguresCircle)
ON_COMMAND(ID_BUTTON32773, OnButton32773)
ON_UPDATE_COMMAND_UI(ID_BUTTON32773, OnUpdateButton32773)
ON_COMMAND(ID_BUTTON32774, OnButton32774)
ON_COMMAND(ID_FIGURES_EXIT, OnFiguresExit)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_BUTTON32775, OnButton32775)
ON_UPDATE_COMMAND_UI(ID_BUTTON32775, OnUpdateButton32775)
ON_COMMAND(ID_FIGURES_SOLIDCIRCLE, OnFiguresSolidcircle)
ON_UPDATE_COMMAND_UI(ID_FIGURES_SOLIDCIRCLE, OnUpdateFiguresSolidcircle)
ON_COMMAND(ID_FIGURES_RECTANGLE, OnFiguresRectangle)
ON_UPDATE_COMMAND_UI(ID_FIGURES_RECTANGLE, OnUpdateFiguresRectangle)
ON_COMMAND(ID_FIGURES_SOLIDRECTANGLE, OnFiguresSolidrectangle)
ON_UPDATE_COMMAND_UI(ID_FIGURES_SOLIDRECTANGLE, OnUpdateFiguresSolidrectangle)
ON_COMMAND(ID_FIGURES_LINE, OnFiguresLine)
ON_UPDATE_COMMAND_UI(ID_FIGURES_LINE, OnUpdateFiguresLine)
ON_COMMAND(ID_BUTTON32780, OnButton32780)
ON_UPDATE_COMMAND_UI(ID_BUTTON32780, OnUpdateButton32780)
ON_COMMAND(ID_BUTTON32782, OnButton32782)
ON_UPDATE_COMMAND_UI(ID_BUTTON32782, OnUpdateButton32782)
ON_COMMAND(ID_BUTTON32781, OnButton32781)
ON_UPDATE_COMMAND_UI(ID_BUTTON32781, OnUpdateButton32781)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_SIZE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPaintingView construction/destruction
CPaintingView::CPaintingView()
{
}
CPaintingView::~CPaintingView()
{
}
BOOL CPaintingView::PreCreateWindow(CREATESTRUCT& cs)
{
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CPaintingView drawing
void CPaintingView::OnDraw(CDC* pDC)
{
CPaintingDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
void CPaintingView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
sizeTotal.cx = 200;
sizeTotal.cy = 200;
SetScrollSizes(MM_HIENGLISH,sizeTotal);
bEllipseFlag = false;
insidepoint = false;
circleDrawn = false;
}
BOOL CPaintingView::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CPaintingView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
void CPaintingView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
#ifdef _DEBUG
void CPaintingView::AssertValid() const
{
CScrollView::AssertValid();
}
void CPaintingView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CPaintingDoc* CPaintingView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPaintingDoc)));
return (CPaintingDoc*)m_pDocument;
}
#endif //_DEBUG
void CPaintingView::OnLButtonDown(UINT nFlags, CPoint point)
{
Anchor = point;
OldPoint = Anchor;
if((nFlags && MK_LBUTTON) && circleDrawn == false) // For First Time
{
CString strReadBuffer,strTokenizer;
int index = -1,ind=0;
for(int i =0; i < strCollect.GetSize(); i++)
{
strReadBuffer = strCollect.GetAt(i);
index = strReadBuffer.Find(",");
do
{
strTokenizer = strReadBuffer.Left(index);
strReadBuffer = strReadBuffer.Mid(index+1);
index = strReadBuffer.Find(",");
array[ind++]= atoi(strTokenizer.GetBuffer(0));
}while(index != -1);
if(index == -1) array[ind++] = atoi(strReadBuffer.GetBuffer(0));
array[ind++] = '\0';
ind =0;
CRgn rgn;
rgn.CreateEllipticRgn(array[0],array[1],array[2],array[3]);
if(rgn.PtInRegion(point)== TRUE) insidepoint = true;
}
}
CScrollView::OnLButtonDown(nFlags, point);
}
void CPaintingView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(this);
DrawTo = point;
CPen one,*old;
if(insidepoint == true && bEllipseFlag == false && insidepoint == true && nFlags & MK_SHIFT)
{
one.CreatePen(PS_DASHDOTDOT,1,RGB(100,0,10));
old = dc.SelectObject(&one);
dc.SetROP2(R2_NOT);
dc.SelectStockObject(NULL_BRUSH);
dc.SetBkMode(TRANSPARENT);
dc.Ellipse(DrawTo.x + array[0],DrawTo.y+array[1],(DrawTo.x + array[2]),(DrawTo.y + array[3]));
insidepoint = false;
dc.SelectObject(old);
showCordinates(DrawTo);
}
else if(bEllipseFlag && insidepoint == false)
{
CRect rect;
GetClientRect(&rect);
ScreenToClient(&rect);
one.CreatePen(PS_DASHDOTDOT,1,RGB(100,0,10));
old = dc.SelectObject(&one);
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(Anchor.x, Anchor.y, point.x, point.y);
dc.SelectObject(old);
CString strCordinates;
strCordinates.Format("%d,%d,%d,%d",Anchor.x,Anchor.y,point.x,point.y);
strCollect.Add(strCordinates);
}
CScrollView::OnLButtonUp(nFlags, point);
}
void CPaintingView::OnMouseMove(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen one,*old;
if(insidepoint == true && bEllipseFlag == false && insidepoint == true && nFlags & MK_SHIFT )
{
OnPrepareDC(&dc);
dc.LPtoDP(&point);
one.CreatePen(PS_DASHDOTDOT,1,RGB(100,0,10));
old = dc.SelectObject(&one);
dc.SelectStockObject(NULL_BRUSH);
dc.SetROP2(R2_NOT);
dc.Ellipse(OldPoint.x+ array[0],OldPoint.y+array[1],(point.x + array[2]),(point.y + array[3]));
dc.Ellipse(OldPoint.x+ array[0],OldPoint.y+array[1],(point.x + array[2]),(point.y + array[3]));
OldPoint = point;
dc.SelectObject(old);
showCordinates(point);
}
if((nFlags && MK_LBUTTON) && bEllipseFlag && circleDrawn == true)
{
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SetROP2(R2_NOT);
dc.SelectStockObject(NULL_BRUSH);
one.CreatePen(PS_DASHDOTDOT,1,RGB(100,0,10));
old = dc.SelectObject(&one);
dc.Ellipse(OldPoint.x, OldPoint.y, Anchor.x, Anchor.y);
dc.Ellipse(Anchor.x, Anchor.y, point.x, point.y);
OldPoint= point;
dc.SelectObject(old);
showCordinates(point);
}
CScrollView::OnMouseMove(nFlags, point);
}
void CPaintingView::showCordinates(CPoint point)
{
szPosx.Format("%d",point.x);
szPosy.Format("%d",point.y);
Res = "x=";
Res += szPosx;
Res += ",";
Res += "y=";
Res += szPosy;
CMainFrame* pFrameParent = (CMainFrame *)GetParentFrame();
pFrameParent->m_wndStatusBar.SetPaneText(4,Res);
}
void CPaintingView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if(circleDrawn == false)
{
CString strReadBuffer,strTokenizer;
int index = -1,ind=0;
for(int i =0; i< strCollect.GetSize(); i++)
{
strReadBuffer = strCollect.GetAt(i);
index = strReadBuffer.Find(",");
do
{
strTokenizer = strReadBuffer.Left(index);
strReadBuffer = strReadBuffer.Mid(index+1);
index = strReadBuffer.Find(",");
array[ind++]= atoi(strTokenizer.GetBuffer(0));
}while(index != -1);
if(index == -1){
array[ind++] = atoi(strReadBuffer.GetBuffer(0));
}
array[ind++] = '\0';
ind =0;
CRgn rgn;
rgn.CreateEllipticRgn(array[0],array[1],array[2],array[3]);
if(rgn.PtInRegion(point)== TRUE)
{
insidepoint = true;
colorattr attr;
attr.ptrPaint = this;
attr.DoModal();
}
if(insidepoint == true) break;
}
}
CScrollView::OnLButtonDblClk(nFlags, point);
}
void CPaintingView::OnRButtonDown(UINT nFlags, CPoint point)
{
if(bEllipseFlag == true){
SetCursor(AfxGetApp()->LoadCursor(IDC_ARROW));
bEllipseFlag = false;
}
CScrollView::OnRButtonDown(nFlags, point);
circleDrawn = false;
}
void CPaintingView::OnPaint()
{
DrawPixel(); //Call this Function to Paint the Back Ground
CPaintDC dc(this);
int nRet;
CDC dcMem;
CRect rect;
CBitmap bmpMem;
GetClientRect(&rect); //Capture the Image of the Screen what we Want
nRet = dcMem.CreateCompatibleDC(&dc);
nRet = bmpMem.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
CBitmap *pOldBmp = (CBitmap *)(dcMem.SelectObject(&bmpMem));
dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0, SRCCOPY);
dcMem.SelectObject(pOldBmp);
bmpMem.DeleteObject();
dcMem.DeleteDC();
}
void CPaintingView::DrawCircles()
{
CString strReadBuffer,strTokenizer;
int index = -1,ind=0;
for(int i =0; i< strCollect.GetSize(); i++)
{
strReadBuffer = strCollect.GetAt(i);
index = strReadBuffer.Find(",");
do
{
strTokenizer = strReadBuffer.Left(index);
strReadBuffer = strReadBuffer.Mid(index+1);
index = strReadBuffer.Find(",");
array[ind++]= atoi(strTokenizer.GetBuffer(0));
}while(index != -1);
if(index == -1) array[ind++] = atoi(strReadBuffer.GetBuffer(0));
array[ind++] = '\0';
ind =0;
CClientDC dc(this);
CPen one,*old;
CRect rect;
GetClientRect(&rect);
one.CreatePen(PS_DASHDOTDOT,1,RGB(100,0,10));
old = dc.SelectObject(&one);
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(array[0],array[1],array[2],array[3]);
dc.SelectObject(old);
}
}
BOOL CPaintingView::OnEraseBkgnd(CDC* pDC)
{
return TRUE; //Erase the BackGround Color
}
void CPaintingView::DrawPixel()
{
CRect Recto; //Draw the BackGround Color
GetClientRect(&Recto);
CPaintDC dc(this);
CBrush bgBrush;
CBrush *pBrush;
bgBrush.CreateSolidBrush(RGB(0,0,0));
pBrush = dc.SelectObject(&bgBrush);
dc.Rectangle(0,0,Recto.Width(), Recto.Height());
for(int x = 0; x < Recto.Width(); x += 17)
{
for(int y = 0; y < Recto.Height(); y += 17)
{
dc.SetPixel(x, y, RGB(255, 255, 255));
}
}
dc.SelectObject(pBrush);
}
void CPaintingView::OnFiguresCircle()
{
m_Circle = ID_FIGURES_CIRCLE;
bEllipseFlag = true;
circleDrawn = true;
}
void CPaintingView::OnButton32773()
{
m_Circle = ID_FIGURES_CIRCLE;
bEllipseFlag = true;
circleDrawn = true;
}
void CPaintingView::OnUpdateButton32773(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_Circle == ID_FIGURES_CIRCLE)?1 );
}
void CPaintingView::OnButton32774()
{
(strCollect.GetSize() > 0 ? strCollect.RemoveAll(): 0);
PostQuitMessage(0);
}
void CPaintingView::OnFiguresExit()
{
(strCollect.GetSize() > 0 ? strCollect.RemoveAll(): 0);
PostQuitMessage(0);
}
void CPaintingView::OnUpdateFiguresCircle(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_Circle == ID_FIGURES_CIRCLE)?1 );
}
void CPaintingView::OnButton32775()
{
m_SolidCircle = ID_FIGURES_SOLIDCIRCLE;
}
void CPaintingView::OnUpdateButton32775(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_SolidCircle == ID_FIGURES_SOLIDCIRCLE) ? 1 );
}
void CPaintingView::OnFiguresSolidcircle()
{
m_SolidCircle = ID_FIGURES_SOLIDCIRCLE;
}
void CPaintingView::OnUpdateFiguresSolidcircle(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_SolidCircle == ID_FIGURES_SOLIDCIRCLE) ? 1 );
}
void CPaintingView::OnFiguresRectangle()
{
m_Rectangle =ID_FIGURES_RECTANGLE;
}
void CPaintingView::OnUpdateFiguresRectangle(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_Rectangle == ID_FIGURES_RECTANGLE) ? 1 );
}
void CPaintingView::OnFiguresSolidrectangle()
{
m_SolidRectangle = ID_FIGURES_SOLIDRECTANGLE;
}
void CPaintingView::OnUpdateFiguresSolidrectangle(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_SolidRectangle == ID_FIGURES_SOLIDRECTANGLE) ? 1 );
}
void CPaintingView::OnFiguresLine()
{
m_Line = ID_FIGURES_LINE;
}
void CPaintingView::OnUpdateFiguresLine(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_Line =ID_FIGURES_LINE) ? 1 );
}
void CPaintingView::OnButton32780()
{
m_Line = ID_FIGURES_LINE;
}
void CPaintingView::OnUpdateButton32780(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_Line =ID_FIGURES_LINE) ? 1 );
}
void CPaintingView::OnButton32782()
{
m_SolidRectangle = ID_FIGURES_SOLIDRECTANGLE;
}
void CPaintingView::OnUpdateButton32782(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_SolidRectangle == ID_FIGURES_SOLIDRECTANGLE) ? 1 );
}
void CPaintingView::OnButton32781()
{
m_Rectangle =ID_FIGURES_RECTANGLE;
}
void CPaintingView::OnUpdateButton32781(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio((m_Rectangle == ID_FIGURES_RECTANGLE) ? 1 );
}
void CPaintingView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
DrawPixel();
DrawCircles();
}
//==============================================================
Please provide me a solution.
Uday kiran
-- modified at 7:43 Tuesday 8th August, 2006
uday
|
|
|
|
|
I can run your code one black page with dots and (it doesnt work i change bEllipseFlag/insidepoint/circleDrawn to true)and when i lbutton it draws a circle but i think your code needs a lot of works for move circle(and...) in the OnLButtonDown you have a for that i think its for move you have a cstringarray that i think you get four numbers in this array and convert them for CreateEllipticRgn but how do you move circle,now:
---------
I have a suggestion for you see this[^] i think your program needs to another things (for example when you draw your circle aftre draw you want to change size of previous circle or need to undo/redo and ...) i dont know you want these things in your program or no but if yes see this link
--------
(2)you want to draw a circle and drag and drop well you can draw your circle and set this circle or circles to a control or controls like static and use from drag drop
--------
|
|
|
|
|
Hello all,
I have developed one dialog based application. How to resize this application according to resolution set by the user for the system. The application contains seven propertysheets in wizard mode.
Regards,
Aj.
|
|
|
|
|
To get the resolution
CRect rcWindow;
GetDesktopWindow()->GetWindowRect( &rcWindow );
Regard's
Dhana
|
|
|
|
|
mails2dhana wrote: GetDesktopWindow()->GetWindowRect( &rcWindow );
this will return only the dektop window. u have to move ur window after this
CRect rcWindow;
GetDesktopWindow()->GetWindowRect( &rcWindow );
Movewindow( &rcWindow );
nave
|
|
|
|
|
or SetWindowPos
|
|
|
|
|
|
|