|
this is my dialog class of the dll.......In the view class you can see I have done ReleaseDC everywhere. Check if could help resolve this error. Thanks a lot for your help.
[code]
// DlgsViewDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DlgsView.h"
#include "DlgsViewDlg.h"
#include "MyView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
static UINT BASED_CODE indicators[] =
{
ID_INDICATOR_NISH,
ID_INDICATOR_TIME
};
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
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()
// CDlgsViewDlg dialog
CString CDlgsViewDlg::fileName = L"";
CDlgsViewDlg::CDlgsViewDlg(CString filename, CWnd* pParent /*=NULL*/)
: CDialog(CDlgsViewDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
fileName = filename;
}
CDlgsViewDlg::~CDlgsViewDlg()
{
delete m_pNewView;
}
void CDlgsViewDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDlgsViewDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_FILE_NEW,OnFileNew)
//}}AFX_MSG_MAP
ON_COMMAND(ID_UTILITY_EXIT, &CDlgsViewDlg::OnUtilityExit)
ON_COMMAND(ID_EXIT, &CDlgsViewDlg::OnExit)
ON_COMMAND(ID_UTILITY_LOADPROFILE, &CDlgsViewDlg::OnUtilityLoadprofile)
ON_COMMAND(ID_UTILITY_GENERATESURFACE, &CDlgsViewDlg::OnUtilityGeneratesurface)
ON_COMMAND(ID_UTILITY_DRAW1, &CDlgsViewDlg::OnUtilityDraw1)
ON_COMMAND(ID_UTILITY_DRAW3, &CDlgsViewDlg::OnUtilityDraw3)
ON_COMMAND(ID_UTILITY_SAVEASIMAGE, &CDlgsViewDlg::OnUtilitySaveasimage)
ON_COMMAND(ID_VIEW_WIREFRAME, &CDlgsViewDlg::OnViewWireframe)
ON_COMMAND(ID_VIEW_SHADE, &CDlgsViewDlg::OnViewShade)
ON_COMMAND(ID_VIEW_NORMAL, &CDlgsViewDlg::OnViewNormal)
ON_COMMAND(ID_VIEW_PAN, &CDlgsViewDlg::OnViewPan)
ON_COMMAND(ID_VIEW_ZOOM, &CDlgsViewDlg::OnViewZoom)
ON_COMMAND(ID_VIEW_ROTATE, &CDlgsViewDlg::OnViewRotate)
ON_COMMAND(ID_VIEW_TOPVIEW, &CDlgsViewDlg::OnViewTopview)
ON_COMMAND(ID_VIEW_FRONTVIEW, &CDlgsViewDlg::OnViewFrontview)
ON_COMMAND(ID_VIEW_SIDEVIEW, &CDlgsViewDlg::OnViewSideview)
ON_COMMAND(ID_VIEW_ISOMETRICVIEW, &CDlgsViewDlg::OnViewIsometricview)
ON_COMMAND(ID_VIEW_ISOMETRICVIEW32787, &CDlgsViewDlg::OnViewIsometricview32787)
ON_COMMAND(ID_VIEW_ISOMETRICVIEW32788, &CDlgsViewDlg::OnViewIsometricview32788)
ON_COMMAND(ID_VIEW_ISOMETRICVIEW32789, &CDlgsViewDlg::OnViewIsometricview32789)
ON_COMMAND(ID_VIEW_COLORMODEL, &CDlgsViewDlg::OnViewColormodel)
ON_COMMAND(ID_VIEW_FITTOSCREEN, &CDlgsViewDlg::OnViewFittoscreen)
ON_COMMAND(ID_HELP_MANUAL, &CDlgsViewDlg::OnHelpManual)
ON_COMMAND(ID_COLORMODEL, &CDlgsViewDlg::OnColormodel)
ON_COMMAND(ID_DRAWHALFSURFACE, &CDlgsViewDlg::OnDrawhalfsurface)
ON_COMMAND(ID_DRAWTHREEFOURTHSURFACE, &CDlgsViewDlg::OnDrawthreefourthsurface)
ON_COMMAND(ID_FITTOSCREEN, &CDlgsViewDlg::OnFittoscreen)
ON_COMMAND(ID_FRONT, &CDlgsViewDlg::OnFront)
ON_COMMAND(ID_GENERATESURFACE, &CDlgsViewDlg::OnGeneratesurface)
ON_COMMAND(ID_ISONORTHEAST, &CDlgsViewDlg::OnIsonortheast)
ON_COMMAND(ID_ISONORTHWEST, &CDlgsViewDlg::OnIsonorthwest)
ON_COMMAND(ID_ISOSOUTHEAST, &CDlgsViewDlg::OnIsosoutheast)
ON_COMMAND(ID_ISOSOUTHWEST, &CDlgsViewDlg::OnIsosouthwest)
ON_COMMAND(ID_LOADPROFILE, &CDlgsViewDlg::OnLoadprofile)
ON_COMMAND(ID_NORMAL, &CDlgsViewDlg::OnNormal)
ON_COMMAND(ID_PAN, &CDlgsViewDlg::OnPan)
ON_COMMAND(ID_ROTATE, &CDlgsViewDlg::OnRotate)
ON_COMMAND(ID_SAVEASIMAGE, &CDlgsViewDlg::OnSaveasimage)
ON_COMMAND(ID_SHADE, &CDlgsViewDlg::OnShade)
ON_COMMAND(ID_SIDE, &CDlgsViewDlg::OnSide)
ON_COMMAND(ID_TOP, &CDlgsViewDlg::OnTop)
ON_COMMAND(ID_WIREFRAME, &CDlgsViewDlg::OnWireframe)
ON_COMMAND(ID_ZOOM, &CDlgsViewDlg::OnZoom)
ON_COMMAND(ID_HELP, &CDlgsViewDlg::OnHelp2)
END_MESSAGE_MAP()
BOOL CDlgsViewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_pNewView = new CMyView();
ShowWindow(SW_SHOWMAXIMIZED);
CRect clientRect;
GetClientRect(&clientRect);
clientRect.DeflateRect(10, 30);
// Creation of the view window
if(! m_pNewView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, clientRect,
this, WM_USER))
{
MessageBox(L"Failed to create view");
}
menu.LoadMenu(IDR_MAINFRAME1);
SetMenu(&menu);
if(!m_FirstToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |
WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |
CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_FirstToolBar.LoadToolBar(IDR_TOOLBAR1))
{
EndDialog(IDCANCEL);
}
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);
m_wndStatusBar.Create(this); //We create the status bar
m_wndStatusBar.SetIndicators(indicators,2); //Set the number of panes
CRect rect;
GetClientRect(&rect);
//Size the two panes
m_wndStatusBar.SetPaneInfo(0,ID_INDICATOR_NISH,
SBPS_NORMAL,rect.Width()-100);
m_wndStatusBar.SetPaneInfo(1,ID_INDICATOR_TIME,SBPS_STRETCH ,0);
//This is where we actually draw it on the screen
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,
ID_INDICATOR_TIME);
m_wndStatusBar.SetPaneText(0,L"MainWindow Initialized");
if(!fileName.IsEmpty()) {
m_pNewView->loadProfile(fileName);
m_pNewView->domainSetUpForProfile();
m_pNewView->drawLines();
m_pNewView->drawArcs();
m_pNewView->drawProfile();
m_pNewView->isModel=true;
m_pNewView->OnGeneratesurface();
m_pNewView->OnShade();
m_pNewView->OnIsosouthwest();
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CDlgsViewDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CDlgsViewDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<wparam>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CDlgsViewDlg::OnQueryDragIcon()
{
return static_cast<hcursor>(m_hIcon);
}
void CDlgsViewDlg ::OnFileNew()
{
AfxMessageBox(L"On file Menu");
}
void CDlgsViewDlg::OnUtilityExit()
{
// TODO: Add your command handler code here
OnExit();
}
void CDlgsViewDlg::OnExit()
{
// TODO: Add your command handler code here
CWnd* pWin = AfxGetMainWnd();
::PostMessage(pWin->m_hWnd, WM_CLOSE,0,0);
}
void CDlgsViewDlg::OnUtilityLoadprofile()
{
// TODO: Add your command handler code here
OnLoadprofile();
}
void CDlgsViewDlg::OnUtilityGeneratesurface()
{
// TODO: Add your command handler code here
OnGeneratesurface();
}
void CDlgsViewDlg::OnUtilityDraw1()
{
// TODO: Add your command handler code here
OnDrawhalfsurface();
}
void CDlgsViewDlg::OnUtilityDraw3()
{
// TODO: Add your command handler code here
OnDrawthreefourthsurface();
}
void CDlgsViewDlg::OnUtilitySaveasimage()
{
// TODO: Add your command handler code here
OnSaveasimage();
}
void CDlgsViewDlg::OnViewWireframe()
{
// TODO: Add your command handler code here
OnWireframe();
}
void CDlgsViewDlg::OnViewShade()
{
// TODO: Add your command handler code here
OnShade();
}
void CDlgsViewDlg::OnViewNormal()
{
// TODO: Add your command handler code here
OnNormal();
}
void CDlgsViewDlg::OnViewPan()
{
// TODO: Add your command handler code here
m_pNewView->OnViewPan();
}
void CDlgsViewDlg::OnViewZoom()
{
// TODO: Add your command handler code here
m_pNewView->OnViewZoom();
}
void CDlgsViewDlg::OnViewRotate()
{
// TODO: Add your command handler code here
m_pNewView->OnViewRotate();
}
void CDlgsViewDlg::OnViewTopview()
{
// TODO: Add your command handler code here
OnTop();
}
void CDlgsViewDlg::OnViewFrontview()
{
// TODO: Add your command handler code here
OnFront();
}
void CDlgsViewDlg::OnViewSideview()
{
// TODO: Add your command handler code here
OnSide();
}
void CDlgsViewDlg::OnViewIsometricview()
{
// TODO: Add your command handler code here
OnIsosouthwest();
}
void CDlgsViewDlg::OnViewIsometricview32787()
{
// TODO: Add your command handler code here
OnIsonorthwest();
}
void CDlgsViewDlg::OnViewIsometricview32788()
{
// TODO: Add your command handler code here
OnIsosoutheast();
}
void CDlgsViewDlg::OnViewIsometricview32789()
{
// TODO: Add your command handler code here
OnIsonortheast();
}
void CDlgsViewDlg::OnViewColormodel()
{
// TODO: Add your command handler code here
OnColormodel();
}
void CDlgsViewDlg::OnViewFittoscreen()
{
// TODO: Add your command handler code here
OnFittoscreen();
}
void CDlgsViewDlg::OnHelpManual()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Opening documentation...");
m_pNewView->OnHelpManual();
}
/////////////////////////////////////////////////////
///////////TOOLBAR///////////////////////////////////
void CDlgsViewDlg::OnColormodel()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Color change for the model...");
m_pNewView->OnColormodel();
}
void CDlgsViewDlg::OnDrawhalfsurface()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Drawing the surface the selected profile...");
m_pNewView->OnDrawhalfsurface();
}
void CDlgsViewDlg::OnDrawthreefourthsurface()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Drawing the surface the selected profile...");
m_pNewView->OnDrawthreefourthsurface();
}
void CDlgsViewDlg::OnFittoscreen()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Fit to the screen...");
m_pNewView->OnFittoscreen();
}
void CDlgsViewDlg::OnFront()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Front view...");
m_pNewView->OnFront();
}
void CDlgsViewDlg::OnGeneratesurface()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Drawing the surface the selected profile...");
m_pNewView->OnGeneratesurface();
}
void CDlgsViewDlg::OnIsonortheast()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Isometric north east view...");
m_pNewView->OnIsonortheast();
}
void CDlgsViewDlg::OnIsonorthwest()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Isometric north west view...");
m_pNewView->OnIsonorthwest();
}
void CDlgsViewDlg::OnIsosoutheast()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Isometric south east view...");
m_pNewView->OnIsosoutheast();
}
void CDlgsViewDlg::OnIsosouthwest()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Isometric south west view...");
m_pNewView->OnIsosouthwest();
}
void CDlgsViewDlg::OnLoadprofile()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Drawing profile for the selected file...");
m_pNewView->OnLoadprofile();
}
void CDlgsViewDlg::OnNormal()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Model normal mode...");
m_pNewView->OnNormal();
}
void CDlgsViewDlg::OnPan()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Pan...");
m_pNewView->OnPan();
}
void CDlgsViewDlg::OnRotate()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Rotate...");
m_pNewView->OnRotate();
}
void CDlgsViewDlg::OnSaveasimage()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Save As Image");
m_pNewView->OnSaveasimage();
}
void CDlgsViewDlg::OnShade()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Model shading...");
m_pNewView->OnShade();
}
void CDlgsViewDlg::OnSide()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Model side view...");
m_pNewView->OnSide();
}
void CDlgsViewDlg::OnTop()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Model top view...");
m_pNewView->OnTop();
}
void CDlgsViewDlg::OnWireframe()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Model wireframe...");
m_pNewView->OnWireframe();
}
void CDlgsViewDlg::OnZoom()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Model zoom...");
m_pNewView->OnZoom();
}
void CDlgsViewDlg::OnHelp2()
{
// TODO: Add your command handler code here
m_wndStatusBar.SetPaneText(0,L"Opening documentation...");
m_pNewView->OnHelpManual();
}
void CDlgsViewDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::PostNcDestroy();
delete this;
}
[/code]
|
|
|
|
|
I'll reply again to this message. You have added too much unformatted code to your other posts (therefore somebody has donevoted them).
- You should use the 'code' button on top of the CP message input window to format the selection as C++ code.
- You should limit the amount of code. Nobody here will step through too many lines.
Regarding the CView deletion:
Why do you use a CView derived class within a CDialog ? Using a CWnd derived class as user control should solve your problem. CView classes are used with the document view model and expect to have a frame window as parent.
|
|
|
|
|
your answer is not a solution. try to solve the problem.
|
|
|
|
|
sujandasmahapatra wrote: your answer is not a solution
Being rude is not a solution either.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
sujandasmahapatra wrote: your answer is not a solution
The solution is to not use a CView derived class as a client window of a dialog.
sujandasmahapatra wrote: try to solve the problem
No. You must solve the problem. It's not my job. The only thing I can do, is to help you.
|
|
|
|
|
5 for your patience.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
i wanted a view on the dialog. so i derived from cview and created the view in the dialog. 1st time everything is coming fine. but without closing the client application if i try to launch again the dialog then it's giving error. Please give me some suggestion how can i get rid of it. Thanks
|
|
|
|
|
The problem is that the view is not properly closed. But even if you would close it properly, there will be other problems. A CView is not designed to be a child view of a dialog. It must be a child of a CFrameWnd derived class. Change your CView class to be based on a CWnd .
|
|
|
|
|
And demonstrating a great deal of restraint as well. Good for you.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
wherever i used GetDc() i have done ReleaseDC...Still the error is coming, "A required resource was unavailable". Please help me to resolve this. why 2nd time my application is not launching.? please tell whatelse I need to do ? Thanks
|
|
|
|
|
sujandasmahapatra wrote: please tell whatelse I need to do ?
You probably need to do some serious debugging, firstly to find out why and where this message is produced.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
it's giving this error
First-chance exception at 0x7c812afb in TestRev.exe: Microsoft C++ exception: CResourceException at memory location 0x0012ed28..
Crashing in wincore.cpp -- AfxRegisterClass(WNDCLASS* lpWndClass)
|
|
|
|
|
And what does that tell us? Pretty much nothing. You need to look at your code where this error occurs and find out what your program is doing, or trying to do: that is where the error lies.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Can u give me your mail id so that I can send you the project. Can u help me ?
|
|
|
|
|
Sorry, but I don't want to write your code. I - and most others here - just enjoy helping.
The design of your application is definitely broken. That is your problem. Tampering with the existing code is the wrong way. Reconsider the design. Read about dialogs hosting user controls.
|
|
|
|
|
I have got the problem I have implemented the PrecreateWindow for my view class.
just check this code.
[code]
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC,::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
cs.dwExStyle = WS_EX_CLIENTEDGE;
return CView::PreCreateWindow(cs);
}
[/code]
If I remove the first line, i.e
cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC,::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
then my dll window is coming all the times from the client call. But it's flickering .
So now please help me what can I do to resolve this. I think some of you must have understood the problem, please help me. Thanks a lot.
|
|
|
|
|
hi all,
can any one help me to read USB type Disk Drive device.
please help me from where i can start.
thanks in advance.
|
|
|
|
|
can u please more specific,how to detect and open this
coz its not open using serial port and CreateFile method.
thanks.
|
|
|
|
|
Le@rner wrote: can u please more specific
Afraid not; as with most questions like this, you need to go and do some research into what features are available and how you can implement them to solve your problem(s).
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
What are you trying to accomplish? ...this question is not clear. If it's a plain storage disk drive, and you're trying to read/write to it, it's the same as reading and writing to any file on your C:\. You just have to specify the full path of the files. The IO is handled by the drivers.
|
|
|
|
|
i want to access the Card reader that is connect as drive.
|
|
|
|
|
What do you want to do though? Are you trying to write to it? Do you not know what logical drive was assigned to it? Be more specific.
|
|
|
|
|
i just want to read this?and read data of smart card is inserted in it.
|
|
|
|
|
Have you tried ReadFile()?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|