|
You mean you want to have the control duplicated (so, exactly the same things will be displayed on both controls) ?
I think you wanted to know how to have two instances of the same control no (it doesn't sound very logical to have the same instance duplicated) ?
If yes, you simply create another variable and create it like the first one. That's it.
|
|
|
|
|
Hi
If u want to use one control to display two or more results on same view or dialog, then place same control twice or thrice on view in design time, declare a variable for each and u can use it.
if u r creating control dynamically, then u can pass the CRect co-ordinates to create function of graph. Most of the graph controls have the option to specify the top left coordinates and right bottom coordinates.
|
|
|
|
|
I have written a MFC application program. Now, I need to create a link between the program to PCI 8255 to printer port. How should i do it and what DLL library should i download?
My hardware consists of sensors to send a signal to PCI 8255, then through parallel port to the software. Then the software will generate a word to be display on the LCD display of my hardware(not my computer monitor). How should I do it?
Help is apprciated..thanks
chris
|
|
|
|
|
|
Hi all,
The code below, works fine in debug version, but gives warning in "Release/Use MFC in Static Library/Code Generation/Multithreaded" configuration.
This is the warning message:
warning C4541: 'typeid' used on polymorphic type 'class CView' with /GR-; unpredictable behavior may result
void CMainFrame::OnUpdateFileClose(CCmdUI* pCmdUI) <br />
{<br />
BOOL bCanBeClosed = TRUE ;<br />
<br />
if(IsAnyChildWindowOpen())<br />
{<br />
CMDIChildWnd *pChildWnd = MDIGetActive() ;<br />
CView *pView = pChildWnd->GetActiveView() ;<br />
<br />
if(typeid(*pView) == typeid(CMyView1) ||<br />
typeid(*pView) == typeid(CMyView2)||<br />
typeid(*pView) == typeid(CMyView3) )<br />
bCanBeClosed = FALSE ;<br />
}<br />
pCmdUI->Enable(IsAnyChildWindowOpen() && <br />
bCanBeClosed) ;<br />
}
Kindly suggest me a solution. I am using VC6.0/Win2000.
Thanks in advance,
Sarvan AL
-- modified at 1:01 Tuesday 18th April, 2006
|
|
|
|
|
Edit the project settings for the release configuration and replace the /GR- option with /GR .
Steve
|
|
|
|
|
Maybe off topic; Or maybe not ... but
Sarvan AL wrote: if(typeid(*pView) == typeid(CMyView1) ||
typeid(*pView) == typeid(CMyView2)||
typeid(*pView) == typeid(CMyView3) )
This is a misuse of typeid. You should use dynamic_cast instead.
Maxwell Chen
|
|
|
|
|
Most programming guidelines would go even further - Don't misuse dynamic_cast ; use virtual functions instead.
Steve
-- modified at 1:35 Tuesday 18th April, 2006
i.e.
class CBaseView : public CView
{
public:
virtual bool CanClose() const = 0;
};
class CMyView1 : public CBaseView
{
public:
virtual bool CanClose() const
{
return false;
}
};
class CMyOtherViews : public CBaseView
{
public:
virtual bool CanClose() const
{
return true;
}
};
pView->CanClose();</code>
This is basic OO design and good use the C++'s features.
|
|
|
|
|
Hi Stephen, Maxwell...
Thanks a lot for your immediate reply. It helped me to solve the problem.
Sarvan AL
|
|
|
|
|
Sarvan AL wrote: warning C4541: 'typeid' used on polymorphic type 'class CView' with /GR-; unpredictable behavior may result
I believe it's telling you that the .rdata sections will increase in size, which may or may not be desirable. It might also have something to do with RTTI.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
While being handy and nice, the MFC CHotKeyCtrl class does act weird sometimes, for example, it does not recognize the "space" key, instead, it rejects the keystroke and cleans all existing contents just like I pressed the "backspace" key. Now the funny thing is that, if I set the "space" key programmatically m_wndHotkey1.SetHotkey(VK_SPACE, 0); it will work, just that it cannot be specified by user input.
Unfortunately I really want the "space" key to be one of the configurable hotkeys in my application. Do I have a way to work around this problem? Thank you.
|
|
|
|
|
Try with:
UnregisterHotKey(...)
m_hotkey1.GetHotKey(...)
...
RegisterHotKey(...)
m_hotkey1.SetHotKey(...)
RegisterHotKey modifier flags defined in "CommCtrl.h" and "WinUser.h" are not same.
The values for fsModifiers are defined in "WinUser.h".
|
|
|
|
|
Hi,
I would like to add drag/drop function to the CTreeCtrl class, just as the
Resource tree in Visual C++ environment. Are there any examples?
Thanks.
|
|
|
|
|
|
Hi, friends,
I used to integrate the simulink package to my project, that is, I opened a
Simulink window and moved the window to the related view, assumed to be the CMHCSimPlatformView, the codes are referred to as follows:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CMHCSimPlatformView::OnStartMatlabEngine()
{
...
m_hSimulink = ::FindWindow(NULL,"Project_1 ");
if(::IsWindow(m_hSimulink))
{
//Set the CMHCSimPlatformView is the parent window for the simulink one
::SetParent(m_hSimulink,this->GetSafeHwnd());
CWnd * pWnd = NULL;
pWnd = FromHandle(m_hSimulink);
CRect rect;
GetClientRect(&rect);
//move the simulink window to the related area, that is to the
//client area of the CMHCSimPlatformView.
pWnd->MoveWindow(&rect,false);
//delete the catpion of the simulink interface
pWnd->ModifyStyle(WS_CAPTION|WS_BORDER,0);
//delte the system menu of the simulink interface
pWnd->SetMenu(NULL);
//delete the system toolbar of the simulink interface
HWND handToolbar = ::FindWindowEx(m_hSimulink,NULL,_T ToolbarWindow32"),NULL);
CWnd* pToolWnd;
pToolWnd = FromHandle(handToolbar);
pToolWnd->ShowWindow(FALSE);
CFrameWnd * pFrame=(CFrameWnd *)AfxGetMainWnd();
pFrame->GetActiveFrame()->UpdateWindow ();
UpdateData(true);
}
...
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
where, Project_1 is the name of a simulink file opened before, and m_hSimulink is a variable of HWND.
Surely, the simulink window was moved to the CMHCSimPlatformView client area when the above codes are executed. However, after later opertions, the simulink window was often covered with the CMHCSimPlatformView window.
How to ensure that the simulink window always stays on the top ?and how to
change the simulink window according to the CMHCSimPlatformView area?
Regards.
zhou_rusheng
|
|
|
|
|
Please give me some ideas.
|
|
|
|
|
I want to add ZoomIn/ZoomOut in my MFC Application, works on text and image, just like MSWORD, how can I get this??
thanks for your response
-- modified at 22:50 Monday 17th April, 2006
|
|
|
|
|
MM_ISOTROPIC will get you zoom with minimal effort. You'll have to work a little though to get an app like MSWORD. I can't help you there.
|
|
|
|
|
Here's a little to get you started. Start a new MFC/SDI app and plop this stuff in the appropriate locations. Set up menu/toolbar buttons for the zoomin/zoomout. Add some drawing code to your OnDraw and you should find that the drawing is fit_to_width in the view and it should be fit to width when printing. The rest is up to you. have fun...
(Let me know if I missed something)
///////////////////////////////////////////////
//Constants
const int MAX_SCALE = 20; // The maximum scale factor
//CDocument members...
protected:
CSize m_DocSize;
CSize CYourDoc::GetDocSize() const
{
return m_DocSize;
}
CYourDoc::CYourDoc()
{
// TODO: add one-time construction code here
m_DocSize=CSize(2000,2800);
}
//CScrollView members...
protected:
int m_Scale;
CYourView::CYourView()
{
// TODO: add construction code here
m_Scale=1; // Set scale factor 1:1
SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values
}
void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC);
// TODO: Add your specialized code here and/or call the base class
// Set up the DC for the current scale factor
int nExtentX;
int nExtentY;
CSize sizeDoc;
CRect rectClient;
// Allows the rectangle to include the bottom and rightmost logical unit
// SetGraphicsMode(pDC->m_hDC,GM_ADVANCED);
pDC->SetMapMode(MM_ISOTROPIC); // Allow scaling with aspect ratio preserved
// Get pertinent rectangle data
GetClientRect(&rectClient);
sizeDoc=GetDocument()->GetDocSize();
sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments
pDC->SetWindowExt(sizeDoc); // Window extent is size of document
// Calculate viewport extent
nExtentX=(int)(GetScale()*rectClient.Width());
nExtentY=(int)((GetScale()*((nExtentX*sizeDoc.cy)/(sizeDoc.cx))));
// What kind of device context do we have?
if (pDC->IsPrinting()==TRUE) {
// Printer Context. Allow printing to edge of context. No scaling. Margins?
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES));
} else {
// Context is for screen
pDC->SetViewportExt(nExtentX,nExtentY);
}
}
int CYourView::GetScale()
{
return m_Scale;
}
void CYourView::SetScale(int nScaleFactor)
{
m_Scale=nScaleFactor;
ResetScrollBars(); // Adjust scrollbars to new scale
}
void CYourView::OnUpdateViewZoomout(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (GetScale()>=2) pCmdUI->Enable(TRUE);
else pCmdUI->Enable(FALSE);
}
void CYourView::OnUpdateViewZoomin(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (GetScale()<MAX_SCALE) pCmdUI->Enable(TRUE);
else pCmdUI->Enable(FALSE);
}
void CYourView::ResetScrollBars()
{
CSize sizeDoc;
CClientDC dc(this);
this->OnPrepareDC(&dc); // Update the device context
sizeDoc=GetDocument()->GetDocSize();
dc.LPtoDP(&sizeDoc); // Logical to device
this->SetScrollSizes(MM_TEXT,sizeDoc); // Update scrollbars
}
void CYourView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: calculate the total size of this view
ResetScrollBars();
}
void CYourView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ResetScrollBars();
}
// Toolbar/menu button handler
void CYourView::OnViewZoomin()
{
// TODO: Add your command handler code here
if (GetScale()<MAX_SCALE) SetScale(GetScale()+1);
Invalidate();
}
// Toolbar/menu button handler
void CYourView::OnViewZoomout()
{
// TODO: Add your command handler code here
if (GetScale()>=2) SetScale(GetScale()-1);
Invalidate();
}
-- modified at 23:44 Monday 17th April, 2006
|
|
|
|
|
really appreciate for your answer.
I add function TextOut in CMyView::OnDraw(), when I clicked ZoomIn, the view extended it's size, but the text in view still keeped it's size.
should I add some other code?
|
|
|
|
|
I get it!
firt time I failed because I used Textout function without creating a CFont.
bob16972,thank you very much!!
|
|
|
|
|
I'm glad it's working.
Take care.
|
|
|
|
|
google offers a set of commands, such as link, pagerank, which can be used on google web-page.
my question is:
how to develop a VC program which uses google commands to retrieve google info of these commands?
any links, sample or comments?
thx
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
includeh10 wrote: how to develop a VC program which uses google commands to retrieve google info of these commands?
Google provide apis for same!, you can get that from google itself
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi all,
Can Windows Media Player play from a buffer instead of a file?
Thanks!
Harshita
|
|
|
|